Skip to content

Commit d8a7f9e

Browse files
authored
Fix the grid accessor (grid registration and type) for 3D grids (#1913)
1 parent ae4584c commit d8a7f9e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pygmt/accessors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def __init__(self, xarray_obj):
2929
self._obj = xarray_obj
3030
try:
3131
self._source = self._obj.encoding["source"] # filepath to NetCDF source
32-
# From the shortened summary information of `grdinfo`,
33-
# get grid registration in column 10, and grid type in column 11
32+
# Get grid registration and grid type from the last two columns of
33+
# the shortened summary information of `grdinfo`.
3434
self._registration, self._gtype = map(
35-
int, grdinfo(self._source, per_column="n", o="10,11").split()
35+
int, grdinfo(self._source, per_column="n").split()[-2:]
3636
)
3737
except (KeyError, ValueError):
3838
self._registration = 0 # Default to Gridline registration

0 commit comments

Comments
 (0)