Skip to content

Commit 872b75c

Browse files
Setting lon and lat as coordinates
1 parent 0ac7ae0 commit 872b75c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

parcels/xgrid.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ def __init__(self, grid: xgcm.Grid, mesh="flat"):
101101
self._mesh = mesh
102102
self._spatialhash = None
103103
ds = grid._ds
104-
if "lon" in ds and hasattr(ds["lon"], "load"):
105-
ds["lon"].load()
106-
if "lat" in ds and hasattr(ds["lat"], "load"):
107-
ds["lat"].load()
104+
105+
# Set the coordinates for the dataset (needed to be done explicitly for curvilinear grids)
106+
if "lon" in ds:
107+
ds.set_coords("lon")
108+
if "lat" in ds:
109+
ds.set_coords("lat")
108110

109111
if len(set(grid.axes) & {"X", "Y", "Z"}) > 0: # Only if spatial grid is >0D (see #2054 for further development)
110112
assert_valid_lat_lon(ds["lat"], ds["lon"], grid.axes)

0 commit comments

Comments
 (0)