Skip to content

Commit 6034d1f

Browse files
Explicitly loading lon and lat
1 parent ad334e2 commit 6034d1f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/parcels/_core/xgrid.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy.typing as npt
88
import xarray as xr
99
import xgcm
10+
from dask import is_dask_collection
1011

1112
import parcels._sgrid as sgrid
1213
import parcels._typing as ptyping
@@ -207,6 +208,9 @@ def lon(self):
207208
_ = self.xgcm_grid.axes["X"]
208209
except KeyError:
209210
return np.zeros(1)
211+
# ensure lon is loaded into memory for dask-backed datasets, as it is used in the search method
212+
if is_dask_collection(self._ds["lon"].data):
213+
self._ds["lon"].load()
210214
return self._ds["lon"].values
211215

212216
@property
@@ -221,6 +225,9 @@ def lat(self):
221225
_ = self.xgcm_grid.axes["Y"]
222226
except KeyError:
223227
return np.zeros(1)
228+
# ensure lat is loaded into memory for dask-backed datasets, as it is used in the search method
229+
if is_dask_collection(self._ds["lat"].data):
230+
self._ds["lat"].load()
224231
return self._ds["lat"].values
225232

226233
@property

0 commit comments

Comments
 (0)