From 3020a3efd8afaeb482906f1c809d07adb98e2457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentina=20Sch=C3=BCller?= Date: Mon, 30 Mar 2026 17:13:52 +0200 Subject: [PATCH 1/5] Add test to reproduce bug observed by Vladimir --- tests/test_oifs_timeseries.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_oifs_timeseries.py b/tests/test_oifs_timeseries.py index d15abc8..90340e5 100644 --- a/tests/test_oifs_timeseries.py +++ b/tests/test_oifs_timeseries.py @@ -29,7 +29,7 @@ def test_oifs_global_mean_year_mean_timeseries_working(tmp_path): ) -def test_oifs_timeseries_compare_grids(tmp_path): +def test_oifs_timeseries_compare_grids_mean(tmp_path): init = { "src": ["./tests/testdata/regular_grid_tas.nc"], "dst": str(tmp_path / "test_reg.nc"), @@ -50,6 +50,27 @@ def test_oifs_timeseries_compare_grids(tmp_path): assert abs(cube_red.data - cube_reg.data) < 1e-3 +def test_oifs_timeseries_compare_grids_sum(tmp_path): + init = { + "src": ["./tests/testdata/regular_grid_tas.nc"], + "dst": str(tmp_path / "test_reg.nc"), + "varname": "tas", + } + atmo_ts = OifsGlobalSumYearMeanTimeseries(init) + atmo_ts.run(init) + cube_reg = iris.load_cube(init["dst"]) + + init = { + "src": ["./tests/testdata/reduced_grid_tas.nc"], + "dst": str(tmp_path / "test_red.nc"), + "varname": "tas", + } + atmo_ts = OifsGlobalSumYearMeanTimeseries(init) + atmo_ts.run(init) + cube_red = iris.load_cube(init["dst"]) + assert abs(cube_red.data - cube_reg.data) < 1e-2 * abs(cube_red.data) + + def test_oifs_global_mean_year_mean_timeseries_wrong_varname(tmp_path): init = { "src": ["./tests/testdata/TES1_atm_1m_1990_2t.nc"], From 37f4187831aff65eaf611b876de67d30423abb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentina=20Sch=C3=BCller?= Date: Mon, 30 Mar 2026 17:14:58 +0200 Subject: [PATCH 2/5] Fix: Use OpenIFS Earth radius in compute_reduced_grid_weights() --- helpers/cubes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/cubes.py b/helpers/cubes.py index a15acbe..93699f2 100644 --- a/helpers/cubes.py +++ b/helpers/cubes.py @@ -185,7 +185,7 @@ def compute_reduced_grid_weights(cube): unique_lats, gridpoints_per_lat = unique_lats[0:-1], gridpoints_per_lat[0:-1] areas = [] last_angle = 0 - earth_radius = 6371 + earth_radius = 6.371229e6 for latitude, amount in zip(unique_lats, gridpoints_per_lat): delta = latitude - last_angle current_angle = last_angle + 2 * delta From 91f46f4636910ab34577588b9aa43ca1470c3e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentina=20Sch=C3=BCller?= Date: Mon, 30 Mar 2026 17:17:04 +0200 Subject: [PATCH 3/5] Update CHANGES --- CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index f9894e0..ebe853d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,10 @@ Next Release ============= +Bugfixes +--------- +- Fix Earth area computation for reduced Gaussian grid (PR #127) + Internal changes ----------------- - Move `get_template` into `helpers.files` (PR #125) From 3ac89132ba78b398ad2e546fce078f719a6ab838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentina=20Sch=C3=BCller?= Date: Mon, 30 Mar 2026 17:46:49 +0200 Subject: [PATCH 4/5] Suppress a warning from regular grid computation This is expected behavior and we can catch it --- helpers/cubes.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/helpers/cubes.py b/helpers/cubes.py index 93699f2..0ac9623 100644 --- a/helpers/cubes.py +++ b/helpers/cubes.py @@ -5,6 +5,7 @@ import iris import iris.analysis.cartography import iris.cube +import iris.warnings import numpy as np from iris.util import equalise_attributes from scriptengine.exceptions import ( @@ -203,7 +204,14 @@ def compute_regular_grid_weights(cube): """compute area weights for a regular lat/lon grid""" cube.coord("latitude").guess_bounds() cube.coord("longitude").guess_bounds() - return iris.analysis.cartography.area_weights(cube) + with warnings.catch_warnings(): + # Suppress default radius warning + warnings.filterwarnings( + action="ignore", + message="Using DEFAULT_SPHERICAL_EARTH_RADIUS", + category=iris.warnings.IrisDefaultingWarning, + ) + return iris.analysis.cartography.area_weights(cube) def align_time_coords(new_cube, old_cube): From fdd4316c5ed8eefe7da476e6bfeeb315f43970da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentina=20Sch=C3=BCller?= <64773821+valentinaschueller@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:24:06 +0200 Subject: [PATCH 5/5] Add comment with unit Co-authored-by: Uwe Fladrich <49554848+uwefladrich@users.noreply.github.com> --- helpers/cubes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/cubes.py b/helpers/cubes.py index 0ac9623..c9ab7a5 100644 --- a/helpers/cubes.py +++ b/helpers/cubes.py @@ -186,7 +186,7 @@ def compute_reduced_grid_weights(cube): unique_lats, gridpoints_per_lat = unique_lats[0:-1], gridpoints_per_lat[0:-1] areas = [] last_angle = 0 - earth_radius = 6.371229e6 + earth_radius = 6.371229e6 # m for latitude, amount in zip(unique_lats, gridpoints_per_lat): delta = latitude - last_angle current_angle = last_angle + 2 * delta