-
Notifications
You must be signed in to change notification settings - Fork 224
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
grdimage does not plot subsets of data correctly on a global map #732
Comments
@PaulWessel I think this is also an upstream GMT bug, possibly related to GenericMappingTools/gmt#4335. Please see if you can help. To reproduce the issue using the above codes, you need to import the following packages first:
|
Ping @PaulWessel |
Still an issue on GMT 6.2.0rc1 import numpy as np
import pygmt
import xarray as xr
lats = np.arange(90.0, -91.0, -1.0)
lons = np.arange(0.0, 361.0, 1.0)
data = np.random.rand(181, 361)
da = xr.DataArray(data, coords=[("latitude", lats), ("longitude", lons)])
fig = pygmt.Figure()
pygmt.makecpt(series=[0.0, 1.0, 0.1], cmap="vik", continuous=True)
fig.grdimage(da[0:121, 0:221], region="g", projection="W0/8i", frame=True)
fig.savefig("temp.png")
fig.show() |
Busy with taxes this weekend but will get on this - sorry it slipped off the radar. Seems like I fixed a very related problem not that long ago, no @seisman ? |
Not sure if https://docs.generic-mapping-tools.org/dev/debug.html#debug-pygmt-in-xcode-on-macos has all required steps. After git pull, make install, conda activate pygmt I try (from pygmt directory)
|
I think you found a PyGMT bug which was introduced recently. Your temporary fix is:
|
So I am on miniconda: (pygmt) pwessel@macnut:~/GMTdev/pygmt-> conda activate python |
Sorry, typo. I meant:
|
OK, that installed a bunch of stuff including ipython. But still some PATH issues perhaps (remember, I do this so infrequently I may not have things set up right): Traceback (most recent call last): |
What's the output of |
/Users/pwessel/opt/miniconda3/bin/python |
The path is incorrect. After activating the pygmt environment, you should be using |
No, and just run it again. Same path coming back. |
It doesn't make sense to me. At line 10 of file |
That runs fine. I get a ton of debug memory leak messages that should be fixed in general but the script works and produces the failed image. |
Ok, some testing on GMT 6.2.0rc2 (install using # Random data setup
import numpy as np
import pygmt
import xarray as xr
lats = np.arange(90.0, -91.0, -1.0)
lons = np.arange(0.0, 361.0, 1.0)
data = np.random.rand(181, 361)
da = xr.DataArray(data, coords=[("latitude", lats), ("longitude", lons)]) Case 1Previous whitespaces on the left and right are now coloured in correctly. fig = pygmt.Figure()
pygmt.makecpt(series=[0.0, 1.0, 0.1], cmap="vik", continuous=True)
fig.grdimage(da[0:121, 0:221], region="g", projection="W0/8i", frame=True)
fig.savefig("temp1.png")
fig.show() Case 2This previously failed with a complete blue image. Now the random data shows up, but there is still a white line running through the middle figure = pygmt.Figure()
pygmt.makecpt(series=[0., 1., 0.1], cmap='vik', continuous=True)
figure.grdimage(da[0:181, 0:360], region='g', projection='W0/8i', frame=True)
figure.savefig("temp2.png")
figure.show() |
You go 0 to 181 in latitude but not 0 to 361 in longitude? Aren't you missing a column? |
Ah right, thanks Paul. So we do need a redundant column to wrap around the dateline. Using Ok to close this issue @seisman since it's resolved with GMT 6.2.0rc2? Or do we want to do some more work/testing on this? |
I think we need to add a test for it although it's an upstream bug. |
Just a note that doing a slice of an |
…bset (#1314) Ensure that a sliced xarray.DataArray grid is plotted correctly on a global Mollweide projection map. This is a regression test to ensure that the bug reported in #732 does not happen in the future. Cross-reference upstream issue GenericMappingTools/gmt#5180, and PR GenericMappingTools/gmt#5181 where the bug was fixed. Co-authored-by: Dongdong Tian <[email protected]>
…bset (GenericMappingTools#1314) Ensure that a sliced xarray.DataArray grid is plotted correctly on a global Mollweide projection map. This is a regression test to ensure that the bug reported in GenericMappingTools#732 does not happen in the future. Cross-reference upstream issue GenericMappingTools/gmt#5180, and PR GenericMappingTools/gmt#5181 where the bug was fixed. Co-authored-by: Dongdong Tian <[email protected]>
Problem
I have a subset of data that I would like to plot on a global projection (such as mollweide). This works with GMT, but pygmt provides incorrect output.
Example
Let's create a global dataset of random numbers on a grid with 1 degree spacing in latitude and longitude:
Now let's plot only the region from 90N-30S and 0E-220E with a Mollweide projection centered on 180 E
This is as expected, but now do the same, but centered on 0 E
And as a second example, here I want to plot the global data, but using a dataset the doesn't contain the redundant data at 360 E
This is a complete failure, but changing the central meridian to 180 degrees works!
The text was updated successfully, but these errors were encountered: