From afbb82ad786c57e93c3b973b205483da0af5396d Mon Sep 17 00:00:00 2001 From: Jonathan Citrin Date: Tue, 7 Jan 2025 09:47:03 -0800 Subject: [PATCH] Update the compare_sim_tests script to avoid 0.0 on-axis values PiperOrigin-RevId: 712945464 --- torax/tests/scripts/compare_sim_tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/torax/tests/scripts/compare_sim_tests.py b/torax/tests/scripts/compare_sim_tests.py index 530a4e4b..2639b4b2 100644 --- a/torax/tests/scripts/compare_sim_tests.py +++ b/torax/tests/scripts/compare_sim_tests.py @@ -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))