Skip to content

Commit

Permalink
Update the compare_sim_tests script to avoid 0.0 on-axis values
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 712942162
  • Loading branch information
jcitrin authored and Torax team committed Jan 7, 2025
1 parent e6a6ace commit 7d7087d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions torax/tests/scripts/compare_sim_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ def _print_diff(profile_name: str, ds_old: xr.Dataset, ds_new: xr.Dataset):
ds_old: Dataset containing the old simulation output.
ds_new: Dataset containing the new simulation output.
"""
old_value = ds_old[profile_name].isel(time=-1).to_numpy()
new_value = ds_new[profile_name].isel(time=-1).to_numpy()

if (profile_name == 's_face') or (profile_name == 'psi'):
# Avoid potential 0.0 on-axis
old_value = ds_old[profile_name].isel(time=-1).to_numpy()[1:]
new_value = ds_new[profile_name].isel(time=-1).to_numpy()[1:]
else:
old_value = ds_old[profile_name].isel(time=-1).to_numpy()
new_value = ds_new[profile_name].isel(time=-1).to_numpy()

abs_diff = np.mean(np.abs(old_value - new_value))
rel_diff = np.mean(np.abs((old_value - new_value) / old_value))
Expand Down

0 comments on commit 7d7087d

Please sign in to comment.