Skip to content

Commit

Permalink
fix: transposed plan and nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsail committed Oct 15, 2024
1 parent a59d547 commit 5045a98
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xarray_selafin/xarray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def write_serafin(fout, ds):
if "plan" in ds.dims: # 3D
slf_header.nb_planes = len(ds.plan)
slf_header.is_2d = False
shape = (slf_header.nb_var, slf_header.nb_nodes_2d, slf_header.nb_planes)
shape = (slf_header.nb_var, slf_header.nb_planes, slf_header.nb_nodes_2d)
else: # 2D (converted if required)
# if ds.attrs["type"] == "3D":
# slf_header.is_2d = False # to enable conversion from 3D
Expand Down Expand Up @@ -166,7 +166,7 @@ def write_serafin(fout, ds):
else:
temp[iv] = ds.isel(time=it)[var]
if slf_header.nb_planes > 1:
temp[iv] = np.reshape(np.ravel(temp[iv]), (slf_header.nb_nodes_2d, slf_header.nb_planes))
temp[iv] = np.reshape(np.ravel(temp[iv]), (slf_header.nb_planes, slf_header.nb_nodes_2d))
resout.write_entire_frame(
slf_header,
t_,
Expand Down Expand Up @@ -291,8 +291,8 @@ def open_dataset(
shape = (len(times), npoin2)
dims = ["time", "node"]
else:
shape = (len(times), npoin2, nplan)
dims = ["time", "node", "plan"]
shape = (len(times), nplan, npoin2)
dims = ["time", "plan", "node"]

for var in vars:
if lazy_loading:
Expand All @@ -306,7 +306,7 @@ def open_dataset(
if is_2d:
data[time_index, :] = values
else:
data[time_index, :, :] = np.reshape(values, (nplan, npoin2)).T
data[time_index, :, :] = np.reshape(values, (nplan, npoin2))
data_vars[var] = xr.Variable(dims=dims, data=data)

coords = {
Expand Down

0 comments on commit 5045a98

Please sign in to comment.