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

Global earth relief data loaded as xarray doesn't work if projection center is not 0 #515

Closed
seisman opened this issue Jul 11, 2020 · 10 comments · Fixed by #560
Closed

Global earth relief data loaded as xarray doesn't work if projection center is not 0 #515

seisman opened this issue Jul 11, 2020 · 10 comments · Fixed by #560
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Milestone

Comments

@seisman
Copy link
Member

seisman commented Jul 11, 2020

Description of the problem

It may work in GMT 6.0.0 + PyGMT v0.1.2, or not. Currently, PyGMT master + GMT 6.1.0 gives me a wrong result.

Full code that generated the error

import pygmt
from pygmt.datasets import load_earth_relief

grid = load_earth_relief()
fig = pygmt.Figure()
fig.grdimage(grid, cmap="geo", region='d', projection="H10c")

fig.shift_origin(xshift="12c")
fig.grdimage(grid, cmap="geo", region='g', projection="H10c")

fig.shift_origin(xshift="-12c", yshift="6c")
fig.grdimage(grid, cmap="geo", region='d', projection="H120/10c")

# this one sometimes crashes
#fig.shift_origin(xshift="12c")
#fig.grdimage(grid, cmap="geo", region='g', projection="H120/10c")
fig.savefig("map.png")

Output

image

@seisman seisman added the bug Something isn't working label Jul 11, 2020
@weiji14
Copy link
Member

weiji14 commented Jul 12, 2020

Not sure if #476 will fix this. I just refactored the code there but it's still giving the strange static-looking image in the gallery at https://pygmt-24935dva1.vercel.app/gallery/grid/track_sampling.html#sphx-glr-gallery-grid-track-sampling-py. This is with the pixel registered earth relief grid.

Sampling along tracks image distorted

Passing in the gridline registered makes it a bit better:

sphx_glr_track_sampling_001

@weiji14 weiji14 added this to the 0.2.x milestone Jul 16, 2020
@seisman seisman changed the title Plotting global earth relief data doesn't work if region="g" is used Global earth relief data loaded as xarray doesn't work if projection center is not 0. Jul 23, 2020
@seisman seisman changed the title Global earth relief data loaded as xarray doesn't work if projection center is not 0. Global earth relief data loaded as xarray doesn't work if projection center is not 0 Jul 23, 2020
@seisman
Copy link
Member Author

seisman commented Jul 23, 2020

@PaulWessel Please see if you have any idea why it fails. FYI, PyGMT is still using GMT_IN|GMT_IS_REFERENCE mode.

@PaulWessel
Copy link
Member

Remind me: The xarray is being passed into GMT as a grid via a GMT_MATRIX structure?

@seisman
Copy link
Member Author

seisman commented Jul 23, 2020

Remind me: The xarray is being passed into GMT as a grid via a GMT_MATRIX structure?

Yes, GMT_IS_GRID|GMT_VIA_MATRIX.

@PaulWessel
Copy link
Member

In gmtapi_import_grid:

case GMT_IS_REFERENCE|GMT_VIA_MATRIX:	/* The user's 2-D grid array of some sort, + info in the args [NOT YET FULLY TESTED] */
	/* Getting a matrix info S_obj->resource. Create grid header and then pass the grid pointer via the matrix pointer */

Not completely reassuring... Could you try GMT_IN|GMT_IS_DUPLICATE and see if that works?

@seisman
Copy link
Member Author

seisman commented Jul 23, 2020

Using GMT_IN|GMT_IS_DUPLICATE, the GMT_Open_VirtualFile function returns a status code 32.

Using GMT_IN, it seems something wrong with the boundary condition:

image

@PaulWessel
Copy link
Member

Sorry, what is different in settings between your TL panel here and the BL panel in the top post?

@seisman
Copy link
Member Author

seisman commented Jul 23, 2020

TL panel here: -Rd -JH120/10c and GMT_IN.

BL panel in the top post: -Rd -JH10c, and GMT_IN|GMT_IS_REFERENCE.

@PaulWessel
Copy link
Member

OK, so -JH120/10.c does not to any rotation and messes up at -180 + 120 = 60W it seems.

@seisman
Copy link
Member Author

seisman commented Aug 4, 2020

The issue is caused by upstream GMT bugs, which was fixed in a series of upstream PRs (GenericMappingTools/gmt#3813, GenericMappingTools/gmt#3813, GenericMappingTools/gmt#3829) and already merged into GMT's master and 6.1 branches.

GMT may release v6.1.1 this month. When GMT v6.1.1 is released, I think we can bump the minimum required GMT version to v6.1.1 and release PyGMT v0.2.0.


HELP NEEDED

PyGMT users who build GMT from source codes may try GMT's 6.1 branch (for the upcoming v6.1.1 release) and see if you can find any related bugs before GMT v6.1.1 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Projects
None yet
3 participants