diff --git a/.zenodo.json b/.zenodo.json index 55593cda80..c276384a2e 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -244,6 +244,10 @@ "affiliation": "BSC, Spain", "name": "Ghosh, Supriyo", "orcid": "0000-0003-0581-9907" + }, + { + "affiliation": "DLR, Germany", + "name": "Caspers, Laura" } ], "description": "ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.", diff --git a/CITATION.cff b/CITATION.cff index 913a2f0a35..a071d563e6 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -248,6 +248,10 @@ authors: family-names: Ghosh given-names: Supriyo orcid: "https://orcid.org/0000-0003-0581-9907" + - + affiliation: "DLR, Germany" + family-names: Caspers + given-names: Laura cff-version: 1.2.0 date-released: 2026-07-15 diff --git a/doc/recipe/preprocessor.rst b/doc/recipe/preprocessor.rst index 6ef6f0b206..e2e8e33513 100644 --- a/doc/recipe/preprocessor.rst +++ b/doc/recipe/preprocessor.rst @@ -2589,6 +2589,10 @@ For example, this enables conversions between precipitation fluxes measured in versa). Currently, the following special conversions are supported: +* ``precipitation_amount`` (``kg m-2``) -- + ``lwe_thickness_of_precipitation_amount`` (``mm``) +* ``surface_snow_amount`` (``kg m-2``) -- + ``lwe_thickness_of_snowfall_amount`` (``mm``) * ``precipitation_flux`` (``kg m-2 s-1``) -- ``lwe_precipitation_rate`` (``mm day-1``) * ``water_evaporation_flux`` (``kg m-2 s-1``) -- diff --git a/esmvalcore/iris_helpers.py b/esmvalcore/iris_helpers.py index 4e917d6b45..f96552f1ce 100644 --- a/esmvalcore/iris_helpers.py +++ b/esmvalcore/iris_helpers.py @@ -401,6 +401,14 @@ def has_unstructured_grid(cube: Cube) -> bool: # special case need to be "physically identical", e.g., 1 kg m-2 s-1 "equals" 1 # mm s-1 for precipitation _SPECIAL_UNIT_CONVERSIONS: list[list[tuple[str | None, str]]] = [ + [ + ("precipitation_amount", "kg m-2"), + ("lwe_thickness_of_precipitation_amount", "mm"), + ], + [ + ("surface_snow_amount", "kg m-2"), + ("lwe_thickness_of_snowfall_amount", "mm"), + ], [ ("precipitation_flux", "kg m-2 s-1"), ("lwe_precipitation_rate", "mm s-1"), diff --git a/esmvalcore/preprocessor/_units.py b/esmvalcore/preprocessor/_units.py index 685e46844d..45f0f013b9 100644 --- a/esmvalcore/preprocessor/_units.py +++ b/esmvalcore/preprocessor/_units.py @@ -38,6 +38,11 @@ def convert_units(cube: Cube, units: str | Unit) -> Cube: Currently, the following special conversions are supported: + + * ``precipitation_amount`` (``kg m-2``) -- + ``lwe_thickness_of_precipitation_amount`` (``mm``) + * ``surface_snow_amount`` (``kg m-2``) -- + ``lwe_thickness_of_snowfall_amount`` (``mm``) * ``precipitation_flux`` (``kg m-2 s-1``) -- ``lwe_precipitation_rate`` (``mm day-1``) * ``water_evaporation_flux`` (``kg m-2 s-1``) -- diff --git a/tests/unit/preprocessor/_units/test_convert_units.py b/tests/unit/preprocessor/_units/test_convert_units.py index 42bf0613a9..f9d4ea6aec 100644 --- a/tests/unit/preprocessor/_units/test_convert_units.py +++ b/tests/unit/preprocessor/_units/test_convert_units.py @@ -85,6 +85,36 @@ def test_convert_ozone_content_du_to_m(self): [[0.0, 1e-2], [2e-2, 3e-2]], ) + def test_convert_precipitation_amount(self): + """Test special conversion of precipitation_amount.""" + self.arr.standard_name = "precipitation_amount" + self.arr.units = "kg m-2" + result = convert_units(self.arr, "mm") + self.assertEqual( + result.standard_name, + "lwe_thickness_of_precipitation_amount", + ) + self.assertEqual(result.units, "mm") + np.testing.assert_allclose( + result.data, + [[0.0, 1.0], [2.0, 3.0]], + ) + + def surface_snow_amount(self): + """Test special conversion of surface_snow_amount.""" + self.arr.standard_name = "surface_snow_amount" + self.arr.units = "kg m-2" + result = convert_units(self.arr, "mm") + self.assertEqual( + result.standard_name, + "lwe_thickness_of_snowfall_amount", + ) + self.assertEqual(result.units, "mm") + np.testing.assert_allclose( + result.data, + [[0.0, 1.0], [2.0, 3.0]], + ) + def test_convert_water_evaporation_flux(self): """Test special conversion of water_evaporation_flux.""" self.arr.standard_name = "water_evaporation_flux"