diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_hr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_hr.py new file mode 100644 index 0000000000..21648fc1dc --- /dev/null +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_hr.py @@ -0,0 +1,83 @@ +"""Fixes for MPI-ESM1-2-HR model.""" + +from ..fix import Fix +from ..shared import add_scalar_height_coord + + +class Tas(Fix): + """Fixes for tas.""" + + def fix_metadata(self, cubes): + """ + Adds missing height2m coordinate. + + Parameters + ---------- + cube: iris.cube.CubeList + + Returns + ------- + iris.cube.CubeList + + """ + for cube in cubes: + add_scalar_height_coord(cube) + + return cubes + + +class Ta(Fix): + """Fixes for ta.""" + + def fix_metadata(self, cubes): + """ + Corrects plev coordinate var_name. + + Parameters + ---------- + cube: iris.cube.CubeList + + Returns + ------- + iris.cube.CubeList + + """ + for cube in cubes: + plev = cube.coord('air_pressure') + plev.var_name = 'plev' + + return cubes + + +class Va(Ta): + """Fixes for va.""" + + +class Zg(Ta): + """Fixes for zg.""" + + +class Ua(Ta): + """Fixes for ua.""" + + +class SfcWind(Fix): + """Fixes for sfcWind.""" + + def fix_metadata(self, cubes): + """ + Adds missing height10m coordinate. + + Parameters + ---------- + cube: iris.cube.CubeList + + Returns + ------- + iris.cube.CubeList + + """ + for cube in cubes: + add_scalar_height_coord(cube, height=10.0) + + return cubes diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py new file mode 100644 index 0000000000..c3ae86a6a6 --- /dev/null +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py @@ -0,0 +1,29 @@ +"""Fixes for MPI-ESM1-2-XR model.""" + +from .mpi_esm1_2_hr import Tas as BaseTas +from .mpi_esm1_2_hr import Ta as BaseFix +from .mpi_esm1_2_hr import SfcWind as BaseSfcWind + + +class Tas(BaseTas): + """Fixes for tas.""" + + +class Ta(BaseFix): + """Fixes for ta.""" + + +class Va(BaseFix): + """Fixes for va.""" + + +class Zg(BaseFix): + """Fixes for zg.""" + + +class Ua(BaseFix): + """Fixes for ua.""" + + +class SfcWind(BaseSfcWind): + """Fixes for sfcWind.""" diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index 5acb7a1ffc..ea7482cf3a 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -17,7 +17,10 @@ def add_scalar_depth_coord(cube, depth=0.0): long_name='depth', units=Unit('m'), attributes={'positive': 'down'}) - cube.add_aux_coord(depth_coord, ()) + try: + cube.coord('depth') + except iris.exceptions.CoordinateNotFoundError: + cube.add_aux_coord(depth_coord, ()) return cube @@ -30,7 +33,10 @@ def add_scalar_height_coord(cube, height=2.0): long_name='height', units=Unit('m'), attributes={'positive': 'up'}) - cube.add_aux_coord(height_coord, ()) + try: + cube.coord('height') + except iris.exceptions.CoordinateNotFoundError: + cube.add_aux_coord(height_coord, ()) return cube @@ -42,7 +48,10 @@ def add_scalar_typeland_coord(cube, value='default'): standard_name='area_type', long_name='Land area type', units=Unit('no unit')) - cube.add_aux_coord(typeland_coord, ()) + try: + cube.coord('area_type') + except iris.exceptions.CoordinateNotFoundError: + cube.add_aux_coord(typeland_coord, ()) return cube @@ -54,7 +63,10 @@ def add_scalar_typesea_coord(cube, value='default'): standard_name='area_type', long_name='Ocean area type', units=Unit('no unit')) - cube.add_aux_coord(typesea_coord, ()) + try: + cube.coord('area_type') + except iris.exceptions.CoordinateNotFoundError: + cube.add_aux_coord(typesea_coord, ()) return cube