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

grdimage can not plot data with decreasing latitudes #368

Closed
MarkWieczorek opened this issue Nov 4, 2019 · 4 comments
Closed

grdimage can not plot data with decreasing latitudes #368

MarkWieczorek opened this issue Nov 4, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@MarkWieczorek
Copy link
Contributor

grdimage fails when attempting to plot grids that are not "global" [0, 360, -90, 90].

The xarray dataset I am trying to plot is equispaced in latitude and longitude, and normally would work with gmt. When trying to plot with pygmt however, the routine goes into some kind of infinite loop and never terminates.

The xarray dataset has the following characteristics:

Coordinates:
  * latitude   (latitude) float64 90.0 80.0 70.0 60.0 ... -60.0 -70.0 -80.0
  * longitude  (longitude) float64 0.0 10.0 20.0 30.0 ... 330.0 340.0 350.0

and I tried to plot the data using

fig.grdimage(grid, region=[0., 360., -90, 90], projection="W0/6i")

I note that the redundant data points at 360 E are not provided, and the data point at the south pole is not provided. I further note that this is the standard format for Driscoll and Healy sampled grids which are employed in pyshtools.

@MarkWieczorek
Copy link
Contributor Author

With more investigation, it turns out that grdimage works when reading a netcdf file, but not when using an xarray dataarray. In particular, the following works:

fig.grdimage('test.cdf', region='g', projection="W0/6i")

but the following doesn't

grid = xr.load_dataset('test.cdf')
fig.grdimage(grid.data, region='g', projection="W0/6i") # data is the name of the dataarray

@MarkWieczorek
Copy link
Contributor Author

I've narrowed the problem down to the following:

pygmt can not deal with grids where latitudes decrease, such as [90, 80, ....-80].

By inverting the array of latitudes, everything worked fine (but with an upside down image). Given that gmt can correctly parse this, the problem is somewhere in pygmt.

@MarkWieczorek MarkWieczorek changed the title grdimage fails when gridded data are not "global" grdimage can not plot data with decreasing latitudes Nov 5, 2019
@weiji14 weiji14 added the bug Something isn't working label Nov 5, 2019
@weiji14
Copy link
Member

weiji14 commented Nov 5, 2019

Hi @MarkWieczorek, thanks for taking a look at this, and opening a Pull Request too! I'll try and review your work in a bit.

@weiji14
Copy link
Member

weiji14 commented Nov 11, 2019

Closed in #369.

@weiji14 weiji14 closed this as completed Nov 11, 2019
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

2 participants