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

Fixes of ocean variables in multiple CMIP6 datasets #1566

Merged
merged 12 commits into from
Apr 22, 2022
3 changes: 3 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/bcc_csm2_mr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@


Sos = OceanFixGrid


Uo = OceanFixGrid
4 changes: 4 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Fixes for CESM2-FV2 model."""
from .cesm2 import Cl as BaseCl
from .cesm2 import Fgco2 as BaseFgco2
from .cesm2 import Omon as BaseOmon
from .cesm2 import Tas as BaseTas
from ..common import SiconcFixScalarCoord

Expand All @@ -17,6 +18,9 @@
Fgco2 = BaseFgco2


Omon = BaseOmon


Siconc = SiconcFixScalarCoord


Expand Down
4 changes: 4 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .cesm2 import Cl as BaseCl
from .cesm2 import Fgco2 as BaseFgco2
from .cesm2 import Omon as BaseOmon
from .cesm2 import Tas as BaseTas
from ..common import SiconcFixScalarCoord

Expand Down Expand Up @@ -52,6 +53,9 @@ def fix_file(self, filepath, output_dir):
Fgco2 = BaseFgco2


Omon = BaseOmon


Siconc = SiconcFixScalarCoord


Expand Down
4 changes: 4 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Fixes for CESM2-WACCM-FV2 model."""
from .cesm2 import Tas as BaseTas
from .cesm2 import Fgco2 as BaseFgco2
from .cesm2 import Omon as BaseOmon
from .cesm2_waccm import Cl as BaseCl
from .cesm2_waccm import Cli as BaseCli
from .cesm2_waccm import Clw as BaseClw
Expand All @@ -19,6 +20,9 @@
Fgco2 = BaseFgco2


Omon = BaseOmon


Siconc = SiconcFixScalarCoord


Expand Down
31 changes: 29 additions & 2 deletions esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

from ..common import ClFixHybridPressureCoord
from ..fix import Fix
from ..shared import add_aux_coords_from_cubes, get_bounds_cube
from ..shared import (
add_aux_coords_from_cubes,
get_bounds_cube,
fix_ocean_depth_coord
)


class Cl(ClFixHybridPressureCoord):
Expand Down Expand Up @@ -73,7 +77,30 @@ def fix_metadata(self, cubes):
return iris.cube.CubeList([cube])


Cli = Cl
class Omon(Fix):
"""Fixes for ocean variables."""

def fix_metadata(self, cubes):
"""Fix ocean depth coordinate.

Parameters
----------
cubes: iris CubeList
List of cubes to fix

Returns
-------
iris.cube.CubeList

"""
for cube in cubes:
if cube.coords(axis='Z'):
z_coord = cube.coord(axis='Z')
if z_coord.standard_name is None:
fix_ocean_depth_coord(cube)
return cubes


Cli = Cl

Clw = Cl
28 changes: 2 additions & 26 deletions esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Fixes for CNRM-ESM2-1 model."""
from ..fix import Fix
from ..shared import (fix_ocean_depth_coord)


from .cnrm_cm6_1 import Cl as BaseCl
from .cnrm_cm6_1 import Clcalipso as BaseClcalipso
from .cnrm_cm6_1 import Cli as BaseCli
from .cnrm_cm6_1 import Clw as BaseClw
from .cnrm_cm6_1 import Omon as BaseOmon


Cl = BaseCl
Expand All @@ -21,25 +18,4 @@
Clw = BaseClw


class Omon(Fix):
"""Fixes for ocean variables."""

def fix_metadata(self, cubes):
"""Fix ocean depth coordinate.

Parameters
----------
cubes: iris CubeList
List of cubes to fix

Returns
-------
iris.cube.CubeList

"""
for cube in cubes:
if cube.coords(axis='Z'):
z_coord = cube.coord(axis='Z')
if z_coord.standard_name is None:
fix_ocean_depth_coord(cube)
return cubes
Omon = BaseOmon
3 changes: 3 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/fgoals_f3_l.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
Tos = OceanFixGrid


Omon = OceanFixGrid


class AllVars(Fix):
"""Fixes for all vars."""
def fix_metadata(self, cubes):
Expand Down
11 changes: 11 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from ..common import ClFixHybridPressureCoord, SiconcFixScalarCoord
from ..fix import Fix
from ..shared import add_aux_coords_from_cubes, add_scalar_height_coord
from .gfdl_esm4 import Omon as BaseOmon
from .gfdl_esm4 import Fgco2 as BaseFgco2


class Cl(ClFixHybridPressureCoord):
Expand Down Expand Up @@ -108,3 +110,12 @@ def fix_metadata(self, cubes):
cube = self.get_cube_from_list(cubes)
add_scalar_height_coord(cube, 10.0)
return cubes


Omon = BaseOmon


Oyr = Omon


Fgco2 = BaseFgco2
3 changes: 3 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ def fix_metadata(self, cubes):
return cubes


Oyr = Omon


Siconc = SiconcFixScalarCoord
13 changes: 13 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Fixes for IPSL-CM5A2-INCA model."""
from .ipsl_cm6a_lr import AllVars as BaseAllVars
from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso
from .ipsl_cm6a_lr import Omon as BaseOmon


AllVars = BaseAllVars


Clcalipso = BaseClcalipso


Omon = BaseOmon
13 changes: 13 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Fixes for IPSL-CM6A-LR-INCA model."""
from .ipsl_cm6a_lr import AllVars as BaseAllVars
from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso
from .ipsl_cm6a_lr import Omon as BaseOmon


AllVars = BaseAllVars


Clcalipso = BaseClcalipso


Omon = BaseOmon
3 changes: 2 additions & 1 deletion tests/integration/cmor/_fixes/cmip6/test_cesm2_fv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Cli,
Clw,
Fgco2,
Omon,
Siconc,
Tas,
)
Expand Down Expand Up @@ -50,7 +51,7 @@ def test_clw_fix():
def test_get_fgco2_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'CESM2-FV2', 'Omon', 'fgco2')
assert fix == [Fgco2(None)]
assert fix == [Fgco2(None), Omon(None)]


def test_fgco2_fix():
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Cli,
Clw,
Fgco2,
Omon,
Siconc,
Tas,
)
Expand Down Expand Up @@ -84,7 +85,7 @@ def test_clw_fix():
def test_get_fgco2_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'CESM2-WACCM', 'Omon', 'fgco2')
assert fix == [Fgco2(None)]
assert fix == [Fgco2(None), Omon(None)]


def test_fgco2_fix():
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm_fv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Cli,
Clw,
Fgco2,
Omon,
Siconc,
Tas,
)
Expand Down Expand Up @@ -50,7 +51,7 @@ def test_clw_fix():
def test_get_fgco2_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'CESM2-WACCM-FV2', 'Omon', 'fgco2')
assert fix == [Fgco2(None)]
assert fix == [Fgco2(None), Omon(None)]


def test_fgco2_fix():
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy as np
import pytest

from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cl, Clcalipso, Cli, Clw
from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import (Cl, Clcalipso,
Cli, Clw, Omon)
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info

Expand Down Expand Up @@ -129,3 +130,9 @@ def test_get_clw_fix():
def test_clw_fix():
"""Test fix for ``clw``."""
assert Clw is Cl


def test_get_thetao_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'CNRM-CM6-1', 'Omon', 'thetao')
assert fix == [Omon(None)]
9 changes: 8 additions & 1 deletion tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np
import pytest

from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import Cl, Cli, Clw, Siconc
from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import (Cl, Cli, Clw,
Fgco2, Omon, Siconc)
from esmvalcore.cmor._fixes.common import SiconcFixScalarCoord
from esmvalcore.cmor.fix import Fix
from esmvalcore.cmor.table import get_var_info
Expand Down Expand Up @@ -93,6 +94,12 @@ def test_clw_fix():
assert Clw is Cl


def test_get_fgco2_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'GFDL-CM4', 'Omon', 'fgco2')
assert fix == [Fgco2(None), Omon(None)]


def test_get_siconc_fix():
"""Test getting of fix."""
fix = Fix.get_fixes('CMIP6', 'GFDL-CM4', 'SImon', 'siconc')
Expand Down