You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
grdimage does not plot subsets of data correctly on a global map #732
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:
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 ?
python ~/bad.py (this is the script posted above)
Traceback (most recent call last):
File "/Users/pwessel/bad.py", line 2, in <module>
import pygmt
File "/Users/pwessel/GMTdev/pygmt/pygmt/__init__.py", line 28, in <module>
from pygmt.figure import Figure, set_display
File "/Users/pwessel/GMTdev/pygmt/pygmt/figure.py", line 9, in <module>
import IPython
ModuleNotFoundError: No module named 'IPython'
python ~/bad.py (this is the script posted above)
Traceback (most recent call last):
File "/Users/pwessel/bad.py", line 2, in <module>
import pygmt
File "/Users/pwessel/GMTdev/pygmt/pygmt/__init__.py", line 28, in <module>
from pygmt.figure import Figure, set_display
File "/Users/pwessel/GMTdev/pygmt/pygmt/figure.py", line 9, in <module>
import IPython
ModuleNotFoundError: No module named 'IPython'
I think you found a PyGMT bug which was introduced recently.
(pygmt) pwessel@macnut:~/GMTdev/pygmt-> conda activate python
Could not find conda environment: python
You can list all discoverable environments with conda info --envs.
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):
File "/Users/pwessel/bad.py", line 2, in
import pygmt
File "/Users/pwessel/GMTdev/pygmt/pygmt/init.py", line 28, in
from pygmt.figure import Figure, set_display
File "/Users/pwessel/GMTdev/pygmt/pygmt/figure.py", line 9, in
import IPython
ModuleNotFoundError: No module named 'IPython'
The path is incorrect. After activating the pygmt environment, you should be using /Users/pwessel/opt/miniconda3/envs/pygmt/bin/python. Did you forget to run conda activate pygmt?
At line 10 of file /Users/pwessel/GMTdev/pygmt/pygmt/figure.py, changing KeyError to ModuleNotFoundError, then try to run the bad.py script, does it work for you?
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 figure.grdimage(da[0:181, 0:361], region="g", projection="W0/8i", frame=True) removes the middle white line (though it complains with grdimage [WARNING]: Longitude range too small; geographic boundary condition changed to natural.):
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?
Just a note that doing a slice of an xarray.DataArray grid resets the coordinate system from Geographic type to Cartesian type as mentioned in #524 (comment) and this may be part of the issue (specifically for the 'white line in the middle' case 2 in #732 (comment)).
Activity
seisman commentedon Dec 15, 2020
@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:
seisman commentedon Dec 30, 2020
Ping @PaulWessel
weiji14 commentedon Apr 23, 2021
Still an issue on GMT 6.2.0rc1
PaulWessel commentedon Apr 25, 2021
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 ?
PaulWessel commentedon Apr 26, 2021
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)
seisman commentedon Apr 26, 2021
I think you found a PyGMT bug which was introduced recently.
Your temporary fix is:
PaulWessel commentedon Apr 26, 2021
So I am on miniconda:
(pygmt) pwessel@macnut:~/GMTdev/pygmt-> conda activate python
Could not find conda environment: python
You can list all discoverable environments with
conda info --envs.seisman commentedon Apr 26, 2021
Sorry, typo. I meant:
PaulWessel commentedon Apr 26, 2021
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):
File "/Users/pwessel/bad.py", line 2, in
import pygmt
File "/Users/pwessel/GMTdev/pygmt/pygmt/init.py", line 28, in
from pygmt.figure import Figure, set_display
File "/Users/pwessel/GMTdev/pygmt/pygmt/figure.py", line 9, in
import IPython
ModuleNotFoundError: No module named 'IPython'
seisman commentedon Apr 26, 2021
What's the output of
which python? Just want to make sure that you're running the one in the pygmt environment.PaulWessel commentedon Apr 26, 2021
/Users/pwessel/opt/miniconda3/bin/python
seisman commentedon Apr 26, 2021
The path is incorrect. After activating the pygmt environment, you should be using
/Users/pwessel/opt/miniconda3/envs/pygmt/bin/python. Did you forget to runconda activate pygmt?PaulWessel commentedon Apr 26, 2021
No, and just run it again. Same path coming back.
seisman commentedon Apr 26, 2021
It doesn't make sense to me.
At line 10 of file
/Users/pwessel/GMTdev/pygmt/pygmt/figure.py, changingKeyErrortoModuleNotFoundError, then try to run the bad.py script, does it work for you?PaulWessel commentedon Apr 26, 2021
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.
weiji14 commentedon May 25, 2021
Ok, some testing on GMT 6.2.0rc2 (install using
conda install -c conda-forge/label/dev gmt=6.2.0rc2):Case 1
Previous whitespaces on the left and right are now coloured in correctly.
Case 2
This previously failed with a complete blue image. Now the random data shows up, but there is still a white line running through the middle
PaulWessel commentedon May 26, 2021
You go 0 to 181 in latitude but not 0 to 361 in longitude? Aren't you missing a column?
weiji14 commentedon May 26, 2021
Ah right, thanks Paul. So we do need a redundant column to wrap around the dateline. Using
figure.grdimage(da[0:181, 0:361], region="g", projection="W0/8i", frame=True)removes the middle white line (though it complains withgrdimage [WARNING]: Longitude range too small; geographic boundary condition changed to natural.):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?
seisman commentedon May 28, 2021
I think we need to add a test for it although it's an upstream bug.
weiji14 commentedon Jun 1, 2021
Just a note that doing a slice of an
xarray.DataArraygrid resets the coordinate system from Geographic type to Cartesian type as mentioned in #524 (comment) and this may be part of the issue (specifically for the 'white line in the middle' case 2 in #732 (comment)).Add regression test for grdimage plotting an xarray.DataArray grid su…
Add regression test for grdimage plotting an xarray.DataArray grid su…