Skip to content

Commit f86d151

Browse files
valeriupredoibouweandelaschlunma
authored
Fix oh for model: EC-Earth3-AerChem mip: AERMonZ (#2634)
Co-authored-by: Bouwe Andela <[email protected]> Co-authored-by: Manuel Schlund <[email protected]>
1 parent 542a374 commit f86d151

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Fixes for EC-Earth3-AerChem model."""
2+
3+
from ..fix import Fix
4+
5+
6+
class Oh(Fix):
7+
"""Fixes for oh."""
8+
9+
def fix_metadata(self, cubes):
10+
"""Fix standard name for ps.
11+
12+
Fix standard_name for Surface Air Pressure (ps).
13+
See discussion in
14+
https://github.com/ESMValGroup/ESMValCore/issues/2613
15+
Cube has two coordinates called air_pressure: an AuxCoord ps
16+
and a DerivedCoord that is 4D and derived using formula terms,
17+
we are setting the former's standard_name to "surface_air_pressure".
18+
19+
Parameters
20+
----------
21+
cubes : iris.cube.CubeList
22+
Input cubes.
23+
24+
Returns
25+
-------
26+
iris.cube.CubeList
27+
"""
28+
cube = self.get_cube_from_list(cubes)
29+
30+
for cube in cubes:
31+
for coord in cube.coords():
32+
if coord.var_name == "ps":
33+
coord.standard_name = "surface_air_pressure"
34+
35+
return cubes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Tests for EC-Earth3-AerChem model."""
2+
3+
import iris
4+
import pytest
5+
6+
from esmvalcore.cmor._fixes.cmip6.ec_earth3_aerchem import Oh
7+
from esmvalcore.cmor.fix import Fix
8+
from esmvalcore.cmor.table import get_var_info
9+
10+
11+
@pytest.fixture
12+
def oh_cubes():
13+
air_pressure_coord = iris.coords.DimCoord(
14+
[1000.09, 600.6, 200.0],
15+
bounds=[[1200.00001, 800], [800, 400.8], [400.8, 1.9]],
16+
var_name="ps",
17+
standard_name="air_pressure",
18+
units="pa",
19+
)
20+
oh_cube = iris.cube.Cube(
21+
[0.0, 1.0, 2.0],
22+
var_name="oh",
23+
dim_coords_and_dims=[(air_pressure_coord, 0)],
24+
)
25+
return iris.cube.CubeList([oh_cube])
26+
27+
28+
def test_get_oh_fix():
29+
"""Test getting of fix."""
30+
fix = Fix.get_fixes("CMIP6", "EC-Earth3-AerChem", "AERmonZ", "oh")
31+
assert Oh(None) in fix
32+
33+
34+
def test_oh_fix_metadata(oh_cubes):
35+
"""Test ``fix_metadata`` for ``oh``."""
36+
vardef = get_var_info("CMIP6", "AERmonZ", "oh")
37+
fix = Oh(vardef)
38+
fixed_cubes = fix.fix_metadata(oh_cubes)
39+
for coord in fixed_cubes[0].coords():
40+
if coord.var_name == "ps":
41+
assert coord.standard_name == "surface_air_pressure"

0 commit comments

Comments
 (0)