Skip to content

Commit

Permalink
updating regen results and expected results for fabm0d
Browse files Browse the repository at this point in the history
  • Loading branch information
wathen committed Jul 24, 2024
1 parent cd97ff6 commit 5a45813
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion github-actions/fabm0d-gotm-ersem/expected.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions github-actions/regen_expected_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@ def default(self, obj):
expected_results = {}
for v in items:
try:
if key == "expected":
if v == "dates":
times = data.variables['time']
dates = nc.num2date(times[:],
units=times.units,
calendar=times.calendar)
dates = [str(d).split(" ")[0] for d in dates]
expected_results[v] = dates
elif v == "time":
print(data.variables[v])
else:
depth = 0.0
var = data.variables[v]
zi = data.variables['zi'][:].squeeze()
z = data.variables['z'][:].squeeze()
var_time_series = []
for i in range(var.shape[0]):
depth_offset = depth + zi[i, -1]
var_time_series.append(interp(depth_offset, z[i, :], var[i, :].squeeze()))
expected_results[v] = var_time_series
if v == "dates":
times = data.variables['time']
dates = nc.num2date(times[:],
units=times.units,
calendar=times.calendar)
dates = [str(d).split(" ")[0] for d in dates]
expected_results[v] = dates
elif key == "expected" and model_run == "gotm":
depth = 0.0
var = data.variables[v]
zi = data.variables['zi'][:].squeeze()
z = data.variables['z'][:].squeeze()
var_time_series = []
for i in range(var.shape[0]):
depth_offset = depth + zi[i, -1]
var_time_series.append(interp(depth_offset, z[i, :], var[i, :].squeeze()))
expected_results[v] = var_time_series

elif data.variables[v].ndim == 4:
expected_results[v] = data.variables[v][:].squeeze()[-1, :]
expected_results[v] = data.variables[v][:].squeeze() \
if model_run == "fabm0d" else expected_results[v][-1, :]
elif data.variables[v].ndim == 3:
expected_results[v] = float(data.variables[v][:].squeeze()[-1])
expected_results[v] = data.variables[v][:].squeeze() \
if model_run == "fabm0d" else \
float(data.variables[v][:].squeeze()[-1])
else:
raise RuntimeError
except Exception as e:
Expand Down

0 comments on commit 5a45813

Please sign in to comment.