Description
Description of the problem
PyGMT currently assumes xarray.DataArray
grids as gridline registered (GMT_GRID_NODE_REG
), and of cartesian type (GMT_GRID_IS_CARTESIAN
). This hardcoding has very likely resulted in the issue reported by @MarkWieczorek at #375. Note that this is a non-issue for users passing in NetCDF filenames directly (phew).
Currrently we are working on allowing for either pixel/gridline registered and cartesian/geographic grids at #476, by changing the virtualfile_from_grid
mechanism. But we'll need to decide on a good default going forward.
Current (hardcoded) default:
- Gridline registered
GMT_GRID_NODE_REG
- Cartesian type
GMT_GRID_IS_CARTESIAN
Proposed default:
- Pixel registered
GMT_GRID_PIXEL_REG
- Geographic type
GMT_GRID_IS_GEO
?
For the former, my rationale for changing the default to pixel registration is because xarray
does so (see http://xarray.pydata.org/en/stable/plotting.html#coordinates), though there are libraries like salem
that allow changing an xarray grid coordinates from corner (gridline) to centre (pixel) based (see salem.Grid.corner_grid
).
For the latter (cartesian/geographic), users will probably realize quite quickly that their grid isn't Geographic and set the appropriate Cartesian flag. It will probably be less surprising for those users plotting across the dateline too (e.g. #390).
In any case, I say we keep the current default for now (say for a v0.1.2 release), and introduce any breaking changes in v0.2.0 (also after GMT 6.1.0 comes out).
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()"
:
PyGMT information:
version: v0.1.1+18.gd203cd5f.dirty
System information:
python: 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:57:50) [GCC 7.5.0]
executable: /home/user/miniconda3/envs/pygmt/bin/python
machine: Linux-5.4.0-37-generic-x86_64-with-debian-bullseye-sid
Dependency information:
numpy: 1.18.5
pandas: 1.0.5
xarray: 0.15.1
netCDF4: 1.5.3
packaging: 20.4
ghostscript: 9.22
gmt: 6.0.0
GMT library information:
binary dir: /home/user/miniconda3/envs/pygmt/bin
cores: 6
grid layout: rows
library path: /home/user/miniconda3/envs/pygmt/lib/libgmt.so
padding: 2
plugin dir: /home/user/miniconda3/envs/pygmt/lib/gmt/plugins
share dir: /home/user/miniconda3/envs/pygmt/share/gmt
version: 6.0.0