Skip to content

Commit 99fcd82

Browse files
Use fillna in convert functions
1 parent 38fc2e8 commit 99fcd82

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/parcels/convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ def nemo_to_sgrid(*, fields: dict[str, xr.Dataset | xr.DataArray], coords: xr.Da
339339
ds = _maybe_remove_depth_from_lonlat(ds)
340340
ds = _set_axis_attrs(ds, _NEMO_AXIS_VARNAMES)
341341

342+
ds = ds.fillna(0) # set NaN values to 0
343+
342344
expected_axes = set("XYZT") # TODO: Update after we have support for 2D spatial fields
343345
if missing_axes := (expected_axes - set(ds.cf.axes)):
344346
raise ValueError(
@@ -541,6 +543,9 @@ def copernicusmarine_to_sgrid(
541543
ds.attrs.clear() # Clear global attributes from the merging
542544

543545
ds = _maybe_rename_coords(ds, _COPERNICUS_MARINE_AXIS_VARNAMES)
546+
547+
ds = ds.fillna(0) # set NaN values to 0
548+
544549
if "W" in ds.data_vars:
545550
# Negate W to convert from up positive to down positive (as that's the direction of positive z)
546551
ds["W"].data *= -1

0 commit comments

Comments
 (0)