Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix grid doesn't always work with different central meridians #4335

Open
seisman opened this issue Oct 16, 2020 · 9 comments
Open

Matrix grid doesn't always work with different central meridians #4335

seisman opened this issue Oct 16, 2020 · 9 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@seisman
Copy link
Member

seisman commented Oct 16, 2020

Description of the problem

The issue was first reported in GenericMappingTools/pygmt#390, but was thought to be fixed by GMT PRs #3813 and #3829. The GMT master branch works for some projection parameters but doesn't always work.

Full script that generated the error

import pygmt
fig = pygmt.Figure()

fig.grdimage("@earth_relief_01d_g", projection="Q123/0/15c", cmap="geo")

fig.shift_origin(yshift="8c")

dem = pygmt.datasets.load_earth_relief(resolution="01d", registration="gridline")
fig.grdimage(dem, projection="Q123/0/15c", cmap="geo")
fig.savefig("map.pdf")

Output

image

Image difference
image

In the PyGMT, we test several different projection parameters. Here are the ones that are known to fail:

  • Q123/0/15c
  • Q123/30/15c
  • Q180/0/15c
  • Q180/30/15c

Here are the ones that are known to work:

  • Q0/0/15c
  • Q0/30/15c

The same parameters work well for General Stereographic projection (i.e., changing Q to S).

Note: Those tests were originally written by @weiji14.

@PaulWessel
Copy link
Member

Is this a gridline registration issue only or is it the same for pixel as well?

@seisman
Copy link
Member Author

seisman commented Oct 16, 2020

Same issue for pixel-registered grids (just tried Q123/0/15c).

@PaulWessel
Copy link
Member

And just to be absolutely clear, the plot on the bottom is what you expect? That rougher plot is what I get with long=0 which you said works, so just checking.

@seisman
Copy link
Member Author

seisman commented Oct 16, 2020

And just to be absolutely clear, the plot on the bottom is what you expect?

Yes, the bottom one uses the earth relief grid file, which gives the same plot as GMT CLI.

@PaulWessel
Copy link
Member

So what happens is this: We have a read-only grid and it has a certain central meridian. This kicks in:

if (got_z_grid && (gmt_whole_earth (GMT, Grid_orig->header->wesn, wesn) == 1))
	need_to_project = true;	/* This can only happen if reading a remote global geographic grid and the central meridian differs from that of the projection */

So now we go the way of resampling the images - hence the smoother apparance. The other image is not resampled, just plotted, but handles the change in longitude. I will see if I can make it work the same. You would think that should be doable, but the big difference is that the file is read in and the matrix is rotated to fit the -R while in the xarray case the pixels are still -180/180. So not the same case.

@stale
Copy link

stale bot commented Jan 16, 2021

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Jan 16, 2021
@stale stale bot closed this as completed Jan 23, 2021
@seisman seisman reopened this Jan 23, 2021
@stale stale bot removed the stale This will not be worked on label Jan 23, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@stale stale bot added the stale This will not be worked on label Jun 2, 2021
@stale stale bot closed this as completed Jun 16, 2021
@seisman seisman reopened this Jun 17, 2021
@stale stale bot removed the stale This will not be worked on label Jun 17, 2021
@maxrjones maxrjones added the bug Something isn't working label Jan 21, 2022
@maxrjones maxrjones added this to the 6.4.0 milestone Mar 23, 2022
@seisman seisman modified the milestones: 6.4.0, 6.5.0 Jun 25, 2022
@seisman seisman modified the milestones: 6.5.0, 6.6.0 Jan 7, 2024
@joa-quim
Copy link
Member

joa-quim commented Apr 6, 2024

What is the status of this? Mane related changes have been committed meanwhile.

@seisman
Copy link
Member Author

seisman commented Apr 6, 2024

I'll find some time to check it.

@seisman seisman self-assigned this Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants