Skip to content

Commit

Permalink
cordex wrf381p: fix tas,tasmax,tasmin height (#2333)
Browse files Browse the repository at this point in the history
Co-authored-by: sloosvel <saskia.loosveldt@bsc.es>
Co-authored-by: sloosvel <45196700+sloosvel@users.noreply.github.com>
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 2, 2024
1 parent 907a8a2 commit 3a0b49f
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 2 deletions.
36 changes: 36 additions & 0 deletions esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/wrf381p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Fixes for rcm WRF381P driven by CNRM-CERFACS-CNRM-CM5."""
from esmvalcore.cmor._fixes.shared import add_scalar_height_coord
from esmvalcore.cmor.fix import Fix


class Tas(Fix):
"""Fixes for tas."""

def fix_metadata(self, cubes):
"""Add height (2m) coordinate and correct long_name for time.
Parameters
----------
cubes : iris.cube.CubeList
Input cubes.
Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube)

return cubes


Tasmin = Tas


Tasmax = Tas


Hurs = Tas


Huss = Tas
36 changes: 36 additions & 0 deletions esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/wrf381p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Fixes for rcm WRF381P driven by ICHEC-EC-EARTH."""
from esmvalcore.cmor._fixes.shared import add_scalar_height_coord
from esmvalcore.cmor.fix import Fix


class Tas(Fix):
"""Fixes for tas."""

def fix_metadata(self, cubes):
"""Add height (2m) coordinate and correct long_name for time.
Parameters
----------
cubes : iris.cube.CubeList
Input cubes.
Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube)

return cubes


Tasmin = Tas


Tasmax = Tas


Hurs = Tas


Huss = Tas
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Fixes for CORDEX data."""
36 changes: 36 additions & 0 deletions esmvalcore/cmor/_fixes/cordex/ipsl_ipsl_cm5a_mr/wrf381p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Fixes for rcm WRF381P driven by IPSL-IPSL-CM5A-MR."""
from esmvalcore.cmor._fixes.shared import add_scalar_height_coord
from esmvalcore.cmor.fix import Fix


class Tas(Fix):
"""Fixes for tas."""

def fix_metadata(self, cubes):
"""Add height (2m) coordinate and correct long_name for time.
Parameters
----------
cubes : iris.cube.CubeList
Input cubes.
Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube)

return cubes


Tasmin = Tas


Tasmax = Tas


Hurs = Tas


Huss = Tas
36 changes: 36 additions & 0 deletions esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/wrf381p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Fixes for rcm WRF381P driven by MOHC-HadGEM2-ES."""
from esmvalcore.cmor._fixes.shared import add_scalar_height_coord
from esmvalcore.cmor.fix import Fix


class Tas(Fix):
"""Fixes for tas."""

def fix_metadata(self, cubes):
"""Add height (2m) coordinate and correct long_name for time.
Parameters
----------
cubes : iris.cube.CubeList
Input cubes.
Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube)

return cubes


Tasmin = Tas


Tasmax = Tas


Hurs = Tas


Huss = Tas
36 changes: 36 additions & 0 deletions esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/wrf381p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Fixes for rcm WRF381P driven by NCC-NorESM1-M."""
from esmvalcore.cmor._fixes.shared import add_scalar_height_coord
from esmvalcore.cmor.fix import Fix


class Tas(Fix):
"""Fixes for tas."""

def fix_metadata(self, cubes):
"""Add height (2m) coordinate and correct long_name for time.
Parameters
----------
cubes : iris.cube.CubeList
Input cubes.
Returns
-------
iris.cube.CubeList
"""
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube)

return cubes


Tasmin = Tas


Tasmax = Tas


Hurs = Tas


Huss = Tas
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
import iris
import pytest

from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import aladin63
from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import (
aladin63,
wrf381p,)
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info


@pytest.fixture
Expand Down Expand Up @@ -59,3 +62,32 @@ def test_aladin63_height_fix(cubes):
assert cubes is out_cubes
for cube in out_cubes:
assert cube.coord('height').points == 2.0


@pytest.mark.parametrize(
'short_name',
['tasmax', 'tasmin', 'tas', 'hurs', 'huss'])
def test_get_wrf381p_fix(short_name):
fix = Fix.get_fixes(
'CORDEX',
'WRF381P',
'Amon',
short_name,
extra_facets={'driver': 'CNRM-CERFACS-CNRM-CM5'})
assert isinstance(fix[0], Fix)


def test_wrf381p_height_fix():
time_coord = iris.coords.DimCoord([0.0],
var_name='time',
standard_name='time',
long_name='time')
cube = iris.cube.Cube(
[10.0],
var_name='tas',
dim_coords_and_dims=[(time_coord, 0)],
)
vardef = get_var_info('CMIP6', 'Amon', 'tas')
fix = wrf381p.Tas(vardef)
out_cubes = fix.fix_metadata([cube])
assert out_cubes[0].coord('height').points == 2.0
32 changes: 32 additions & 0 deletions tests/integration/cmor/_fixes/cordex/test_ichec_ec_earth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Tests for the fixes for driver ICHEC-EC-Earth."""
import iris
import pytest

from esmvalcore.cmor._fixes.cordex.ichec_ec_earth import wrf381p
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info


def test_get_remo2015_fix():
Expand Down Expand Up @@ -44,3 +47,32 @@ def test_get_rca4_fix(short_name):
short_name,
extra_facets={'driver': 'ICHEC-EC-Earth'})
assert isinstance(fix[0], Fix)


@pytest.mark.parametrize(
'short_name',
['tasmax', 'tasmin', 'tas', 'hurs', 'huss'])
def test_get_wrf381p_fix(short_name):
fix = Fix.get_fixes(
'CORDEX',
'WRF381P',
'Amon',
short_name,
extra_facets={'driver': 'ICHEC-EC-Earth'})
assert isinstance(fix[0], Fix)


def test_wrf381p_height_fix():
time_coord = iris.coords.DimCoord([0.0],
var_name='time',
standard_name='time',
long_name='time')
cube = iris.cube.Cube(
[10.0],
var_name='tas',
dim_coords_and_dims=[(time_coord, 0)],
)
vardef = get_var_info('CMIP6', 'Amon', 'tas')
fix = wrf381p.Tas(vardef)
out_cubes = fix.fix_metadata([cube])
assert out_cubes[0].coord('height').points == 2.0
36 changes: 36 additions & 0 deletions tests/integration/cmor/_fixes/cordex/test_ipsl_ipsl_cm5a_mr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Tests for the fixes of driver IPSL-CM5A-MR."""
import iris
import pytest

from esmvalcore.cmor._fixes.cordex.ipsl_ipsl_cm5a_mr import wrf381p
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info


@pytest.mark.parametrize(
'short_name',
['tasmax', 'tasmin', 'tas', 'hurs', 'huss'])
def test_get_wrf381p_fix(short_name):
fix = Fix.get_fixes(
'CORDEX',
'WRF381P',
'Amon',
short_name,
extra_facets={'driver': 'IPSL-CM5A-MR'})
assert isinstance(fix[0], Fix)


def test_wrf381p_height_fix():
time_coord = iris.coords.DimCoord([0.0],
var_name='time',
standard_name='time',
long_name='time')
cube = iris.cube.Cube(
[10.0],
var_name='tas',
dim_coords_and_dims=[(time_coord, 0)],
)
vardef = get_var_info('CMIP6', 'Amon', 'tas')
fix = wrf381p.Tas(vardef)
out_cubes = fix.fix_metadata([cube])
assert out_cubes[0].coord('height').points == 2.0
32 changes: 31 additions & 1 deletion tests/integration/cmor/_fixes/cordex/test_mohc_hadgem2_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import iris
import pytest

from esmvalcore.cmor._fixes.cordex.mohc_hadgem2_es import hirham5
from esmvalcore.cmor._fixes.cordex.mohc_hadgem2_es import hirham5, wrf381p
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info


@pytest.fixture
Expand Down Expand Up @@ -103,3 +104,32 @@ def test_hirham5_fix(cubes):
for cube in out_cubes:
assert cube.coord('latitude').attributes == {}
assert cube.coord('longitude').attributes == {}


@pytest.mark.parametrize(
'short_name',
['tasmax', 'tasmin', 'tas', 'hurs', 'huss'])
def test_get_wrf381p_fix(short_name):
fix = Fix.get_fixes(
'CORDEX',
'WRF381P',
'Amon',
short_name,
extra_facets={'driver': 'MOHC-HadGEM2-ES'})
assert isinstance(fix[0], Fix)


def test_wrf381p_height_fix():
time_coord = iris.coords.DimCoord([0.0],
var_name='time',
standard_name='time',
long_name='time')
cube = iris.cube.Cube(
[10.0],
var_name='tas',
dim_coords_and_dims=[(time_coord, 0)],
)
vardef = get_var_info('CMIP6', 'Amon', 'tas')
fix = wrf381p.Tas(vardef)
out_cubes = fix.fix_metadata([cube])
assert out_cubes[0].coord('height').points == 2.0

0 comments on commit 3a0b49f

Please sign in to comment.