Skip to content

Commit 0a4664d

Browse files
Fix surface field plotter for MNC diagnostics Z dimension naming
MNC NetCDF uses Zmd000050 (not Z) for the vertical dimension in diagnostics output. Match any dimension starting with Z when extracting the surface level. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent accc22f commit 0a4664d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

spectre_utils/plot_surface_fields.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,19 @@ def stitch_field_2d(run_dir, file_prefix, timestep_str, var_name, layout,
9898
ds.close()
9999
continue
100100
data = ds[var_name]
101-
if k is not None and "Z" in data.dims:
102-
data = data.isel(Z=k)
101+
# Select surface level — Z dim name varies (e.g. Zmd000050, Z, Zl)
102+
if k is not None:
103+
z_dims = [d for d in data.dims if d.startswith("Z")]
104+
if z_dims:
105+
data = data.isel({z_dims[0]: k})
103106
if "T" in data.dims:
104107
data = data.isel(T=-1)
105108
arr = data.values.squeeze()
106109
ds.close()
107110

108111
j0 = py * sNy
109112
i0 = px * sNx
110-
# Handle possible halo differences
113+
# Trim staggered grid points (Xp1/Yp1) and halos to tile size
111114
ny_tile = min(arr.shape[-2], sNy)
112115
nx_tile = min(arr.shape[-1], sNx)
113116
global_field[j0:j0 + ny_tile, i0:i0 + nx_tile] = arr[:ny_tile, :nx_tile]

0 commit comments

Comments
 (0)