Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 4 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions doc/recipe/preprocessor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``) --
Expand Down
8 changes: 8 additions & 0 deletions esmvalcore/iris_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
5 changes: 5 additions & 0 deletions esmvalcore/preprocessor/_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``) --
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/preprocessor/_units/test_convert_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down