Skip to content

Commit d6fc988

Browse files
committed
Small refactor of from_copernicusmarine
1 parent 6e47206 commit d6fc988

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/parcels/_core/fieldset.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ def from_copernicusmarine(ds: xr.Dataset):
216216
)
217217

218218
ds = _rename_coords_copernicusmarine(ds)
219+
if "W" in ds.data_vars:
220+
ds["W"] -= ds[
221+
"W"
222+
] # Negate W to convert from up positive to down positive (as that's the direction of positive z)
219223
grid = XGrid(
220224
xgcm.Grid(
221225
ds,
@@ -245,10 +249,9 @@ def from_copernicusmarine(ds: xr.Dataset):
245249
fields["V"] = Field("V", ds["V"], grid, XLinear)
246250

247251
if "W" in ds.data_vars:
248-
ds["W"] -= ds[
249-
"W"
250-
] # Negate W to convert from up positive to down positive (as that's the direction of positive z)
251-
fields["W"] = Field("W", ds["W"], grid, XLinear)
252+
fields["W"] = Field(
253+
"W", ds["W"], grid, XLinear
254+
) # TODO: Choose interpolator based on `location` SGRID attribute
252255
fields["UVW"] = VectorField("UVW", fields["U"], fields["V"], fields["W"])
253256
else:
254257
fields["UV"] = VectorField("UV", fields["U"], fields["V"])

0 commit comments

Comments
 (0)