Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordex wrf381p: fix tas,tasmax,tasmin height #2333

Merged
merged 11 commits into from
Apr 2, 2024
32 changes: 32 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,32 @@
"""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


class Tasmin(Tas):
"""Fixes for tasmin."""


class Tasmax(Tas):
"""Fixes for tasmax."""
32 changes: 32 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,32 @@
"""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


class Tasmin(Tas):
"""Fixes for tasmin."""


class Tasmax(Tas):
"""Fixes for tasmax."""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Fixes for CORDEX data."""
32 changes: 32 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,32 @@
"""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


class Tasmin(Tas):
"""Fixes for tasmin."""


class Tasmax(Tas):
"""Fixes for tasmax."""
32 changes: 32 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,32 @@
"""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


class Tasmin(Tas):
"""Fixes for tasmin."""


class Tasmax(Tas):
"""Fixes for tasmax."""
32 changes: 32 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,32 @@
"""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


class Tasmin(Tas):
"""Fixes for tasmin."""


class Tasmax(Tas):
"""Fixes for tasmax."""
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,30 @@ 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'])
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
30 changes: 30 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,30 @@ 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'])
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
34 changes: 34 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,34 @@
"""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'])
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
30 changes: 29 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,30 @@ 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'])
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
30 changes: 30 additions & 0 deletions tests/integration/cmor/_fixes/cordex/test_ncc_noresm1_m.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Tests for the fixes of driver NCC-NorESM1-M."""
import iris
import pytest

from esmvalcore.cmor._fixes.cordex.ncc_noresm1_m 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,30 @@ def test_get_rca4_fix(short_name):
short_name,
extra_facets={'driver': 'NCC-NorESM1-M'})
assert isinstance(fix[0], Fix)


@pytest.mark.parametrize('short_name', ['tasmax', 'tasmin', 'tas'])
def test_get_wrf381p_fix(short_name):
fix = Fix.get_fixes(
'CORDEX',
'WRF381P',
'Amon',
short_name,
extra_facets={'driver': 'NCC-NorESM1-M'})
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