From b529094bfa184934bcc158fba6cbdee6e714b3c3 Mon Sep 17 00:00:00 2001 From: James Warner Date: Tue, 31 Mar 2026 09:04:42 +0100 Subject: [PATCH 1/4] read fixes --- src/CSET/operators/read.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CSET/operators/read.py b/src/CSET/operators/read.py index 6c30af1e7..b294093cf 100644 --- a/src/CSET/operators/read.py +++ b/src/CSET/operators/read.py @@ -430,6 +430,9 @@ def _lfric_normalise_callback(cube: iris.cube.Cube, field, filename): cube.attributes.pop("timeStamp", None) cube.attributes.pop("uuid", None) cube.attributes.pop("name", None) + cube.attributes.pop("source", None) + cube.attributes.pop("analysis_source", None) + cube.attributes.pop("history", None) # Sort STASH code list. stash_list = cube.attributes.get("um_stash_source") @@ -968,6 +971,8 @@ def _lfric_forecast_period_standard_name_callback(cube: iris.cube.Cube): """Add forecast_period standard name if missing.""" try: coord = cube.coord("forecast_period") + if coord.units != "hours": + cube.coord("forecast_period").convert_units("hours") if not coord.standard_name: coord.standard_name = "forecast_period" except iris.exceptions.CoordinateNotFoundError: From 909331334be6bc466b3a2bf101cef8a767c16ebe Mon Sep 17 00:00:00 2001 From: James Warner Date: Tue, 31 Mar 2026 14:08:27 +0100 Subject: [PATCH 2/4] add test --- tests/operators/test_read.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/operators/test_read.py b/tests/operators/test_read.py index 716362ee8..d519ce539 100644 --- a/tests/operators/test_read.py +++ b/tests/operators/test_read.py @@ -792,6 +792,14 @@ def test_lfric_forecast_period_standard_name_callback(cube): assert cube.coord("forecast_period").standard_name == "forecast_period" +def test_lfric_forecast_period_convert_units_callback(cube): + """Ensure forecast period coordinates have a standard name.""" + cube.coord("forecast_period").convert_units("seconds") + assert cube.coord("forecast_period").units == "seconds" + read._lfric_forecast_period_standard_name_callback(cube) + assert cube.coord("forecast_period").units == "hours" + + def test_read_cubes_extract_cells(): """Read cube and ensure appropriate number of cells are trimmed from domain edges.""" cube = read.read_cubes( From f8ba388cce01763a8ba0474f0ba30bd2a7249235 Mon Sep 17 00:00:00 2001 From: James Warner Date: Tue, 31 Mar 2026 14:13:57 +0100 Subject: [PATCH 3/4] update test --- tests/operators/test_read.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/operators/test_read.py b/tests/operators/test_read.py index d519ce539..a9a7ebcfa 100644 --- a/tests/operators/test_read.py +++ b/tests/operators/test_read.py @@ -788,7 +788,7 @@ def test_normalise_var0_varname(model_level_cube): def test_lfric_forecast_period_standard_name_callback(cube): """Ensure forecast period coordinates have a standard name.""" cube.coord("forecast_period").standard_name = None - read._lfric_forecast_period_standard_name_callback(cube) + read._lfric_forecast_period_callback(cube) assert cube.coord("forecast_period").standard_name == "forecast_period" @@ -796,7 +796,7 @@ def test_lfric_forecast_period_convert_units_callback(cube): """Ensure forecast period coordinates have a standard name.""" cube.coord("forecast_period").convert_units("seconds") assert cube.coord("forecast_period").units == "seconds" - read._lfric_forecast_period_standard_name_callback(cube) + read._lfric_forecast_period_callback(cube) assert cube.coord("forecast_period").units == "hours" From cd001284a26a11ef3ebef985ea0de7c8bcde4cb6 Mon Sep 17 00:00:00 2001 From: James Warner Date: Tue, 31 Mar 2026 14:19:57 +0100 Subject: [PATCH 4/4] update func name --- src/CSET/operators/read.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CSET/operators/read.py b/src/CSET/operators/read.py index b294093cf..775e0b115 100644 --- a/src/CSET/operators/read.py +++ b/src/CSET/operators/read.py @@ -373,7 +373,7 @@ def _loading_callback(cube: iris.cube.Cube, field, filename: str) -> iris.cube.C _fix_lfric_cloud_base_altitude(cube) _proleptic_gregorian_fix(cube) _lfric_time_callback(cube) - _lfric_forecast_period_standard_name_callback(cube) + _lfric_forecast_period_callback(cube) return cube @@ -967,8 +967,8 @@ def _lfric_time_callback(cube: iris.cube.Cube): logging.warning("No time coordinate on cube.") -def _lfric_forecast_period_standard_name_callback(cube: iris.cube.Cube): - """Add forecast_period standard name if missing.""" +def _lfric_forecast_period_callback(cube: iris.cube.Cube): + """Check forecast_period name and units.""" try: coord = cube.coord("forecast_period") if coord.units != "hours":