-
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 correctly plot xarray DataArrays when they don't contain the redundant longitude at 360 E #375
Comments
And here is a simple script that demonstrates this problem:
|
This might be related to pixel registered vs grid node registered grids. GMT makes a lot of internal assumptions when reading the netCDF file that we don't when converting the xarray.DataArray. |
If I use the As for pygmt, grdimage creates a virtual file using
And here is the code for this function
If you look at So, to the best of my knowledge, pygmt is assuming that all xarrays are gridline registered. If this is the case, this is a bug. There are probably one of three ways to resolve this problem:
Edit: by the way, I think that pygmt routines should have a keyword |
Ah, the ol' gridline vs pixel based registration problem. I think you hit the nail on the head there @MarkWieczorek. I'm pretty sure Not sure if setting the default registration to pixel-based would solve the issue (since we're using xarray, it might be necessary?), but |
I don't think that this is a pixel related issue. pygmt uses the routine As you say, xarray used center-based coordinates, but this corresponds to gridline registration in gmt. (The coordinates are at the grid line intersections that occur at the center of the pixel, not the edges). It is possible that gmt is misinterpreting the virtual file as pixel registered, and if this is the case, this is a bug with gmt. It is conceivable that gmt uses the ration of nlat and nlon to guess the registration, and since my grid doesn't include the redundant longitude at 360E, I could perhaps see this being a problem if gmt has to guess the registration. |
Hi @MarkWieczorek, sorry for not following up on this soon enough. I think we've found the issue, and it's probably because the virtualfile mechanism assumes all xarray grids as Cartesian instead of Geographic (see #476 (comment)). We're working on allowing users to tell PyGMT whether their grid is Cartesian/Geographic, and Pixel/Gridline registered. This might take some time to implement as there's a lot of issues to iron out, and the team will be busy with GMT 6.1.0. But you can provide some feedback on #487 which decides what the recommended default will be going forward. |
Keep the default as Cartesian, but allow for either Cartesian (c) or Geographic (g) coordinate system grid types. Test case based on #375 (comment).
grdimage
of pygmt does not correctly plot xarray DataArrays when they do not contain the redundant column of data at 360 E.Using pygmt directly with a netcdf file provides the correct output, such as with a command like:
However, here is the same output generated by pygmt when using an xarray in memory:
The text was updated successfully, but these errors were encountered: