Skip to content

Commit c1bf85a

Browse files
committed
Update _maybe_bring_other_depths_to_depth
1 parent b1b95b2 commit c1bf85a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/parcels/convert.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,14 @@ def _pick_expected_coords(coords: xr.Dataset, expected_coord_names: list[str]) -
9696
def _maybe_bring_other_depths_to_depth(ds):
9797
if "depth" in ds.coords:
9898
for var in ds.data_vars:
99-
for old_depth in ["depthu", "depthv", "deptht", "depthw"]:
99+
for old_depth, target in [
100+
("depthu", "depth_center"),
101+
("depthv", "depth_center"),
102+
("deptht", "depth_center"),
103+
("depthw", "depth"),
104+
]:
100105
if old_depth in ds[var].dims:
101-
ds[var] = ds[var].assign_coords(**{old_depth: ds["depth"].values}).rename({old_depth: "depth"})
106+
ds[var] = ds[var].rename({old_depth: target})
102107
return ds
103108

104109

0 commit comments

Comments
 (0)