diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_0.py b/esmvalcore/cmor/_fixes/cmip5/access1_0.py index f5da46571f..d9a6cd2ab2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_0.py @@ -1,11 +1,11 @@ """Fixes for the ACCESS1-0 model.""" - -from cf_units import Unit import iris +from cf_units import Unit + +from ..common import ClFixHybridHeightCoord from ..fix import Fix -# noinspection PyPep8 class AllVars(Fix): """Common fixes to all vars.""" @@ -13,15 +13,16 @@ def fix_metadata(self, cubes): """ Fix metadata. - Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian' + Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian'. Parameters ---------- - cube: iris.cube.Cube + cubes : iris.cube.CubeList + Input cubes which need to be fixed. Returns ------- - iris.cube.Cube + iris.cube.CubeList """ for cube in cubes: @@ -32,3 +33,28 @@ def fix_metadata(self, cubes): else: time.units = Unit(time.units.name, 'gregorian') return cubes + + +class Cl(ClFixHybridHeightCoord): + """Fixes for ``cl``.""" + + def fix_metadata(self, cubes): + """Remove attributes from ``vertical coordinate formula term: b(k)``. + + Additionally add pressure level coordiante. + + Parameters + ---------- + cubes : iris.cube.CubeList + Input cubes which need to be fixed. + + Returns + ------- + iris.cube.CubeList + + """ + cubes = super().fix_metadata(cubes) + cube = self.get_cube_from_list(cubes) + coord = cube.coord(long_name='vertical coordinate formula term: b(k)') + coord.attributes = {} + return cubes diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_3.py b/esmvalcore/cmor/_fixes/cmip5/access1_3.py index 638613f1e8..dd5cc90d28 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_3.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_3.py @@ -1,26 +1,30 @@ """Fixes for ACCESS1-3 model.""" - -from cf_units import Unit import iris +from cf_units import Unit + from ..fix import Fix +from .access1_0 import Cl as BaseCl + + +Cl = BaseCl class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian' Parameters ---------- - cube: iris.cube.Cube + cubes : iris.cube.CubeList + Input cubes which need to be fixed. Returns ------- - iris.cube.Cube + iris.cube.CubeList """ for cube in cubes: diff --git a/esmvalcore/cmor/_fixes/cmip5/bcc_csm1_1_m.py b/esmvalcore/cmor/_fixes/cmip5/bcc_csm1_1_m.py index 4507ac2141..8a1ab262a0 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bcc_csm1_1_m.py +++ b/esmvalcore/cmor/_fixes/cmip5/bcc_csm1_1_m.py @@ -1,10 +1,9 @@ """Fixes for bcc-csm1-1-m.""" -from .bcc_csm1_1 import Tos as BaseTos from ..common import ClFixHybridPressureCoord +from .bcc_csm1_1 import Tos as BaseTos Cl = ClFixHybridPressureCoord -class Tos(BaseTos): - """Fixes for tos.""" +Tos = BaseTos diff --git a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py index 0b92c19e8a..544744617c 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py @@ -1,11 +1,14 @@ - -"""Fixes for BNU ESM model.""" +"""Fixes for BNU-ESM model.""" from cf_units import Unit from dask import array as da +from ..common import ClFixHybridPressureCoord from ..fix import Fix +Cl = ClFixHybridPressureCoord + + class FgCo2(Fix): """Fixes for fgco2.""" @@ -13,15 +16,16 @@ def fix_metadata(self, cubes): """ Fix metadata. - Fixes cube units + Fixes cube units. Parameters ---------- - cube: iris.cube.CubeList + cubes : iris.cube.CubeList + Input cubes to fix. Returns ------- - iris.cube.Cube + iris.cube.CubeList """ self.get_cube_from_list(cubes).units = Unit('kg m-2 s-1') @@ -31,11 +35,12 @@ def fix_data(self, cube): """ Fix data. - Fixes cube units + Fixes cube units. Parameters ---------- cube: iris.cube.Cube + Input cube to fix. Returns ------- @@ -55,11 +60,12 @@ def fix_metadata(self, cubes): """ Fix metadata. - Fixes cube units + Fixes cube units. Parameters ---------- - cubes: iris.cube.CubeList + cubes : iris.cube.CubeList + Input cubes to fix. Returns ------- @@ -73,11 +79,13 @@ def fix_data(self, cube): """ Fix metadata. - Fixes cube units + Fixes cube units. Parameters ---------- cube: iris.cube.Cube + Input cube to fix. + Returns ------- @@ -97,11 +105,12 @@ def fix_metadata(self, cubes): """ Fix metadata. - Fixes cube units + Fixes cube units. Parameters ---------- - cubes: iris.cube.CubeList + cubes : iris.cube.CubeList + Input cubes to fix. Returns ------- @@ -115,11 +124,12 @@ def fix_data(self, cube): """ Fix data. - Fixes cube units + Fixes cube units. Parameters ---------- cube: iris.cube.Cube + Input cube to fix. Returns ------- @@ -139,11 +149,12 @@ def fix_data(self, cube): """ Fix data. - Fixes cube units + Fixes cube units. Parameters ---------- - cube: iris.cube.Cube + cube : iris.cube.Cube + Input cube to fix. Returns ------- @@ -167,7 +178,8 @@ def fix_data(self, cube): Parameters ---------- - cube: iris.cube.Cube + cube : iris.cube.Cube + Input cube to fix. Returns ------- diff --git a/esmvalcore/cmor/_fixes/cmip5/ccsm4.py b/esmvalcore/cmor/_fixes/cmip5/ccsm4.py index 7c36ea93bc..5e4208873e 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ccsm4.py +++ b/esmvalcore/cmor/_fixes/cmip5/ccsm4.py @@ -21,12 +21,12 @@ def fix_data(self, cube): Parameters ---------- - cubes : iris.cube.Cube + cube : iris.cube.Cube Input cube. Returns ------- - iris.cube.CubeList + iris.cube.Cube """ cube.data = da.ma.masked_equal(cube.core_data(), 1.e33) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py index c6c7c239c2..b2cf33c8d2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py @@ -1,7 +1,7 @@ - """Fix HadGEM2_ES.""" import numpy as np +from ..common import ClFixHybridHeightCoord from ..fix import Fix @@ -9,12 +9,12 @@ class AllVars(Fix): """Fix errors common to all vars.""" def fix_metadata(self, cubes): - """ - Fix latitude. + """Fix latitude. Parameters ---------- - cube: iris.cube.CubeList + cubes : iris.cube.CubeList + Input cubes which need to be fixed. Returns ------- @@ -33,16 +33,19 @@ def fix_metadata(self, cubes): return cubes +Cl = ClFixHybridHeightCoord + + class O2(Fix): """Fix o2.""" def fix_metadata(self, cubes): - """ - Fix standard and long name. + """Fix standard and long name. Parameters ---------- - cube: iris.cube.CubeList + cubes : iris.cube.CubeList + Input cubes which need to be fixed. Returns ------- diff --git a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py new file mode 100644 index 0000000000..69db0fa3bf --- /dev/null +++ b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py @@ -0,0 +1,11 @@ +"""Fixes for ACCESS-CM2.""" +from ..common import ClFixHybridHeightCoord + + +Cl = ClFixHybridHeightCoord + + +Cli = ClFixHybridHeightCoord + + +Clw = ClFixHybridHeightCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/access_esm1_5.py b/esmvalcore/cmor/_fixes/cmip6/access_esm1_5.py new file mode 100644 index 0000000000..939368e687 --- /dev/null +++ b/esmvalcore/cmor/_fixes/cmip6/access_esm1_5.py @@ -0,0 +1,11 @@ +"""Fixes for ACCESS-ESM1-5.""" +from ..common import ClFixHybridHeightCoord + + +Cl = ClFixHybridHeightCoord + + +Cli = ClFixHybridHeightCoord + + +Clw = ClFixHybridHeightCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/bcc_esm1.py b/esmvalcore/cmor/_fixes/cmip6/bcc_esm1.py index c42746bb92..cae45b3f2f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/bcc_esm1.py +++ b/esmvalcore/cmor/_fixes/cmip6/bcc_esm1.py @@ -1,6 +1,6 @@ """Fixes for BCC-ESM1 model.""" -from .bcc_csm2_mr import Tos as BaseTos from ..common import ClFixHybridPressureCoord +from .bcc_csm2_mr import Tos as BaseTos Cl = ClFixHybridPressureCoord @@ -12,5 +12,4 @@ Clw = ClFixHybridPressureCoord -class Tos(BaseTos): - """Fixes for tos.""" +Tos = BaseTos diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2.py index c47222abec..d763e04244 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2.py @@ -56,12 +56,10 @@ def fix_file(self, filepath, output_dir): return new_path -class Cli(Cl): - """Fixes for ``cli``.""" +Cli = Cl -class Clw(Cl): - """Fixes for ``clw``.""" +Clw = Cl class Fgco2(Fix): diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py index e48bcce1ef..74dff9bc74 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py @@ -3,17 +3,13 @@ from .cesm2 import Tas as BaseTas -class Cl(BaseCl): - """Fixes for ``cl``.""" +Cl = BaseCl -class Clw(Cl): - """Fixes for ``clw``.""" +Cli = Cl -class Cli(Cl): - """Fixes for ``cli``.""" +Clw = Cl -class Tas(BaseTas): - """Fixes for ``tas``.""" +Tas = BaseTas diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py index 79048057a6..dad451339f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py @@ -42,13 +42,10 @@ def fix_file(self, filepath, output_dir): return new_path -class Cli(Cl): - """Fixes for ``cli``.""" +Cli = Cl -class Clw(Cl): - """Fixes for ``clw``.""" +Clw = Cl -class Tas(BaseTas): - """Fixes for tas.""" +Tas = BaseTas diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py index 1039b10b7d..b5db40fc11 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py @@ -1,11 +1,13 @@ """Fixes for CNRM-CM6-1-HR model.""" from .cnrm_cm6_1 import Cl as BaseCl +from .cnrm_cm6_1 import Cli as BaseCli +from .cnrm_cm6_1 import Clw as BaseClw Cl = BaseCl -Cli = BaseCl +Cli = BaseCli -Clw = BaseCl +Clw = BaseClw diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py index a449b642ef..25e2a22b74 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py @@ -1,6 +1,8 @@ """Fixes for CNRM-ESM2-1 model.""" 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 Cl = BaseCl @@ -9,7 +11,7 @@ Clcalipso = BaseClcalipso -Cli = BaseCl +Cli = BaseCli -Clw = BaseCl +Clw = BaseClw diff --git a/esmvalcore/cmor/_fixes/cmip6/fgoals_g3.py b/esmvalcore/cmor/_fixes/cmip6/fgoals_g3.py index b5532b0e9c..df6de94284 100644 --- a/esmvalcore/cmor/_fixes/cmip6/fgoals_g3.py +++ b/esmvalcore/cmor/_fixes/cmip6/fgoals_g3.py @@ -1,14 +1,10 @@ """Fixes for FGOALS-g3 model.""" from ..cmip5.fgoals_g2 import Cl as BaseCl +Cl = BaseCl -class Cl(BaseCl): - """Fixes for ``cl``.""" +Cli = BaseCl -class Clw(Cl): - """Fixes for ``clw``.""" - -class Cli(Cl): - """Fixes for ``cli``.""" +Clw = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py index f24bad44ac..99db1e2be1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py @@ -1,29 +1,15 @@ """Fixes for CMIP6 HadGEM-GC31-LL.""" -from ..fix import Fix - - -class AllVars(Fix): - """Fixes for all vars.""" - - def fix_metadata(self, cubes): - """ - Fix parent time units. - - Parameters - ---------- - cube : iris.cube.CubeList - - Returns - ------- - iris.cube.Cube - - """ - parent_units = 'parent_time_units' - bad_value = 'days since 1850-01-01-00-00-00' - for cube in cubes: - try: - if cube.attributes[parent_units] == bad_value: - cube.attributes[parent_units] = 'days since 1850-01-01' - except AttributeError: - pass - return cubes +from ..common import ClFixHybridHeightCoord +from .ukesm1_0_ll import AllVars as BaseAllVars + + +AllVars = BaseAllVars + + +Cl = ClFixHybridHeightCoord + + +Cli = ClFixHybridHeightCoord + + +Clw = ClFixHybridHeightCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/kace_1_0_g.py b/esmvalcore/cmor/_fixes/cmip6/kace_1_0_g.py new file mode 100644 index 0000000000..678b415c5d --- /dev/null +++ b/esmvalcore/cmor/_fixes/cmip6/kace_1_0_g.py @@ -0,0 +1,11 @@ +"""Fixes for KACE-1-0-G.""" +from ..common import ClFixHybridHeightCoord + + +Cl = ClFixHybridHeightCoord + + +Cli = ClFixHybridHeightCoord + + +Clw = ClFixHybridHeightCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py index f111198cd8..8bef01c21f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py @@ -1,6 +1,39 @@ """Fixes for CMIP6 UKESM1-0-LL.""" -from .hadgem3_gc31_ll import AllVars as BaseAllVars +from ..common import ClFixHybridHeightCoord +from ..fix import Fix -class AllVars(BaseAllVars): +class AllVars(Fix): """Fixes for all vars.""" + + def fix_metadata(self, cubes): + """Fix parent time units. + + Parameters + ---------- + cubes : iris.cube.CubeList + Input cubes. + + Returns + ------- + iris.cube.CubeList + + """ + parent_units = 'parent_time_units' + bad_value = 'days since 1850-01-01-00-00-00' + for cube in cubes: + try: + if cube.attributes[parent_units] == bad_value: + cube.attributes[parent_units] = 'days since 1850-01-01' + except AttributeError: + pass + return cubes + + +Cl = ClFixHybridHeightCoord + + +Cli = ClFixHybridHeightCoord + + +Clw = ClFixHybridHeightCoord diff --git a/esmvalcore/cmor/_fixes/common.py b/esmvalcore/cmor/_fixes/common.py index 7988395bed..d60b2eb7f0 100644 --- a/esmvalcore/cmor/_fixes/common.py +++ b/esmvalcore/cmor/_fixes/common.py @@ -2,7 +2,46 @@ import iris from .fix import Fix -from .shared import fix_bounds +from .shared import add_plev_from_altitude, fix_bounds + + +class ClFixHybridHeightCoord(Fix): + """Fixes for ``cl`` regarding hybrid sigma height coordinates.""" + + def fix_metadata(self, cubes): + """Fix hybrid sigma height coordinate and add pressure levels. + + Parameters + ---------- + cubes : iris.cube.CubeList + Input cubes which need to be fixed. + + Returns + ------- + iris.cube.CubeList + + """ + cube = self.get_cube_from_list(cubes) + + # Remove all existing aux_factories + for aux_factory in cube.aux_factories: + cube.remove_aux_factory(aux_factory) + + # Fix bounds + fix_bounds(cube, cubes, ('lev', 'b')) + + # Add aux_factory again + height_coord_factory = iris.aux_factory.HybridHeightFactory( + delta=cube.coord(var_name='lev'), + sigma=cube.coord(var_name='b'), + orography=cube.coord(var_name='orog'), + ) + cube.add_aux_factory(height_coord_factory) + + # Add pressure level coordinate + add_plev_from_altitude(cube) + + return iris.cube.CubeList([cube]) class ClFixHybridPressureCoord(Fix): @@ -21,44 +60,44 @@ def fix_metadata(self, cubes): iris.cube.CubeList """ - cl_cube = self.get_cube_from_list(cubes, short_name='cl') + cube = self.get_cube_from_list(cubes) # Remove all existing aux_factories - for aux_factory in cl_cube.aux_factories: - cl_cube.remove_aux_factory(aux_factory) + for aux_factory in cube.aux_factories: + cube.remove_aux_factory(aux_factory) # Fix bounds coords_to_fix = ['b'] try: - cl_cube.coord(var_name='a') + cube.coord(var_name='a') coords_to_fix.append('a') except iris.exceptions.CoordinateNotFoundError: coords_to_fix.append('ap') - fix_bounds(cl_cube, cubes, coords_to_fix) + fix_bounds(cube, cubes, coords_to_fix) # Fix bounds for ap if only a is given in original file # This was originally done by iris, but it has to be repeated since # a has bounds now - ap_coord = cl_cube.coord(var_name='ap') + ap_coord = cube.coord(var_name='ap') if ap_coord.bounds is None: - cl_cube.remove_coord(ap_coord) - a_coord = cl_cube.coord(var_name='a') - p0_coord = cl_cube.coord(var_name='p0') + cube.remove_coord(ap_coord) + a_coord = cube.coord(var_name='a') + p0_coord = cube.coord(var_name='p0') ap_coord = a_coord * p0_coord.points[0] ap_coord.units = a_coord.units * p0_coord.units ap_coord.rename('vertical pressure') ap_coord.var_name = 'ap' - cl_cube.add_aux_coord(ap_coord, cl_cube.coord_dims(a_coord)) + cube.add_aux_coord(ap_coord, cube.coord_dims(a_coord)) # Add aux_factory again pressure_coord_factory = iris.aux_factory.HybridPressureFactory( delta=ap_coord, - sigma=cl_cube.coord(var_name='b'), - surface_air_pressure=cl_cube.coord(var_name='ps'), + sigma=cube.coord(var_name='b'), + surface_air_pressure=cube.coord(var_name='ps'), ) - cl_cube.add_aux_factory(pressure_coord_factory) + cube.add_aux_factory(pressure_coord_factory) # Remove attributes from Surface Air Pressure coordinate - cl_cube.coord(var_name='ps').attributes = {} + cube.coord(var_name='ps').attributes = {} - return iris.cube.CubeList([cl_cube]) + return iris.cube.CubeList([cube]) diff --git a/esmvalcore/cmor/_fixes/fix.py b/esmvalcore/cmor/_fixes/fix.py index db7effa439..12aee7b9a0 100644 --- a/esmvalcore/cmor/_fixes/fix.py +++ b/esmvalcore/cmor/_fixes/fix.py @@ -1,7 +1,7 @@ """Contains the base class for dataset fixes""" import importlib -import os import inspect +import os from ..table import CMOR_TABLES @@ -89,7 +89,7 @@ def get_cube_from_list(self, cubes, short_name=None): Variable's cube """ if short_name is None: - short_name = self.__class__.__name__.lower() + short_name = self.vardef.short_name for cube in cubes: if cube.var_name == short_name: return cube diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index 53b1ca023f..513829401f 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -1,16 +1,34 @@ """Shared functions for fixes.""" import logging +import os import warnings import dask.array as da import iris +import pandas as pd from cf_units import Unit +from scipy.interpolate import interp1d from esmvalcore.preprocessor._derive._shared import var_name_constraint logger = logging.getLogger(__name__) +def _get_altitude_to_pressure_func(): + """Get function converting altitude [m] to air pressure [Pa].""" + base_dir = os.path.dirname(os.path.abspath(__file__)) + source_file = os.path.join(base_dir, 'us_standard_atmosphere.csv') + data_frame = pd.read_csv(source_file, comment='#') + func = interp1d(data_frame['Altitude [m]'], + data_frame['Pressure [Pa]'], + kind='cubic', + fill_value='extrapolate') + return func + + +altitude_to_pressure = _get_altitude_to_pressure_func() # noqa + + class AtmosphereSigmaFactory(iris.aux_factory.AuxCoordFactory): """Defines an atmosphere sigma coordinate factory.""" @@ -161,7 +179,19 @@ def update(self, old_coord, new_coord=None): def add_sigma_factory(cube): - """Add factory for ``atmosphere_sigma_coordinate``.""" + """Add factory for ``atmosphere_sigma_coordinate``. + + Parameters + ---------- + cube : iris.cube.Cube + Input cube. + + Raises + ------ + ValueError + ``cube`` does not contain coordinate ``atmosphere_sigma_coordinate``. + + """ if cube.coords('atmosphere_sigma_coordinate'): aux_factory = AtmosphereSigmaFactory( pressure_at_top=cube.coord(var_name='ptop'), @@ -176,7 +206,27 @@ def add_sigma_factory(cube): def add_aux_coords_from_cubes(cube, cubes, coord_dict): - """Add auxiliary coordinate to cube from another cube in list of cubes.""" + """Add auxiliary coordinate to cube from another cube in list of cubes. + + Parameters + ---------- + cube : iris.cube.Cube + Input cube to which the auxiliary coordinates will be added. + cubes : iris.cube.CubeList + List of cubes which contains the desired coordinates as single cubes. + coord_dict : dict + Dictionary of the form ``coord_name: coord_dims``, where ``coord_name`` + is the ``var_name`` (:obj:`str`) of the desired coordinates and + ``coord_dims`` a :obj:`tuple` of :obj:`int` describing the coordinate + dimensions in ``cube``. + + Raises + ------ + ValueError + ``cubes`` do not contain a desired coordinate or multiple copies of + it. + + """ for (coord_name, coord_dims) in coord_dict.items(): coord_cube = cubes.extract(var_name_constraint(coord_name)) if len(coord_cube) != 1: @@ -189,6 +239,39 @@ def add_aux_coords_from_cubes(cube, cubes, coord_dict): cubes.remove(coord_cube) +def add_plev_from_altitude(cube): + """Add pressure level coordinate from altitude coordinate. + + Parameters + ---------- + cube : iris.cube.Cube + Input cube. + + Raises + ------ + ValueError + ``cube`` does not contain coordinate ``altitude``. + + """ + if cube.coords('altitude'): + height_coord = cube.coord('altitude') + if height_coord.units != 'm': + height_coord.convert_units('m') + pressure_points = altitude_to_pressure(height_coord.core_points()) + pressure_bounds = altitude_to_pressure(height_coord.core_bounds()) + pressure_coord = iris.coords.AuxCoord(pressure_points, + bounds=pressure_bounds, + var_name='plev', + standard_name='air_pressure', + long_name='pressure', + units='Pa') + cube.add_aux_coord(pressure_coord, cube.coord_dims(height_coord)) + return + raise ValueError( + "Cannot add 'air_pressure' coordinate, 'altitude' coordinate not " + "available") + + def add_scalar_depth_coord(cube, depth=0.0): """Add scalar coordinate 'depth' with value of `depth`m.""" logger.debug("Adding depth coordinate (%sm)", depth) @@ -263,7 +346,29 @@ def cube_to_aux_coord(cube): def get_bounds_cube(cubes, coord_var_name): - """Find bound cube for a given variable in a list of cubes.""" + """Find bound cube for a given variable in a :class:`iris.cube.CubeList`. + + Parameters + ---------- + cubes : iris.cube.CubeList + List of cubes containing the coordinate bounds for the desired + coordinate as single cube. + coord_var_name : str + ``var_name`` of the desired coordinate (without suffix ``_bnds`` or + ``_bounds``). + + Returns + ------- + iris.cube.Cube + Bounds cube. + + Raises + ------ + ValueError + ``cubes`` do not contain the desired coordinate bounds or multiple + copies of them. + + """ for bounds in ('bnds', 'bounds'): bound_var = f'{coord_var_name}_{bounds}' cube = cubes.extract(var_name_constraint(bound_var)) @@ -278,7 +383,26 @@ def get_bounds_cube(cubes, coord_var_name): def fix_bounds(cube, cubes, coord_var_names): - """Fix bounds for cube that could not be read correctly by :mod:`iris`.""" + """Fix bounds for cube that could not be read correctly by :mod:`iris`. + + Parameters + ---------- + cube : iris.cube.Cube + Input cube whose coordinate bounds will be fixed. + cubes : iris.cube.CubeList + List of cubes which contains the desired coordinate bounds as single + cubes. + coord_var_names : list of str + ``var_name``s of the desired coordinates (without suffix ``_bnds`` or + ``_bounds``). + + Raises + ------ + ValueError + ``cubes`` do not contain a desired coordinate bounds or multiple copies + of them. + + """ for coord_var_name in coord_var_names: coord = cube.coord(var_name=coord_var_name) if coord.bounds is not None: diff --git a/esmvalcore/cmor/_fixes/us_standard_atmosphere.csv b/esmvalcore/cmor/_fixes/us_standard_atmosphere.csv new file mode 100644 index 0000000000..1280d65543 --- /dev/null +++ b/esmvalcore/cmor/_fixes/us_standard_atmosphere.csv @@ -0,0 +1,913 @@ +# Source: https://www.digitaldutch.com/atmoscalc/table.htm +Altitude [m],Temperature [K],Pressure [Pa],Density [kg m-3],Speed of sound [m s-1],Viscosity [Pa s] +-5000,320.65,177687,1.93047,358.972,1.97023E-05 +-4900,320,175802,1.91387,358.608,1.96714E-05 +-4800,319.35,173933,1.89738,358.244,1.96405E-05 +-4700,318.7,172081,1.881,357.879,1.96096E-05 +-4600,318.05,170244,1.86472,357.514,1.95787E-05 +-4500,317.4,168423,1.84856,357.148,1.95477E-05 +-4400,316.75,166618,1.8325,356.782,1.95167E-05 +-4300,316.1,164829,1.81655,356.416,1.94856E-05 +-4200,315.45,163055,1.80071,356.049,1.94545E-05 +-4100,314.8,161297,1.78497,355.682,1.94234E-05 +-4000,314.15,159554,1.76933,355.315,1.93923E-05 +-3900,313.5,157827,1.75381,354.947,1.93611E-05 +-3800,312.85,156115,1.73838,354.579,1.93299E-05 +-3700,312.2,154417,1.72306,354.211,1.92987E-05 +-3600,311.55,152735,1.70785,353.842,1.92674E-05 +-3500,310.9,151068,1.69273,353.472,1.92362E-05 +-3400,310.25,149415,1.67772,353.103,1.92048E-05 +-3300,309.6,147777,1.66282,352.733,1.91735E-05 +-3200,308.95,146154,1.64801,352.362,1.91421E-05 +-3100,308.3,144545,1.6333,351.991,1.91107E-05 +-3000,307.65,142950,1.6187,351.62,1.90792E-05 +-2900,307,141370,1.60419,351.248,1.90477E-05 +-2800,306.35,139804,1.58979,350.876,1.90162E-05 +-2700,305.7,138252,1.57548,350.504,1.89847E-05 +-2600,305.05,136714,1.56127,350.131,1.89531E-05 +-2500,304.4,135190,1.54717,349.758,1.89215E-05 +-2400,303.75,133679,1.53315,349.384,1.88898E-05 +-2300,303.1,132183,1.51924,349.01,1.88582E-05 +-2200,302.45,130699,1.50542,348.636,1.88265E-05 +-2100,301.8,129230,1.4917,348.261,1.87947E-05 +-2000,301.15,127774,1.47808,347.886,1.8763E-05 +-1900,300.5,126331,1.46455,347.51,1.87311E-05 +-1800,299.85,124901,1.45111,347.134,1.86993E-05 +-1700,299.2,123485,1.43777,346.757,1.86674E-05 +-1600,298.55,122081,1.42452,346.381,1.86355E-05 +-1500,297.9,120691,1.41137,346.003,1.86036E-05 +-1400,297.25,119313,1.39831,345.626,1.85716E-05 +-1300,296.6,117948,1.38535,345.248,1.85396E-05 +-1200,295.95,116596,1.37247,344.869,1.85076E-05 +-1100,295.3,115256,1.35969,344.49,1.84755E-05 +-1000,294.65,113929,1.347,344.111,1.84434E-05 +-900,294,112614,1.33439,343.731,1.84113E-05 +-800,293.35,111312,1.32188,343.351,1.83791E-05 +-700,292.7,110022,1.30946,342.97,1.83469E-05 +-600,292.05,108744,1.29713,342.589,1.83147E-05 +-500,291.4,107478,1.28489,342.208,1.82824E-05 +-400,290.75,106223,1.27274,341.826,1.82501E-05 +-300,290.1,104981,1.26067,341.444,1.82178E-05 +-200,289.45,103751,1.24869,341.061,1.81854E-05 +-100,288.8,102532,1.2368,340.678,1.8153E-05 +0,288.15,101325,1.225,340.294,1.81206E-05 +100,287.5,100129,1.21328,339.91,1.80881E-05 +200,286.85,98945.3,1.20165,339.526,1.80556E-05 +300,286.2,97772.6,1.19011,339.141,1.8023E-05 +400,285.55,96611.1,1.17864,338.755,1.79905E-05 +500,284.9,95460.8,1.16727,338.37,1.79579E-05 +600,284.25,94321.7,1.15598,337.983,1.79252E-05 +700,283.6,93193.6,1.14477,337.597,1.78925E-05 +800,282.95,92076.4,1.13364,337.21,1.78598E-05 +900,282.3,90970.1,1.1226,336.822,1.78271E-05 +1000,281.65,89874.6,1.11164,336.434,1.77943E-05 +1100,281,88789.8,1.10077,336.046,1.77615E-05 +1200,280.35,87715.6,1.08997,335.657,1.77286E-05 +1300,279.7,86651.9,1.07925,335.267,1.76957E-05 +1400,279.05,85598.8,1.06862,334.878,1.76628E-05 +1500,278.4,84556,1.05807,334.487,1.76298E-05 +1600,277.75,83523.5,1.04759,334.097,1.75968E-05 +1700,277.1,82501.3,1.0372,333.705,1.75638E-05 +1800,276.45,81489.2,1.02688,333.314,1.75307E-05 +1900,275.8,80487.2,1.01665,332.922,1.74976E-05 +2000,275.15,79495.2,1.00649,332.529,1.74645E-05 +2100,274.5,78513.1,0.99641,332.136,1.74313E-05 +2200,273.85,77540.9,0.986407,331.743,1.73981E-05 +2300,273.2,76578.4,0.976481,331.349,1.73649E-05 +2400,272.55,75625.7,0.966632,330.954,1.73316E-05 +2500,271.9,74682.5,0.956859,330.56,1.72983E-05 +2600,271.25,73748.9,0.947162,330.164,1.72649E-05 +2700,270.6,72824.8,0.93754,329.768,1.72315E-05 +2800,269.95,71910.1,0.927993,329.372,1.71981E-05 +2900,269.3,71004.7,0.91852,328.975,1.71646E-05 +3000,268.65,70108.5,0.909122,328.578,1.71311E-05 +3100,268,69221.6,0.899798,328.18,1.70976E-05 +3200,267.35,68343.7,0.890546,327.782,1.7064E-05 +3300,266.7,67474.9,0.881368,327.383,1.70304E-05 +3400,266.05,66615,0.872262,326.984,1.69967E-05 +3500,265.4,65764.1,0.863229,326.584,1.6963E-05 +3600,264.75,64921.9,0.854267,326.184,1.69293E-05 +3700,264.1,64088.6,0.845377,325.784,1.68955E-05 +3800,263.45,63263.9,0.836557,325.382,1.68617E-05 +3900,262.8,62447.8,0.827808,324.981,1.68279E-05 +4000,262.15,61640.2,0.819129,324.579,1.6794E-05 +4100,261.5,60841.2,0.81052,324.176,1.67601E-05 +4200,260.85,60050.5,0.801981,323.773,1.67261E-05 +4300,260.2,59268.2,0.79351,323.369,1.66922E-05 +4400,259.55,58494.2,0.785108,322.965,1.66581E-05 +4500,258.9,57728.3,0.776775,322.56,1.66241E-05 +4600,258.25,56970.6,0.768509,322.155,1.659E-05 +4700,257.6,56221,0.76031,321.75,1.65558E-05 +4800,256.95,55479.4,0.752179,321.343,1.65216E-05 +4900,256.3,54745.7,0.744114,320.937,1.64874E-05 +5000,255.65,54019.9,0.736116,320.529,1.64531E-05 +5100,255,53301.9,0.728183,320.122,1.64188E-05 +5200,254.35,52591.7,0.720317,319.713,1.63845E-05 +5300,253.7,51889.1,0.712515,319.305,1.63501E-05 +5400,253.05,51194.2,0.704778,318.895,1.63157E-05 +5500,252.4,50506.8,0.697106,318.486,1.62813E-05 +5600,251.75,49826.9,0.689497,318.075,1.62468E-05 +5700,251.1,49154.5,0.681953,317.664,1.62122E-05 +5800,250.45,48489.4,0.674471,317.253,1.61777E-05 +5900,249.8,47831.6,0.667053,316.841,1.6143E-05 +6000,249.15,47181,0.659697,316.428,1.61084E-05 +6100,248.5,46537.7,0.652404,316.015,1.60737E-05 +6200,247.85,45901.4,0.645172,315.602,1.6039E-05 +6300,247.2,45272.3,0.638002,315.188,1.60042E-05 +6400,246.55,44650.1,0.630892,314.773,1.59694E-05 +6500,245.9,44034.8,0.623844,314.358,1.59345E-05 +6600,245.25,43426.5,0.616856,313.942,1.58996E-05 +6700,244.6,42825,0.609928,313.526,1.58647E-05 +6800,243.95,42230.2,0.60306,313.109,1.58297E-05 +6900,243.3,41642.2,0.596251,312.692,1.57947E-05 +7000,242.65,41060.7,0.589501,312.274,1.57596E-05 +7100,242,40485.9,0.58281,311.855,1.57245E-05 +7200,241.35,39917.6,0.576177,311.436,1.56894E-05 +7300,240.7,39355.8,0.569602,311.016,1.56542E-05 +7400,240.05,38800.4,0.563084,310.596,1.5619E-05 +7500,239.4,38251.4,0.556624,310.175,1.55837E-05 +7600,238.75,37708.7,0.55022,309.754,1.55484E-05 +7700,238.1,37172.2,0.543873,309.332,1.55131E-05 +7800,237.45,36642,0.537582,308.909,1.54777E-05 +7900,236.8,36117.8,0.531347,308.486,1.54423E-05 +8000,236.15,35599.8,0.525168,308.063,1.54068E-05 +8100,235.5,35087.8,0.519043,307.638,1.53713E-05 +8200,234.85,34581.8,0.512973,307.214,1.53357E-05 +8300,234.2,34081.7,0.506958,306.788,1.53001E-05 +8400,233.55,33587.5,0.500997,306.362,1.52645E-05 +8500,232.9,33099,0.49509,305.935,1.52288E-05 +8600,232.25,32616.4,0.489236,305.508,1.51931E-05 +8700,231.6,32139.5,0.483435,305.08,1.51573E-05 +8800,230.95,31668.2,0.477687,304.652,1.51215E-05 +8900,230.3,31202.6,0.471992,304.223,1.50857E-05 +9000,229.65,30742.5,0.466348,303.793,1.50498E-05 +9100,229,30287.9,0.460756,303.363,1.50138E-05 +9200,228.35,29838.7,0.455216,302.932,1.49778E-05 +9300,227.7,29395,0.449727,302.501,1.49418E-05 +9400,227.05,28956.7,0.444289,302.069,1.49058E-05 +9500,226.4,28523.6,0.438901,301.636,1.48696E-05 +9600,225.75,28095.8,0.433563,301.203,1.48335E-05 +9700,225.1,27673.2,0.428275,300.769,1.47973E-05 +9800,224.45,27255.8,0.423036,300.334,1.4761E-05 +9900,223.8,26843.5,0.417847,299.899,1.47247E-05 +10000,223.15,26436.3,0.412707,299.463,1.46884E-05 +10100,222.5,26034,0.407615,299.027,1.4652E-05 +10200,221.85,25636.8,0.402571,298.59,1.46156E-05 +10300,221.2,25244.5,0.397575,298.152,1.45792E-05 +10400,220.55,24857,0.392627,297.714,1.45426E-05 +10500,219.9,24474.4,0.387725,297.275,1.45061E-05 +10600,219.25,24096.5,0.382871,296.835,1.44695E-05 +10700,218.6,23723.4,0.378064,296.395,1.44328E-05 +10800,217.95,23355,0.373303,295.954,1.43962E-05 +10900,217.3,22991.2,0.368588,295.512,1.43594E-05 +11000,216.65,22632.1,0.363918,295.07,1.43226E-05 +11100,216.65,22278,0.358224,295.07,1.43226E-05 +11200,216.65,21929.4,0.35262,295.07,1.43226E-05 +11300,216.65,21586.3,0.347103,295.07,1.43226E-05 +11400,216.65,21248.6,0.341673,295.07,1.43226E-05 +11500,216.65,20916.2,0.336327,295.07,1.43226E-05 +11600,216.65,20589,0.331065,295.07,1.43226E-05 +11700,216.65,20266.8,0.325886,295.07,1.43226E-05 +11800,216.65,19949.8,0.320787,295.07,1.43226E-05 +11900,216.65,19637.6,0.315768,295.07,1.43226E-05 +12000,216.65,19330.4,0.310828,295.07,1.43226E-05 +12100,216.65,19028,0.305965,295.07,1.43226E-05 +12200,216.65,18730.3,0.301178,295.07,1.43226E-05 +12300,216.65,18437.2,0.296466,295.07,1.43226E-05 +12400,216.65,18148.8,0.291828,295.07,1.43226E-05 +12500,216.65,17864.8,0.287262,295.07,1.43226E-05 +12600,216.65,17585.4,0.282768,295.07,1.43226E-05 +12700,216.65,17310.2,0.278344,295.07,1.43226E-05 +12800,216.65,17039.4,0.273989,295.07,1.43226E-05 +12900,216.65,16772.8,0.269703,295.07,1.43226E-05 +13000,216.65,16510.4,0.265483,295.07,1.43226E-05 +13100,216.65,16252.1,0.26133,295.07,1.43226E-05 +13200,216.65,15997.8,0.257241,295.07,1.43226E-05 +13300,216.65,15747.5,0.253217,295.07,1.43226E-05 +13400,216.65,15501.2,0.249255,295.07,1.43226E-05 +13500,216.65,15258.7,0.245355,295.07,1.43226E-05 +13600,216.65,15019.9,0.241517,295.07,1.43226E-05 +13700,216.65,14784.9,0.237738,295.07,1.43226E-05 +13800,216.65,14553.6,0.234019,295.07,1.43226E-05 +13900,216.65,14325.9,0.230357,295.07,1.43226E-05 +14000,216.65,14101.8,0.226753,295.07,1.43226E-05 +14100,216.65,13881.2,0.223206,295.07,1.43226E-05 +14200,216.65,13664,0.219714,295.07,1.43226E-05 +14300,216.65,13450.2,0.216276,295.07,1.43226E-05 +14400,216.65,13239.8,0.212893,295.07,1.43226E-05 +14500,216.65,13032.7,0.209562,295.07,1.43226E-05 +14600,216.65,12828.8,0.206283,295.07,1.43226E-05 +14700,216.65,12628.1,0.203056,295.07,1.43226E-05 +14800,216.65,12430.5,0.199879,295.07,1.43226E-05 +14900,216.65,12236,0.196752,295.07,1.43226E-05 +15000,216.65,12044.6,0.193674,295.07,1.43226E-05 +15100,216.65,11856.1,0.190644,295.07,1.43226E-05 +15200,216.65,11670.6,0.187661,295.07,1.43226E-05 +15300,216.65,11488.1,0.184725,295.07,1.43226E-05 +15400,216.65,11308.3,0.181835,295.07,1.43226E-05 +15500,216.65,11131.4,0.17899,295.07,1.43226E-05 +15600,216.65,10957.2,0.17619,295.07,1.43226E-05 +15700,216.65,10785.8,0.173433,295.07,1.43226E-05 +15800,216.65,10617.1,0.17072,295.07,1.43226E-05 +15900,216.65,10451,0.168049,295.07,1.43226E-05 +16000,216.65,10287.5,0.16542,295.07,1.43226E-05 +16100,216.65,10126.5,0.162832,295.07,1.43226E-05 +16200,216.65,9968.08,0.160284,295.07,1.43226E-05 +16300,216.65,9812.13,0.157777,295.07,1.43226E-05 +16400,216.65,9658.61,0.155308,295.07,1.43226E-05 +16500,216.65,9507.5,0.152878,295.07,1.43226E-05 +16600,216.65,9358.76,0.150487,295.07,1.43226E-05 +16700,216.65,9212.34,0.148132,295.07,1.43226E-05 +16800,216.65,9068.21,0.145815,295.07,1.43226E-05 +16900,216.65,8926.34,0.143533,295.07,1.43226E-05 +17000,216.65,8786.68,0.141288,295.07,1.43226E-05 +17100,216.65,8649.21,0.139077,295.07,1.43226E-05 +17200,216.65,8513.89,0.136901,295.07,1.43226E-05 +17300,216.65,8380.69,0.134759,295.07,1.43226E-05 +17400,216.65,8249.58,0.132651,295.07,1.43226E-05 +17500,216.65,8120.51,0.130576,295.07,1.43226E-05 +17600,216.65,7993.46,0.128533,295.07,1.43226E-05 +17700,216.65,7868.4,0.126522,295.07,1.43226E-05 +17800,216.65,7745.3,0.124543,295.07,1.43226E-05 +17900,216.65,7624.13,0.122594,295.07,1.43226E-05 +18000,216.65,7504.84,0.120676,295.07,1.43226E-05 +18100,216.65,7387.43,0.118788,295.07,1.43226E-05 +18200,216.65,7271.85,0.11693,295.07,1.43226E-05 +18300,216.65,7158.08,0.1151,295.07,1.43226E-05 +18400,216.65,7046.09,0.113299,295.07,1.43226E-05 +18500,216.65,6935.86,0.111527,295.07,1.43226E-05 +18600,216.65,6827.34,0.109782,295.07,1.43226E-05 +18700,216.65,6720.53,0.108064,295.07,1.43226E-05 +18800,216.65,6615.39,0.106374,295.07,1.43226E-05 +18900,216.65,6511.89,0.10471,295.07,1.43226E-05 +19000,216.65,6410.01,0.103071,295.07,1.43226E-05 +19100,216.65,6309.72,0.101459,295.07,1.43226E-05 +19200,216.65,6211,0.0998714,295.07,1.43226E-05 +19300,216.65,6113.83,0.0983089,295.07,1.43226E-05 +19400,216.65,6018.18,0.0967709,295.07,1.43226E-05 +19500,216.65,5924.03,0.0952569,295.07,1.43226E-05 +19600,216.65,5831.34,0.0937666,295.07,1.43226E-05 +19700,216.65,5740.11,0.0922996,295.07,1.43226E-05 +19800,216.65,5650.31,0.0908555,295.07,1.43226E-05 +19900,216.65,5561.91,0.0894341,295.07,1.43226E-05 +20000,216.65,5474.89,0.0880349,295.07,1.43226E-05 +20100,216.75,5389.25,0.0866179,295.138,1.43283E-05 +20200,216.85,5304.99,0.0852243,295.206,1.4334E-05 +20300,216.95,5222.09,0.0838538,295.274,1.43396E-05 +20400,217.05,5140.52,0.082506,295.342,1.43453E-05 +20500,217.15,5060.26,0.0811804,295.41,1.43509E-05 +20600,217.25,4981.29,0.0798768,295.478,1.43566E-05 +20700,217.35,4903.59,0.0785946,295.546,1.43622E-05 +20800,217.45,4827.14,0.0773336,295.614,1.43679E-05 +20900,217.55,4751.91,0.0760934,295.682,1.43736E-05 +21000,217.65,4677.89,0.0748737,295.75,1.43792E-05 +21100,217.75,4605.05,0.073674,295.818,1.43849E-05 +21200,217.85,4533.38,0.0724941,295.886,1.43905E-05 +21300,217.95,4462.86,0.0713336,295.954,1.43962E-05 +21400,218.05,4393.47,0.0701923,296.021,1.44018E-05 +21500,218.15,4325.18,0.0690697,296.089,1.44074E-05 +21600,218.25,4257.99,0.0679655,296.157,1.44131E-05 +21700,218.35,4191.87,0.0668795,296.225,1.44187E-05 +21800,218.45,4126.81,0.0658114,296.293,1.44244E-05 +21900,218.55,4062.79,0.0647607,296.361,1.443E-05 +22000,218.65,3999.79,0.0637273,296.428,1.44357E-05 +22100,218.75,3937.79,0.0627109,296.496,1.44413E-05 +22200,218.85,3876.79,0.0617111,296.564,1.44469E-05 +22300,218.95,3816.75,0.0607278,296.632,1.44526E-05 +22400,219.05,3757.68,0.0597605,296.699,1.44582E-05 +22500,219.15,3699.54,0.0588091,296.767,1.44639E-05 +22600,219.25,3642.33,0.0578732,296.835,1.44695E-05 +22700,219.35,3586.03,0.0569526,296.903,1.44751E-05 +22800,219.45,3530.62,0.0560471,296.97,1.44808E-05 +22900,219.55,3476.09,0.0551564,297.038,1.44864E-05 +23000,219.65,3422.43,0.0542803,297.105,1.4492E-05 +23100,219.75,3369.63,0.0534184,297.173,1.44976E-05 +23200,219.85,3317.66,0.0525706,297.241,1.45033E-05 +23300,219.95,3266.51,0.0517367,297.308,1.45089E-05 +23400,220.05,3216.18,0.0509164,297.376,1.45145E-05 +23500,220.15,3166.65,0.0501094,297.443,1.45202E-05 +23600,220.25,3117.9,0.0493155,297.511,1.45258E-05 +23700,220.35,3069.92,0.0485346,297.579,1.45314E-05 +23800,220.45,3022.7,0.0477665,297.646,1.4537E-05 +23900,220.55,2976.23,0.0470108,297.714,1.45426E-05 +24000,220.65,2930.49,0.0462674,297.781,1.45483E-05 +24100,220.75,2885.48,0.045536,297.849,1.45539E-05 +24200,220.85,2841.18,0.0448166,297.916,1.45595E-05 +24300,220.95,2797.58,0.0441089,297.983,1.45651E-05 +24400,221.05,2754.66,0.0434126,298.051,1.45707E-05 +24500,221.15,2712.42,0.0427276,298.118,1.45763E-05 +24600,221.25,2670.85,0.0420538,298.186,1.4582E-05 +24700,221.35,2629.94,0.0413909,298.253,1.45876E-05 +24800,221.45,2589.67,0.0407387,298.32,1.45932E-05 +24900,221.55,2550.03,0.0400971,298.388,1.45988E-05 +25000,221.65,2511.02,0.0394658,298.455,1.46044E-05 +25100,221.75,2472.63,0.0388448,298.522,1.461E-05 +25200,221.85,2434.83,0.0382338,298.59,1.46156E-05 +25300,221.95,2397.63,0.0376327,298.657,1.46212E-05 +25400,222.05,2361.02,0.0370414,298.724,1.46268E-05 +25500,222.15,2324.98,0.0364595,298.791,1.46324E-05 +25600,222.25,2289.51,0.0358871,298.859,1.4638E-05 +25700,222.35,2254.59,0.0353239,298.926,1.46436E-05 +25800,222.45,2220.22,0.0347698,298.993,1.46492E-05 +25900,222.55,2186.39,0.0342246,299.06,1.46548E-05 +26000,222.65,2153.09,0.0336882,299.128,1.46604E-05 +26100,222.75,2120.32,0.0331605,299.195,1.4666E-05 +26200,222.85,2088.05,0.0326413,299.262,1.46716E-05 +26300,222.95,2056.29,0.0321304,299.329,1.46772E-05 +26400,223.05,2025.03,0.0316277,299.396,1.46828E-05 +26500,223.15,1994.26,0.0311331,299.463,1.46884E-05 +26600,223.25,1963.97,0.0306465,299.53,1.4694E-05 +26700,223.35,1934.15,0.0301677,299.597,1.46996E-05 +26800,223.45,1904.8,0.0296966,299.664,1.47052E-05 +26900,223.55,1875.9,0.029233,299.732,1.47108E-05 +27000,223.65,1847.46,0.0287769,299.799,1.47164E-05 +27100,223.75,1819.46,0.0283281,299.866,1.4722E-05 +27200,223.85,1791.89,0.0278865,299.933,1.47275E-05 +27300,223.95,1764.76,0.0274519,300,1.47331E-05 +27400,224.05,1738.05,0.0270244,300.067,1.47387E-05 +27500,224.15,1711.75,0.0266036,300.133,1.47443E-05 +27600,224.25,1685.87,0.0261896,300.2,1.47499E-05 +27700,224.35,1660.39,0.0257823,300.267,1.47555E-05 +27800,224.45,1635.3,0.0253814,300.334,1.4761E-05 +27900,224.55,1610.6,0.024987,300.401,1.47666E-05 +28000,224.65,1586.29,0.0245988,300.468,1.47722E-05 +28100,224.75,1562.35,0.0242169,300.535,1.47778E-05 +28200,224.85,1538.79,0.023841,300.602,1.47833E-05 +28300,224.95,1515.59,0.0234712,300.669,1.47889E-05 +28400,225.05,1492.75,0.0231072,300.735,1.47945E-05 +28500,225.15,1470.27,0.022749,300.802,1.48001E-05 +28600,225.25,1448.13,0.0223966,300.869,1.48056E-05 +28700,225.35,1426.34,0.0220498,300.936,1.48112E-05 +28800,225.45,1404.89,0.0217084,301.003,1.48168E-05 +28900,225.55,1383.76,0.0213726,301.069,1.48223E-05 +29000,225.65,1362.96,0.021042,301.136,1.48279E-05 +29100,225.75,1342.49,0.0207167,301.203,1.48335E-05 +29200,225.85,1322.33,0.0203966,301.269,1.4839E-05 +29300,225.95,1302.48,0.0200816,301.336,1.48446E-05 +29400,226.05,1282.94,0.0197716,301.403,1.48502E-05 +29500,226.15,1263.7,0.0194664,301.469,1.48557E-05 +29600,226.25,1244.76,0.0191662,301.536,1.48613E-05 +29700,226.35,1226.11,0.0188707,301.603,1.48669E-05 +29800,226.45,1207.75,0.0185798,301.669,1.48724E-05 +29900,226.55,1189.67,0.0182936,301.736,1.4878E-05 +30000,226.65,1171.87,0.0180119,301.803,1.48835E-05 +30100,226.75,1154.34,0.0177347,301.869,1.48891E-05 +30200,226.85,1137.08,0.0174619,301.936,1.48946E-05 +30300,226.95,1120.09,0.0171934,302.002,1.49002E-05 +30400,227.05,1103.36,0.0169291,302.069,1.49058E-05 +30500,227.15,1086.88,0.016669,302.135,1.49113E-05 +30600,227.25,1070.66,0.016413,302.202,1.49169E-05 +30700,227.35,1054.69,0.016161,302.268,1.49224E-05 +30800,227.45,1038.97,0.015913,302.335,1.4928E-05 +30900,227.55,1023.48,0.015669,302.401,1.49335E-05 +31000,227.65,1008.23,0.0154288,302.468,1.4939E-05 +31100,227.75,993.218,0.0151923,302.534,1.49446E-05 +31200,227.85,978.434,0.0149596,302.6,1.49501E-05 +31300,227.95,963.876,0.0147306,302.667,1.49557E-05 +31400,228.05,949.541,0.0145051,302.733,1.49612E-05 +31500,228.15,935.425,0.0142832,302.8,1.49668E-05 +31600,228.25,921.526,0.0140648,302.866,1.49723E-05 +31700,228.35,907.838,0.0138499,302.932,1.49778E-05 +31800,228.45,894.36,0.0136383,302.999,1.49834E-05 +31900,228.55,881.088,0.01343,303.065,1.49889E-05 +32000,228.65,868.019,0.013225,303.131,1.49945E-05 +32100,228.93,855.154,0.0130131,303.317,1.501E-05 +32200,229.21,842.495,0.0128048,303.502,1.50254E-05 +32300,229.49,830.038,0.0126001,303.688,1.50409E-05 +32400,229.77,817.781,0.0123989,303.873,1.50564E-05 +32500,230.05,805.719,0.0122011,304.058,1.50719E-05 +32600,230.33,793.849,0.0120068,304.243,1.50873E-05 +32700,230.61,782.168,0.0118157,304.428,1.51028E-05 +32800,230.89,770.674,0.011628,304.612,1.51182E-05 +32900,231.17,759.361,0.0114434,304.797,1.51336E-05 +33000,231.45,748.228,0.011262,304.982,1.51491E-05 +33100,231.73,737.272,0.0110837,305.166,1.51645E-05 +33200,232.01,726.489,0.0109084,305.35,1.51799E-05 +33300,232.29,715.876,0.0107361,305.535,1.51953E-05 +33400,232.57,705.431,0.0105667,305.719,1.52107E-05 +33500,232.85,695.15,0.0104002,305.903,1.52261E-05 +33600,233.13,685.032,0.0102365,306.086,1.52414E-05 +33700,233.41,675.072,0.0100756,306.27,1.52568E-05 +33800,233.69,665.269,0.00991734,306.454,1.52722E-05 +33900,233.97,655.62,0.00976181,306.637,1.52875E-05 +34000,234.25,646.122,0.00960889,306.821,1.53029E-05 +34100,234.53,636.773,0.00945855,307.004,1.53182E-05 +34200,234.81,627.57,0.00931073,307.187,1.53335E-05 +34300,235.09,618.511,0.0091654,307.37,1.53489E-05 +34400,235.37,609.593,0.0090225,307.553,1.53642E-05 +34500,235.65,600.814,0.008882,307.736,1.53795E-05 +34600,235.93,592.172,0.00874385,307.919,1.53948E-05 +34700,236.21,583.664,0.008608,308.102,1.54101E-05 +34800,236.49,575.288,0.00847443,308.284,1.54254E-05 +34900,236.77,567.042,0.00834308,308.467,1.54406E-05 +35000,237.05,558.924,0.00821392,308.649,1.54559E-05 +35100,237.33,550.931,0.00808691,308.831,1.54712E-05 +35200,237.61,543.062,0.00796201,309.013,1.54864E-05 +35300,237.89,535.314,0.00783918,309.195,1.55017E-05 +35400,238.17,527.686,0.00771839,309.377,1.55169E-05 +35500,238.45,520.175,0.00759959,309.559,1.55321E-05 +35600,238.73,512.78,0.00748277,309.741,1.55474E-05 +35700,239.01,505.498,0.00736787,309.922,1.55626E-05 +35800,239.29,498.329,0.00725486,310.104,1.55778E-05 +35900,239.57,491.269,0.00714372,310.285,1.5593E-05 +36000,239.85,484.317,0.00703441,310.467,1.56082E-05 +36100,240.13,477.471,0.0069269,310.648,1.56233E-05 +36200,240.41,470.73,0.00682115,310.829,1.56385E-05 +36300,240.69,464.092,0.00671714,311.01,1.56537E-05 +36400,240.97,457.555,0.00661483,311.191,1.56688E-05 +36500,241.25,451.118,0.00651419,311.371,1.5684E-05 +36600,241.53,444.778,0.0064152,311.552,1.56991E-05 +36700,241.81,438.535,0.00631783,311.733,1.57143E-05 +36800,242.09,432.386,0.00622205,311.913,1.57294E-05 +36900,242.37,426.331,0.00612782,312.093,1.57445E-05 +37000,242.65,420.367,0.00603513,312.274,1.57596E-05 +37100,242.93,414.494,0.00594394,312.454,1.57748E-05 +37200,243.21,408.709,0.00585424,312.634,1.57898E-05 +37300,243.49,403.011,0.00576599,312.814,1.58049E-05 +37400,243.77,397.399,0.00567917,312.993,1.582E-05 +37500,244.05,391.872,0.00559375,313.173,1.58351E-05 +37600,244.33,386.427,0.00550972,313.353,1.58502E-05 +37700,244.61,381.065,0.00542704,313.532,1.58652E-05 +37800,244.89,375.783,0.00534569,313.712,1.58803E-05 +37900,245.17,370.58,0.00526566,313.891,1.58953E-05 +38000,245.45,365.455,0.00518691,314.07,1.59104E-05 +38100,245.73,360.406,0.00510943,314.249,1.59254E-05 +38200,246.01,355.433,0.00503319,314.428,1.59404E-05 +38300,246.29,350.534,0.00495817,314.607,1.59554E-05 +38400,246.57,345.708,0.00488436,314.786,1.59704E-05 +38500,246.85,340.954,0.00481172,314.965,1.59854E-05 +38600,247.13,336.27,0.00474025,315.143,1.60004E-05 +38700,247.41,331.656,0.00466992,315.322,1.60154E-05 +38800,247.69,327.111,0.00460071,315.5,1.60304E-05 +38900,247.97,322.632,0.0045326,315.678,1.60454E-05 +39000,248.25,318.22,0.00446557,315.856,1.60603E-05 +39100,248.53,313.874,0.00439961,316.034,1.60753E-05 +39200,248.81,309.591,0.0043347,316.212,1.60902E-05 +39300,249.09,305.372,0.00427081,316.39,1.61052E-05 +39400,249.37,301.214,0.00420794,316.568,1.61201E-05 +39500,249.65,297.118,0.00414606,316.746,1.6135E-05 +39600,249.93,293.082,0.00408516,316.923,1.615E-05 +39700,250.21,289.105,0.00402522,317.101,1.61649E-05 +39800,250.49,285.187,0.00396623,317.278,1.61798E-05 +39900,250.77,281.326,0.00390816,317.455,1.61947E-05 +40000,251.05,277.522,0.00385101,317.633,1.62096E-05 +40100,251.33,273.773,0.00379476,317.81,1.62245E-05 +40200,251.61,270.079,0.00373939,317.987,1.62393E-05 +40300,251.89,266.438,0.00368488,318.164,1.62542E-05 +40400,252.17,262.851,0.00363123,318.34,1.62691E-05 +40500,252.45,259.316,0.00357842,318.517,1.62839E-05 +40600,252.73,255.832,0.00352644,318.694,1.62988E-05 +40700,253.01,252.399,0.00347527,318.87,1.63136E-05 +40800,253.29,249.016,0.00342489,319.047,1.63284E-05 +40900,253.57,245.682,0.0033753,319.223,1.63433E-05 +41000,253.85,242.395,0.00332648,319.399,1.63581E-05 +41100,254.13,239.157,0.00327842,319.575,1.63729E-05 +41200,254.41,235.965,0.00323111,319.751,1.63877E-05 +41300,254.69,232.819,0.00318453,319.927,1.64025E-05 +41400,254.97,229.719,0.00313867,320.103,1.64173E-05 +41500,255.25,226.663,0.00309352,320.279,1.6432E-05 +41600,255.53,223.651,0.00304907,320.454,1.64468E-05 +41700,255.81,220.683,0.00300531,320.63,1.64616E-05 +41800,256.09,217.757,0.00296222,320.805,1.64763E-05 +41900,256.37,214.873,0.00291979,320.981,1.64911E-05 +42000,256.65,212.03,0.00287802,321.156,1.65058E-05 +42100,256.93,209.228,0.00283689,321.331,1.65206E-05 +42200,257.21,206.466,0.00279639,321.506,1.65353E-05 +42300,257.49,203.743,0.00275651,321.681,1.655E-05 +42400,257.77,201.059,0.00271725,321.856,1.65647E-05 +42500,258.05,198.413,0.00267858,322.03,1.65795E-05 +42600,258.33,195.805,0.00264051,322.205,1.65942E-05 +42700,258.61,193.234,0.00260302,322.38,1.66088E-05 +42800,258.89,190.7,0.00256609,322.554,1.66235E-05 +42900,259.17,188.201,0.00252974,322.729,1.66382E-05 +43000,259.45,185.738,0.00249393,322.903,1.66529E-05 +43100,259.73,183.309,0.00245867,323.077,1.66676E-05 +43200,260.01,180.915,0.00242395,323.251,1.66822E-05 +43300,260.29,178.555,0.00238975,323.425,1.66969E-05 +43400,260.57,176.228,0.00235607,323.599,1.67115E-05 +43500,260.85,173.934,0.00232291,323.773,1.67261E-05 +43600,261.13,171.672,0.00229024,323.947,1.67408E-05 +43700,261.41,169.442,0.00225807,324.12,1.67554E-05 +43800,261.69,167.243,0.00222638,324.294,1.677E-05 +43900,261.97,165.075,0.00219517,324.467,1.67846E-05 +44000,262.25,162.937,0.00216443,324.641,1.67992E-05 +44100,262.53,160.83,0.00213415,324.814,1.68138E-05 +44200,262.81,158.751,0.00210433,324.987,1.68284E-05 +44300,263.09,156.702,0.00207496,325.16,1.6843E-05 +44400,263.37,154.682,0.00204602,325.333,1.68576E-05 +44500,263.65,152.689,0.00201752,325.506,1.68721E-05 +44600,263.93,150.724,0.00198945,325.679,1.68867E-05 +44700,264.21,148.787,0.0019618,325.851,1.69013E-05 +44800,264.49,146.877,0.00193456,326.024,1.69158E-05 +44900,264.77,144.993,0.00190772,326.197,1.69303E-05 +45000,265.05,143.135,0.00188129,326.369,1.69449E-05 +45100,265.33,141.303,0.00185525,326.541,1.69594E-05 +45200,265.61,139.496,0.0018296,326.714,1.69739E-05 +45300,265.89,137.714,0.00180432,326.886,1.69884E-05 +45400,266.17,135.957,0.00177943,327.058,1.70029E-05 +45500,266.45,134.224,0.0017549,327.23,1.70174E-05 +45600,266.73,132.515,0.00173074,327.402,1.70319E-05 +45700,267.01,130.829,0.00170693,327.574,1.70464E-05 +45800,267.29,129.167,0.00168348,327.745,1.70609E-05 +45900,267.57,127.527,0.00166037,327.917,1.70754E-05 +46000,267.85,125.91,0.0016376,328.088,1.70898E-05 +46100,268.13,124.315,0.00161517,328.26,1.71043E-05 +46200,268.41,122.742,0.00159307,328.431,1.71187E-05 +46300,268.69,121.191,0.00157129,328.602,1.71332E-05 +46400,268.97,119.66,0.00154983,328.774,1.71476E-05 +46500,269.25,118.151,0.00152869,328.945,1.7162E-05 +46600,269.53,116.662,0.00150786,329.116,1.71764E-05 +46700,269.81,115.193,0.00148733,329.287,1.71909E-05 +46800,270.09,113.745,0.0014671,329.457,1.72053E-05 +46900,270.37,112.316,0.00144717,329.628,1.72197E-05 +47000,270.65,110.906,0.00142753,329.799,1.72341E-05 +47100,270.65,109.515,0.00140963,329.799,1.72341E-05 +47200,270.65,108.141,0.00139195,329.799,1.72341E-05 +47300,270.65,106.785,0.00137449,329.799,1.72341E-05 +47400,270.65,105.446,0.00135725,329.799,1.72341E-05 +47500,270.65,104.123,0.00134022,329.799,1.72341E-05 +47600,270.65,102.817,0.00132341,329.799,1.72341E-05 +47700,270.65,101.527,0.00130681,329.799,1.72341E-05 +47800,270.65,100.254,0.00129042,329.799,1.72341E-05 +47900,270.65,98.9962,0.00127423,329.799,1.72341E-05 +48000,270.65,97.7545,0.00125825,329.799,1.72341E-05 +48100,270.65,96.5283,0.00124247,329.799,1.72341E-05 +48200,270.65,95.3176,0.00122688,329.799,1.72341E-05 +48300,270.65,94.122,0.00121149,329.799,1.72341E-05 +48400,270.65,92.9414,0.0011963,329.799,1.72341E-05 +48500,270.65,91.7756,0.00118129,329.799,1.72341E-05 +48600,270.65,90.6244,0.00116647,329.799,1.72341E-05 +48700,270.65,89.4877,0.00115184,329.799,1.72341E-05 +48800,270.65,88.3652,0.00113739,329.799,1.72341E-05 +48900,270.65,87.2568,0.00112313,329.799,1.72341E-05 +49000,270.65,86.1623,0.00110904,329.799,1.72341E-05 +49100,270.65,85.0815,0.00109513,329.799,1.72341E-05 +49200,270.65,84.0143,0.00108139,329.799,1.72341E-05 +49300,270.65,82.9605,0.00106783,329.799,1.72341E-05 +49400,270.65,81.9199,0.00105443,329.799,1.72341E-05 +49500,270.65,80.8924,0.00104121,329.799,1.72341E-05 +49600,270.65,79.8777,0.00102815,329.799,1.72341E-05 +49700,270.65,78.8758,0.00101525,329.799,1.72341E-05 +49800,270.65,77.8864,0.00100252,329.799,1.72341E-05 +49900,270.65,76.9095,0.000989942,329.799,1.72341E-05 +50000,270.65,75.9448,0.000977525,329.799,1.72341E-05 +50100,270.65,74.9922,0.000965264,329.799,1.72341E-05 +50200,270.65,74.0515,0.000953156,329.799,1.72341E-05 +50300,270.65,73.1227,0.0009412,329.799,1.72341E-05 +50400,270.65,72.2055,0.000929395,329.799,1.72341E-05 +50500,270.65,71.2998,0.000917737,329.799,1.72341E-05 +50600,270.65,70.4054,0.000906225,329.799,1.72341E-05 +50700,270.65,69.5223,0.000894858,329.799,1.72341E-05 +50800,270.65,68.6503,0.000883634,329.799,1.72341E-05 +50900,270.65,67.7892,0.00087255,329.799,1.72341E-05 +51000,270.65,66.9389,0.000861606,329.799,1.72341E-05 +51100,270.37,66.0988,0.000851674,329.628,1.72197E-05 +51200,270.09,65.2684,0.000841846,329.457,1.72053E-05 +51300,269.81,64.4476,0.000832122,329.287,1.71909E-05 +51400,269.53,63.6363,0.0008225,329.116,1.71764E-05 +51500,269.25,62.8344,0.00081298,328.945,1.7162E-05 +51600,268.97,62.0418,0.00080356,328.774,1.71476E-05 +51700,268.69,61.2583,0.00079424,328.602,1.71332E-05 +51800,268.41,60.484,0.000785018,328.431,1.71187E-05 +51900,268.13,59.7186,0.000775894,328.26,1.71043E-05 +52000,267.85,58.9622,0.000766867,328.088,1.70898E-05 +52100,267.57,58.2145,0.000757935,327.917,1.70754E-05 +52200,267.29,57.4756,0.000749098,327.745,1.70609E-05 +52300,267.01,56.7453,0.000740355,327.574,1.70464E-05 +52400,266.73,56.0235,0.000731705,327.402,1.70319E-05 +52500,266.45,55.3101,0.000723147,327.23,1.70174E-05 +52600,266.17,54.6051,0.000714681,327.058,1.70029E-05 +52700,265.89,53.9084,0.000706305,326.886,1.69884E-05 +52800,265.61,53.2198,0.000698018,326.714,1.69739E-05 +52900,265.33,52.5393,0.00068982,326.541,1.69594E-05 +53000,265.05,51.8668,0.00068171,326.369,1.69449E-05 +53100,264.77,51.2022,0.000673687,326.197,1.69303E-05 +53200,264.49,50.5454,0.000665749,326.024,1.69158E-05 +53300,264.21,49.8964,0.000657897,325.851,1.69013E-05 +53400,263.93,49.2551,0.00065013,325.679,1.68867E-05 +53500,263.65,48.6213,0.000642446,325.506,1.68721E-05 +53600,263.37,47.995,0.000634845,325.333,1.68576E-05 +53700,263.09,47.3761,0.000627326,325.16,1.6843E-05 +53800,262.81,46.7646,0.000619888,324.987,1.68284E-05 +53900,262.53,46.1603,0.00061253,324.814,1.68138E-05 +54000,262.25,45.5632,0.000605252,324.641,1.67992E-05 +54100,261.97,44.9731,0.000598053,324.467,1.67846E-05 +54200,261.69,44.3902,0.000590932,324.294,1.677E-05 +54300,261.41,43.8141,0.000583888,324.12,1.67554E-05 +54400,261.13,43.2449,0.000576921,323.947,1.67408E-05 +54500,260.85,42.6826,0.00057003,323.773,1.67261E-05 +54600,260.57,42.1269,0.000563214,323.599,1.67115E-05 +54700,260.29,41.5779,0.000556472,323.425,1.66969E-05 +54800,260.01,41.0354,0.000549803,323.251,1.66822E-05 +54900,259.73,40.4995,0.000543208,323.077,1.66676E-05 +55000,259.45,39.97,0.000536684,322.903,1.66529E-05 +55100,259.17,39.4469,0.000530232,322.729,1.66382E-05 +55200,258.89,38.93,0.000523851,322.554,1.66235E-05 +55300,258.61,38.4194,0.000517539,322.38,1.66088E-05 +55400,258.33,37.9149,0.000511298,322.205,1.65942E-05 +55500,258.05,37.4166,0.000505124,322.03,1.65795E-05 +55600,257.77,36.9242,0.000499019,321.856,1.65647E-05 +55700,257.49,36.4378,0.000492981,321.681,1.655E-05 +55800,257.21,35.9573,0.000487009,321.506,1.65353E-05 +55900,256.93,35.4826,0.000481104,321.331,1.65206E-05 +56000,256.65,35.0137,0.000475263,321.156,1.65058E-05 +56100,256.37,34.5504,0.000469488,320.981,1.64911E-05 +56200,256.09,34.0928,0.000463776,320.805,1.64763E-05 +56300,255.81,33.6408,0.000458128,320.63,1.64616E-05 +56400,255.53,33.1943,0.000452542,320.454,1.64468E-05 +56500,255.25,32.7532,0.000447019,320.279,1.6432E-05 +56600,254.97,32.3175,0.000441557,320.103,1.64173E-05 +56700,254.69,31.8871,0.000436156,319.927,1.64025E-05 +56800,254.41,31.462,0.000430815,319.751,1.63877E-05 +56900,254.13,31.0421,0.000425534,319.575,1.63729E-05 +57000,253.85,30.6274,0.000420311,319.399,1.63581E-05 +57100,253.57,30.2178,0.000415147,319.223,1.63433E-05 +57200,253.29,29.8131,0.000410041,319.047,1.63284E-05 +57300,253.01,29.4135,0.000404993,318.87,1.63136E-05 +57400,252.73,29.0188,0.000400001,318.694,1.62988E-05 +57500,252.45,28.629,0.000395065,318.517,1.62839E-05 +57600,252.17,28.2439,0.000390184,318.34,1.62691E-05 +57700,251.89,27.8637,0.000385359,318.164,1.62542E-05 +57800,251.61,27.4881,0.000380588,317.987,1.62393E-05 +57900,251.33,27.1172,0.000375871,317.81,1.62245E-05 +58000,251.05,26.7509,0.000371207,317.633,1.62096E-05 +58100,250.77,26.3891,0.000366596,317.455,1.61947E-05 +58200,250.49,26.0318,0.000362037,317.278,1.61798E-05 +58300,250.21,25.679,0.000357529,317.101,1.61649E-05 +58400,249.93,25.3306,0.000353073,316.923,1.615E-05 +58500,249.65,24.9865,0.000348668,316.746,1.6135E-05 +58600,249.37,24.6467,0.000344313,316.568,1.61201E-05 +58700,249.09,24.3112,0.000340007,316.39,1.61052E-05 +58800,248.81,23.9798,0.00033575,316.212,1.60902E-05 +58900,248.53,23.6526,0.000331542,316.034,1.60753E-05 +59000,248.25,23.3296,0.000327382,315.856,1.60603E-05 +59100,247.97,23.0105,0.00032327,315.678,1.60454E-05 +59200,247.69,22.6955,0.000319205,315.5,1.60304E-05 +59300,247.41,22.3844,0.000315186,315.322,1.60154E-05 +59400,247.13,22.0773,0.000311214,315.143,1.60004E-05 +59500,246.85,21.774,0.000307287,314.965,1.59854E-05 +59600,246.57,21.4746,0.000303405,314.786,1.59704E-05 +59700,246.29,21.1789,0.000299568,314.607,1.59554E-05 +59800,246.01,20.887,0.000295775,314.428,1.59404E-05 +59900,245.73,20.5988,0.000292027,314.249,1.59254E-05 +60000,245.45,20.3143,0.000288321,314.07,1.59104E-05 +60100,245.17,20.0333,0.000284658,313.891,1.58953E-05 +60200,244.89,19.7559,0.000281038,313.712,1.58803E-05 +60300,244.61,19.4821,0.000277459,313.532,1.58652E-05 +60400,244.33,19.2117,0.000273923,313.353,1.58502E-05 +60500,244.05,18.9448,0.000270427,313.173,1.58351E-05 +60600,243.77,18.6813,0.000266972,312.993,1.582E-05 +60700,243.49,18.4212,0.000263557,312.814,1.58049E-05 +60800,243.21,18.1644,0.000260182,312.634,1.57898E-05 +60900,242.93,17.9109,0.000256847,312.454,1.57748E-05 +61000,242.65,17.6606,0.00025355,312.274,1.57596E-05 +61100,242.37,17.4136,0.000250292,312.093,1.57445E-05 +61200,242.09,17.1697,0.000247072,311.913,1.57294E-05 +61300,241.81,16.929,0.00024389,311.733,1.57143E-05 +61400,241.53,16.6913,0.000240746,311.552,1.56991E-05 +61500,241.25,16.4568,0.000237638,311.371,1.5684E-05 +61600,240.97,16.2252,0.000234567,311.191,1.56688E-05 +61700,240.69,15.9967,0.000231532,311.01,1.56537E-05 +61800,240.41,15.7711,0.000228533,310.829,1.56385E-05 +61900,240.13,15.5485,0.000225569,310.648,1.56233E-05 +62000,239.85,15.3287,0.00022264,310.467,1.56082E-05 +62100,239.57,15.1118,0.000219746,310.285,1.5593E-05 +62200,239.29,14.8977,0.000216886,310.104,1.55778E-05 +62300,239.01,14.6864,0.000214061,309.922,1.55626E-05 +62400,238.73,14.4778,0.000211268,309.741,1.55474E-05 +62500,238.45,14.272,0.000208509,309.559,1.55321E-05 +62600,238.17,14.0689,0.000205783,309.377,1.55169E-05 +62700,237.89,13.8684,0.00020309,309.195,1.55017E-05 +62800,237.61,13.6705,0.000200428,309.013,1.54864E-05 +62900,237.33,13.4753,0.000197798,308.831,1.54712E-05 +63000,237.05,13.2826,0.0001952,308.649,1.54559E-05 +63100,236.77,13.0924,0.000192633,308.467,1.54406E-05 +63200,236.49,12.9047,0.000190097,308.284,1.54254E-05 +63300,236.21,12.7196,0.000187591,308.102,1.54101E-05 +63400,235.93,12.5368,0.000185115,307.919,1.53948E-05 +63500,235.65,12.3565,0.000182669,307.736,1.53795E-05 +63600,235.37,12.1785,0.000180253,307.553,1.53642E-05 +63700,235.09,12.0029,0.000177865,307.37,1.53489E-05 +63800,234.81,11.8297,0.000175507,307.187,1.53335E-05 +63900,234.53,11.6587,0.000173177,307.004,1.53182E-05 +64000,234.25,11.49,0.000170875,306.821,1.53029E-05 +64100,233.97,11.3235,0.000168601,306.637,1.52875E-05 +64200,233.69,11.1593,0.000166355,306.454,1.52722E-05 +64300,233.41,10.9973,0.000164136,306.27,1.52568E-05 +64400,233.13,10.8374,0.000161944,306.086,1.52414E-05 +64500,232.85,10.6796,0.000159778,305.903,1.52261E-05 +64600,232.57,10.524,0.000157639,305.719,1.52107E-05 +64700,232.29,10.3704,0.000155527,305.535,1.51953E-05 +64800,232.01,10.2189,0.00015344,305.35,1.51799E-05 +64900,231.73,10.0695,0.000151378,305.166,1.51645E-05 +65000,231.45,9.92203,0.000149342,304.982,1.51491E-05 +65100,231.17,9.77656,0.000147331,304.797,1.51336E-05 +65200,230.89,9.63306,0.000145344,304.612,1.51182E-05 +65300,230.61,9.49149,0.000143382,304.428,1.51028E-05 +65400,230.33,9.35183,0.000141444,304.243,1.50873E-05 +65500,230.05,9.21406,0.00013953,304.058,1.50719E-05 +65600,229.77,9.07816,0.000137639,303.873,1.50564E-05 +65700,229.49,8.9441,0.000135772,303.688,1.50409E-05 +65800,229.21,8.81186,0.000133928,303.502,1.50254E-05 +65900,228.93,8.68141,0.000132107,303.317,1.501E-05 +66000,228.65,8.55275,0.000130308,303.131,1.49945E-05 +66100,228.37,8.42583,0.000128532,302.946,1.4979E-05 +66200,228.09,8.30064,0.000126778,302.76,1.49634E-05 +66300,227.81,8.17717,0.000125046,302.574,1.49479E-05 +66400,227.53,8.05538,0.000123335,302.388,1.49324E-05 +66500,227.25,7.93526,0.000121645,302.202,1.49169E-05 +66600,226.97,7.81679,0.000119977,302.016,1.49013E-05 +66700,226.69,7.69994,0.00011833,301.829,1.48858E-05 +66800,226.41,7.5847,0.000116703,301.643,1.48702E-05 +66900,226.13,7.47104,0.000115096,301.456,1.48546E-05 +67000,225.85,7.35895,0.00011351,301.269,1.4839E-05 +67100,225.57,7.24841,0.000111944,301.083,1.48235E-05 +67200,225.29,7.13939,0.000110397,300.896,1.48079E-05 +67300,225.01,7.03187,0.00010887,300.709,1.47923E-05 +67400,224.73,6.92585,0.000107362,300.522,1.47767E-05 +67500,224.45,6.8213,0.000105873,300.334,1.4761E-05 +67600,224.17,6.71819,0.000104403,300.147,1.47454E-05 +67700,223.89,6.61652,0.000102952,299.959,1.47298E-05 +67800,223.61,6.51626,0.000101519,299.772,1.47141E-05 +67900,223.33,6.4174,0.000100104,299.584,1.46985E-05 +68000,223.05,6.31992,9.87069E-05,299.396,1.46828E-05 +68100,222.77,6.2238,9.73279E-05,299.208,1.46672E-05 +68200,222.49,6.12902,9.59663E-05,299.02,1.46515E-05 +68300,222.21,6.03557,9.46222E-05,298.832,1.46358E-05 +68400,221.93,5.94343,9.32952E-05,298.644,1.46201E-05 +68500,221.65,5.85259,9.19852E-05,298.455,1.46044E-05 +68600,221.37,5.76302,9.0692E-05,298.266,1.45887E-05 +68700,221.09,5.6747,8.94154E-05,298.078,1.4573E-05 +68800,220.81,5.58764,8.81551E-05,297.889,1.45573E-05 +68900,220.53,5.5018,8.69111E-05,297.7,1.45415E-05 +69000,220.25,5.41717,8.5683E-05,297.511,1.45258E-05 +69100,219.97,5.33374,8.44708E-05,297.322,1.451E-05 +69200,219.69,5.25149,8.32742E-05,297.133,1.44943E-05 +69300,219.41,5.17041,8.2093E-05,296.943,1.44785E-05 +69400,219.13,5.09047,8.09272E-05,296.754,1.44627E-05 +69500,218.85,5.01168,7.97764E-05,296.564,1.44469E-05 +69600,218.57,4.934,7.86406E-05,296.374,1.44312E-05 +69700,218.29,4.85743,7.75195E-05,296.184,1.44154E-05 +69800,218.01,4.78196,7.6413E-05,295.994,1.43995E-05 +69900,217.73,4.70756,7.53209E-05,295.804,1.43837E-05 +70000,217.45,4.63422,7.4243E-05,295.614,1.43679E-05 +70100,217.17,4.56194,7.31792E-05,295.423,1.43521E-05 +70200,216.89,4.49069,7.21293E-05,295.233,1.43362E-05 +70300,216.61,4.42046,7.10931E-05,295.042,1.43204E-05 +70400,216.33,4.35125,7.00705E-05,294.852,1.43045E-05 +70500,216.05,4.28303,6.90613E-05,294.661,1.42886E-05 +70600,215.77,4.21579,6.80654E-05,294.47,1.42728E-05 +70700,215.49,4.14952,6.70825E-05,294.279,1.42569E-05 +70800,215.21,4.08422,6.61126E-05,294.087,1.4241E-05 +70900,214.93,4.01985,6.51555E-05,293.896,1.42251E-05 +71000,214.65,3.95642,6.4211E-05,293.704,1.42092E-05 +71100,214.45,3.89392,6.32556E-05,293.568,1.41978E-05 +71200,214.25,3.83235,6.23136E-05,293.431,1.41864E-05 +71300,214.05,3.7717,6.13847E-05,293.294,1.41751E-05 +71400,213.85,3.71195,6.04688E-05,293.157,1.41637E-05 +71500,213.65,3.6531,5.95657E-05,293.019,1.41523E-05 +71600,213.45,3.59512,5.86753E-05,292.882,1.41409E-05 +71700,213.25,3.53801,5.77974E-05,292.745,1.41295E-05 +71800,213.05,3.48176,5.69318E-05,292.608,1.41181E-05 +71900,212.85,3.42634,5.60784E-05,292.47,1.41067E-05 +72000,212.65,3.37176,5.5237E-05,292.333,1.40953E-05 +72100,212.45,3.318,5.44074E-05,292.195,1.40839E-05 +72200,212.25,3.26505,5.35895E-05,292.058,1.40725E-05 +72300,212.05,3.21289,5.27832E-05,291.92,1.4061E-05 +72400,211.85,3.16152,5.19883E-05,291.783,1.40496E-05 +72500,211.65,3.11092,5.12046E-05,291.645,1.40382E-05 +72600,211.45,3.06109,5.0432E-05,291.507,1.40268E-05 +72700,211.25,3.012,4.96703E-05,291.369,1.40153E-05 +72800,211.05,2.96366,4.89195E-05,291.231,1.40039E-05 +72900,210.85,2.91605,4.81793E-05,291.093,1.39924E-05 +73000,210.65,2.86917,4.74496E-05,290.955,1.3981E-05 +73100,210.45,2.82299,4.67302E-05,290.817,1.39695E-05 +73200,210.25,2.77751,4.60212E-05,290.679,1.39581E-05 +73300,210.05,2.73272,4.53222E-05,290.54,1.39466E-05 +73400,209.85,2.68861,4.46331E-05,290.402,1.39351E-05 +73500,209.65,2.64518,4.3954E-05,290.264,1.39236E-05 +73600,209.45,2.6024,4.32845E-05,290.125,1.39122E-05 +73700,209.25,2.56028,4.26246E-05,289.987,1.39007E-05 +73800,209.05,2.5188,4.19741E-05,289.848,1.38892E-05 +73900,208.85,2.47795,4.13329E-05,289.709,1.38777E-05 +74000,208.65,2.43773,4.0701E-05,289.57,1.38662E-05 +74100,208.45,2.39812,4.00781E-05,289.432,1.38547E-05 +74200,208.25,2.35912,3.94642E-05,289.293,1.38432E-05 +74300,208.05,2.32071,3.8859E-05,289.154,1.38317E-05 +74400,207.85,2.2829,3.82626E-05,289.015,1.38202E-05 +74500,207.65,2.24567,3.76748E-05,288.876,1.38087E-05 +74600,207.45,2.209,3.70955E-05,288.737,1.37971E-05 +74700,207.25,2.17291,3.65245E-05,288.597,1.37856E-05 +74800,207.05,2.13737,3.59618E-05,288.458,1.37741E-05 +74900,206.85,2.10237,3.54072E-05,288.319,1.37625E-05 +75000,206.65,2.06792,3.48607E-05,288.179,1.3751E-05 +75100,206.45,2.034,3.43221E-05,288.04,1.37394E-05 +75200,206.25,2.0006,3.37912E-05,287.9,1.37279E-05 +75300,206.05,1.96772,3.32681E-05,287.761,1.37163E-05 +75400,205.85,1.93535,3.27526E-05,287.621,1.37048E-05 +75500,205.65,1.90348,3.22446E-05,287.481,1.36932E-05 +75600,205.45,1.8721,3.1744E-05,287.341,1.36817E-05 +75700,205.25,1.84121,3.12507E-05,287.201,1.36701E-05 +75800,205.05,1.81081,3.07645E-05,287.061,1.36585E-05 +75900,204.85,1.78087,3.02855E-05,286.921,1.36469E-05 +76000,204.65,1.7514,2.98135E-05,286.781,1.36353E-05 +76100,204.45,1.7224,2.93484E-05,286.641,1.36237E-05 +76200,204.25,1.69384,2.88901E-05,286.501,1.36122E-05 +76300,204.05,1.66573,2.84385E-05,286.361,1.36006E-05 +76400,203.85,1.63806,2.79935E-05,286.22,1.35889E-05 +76500,203.65,1.61082,2.75551E-05,286.08,1.35773E-05 +76600,203.45,1.58401,2.71231E-05,285.939,1.35657E-05 +76700,203.25,1.55762,2.66975E-05,285.799,1.35541E-05 +76800,203.05,1.53165,2.62781E-05,285.658,1.35425E-05 +76900,202.85,1.50608,2.5865E-05,285.517,1.35309E-05 +77000,202.65,1.48092,2.54579E-05,285.377,1.35192E-05 +77100,202.45,1.45615,2.50568E-05,285.236,1.35076E-05 +77200,202.25,1.43177,2.46617E-05,285.095,1.3496E-05 +77300,202.05,1.40778,2.42724E-05,284.954,1.34843E-05 +77400,201.85,1.38416,2.38889E-05,284.813,1.34727E-05 +77500,201.65,1.36092,2.35111E-05,284.672,1.3461E-05 +77600,201.45,1.33805,2.31389E-05,284.53,1.34493E-05 +77700,201.25,1.31554,2.27722E-05,284.389,1.34377E-05 +77800,201.05,1.29338,2.2411E-05,284.248,1.3426E-05 +77900,200.85,1.27158,2.20551E-05,284.106,1.34143E-05 +78000,200.65,1.25012,2.17046E-05,283.965,1.34027E-05 +78100,200.45,1.22901,2.13593E-05,283.823,1.3391E-05 +78200,200.25,1.20823,2.10191E-05,283.682,1.33793E-05 +78300,200.05,1.18778,2.06841E-05,283.54,1.33676E-05 +78400,199.85,1.16766,2.0354E-05,283.398,1.33559E-05 +78500,199.65,1.14786,2.00289E-05,283.256,1.33442E-05 +78600,199.45,1.12837,1.97087E-05,283.114,1.33325E-05 +78700,199.25,1.1092,1.93932E-05,282.972,1.33208E-05 +78800,199.05,1.09034,1.90826E-05,282.83,1.33091E-05 +78900,198.85,1.07177,1.87765E-05,282.688,1.32974E-05 +79000,198.65,1.05351,1.84751E-05,282.546,1.32856E-05 +79100,198.45,1.03554,1.81783E-05,282.404,1.32739E-05 +79200,198.25,1.01785,1.78859E-05,282.262,1.32622E-05 +79300,198.05,1.00045,1.75979E-05,282.119,1.32504E-05 +79400,197.85,0.983336,1.73143E-05,281.977,1.32387E-05 +79500,197.65,0.966494,1.70349E-05,281.834,1.3227E-05 +79600,197.45,0.949924,1.67598E-05,281.691,1.32152E-05 +79700,197.25,0.933621,1.64889E-05,281.549,1.32035E-05 +79800,197.05,0.917582,1.62221E-05,281.406,1.31917E-05 +79900,196.85,0.901803,1.59593E-05,281.263,1.31799E-05 +80000,196.65,0.88628,1.57005E-05,281.12,1.31682E-05 +80100,196.45,0.871008,1.54457E-05,280.977,1.31564E-05 +80200,196.25,0.855984,1.51948E-05,280.834,1.31446E-05 +80300,196.05,0.841205,1.49476E-05,280.691,1.31328E-05 +80400,195.85,0.826666,1.47043E-05,280.548,1.3121E-05 +80500,195.65,0.812363,1.44647E-05,280.405,1.31092E-05 +80600,195.45,0.798294,1.42287E-05,280.261,1.30974E-05 +80700,195.25,0.784455,1.39964E-05,280.118,1.30856E-05 +80800,195.05,0.770842,1.37676E-05,279.974,1.30738E-05 +80900,194.85,0.757451,1.35423E-05,279.831,1.3062E-05 +81000,194.65,0.74428,1.33205E-05,279.687,1.30502E-05 +81100,194.45,0.731324,1.31021E-05,279.543,1.30384E-05 +81200,194.25,0.718581,1.2887E-05,279.399,1.30266E-05 +81300,194.05,0.706047,1.26753E-05,279.256,1.30147E-05 +81400,193.85,0.69372,1.24668E-05,279.112,1.30029E-05 +81500,193.65,0.681595,1.22616E-05,278.968,1.29911E-05 +81600,193.45,0.66967,1.20595E-05,278.824,1.29792E-05 +81700,193.25,0.657941,1.18606E-05,278.679,1.29674E-05 +81800,193.05,0.646406,1.16647E-05,278.535,1.29555E-05 +81900,192.85,0.635062,1.14719E-05,278.391,1.29437E-05 +82000,192.65,0.623905,1.1282E-05,278.246,1.29318E-05 +82100,192.45,0.612933,1.10952E-05,278.102,1.29199E-05 +82200,192.25,0.602143,1.09112E-05,277.957,1.29081E-05 +82300,192.05,0.591532,1.07301E-05,277.813,1.28962E-05 +82400,191.85,0.581097,1.05518E-05,277.668,1.28843E-05 +82500,191.65,0.570835,1.03762E-05,277.523,1.28724E-05 +82600,191.45,0.560745,1.02035E-05,277.378,1.28605E-05 +82700,191.25,0.550822,1.00334E-05,277.234,1.28486E-05 +82800,191.05,0.541065,9.86599E-06,277.089,1.28367E-05 +82900,190.85,0.531471,9.7012E-06,276.943,1.28248E-05 +83000,190.65,0.522037,9.53899E-06,276.798,1.28129E-05 +83100,190.45,0.512761,9.37933E-06,276.653,1.2801E-05 +83200,190.25,0.50364,9.22218E-06,276.508,1.27891E-05 +83300,190.05,0.494672,9.06751E-06,276.362,1.27771E-05 +83400,189.85,0.485855,8.91526E-06,276.217,1.27652E-05 +83500,189.65,0.477186,8.76542E-06,276.071,1.27533E-05 +83600,189.45,0.468662,8.61794E-06,275.926,1.27413E-05 +83700,189.25,0.460282,8.47279E-06,275.78,1.27294E-05 +83800,189.05,0.452044,8.32994E-06,275.634,1.27174E-05 +83900,188.85,0.443944,8.18935E-06,275.489,1.27055E-05 +84000,188.65,0.435981,8.05098E-06,275.343,1.26935E-05 +84100,188.45,0.428153,7.91481E-06,275.197,1.26816E-05 +84200,188.25,0.420457,7.7808E-06,275.051,1.26696E-05 +84300,188.05,0.412891,7.64892E-06,274.904,1.26576E-05 +84400,187.85,0.405454,7.51914E-06,274.758,1.26457E-05 +84500,187.65,0.398143,7.39143E-06,274.612,1.26337E-05 +84600,187.45,0.390956,7.26576E-06,274.466,1.26217E-05 +84700,187.25,0.383892,7.14209E-06,274.319,1.26097E-05 +84800,187.05,0.376948,7.02039E-06,274.173,1.25977E-05 +84900,186.946,0.370123,6.89712E-06,274.096,1.25915E-05 +85000,186.946,0.36342,6.77222E-06,274.096,1.25915E-05 +85100,186.946,0.356839,6.64959E-06,274.096,1.25915E-05 +85200,186.946,0.350378,6.52917E-06,274.096,1.25915E-05 +85300,186.946,0.344033,6.41094E-06,274.096,1.25915E-05 +85400,186.946,0.337803,6.29485E-06,274.096,1.25915E-05 +85500,186.946,0.331686,6.18086E-06,274.096,1.25915E-05 +85600,186.946,0.32568,6.06893E-06,274.096,1.25915E-05 +85700,186.946,0.319782,5.95904E-06,274.096,1.25915E-05 +85800,186.946,0.313991,5.85113E-06,274.096,1.25915E-05 +85900,186.946,0.308305,5.74517E-06,274.096,1.25915E-05 +86000,186.946,0.302723,5.64114E-06,274.096,1.25915E-05 diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index 2cedc13a3e..ca2037a2eb 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -4,14 +4,15 @@ Read variable information from CMOR 2 and CMOR 3 tables and make it easily available for the other components of ESMValTool """ -from functools import total_ordering import copy import errno import glob import json import logging import os +from functools import total_ordering from pathlib import Path + import yaml logger = logging.getLogger(__name__) @@ -20,6 +21,21 @@ """dict of str, obj: CMOR info objects.""" +def get_var_info(project, mip, short_name): + """Get variable information. + + Parameters + ---------- + project : str + Dataset's project. + mip : str + Variable's cmor table. + short_name : str + Variable's short name. + """ + return CMOR_TABLES[project].get_variable(mip, short_name) + + def read_cmor_tables(cfg_developer=None): """Read cmor tables required in the configuration. diff --git a/tests/integration/cmor/_fixes/cmip5/test_access1_0.py b/tests/integration/cmor/_fixes/cmip5/test_access1_0.py index 3669a2b380..c0cf54d7ee 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_access1_0.py +++ b/tests/integration/cmor/_fixes/cmip5/test_access1_0.py @@ -1,16 +1,19 @@ """Test Access1-0 fixes.""" import unittest +import pytest from cf_units import Unit -from iris.cube import Cube from iris.coords import AuxCoord +from iris.cube import Cube, CubeList +from esmvalcore.cmor._fixes.cmip5.access1_0 import AllVars, Cl from esmvalcore.cmor._fixes.fix import Fix -from esmvalcore.cmor._fixes.cmip5.access1_0 import AllVars +from esmvalcore.cmor.table import get_var_info class TestAllVars(unittest.TestCase): """Test all vars fixes.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='co2', units='J') @@ -20,6 +23,7 @@ def setUp(self): self.fix = AllVars(None) def test_get(self): + """Test getting of fix.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'ACCESS1-0', 'Amon', 'tas'), [AllVars(None)]) @@ -33,3 +37,50 @@ def test_fix_metadata_if_not_time(self): """Test calendar fix do not fail if no time coord present.""" self.cube.remove_coord('time') self.fix.fix_metadata([self.cube]) + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP5', 'ACCESS1-0', 'Amon', 'cl') + assert fix == [Cl(None), AllVars(None)] + + +@pytest.fixture +def cl_cubes(): + """Cubes for ``cl.``.""" + b_coord = AuxCoord( + [1.0], + var_name='b', + long_name='vertical coordinate formula term: b(k)', + attributes={'a': 1, 'b': '2'}, + ) + cl_cube = Cube( + [0.0], + var_name='cl', + standard_name='cloud_area_fraction_in_atmosphere_layer', + aux_coords_and_dims=[(b_coord.copy(), 0)], + ) + x_cube = Cube([0.0], + long_name='x', + aux_coords_and_dims=[(b_coord.copy(), 0)]) + cubes = CubeList([cl_cube, x_cube]) + return cubes + + +@unittest.mock.patch( + 'esmvalcore.cmor._fixes.cmip5.access1_0.ClFixHybridHeightCoord.' + 'fix_metadata', autospec=True) +def test_cl_fix_metadata(mock_base_fix_metadata, cl_cubes): + """Test ``fix_metadata`` for ``cl``.""" + mock_base_fix_metadata.return_value = cl_cubes + fix = Cl(get_var_info('CMIP5', 'Amon', 'cl')) + fixed_cubes = fix.fix_metadata(cl_cubes) + mock_base_fix_metadata.assert_called_once_with(fix, cl_cubes) + assert len(fixed_cubes) == 2 + cl_cube = fixed_cubes.extract_strict( + 'cloud_area_fraction_in_atmosphere_layer') + b_coord_cl = cl_cube.coord('vertical coordinate formula term: b(k)') + assert not b_coord_cl.attributes + x_cube = fixed_cubes.extract_strict('x') + b_coord_x = x_cube.coord('vertical coordinate formula term: b(k)') + assert b_coord_x.attributes == {'a': 1, 'b': '2'} diff --git a/tests/integration/cmor/_fixes/cmip5/test_access1_3.py b/tests/integration/cmor/_fixes/cmip5/test_access1_3.py index a09b79f266..6635382c06 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_access1_3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_access1_3.py @@ -2,15 +2,17 @@ import unittest from cf_units import Unit -from iris.cube import Cube from iris.coords import AuxCoord +from iris.cube import Cube +from esmvalcore.cmor._fixes.cmip5.access1_0 import Cl as BaseCl +from esmvalcore.cmor._fixes.cmip5.access1_3 import AllVars, Cl from esmvalcore.cmor._fixes.fix import Fix -from esmvalcore.cmor._fixes.cmip5.access1_3 import AllVars class TestAllVars(unittest.TestCase): """Test fixes for all vars.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='co2', units='J') @@ -20,6 +22,7 @@ def setUp(self): self.fix = AllVars(None) def test_get(self): + """Test getting of fix.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'ACCESS1-3', 'Amon', 'tas'), [AllVars(None)]) @@ -33,3 +36,14 @@ def test_fix_metadata_if_not_time(self): """Test calendar fix do not fail if no time coord present.""" self.cube.remove_coord('time') self.fix.fix_metadata([self.cube]) + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP5', 'ACCESS1-3', 'Amon', 'cl') + assert fix == [Cl(None), AllVars(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is BaseCl diff --git a/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1.py b/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1.py index 93e9912918..a55007923e 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1.py @@ -17,7 +17,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestTos(unittest.TestCase): diff --git a/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1_m.py b/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1_m.py index e25d62709f..ce8af0eeb5 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1_m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bcc_csm1_1_m.py @@ -1,6 +1,7 @@ """Test fixes for bcc-csm1-1-m.""" import unittest +from esmvalcore.cmor._fixes.cmip5.bcc_csm1_1 import Tos as BaseTos from esmvalcore.cmor._fixes.cmip5.bcc_csm1_1_m import Cl, Tos from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor._fixes.fix import Fix @@ -14,7 +15,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestTos(unittest.TestCase): @@ -26,11 +27,6 @@ def test_get(self): Fix.get_fixes('CMIP5', 'bcc-csm1-1-m', 'Amon', 'tos'), [Tos(None)]) -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip5.bcc_csm1_1_m.BaseTos.fix_data', - autospec=True) -def test_tos_fix_data(mock_base_fix_data): - """Test ``fix_data`` for ``tos``.""" - fix = Tos(None) - fix.fix_data('cubes') - mock_base_fix_data.assert_called_once_with(fix, 'cubes') +def test_tos_fix(): + """Test fix for ``tos``.""" + assert Tos is BaseTos diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index 6fd29d47a2..76eca15a25 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -5,22 +5,37 @@ from cf_units import Unit from iris.cube import Cube +from esmvalcore.cmor._fixes.cmip5.bnu_esm import (Ch4, Cl, Co2, FgCo2, + Od550Aer, SpCo2) +from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor.fix import Fix -from esmvalcore.cmor._fixes.cmip5.bnu_esm import (Ch4, Co2, FgCo2, SpCo2, - Od550Aer) +from esmvalcore.cmor.table import get_var_info + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP5', 'bcc-csm1-1', 'Amon', 'cl') + assert fix == [Cl(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridPressureCoord class TestCo2(unittest.TestCase): """Test fixes for CO2.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='co2', units='J') - self.fix = Co2(None) + self.vardef = get_var_info('CMIP5', 'Amon', self.cube.var_name) + self.fix = Co2(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'co2'), - [Co2(None)]) + [Co2(self.vardef)]) def test_fix_metadata(self): """Test unit change.""" @@ -37,15 +52,18 @@ def test_fix_data(self): class Testfgco2(unittest.TestCase): """Test fixes for FgCO2.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='fgco2', units='J') - self.fix = FgCo2(None) + self.vardef = get_var_info('CMIP5', 'Omon', self.cube.var_name) + self.fix = FgCo2(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'fgco2'), [FgCo2(None)]) + Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'fgco2'), + [FgCo2(self.vardef)]) def test_fix_metadata(self): """Test unit fix.""" @@ -62,15 +80,17 @@ def test_fix_data(self): class TestCh4(unittest.TestCase): """Test fixes for ch4.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='ch4', units='J') - self.fix = Ch4(None) + self.vardef = get_var_info('CMIP5', 'Amon', self.cube.var_name) + self.fix = Ch4(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'ch4'), - [Ch4(None)]) + [Ch4(self.vardef)]) def test_fix_metadata(self): """Test unit fix.""" @@ -87,13 +107,14 @@ def test_fix_data(self): class Testspco2(unittest.TestCase): """Test fixes for SpCO2.""" + def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='spco2', units='J') self.fix = SpCo2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'spco2'), [SpCo2(None)]) @@ -112,6 +133,7 @@ def test_fix_data(self): class TestOd550Aer(unittest.TestCase): """Test fixes for SpCO2.""" + def setUp(self): """Prepare tests.""" self.cube = Cube( @@ -121,7 +143,7 @@ def setUp(self): self.fix = Od550Aer(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'od550aer'), [Od550Aer(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_canesm2.py b/tests/integration/cmor/_fixes/cmip5/test_canesm2.py index e63ff987b8..27d29839ab 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_canesm2.py +++ b/tests/integration/cmor/_fixes/cmip5/test_canesm2.py @@ -17,7 +17,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestCanESM2Fgco2(unittest.TestCase): diff --git a/tests/integration/cmor/_fixes/cmip5/test_ccsm4.py b/tests/integration/cmor/_fixes/cmip5/test_ccsm4.py index d5f88b3444..3ba6b38a99 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ccsm4.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ccsm4.py @@ -8,6 +8,7 @@ from esmvalcore.cmor._fixes.cmip5.ccsm4 import Cl, Csoil, Rlut, Rlutcs, So from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info def test_get_cl_fix(): @@ -18,7 +19,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestCsoil(unittest.TestCase): @@ -109,12 +110,13 @@ class TestSo(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0, 2.0], var_name='so', units='1.0') - self.fix = So(None) + self.vardef = get_var_info('CMIP5', 'Omon', self.cube.var_name) + self.fix = So(self.vardef) def test_get(self): """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'CCSM4', 'Amon', 'so'), - [So(None)]) + [So(self.vardef)]) def test_fix_metadata(self): """Checks that units are changed to the correct value.""" diff --git a/tests/integration/cmor/_fixes/cmip5/test_csiro_mk3_6_0.py b/tests/integration/cmor/_fixes/cmip5/test_csiro_mk3_6_0.py index 7b89ba4ec9..a7d23d9d41 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_csiro_mk3_6_0.py +++ b/tests/integration/cmor/_fixes/cmip5/test_csiro_mk3_6_0.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_fgoals_g2.py b/tests/integration/cmor/_fixes/cmip5/test_fgoals_g2.py index 36b16919f4..36b969a4cb 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fgoals_g2.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fgoals_g2.py @@ -7,6 +7,7 @@ from esmvalcore.cmor._fixes.cmip5.fgoals_g2 import AllVars, Cl from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info class TestAll(unittest.TestCase): @@ -62,7 +63,8 @@ def test_get_cl_fix(): def test_cl_fix_metadata(mock_add_sigma_factory): """Test ``fix_metadata`` for ``cl``.""" cubes = CubeList([Cube(0.0, var_name='cl'), Cube(1.0, var_name='x')]) - fix = Cl(None) + vardef = get_var_info('CMIP6', 'Amon', 'cl') + fix = Cl(vardef) fixed_cubes = fix.fix_metadata(cubes) mock_add_sigma_factory.assert_called_once_with(cubes[0]) assert fixed_cubes == CubeList([cubes[0]]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index eabead476b..323a7451b2 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -2,13 +2,14 @@ import unittest from unittest import mock -from cf_units import Unit import iris +from cf_units import Unit from iris.cube import Cube +from esmvalcore.cmor._fixes.cmip5.gfdl_cm2p1 import (AllVars, Areacello, Sftof, + Sit) from esmvalcore.cmor.fix import Fix -from esmvalcore.cmor._fixes.cmip5.gfdl_cm2p1 import (Sftof, AllVars, - Areacello, Sit) +from esmvalcore.cmor.table import get_var_info class TestSftof(unittest.TestCase): @@ -21,7 +22,7 @@ def setUp(self): def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'sftof'), + Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'fx', 'sftof'), [Sftof(None), AllVars(None)]) def test_fix_data(self): @@ -37,13 +38,14 @@ class TestAreacello(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='areacello', units='m-2') - self.fix = Areacello(None) + self.vardef = get_var_info('CMIP5', 'fx', self.cube.var_name) + self.fix = Areacello(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'areacello'), - [Areacello(None), AllVars(None)]) + [Areacello(self.vardef), AllVars(self.vardef)]) def test_fix_metadata(self): """Test data fix.""" @@ -78,6 +80,7 @@ def setUp(self): ) self.var_info_mock = mock.Mock() self.var_info_mock.frequency = 'mon' + self.var_info_mock.short_name = 'sit' self.fix = Sit(self.var_info_mock) def test_get(self): diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index fdd2f4c4c2..c4aaae2729 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -4,8 +4,9 @@ from cf_units import Unit from iris.cube import Cube +from esmvalcore.cmor._fixes.cmip5.gfdl_cm3 import AllVars, Areacello, Sftof from esmvalcore.cmor.fix import Fix -from esmvalcore.cmor._fixes.cmip5.gfdl_cm3 import Sftof, AllVars, Areacello +from esmvalcore.cmor.table import get_var_info class TestSftof(unittest.TestCase): @@ -18,7 +19,7 @@ def setUp(self): def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'sftof'), + Fix.get_fixes('CMIP5', 'GFDL-CM3', 'fx', 'sftof'), [Sftof(None), AllVars(None)]) def test_fix_data(self): @@ -33,13 +34,14 @@ class TestAreacello(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='areacello', units='m-2') - self.fix = Areacello(None) + self.vardef = get_var_info('CMIP5', 'fx', self.cube.var_name) + self.fix = Areacello(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'areacello'), - [Areacello(None), AllVars(None)]) + [Areacello(self.vardef), AllVars(self.vardef)]) def test_fix_metadata(self): """Test data fix.""" diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index 8c24e35077..89a1a1e32b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -11,6 +11,7 @@ FgCo2, Usi, Vsi, _get_and_remove) from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info CUBE_1 = iris.cube.Cube([1.0], long_name='to_be_rm') CUBE_2 = iris.cube.Cube([1.0], long_name='not_to_be_rm') @@ -84,13 +85,14 @@ class TestUsi(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = iris.cube.Cube([1.0], var_name='usi', units='J') - self.fix = Usi(None) + self.vardef = get_var_info('CMIP5', 'day', self.cube.var_name) + self.fix = Usi(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'usi'), - [Usi(None), AllVars(None)]) + Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'usi'), + [Usi(self.vardef), AllVars(self.vardef)]) def test_fix_data(self): """Test metadata fix.""" @@ -103,13 +105,14 @@ class TestVsi(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = iris.cube.Cube([1.0], var_name='vsi', units='J') - self.fix = Vsi(None) + self.vardef = get_var_info('CMIP5', 'day', self.cube.var_name) + self.fix = Vsi(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'vsi'), - [Vsi(None), AllVars(None)]) + Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'vsi'), + [Vsi(self.vardef), AllVars(self.vardef)]) def test_fix_data(self): """Test metadata fix.""" @@ -122,13 +125,14 @@ class TestAreacello(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='areacello', units='m-2') - self.fix = Areacello(None) + self.vardef = get_var_info('CMIP5', 'fx', self.cube.var_name) + self.fix = Areacello(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'areacello'), - [Areacello(None), AllVars(None)]) + Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'fx', 'areacello'), + [Areacello(self.vardef), AllVars(self.vardef)]) def test_fix_metadata(self): """Test data fix.""" diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 900da08a97..1538098d25 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -4,9 +4,10 @@ from cf_units import Unit from iris.cube import Cube +from esmvalcore.cmor._fixes.cmip5.gfdl_esm2m import (AllVars, Areacello, Co2, + Sftof) from esmvalcore.cmor.fix import Fix -from esmvalcore.cmor._fixes.cmip5.gfdl_esm2m import Co2, Sftof, AllVars, \ - Areacello +from esmvalcore.cmor.table import get_var_info class TestSftof(unittest.TestCase): @@ -19,7 +20,7 @@ def setUp(self): def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'sftof'), + Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'sftof'), [Sftof(None), AllVars(None)]) def test_fix_data(self): @@ -54,13 +55,14 @@ class TestAreacello(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='areacello', units='m-2') - self.fix = Areacello(None) + self.vardef = get_var_info('CMIP5', 'fx', self.cube.var_name) + self.fix = Areacello(self.vardef) def test_get(self): """Test fix get""" self.assertListEqual( - Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'areacello'), - [Areacello(None), AllVars(None)]) + Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'areacello'), + [Areacello(self.vardef), AllVars(self.vardef)]) def test_fix_metadata(self): """Test data fix.""" diff --git a/tests/integration/cmor/_fixes/cmip5/test_giss_e2_h.py b/tests/integration/cmor/_fixes/cmip5/test_giss_e2_h.py index f667219a6b..5fd78f648c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_giss_e2_h.py +++ b/tests/integration/cmor/_fixes/cmip5/test_giss_e2_h.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_giss_e2_r.py b/tests/integration/cmor/_fixes/cmip5/test_giss_e2_r.py index f42f98da5c..e030bb4aaf 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_giss_e2_r.py +++ b/tests/integration/cmor/_fixes/cmip5/test_giss_e2_r.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_es.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_es.py index b6eea1cd25..99c7eb4aa9 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_es.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_es.py @@ -1,14 +1,16 @@ """Test HADGEM2-ES fixes.""" import unittest +from esmvalcore.cmor._fixes.cmip5.hadgem2_es import O2, AllVars, Cl +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord from esmvalcore.cmor.fix import Fix -from esmvalcore.cmor._fixes.cmip5.hadgem2_es import AllVars, O2 class TestAllVars(unittest.TestCase): """Test allvars fixes.""" + def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-ES', 'Amon', 'tas'), [AllVars(None)]) @@ -16,8 +18,20 @@ def test_get(self): class TestO2(unittest.TestCase): """Test o2 fixes.""" + def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-ES', 'Amon', 'o2'), [O2(None), AllVars(None)]) + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP5', 'HadGEM2-ES', 'Amon', 'cl') + assert fix == [Cl(None), AllVars(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_inmcm4.py b/tests/integration/cmor/_fixes/cmip5/test_inmcm4.py index a86c6decad..a5a5cf0235 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_inmcm4.py +++ b/tests/integration/cmor/_fixes/cmip5/test_inmcm4.py @@ -17,7 +17,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestGpp(unittest.TestCase): diff --git a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_lr.py b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_lr.py index c6e9f02b1a..443a4aafbb 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_lr.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_lr.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_mr.py b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_mr.py index 08ddaec198..ff3e0adc25 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_mr.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5a_mr.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5b_lr.py b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5b_lr.py index 746a83335c..e04fa4718a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5b_lr.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ipsl_cm5b_lr.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc5.py b/tests/integration/cmor/_fixes/cmip5/test_miroc5.py index 8cbf02fad8..9be2a5f269 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc5.py @@ -18,7 +18,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_hur_fix(): diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm.py index 9a034be48f..884a53be17 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm.py @@ -9,6 +9,7 @@ from esmvalcore.cmor._fixes.cmip5.miroc_esm import AllVars, Cl, Co2, Tro3 from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info def test_get_cl_fix(): @@ -19,7 +20,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestCo2(unittest.TestCase): @@ -28,13 +29,14 @@ class TestCo2(unittest.TestCase): def setUp(self): """Prepare tests.""" self.cube = Cube([1.0], var_name='co2', units='J') - self.fix = Co2(None) + self.vardef = get_var_info('CMIP5', 'Amon', self.cube.var_name) + self.fix = Co2(self.vardef) def test_get(self): """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM', 'Amon', 'co2'), - [Co2(None), AllVars(None)]) + [Co2(self.vardef), AllVars(self.vardef)]) def test_fix_metadata(self): """Test unit fix.""" diff --git a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_lr.py b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_lr.py index 93fb6c0e2d..effb781f9f 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_lr.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_lr.py @@ -17,7 +17,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestPctisccp2(unittest.TestCase): diff --git a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_mr.py b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_mr.py index 715cfcab42..1c074d41a6 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_mr.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_mr.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_p.py b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_p.py index b88f032a43..7e0aa87a5a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_p.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mpi_esm_p.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_cgcm3.py b/tests/integration/cmor/_fixes/cmip5/test_mri_cgcm3.py index 598ceee0db..2b0d85ab7a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_cgcm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_cgcm3.py @@ -14,7 +14,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord class TestMsftmyz(unittest.TestCase): diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_m.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_m.py index dc1c25b49c..79664ce6b9 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_m.py @@ -12,4 +12,4 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_access_cm2.py b/tests/integration/cmor/_fixes/cmip6/test_access_cm2.py new file mode 100644 index 0000000000..b0344dc143 --- /dev/null +++ b/tests/integration/cmor/_fixes/cmip6/test_access_cm2.py @@ -0,0 +1,37 @@ +"""Tests for the fixes of ACCESS-CM2.""" +from esmvalcore.cmor._fixes.cmip6.access_cm2 import Cl, Cli, Clw +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord +from esmvalcore.cmor.fix import Fix + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-CM2', 'Amon', 'cl') + assert fix == [Cl(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord + + +def test_get_cli_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-CM2', 'Amon', 'cli') + assert fix == [Cli(None)] + + +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is ClFixHybridHeightCoord + + +def test_get_clw_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-CM2', 'Amon', 'clw') + assert fix == [Clw(None)] + + +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_access_esm1_5.py b/tests/integration/cmor/_fixes/cmip6/test_access_esm1_5.py new file mode 100644 index 0000000000..1f3c5b6c19 --- /dev/null +++ b/tests/integration/cmor/_fixes/cmip6/test_access_esm1_5.py @@ -0,0 +1,37 @@ +"""Tests for the fixes of ACCESS-ESM1-5.""" +from esmvalcore.cmor._fixes.cmip6.access_esm1_5 import Cl, Cli, Clw +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord +from esmvalcore.cmor.fix import Fix + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-ESM1-5', 'Amon', 'cl') + assert fix == [Cl(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord + + +def test_get_cli_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-ESM1-5', 'Amon', 'cli') + assert fix == [Cli(None)] + + +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is ClFixHybridHeightCoord + + +def test_get_clw_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'ACCESS-ESM1-5', 'Amon', 'clw') + assert fix == [Clw(None)] + + +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_bcc_csm2_mr.py b/tests/integration/cmor/_fixes/cmip6/test_bcc_csm2_mr.py index 3ce07f65a9..d6081042ef 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_bcc_csm2_mr.py +++ b/tests/integration/cmor/_fixes/cmip6/test_bcc_csm2_mr.py @@ -1,11 +1,12 @@ """Test fixes for BCC-CSM2-MR.""" -import unittest +import unittest.mock import iris from esmvalcore.cmor._fixes.cmip6.bcc_csm2_mr import Cl, Cli, Clw, Tos from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor._fixes.fix import Fix +from esmvalcore.cmor.table import get_var_info def test_get_cl_fix(): @@ -16,7 +17,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -27,7 +28,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -38,7 +39,7 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord def test_get_tos_fix(): @@ -91,7 +92,8 @@ def test_tos_fix_metadata(): (longitude.copy(), (1, 2))], ) cubes = iris.cube.CubeList([cube, iris.cube.Cube(0.0)]) - fix = Tos(None) + vardef = get_var_info('CMIP6', 'Omon', 'tos') + fix = Tos(vardef) fixed_cubes = fix.fix_metadata(cubes) tos_cube = fixed_cubes.extract_strict('sea_surface_temperature') diff --git a/tests/integration/cmor/_fixes/cmip6/test_bcc_esm1.py b/tests/integration/cmor/_fixes/cmip6/test_bcc_esm1.py index ec2d3475f1..c6ce251355 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_bcc_esm1.py +++ b/tests/integration/cmor/_fixes/cmip6/test_bcc_esm1.py @@ -1,6 +1,5 @@ """Test fixes for BCC-ESM1.""" -import unittest - +from esmvalcore.cmor._fixes.cmip6.bcc_csm2_mr import Tos as BaseTos from esmvalcore.cmor._fixes.cmip6.bcc_esm1 import Cl, Cli, Clw, Tos from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord from esmvalcore.cmor._fixes.fix import Fix @@ -14,7 +13,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -25,7 +24,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -36,7 +35,7 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord def test_get_tos_fix(): @@ -45,11 +44,6 @@ def test_get_tos_fix(): assert fix == [Tos(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.bcc_esm1.BaseTos.fix_metadata', - autospec=True) -def test_tos_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``tos``.""" - fix = Tos(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_tos_fix(): + """Test fix for ``tos``.""" + assert Tos is BaseTos diff --git a/tests/integration/cmor/_fixes/cmip6/test_cams_csm1_0.py b/tests/integration/cmor/_fixes/cmip6/test_cams_csm1_0.py index 9bc0f83fec..55cb512aee 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cams_csm1_0.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cams_csm1_0.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_cesm2.py b/tests/integration/cmor/_fixes/cmip6/test_cesm2.py index 93f66d6b9a..28e5f3e5fb 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cesm2.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cesm2.py @@ -1,6 +1,6 @@ """Tests for the fixes of CESM2.""" import os -import unittest +import unittest.mock import iris import numpy as np @@ -10,6 +10,7 @@ from esmvalcore.cmor._fixes.cmip6.cesm2 import Cl, Cli, Clw, Tas from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info @pytest.fixture @@ -166,14 +167,9 @@ def test_get_cli_fix(): assert fix == [Cli(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2.Cl.fix_metadata', - autospec=True) -def test_cli_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cli``.""" - fix = Cli(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is Cl def test_get_clw_fix(): @@ -182,14 +178,9 @@ def test_get_clw_fix(): assert fix == [Clw(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2.Cl.fix_metadata', - autospec=True) -def test_clw_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``clw``.""" - fix = Clw(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is Cl @pytest.fixture @@ -217,7 +208,8 @@ def test_tas_fix_metadata(tas_cubes): long_name='height', units=Unit('m'), attributes={'positive': 'up'}) - fix = Tas(None) + vardef = get_var_info('CMIP6', 'Amon', 'tas') + fix = Tas(vardef) out_cubes = fix.fix_metadata(tas_cubes) assert out_cubes is tas_cubes for cube in out_cubes: diff --git a/tests/integration/cmor/_fixes/cmip6/test_cesm2_fv2.py b/tests/integration/cmor/_fixes/cmip6/test_cesm2_fv2.py index 5470234a62..5159cbea9b 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cesm2_fv2.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cesm2_fv2.py @@ -1,6 +1,6 @@ """Tests for the fixes of CESM2-FV2.""" -import unittest - +from esmvalcore.cmor._fixes.cmip6.cesm2 import Cl as BaseCl +from esmvalcore.cmor._fixes.cmip6.cesm2 import Tas as BaseTas from esmvalcore.cmor._fixes.cmip6.cesm2_fv2 import Cl, Cli, Clw, Tas from esmvalcore.cmor.fix import Fix @@ -11,14 +11,9 @@ def test_get_cl_fix(): assert fix == [Cl(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_fv2.BaseCl.fix_metadata', - autospec=True) -def test_cl_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cl``.""" - fix = Cl(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is BaseCl def test_get_cli_fix(): @@ -27,14 +22,9 @@ def test_get_cli_fix(): assert fix == [Cl(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_fv2.Cl.fix_metadata', - autospec=True) -def test_cli_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cli``.""" - fix = Cli(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is BaseCl def test_get_clw_fix(): @@ -43,14 +33,9 @@ def test_get_clw_fix(): assert fix == [Clw(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_fv2.Cl.fix_metadata', - autospec=True) -def test_clw_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``clw``.""" - fix = Clw(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is BaseCl def test_get_tas_fix(): @@ -59,11 +44,6 @@ def test_get_tas_fix(): assert fix == [Tas(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_fv2.BaseTas.fix_metadata', - autospec=True) -def test_tas_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``tas``.""" - fix = Tas(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_tas_fix(): + """Test fix for ``tas``.""" + assert Tas is BaseTas diff --git a/tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm.py b/tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm.py index ff2c1f7bc2..2dc7bd97b3 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cesm2_waccm.py @@ -1,13 +1,13 @@ """Tests for the fixes of CESM2-WACCM.""" import os -import unittest +import unittest.mock import iris import numpy as np import pytest -from cf_units import Unit from netCDF4 import Dataset +from esmvalcore.cmor._fixes.cmip6.cesm2 import Tas as BaseTas from esmvalcore.cmor._fixes.cmip6.cesm2_waccm import Cl, Cli, Clw, Tas from esmvalcore.cmor.fix import Fix @@ -85,14 +85,9 @@ def test_get_cli_fix(): assert fix == [Cli(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_waccm.Cl.fix_metadata', - autospec=True) -def test_cli_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cli``.""" - fix = Cli(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is Cl def test_get_clw_fix(): @@ -101,14 +96,9 @@ def test_get_clw_fix(): assert fix == [Clw(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.cesm2_waccm.Cl.fix_metadata', - autospec=True) -def test_clw_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``clw``.""" - fix = Clw(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is Cl @pytest.fixture @@ -125,24 +115,6 @@ def test_get_tas_fix(): assert fix == [Tas(None)] -def test_tas_fix_metadata(tas_cubes): - """Test ``fix_metadata`` for ``tas``.""" - for cube in tas_cubes: - with pytest.raises(iris.exceptions.CoordinateNotFoundError): - cube.coord('height') - height_coord = iris.coords.AuxCoord(2.0, - var_name='height', - standard_name='height', - long_name='height', - units=Unit('m'), - attributes={'positive': 'up'}) - fix = Tas(None) - out_cubes = fix.fix_metadata(tas_cubes) - assert out_cubes is tas_cubes - for cube in out_cubes: - if cube.var_name == 'tas': - coord = cube.coord('height') - assert coord == height_coord - else: - with pytest.raises(iris.exceptions.CoordinateNotFoundError): - cube.coord('height') +def test_tas_fix(): + """Test fix for ``tas``.""" + assert Tas is BaseTas diff --git a/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1.py b/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1.py index fe14974f7d..69b00ca570 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1.py @@ -8,6 +8,7 @@ from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cl, Clcalipso, Cli, Clw from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info @pytest.fixture @@ -123,7 +124,8 @@ def test_cl_fix_metadata(cl_file): assert not cl_cube.coords('air_pressure') # Apply fix - fix = Cl(None) + vardef = get_var_info('CMIP6', 'Amon', 'cl') + fix = Cl(vardef) fixed_cubes = fix.fix_metadata(cubes) assert len(fixed_cubes) == 1 fixed_cl_cube = fixed_cubes.extract_strict( @@ -149,7 +151,7 @@ def test_cl_fix_metadata(cl_file): def test_get_clcalipso_fix(): """Test getting of fix.""" - fix = Fix.get_fixes('CMIP6', 'CNRM-CM6-1', 'Amon', 'clcalipso') + fix = Fix.get_fixes('CMIP6', 'CNRM-CM6-1', 'CFmon', 'clcalipso') assert fix == [Clcalipso(None)] @@ -166,7 +168,8 @@ def clcalipso_cubes(): def test_clcalipso_fix_metadata(clcalipso_cubes): """Test ``fix_metadata`` for ``clcalipso``.""" - fix = Clcalipso(None) + vardef = get_var_info('CMIP6', 'CFmon', 'clcalipso') + fix = Clcalipso(vardef) cubes = fix.fix_metadata(clcalipso_cubes) assert len(cubes) == 1 cube = cubes[0] @@ -182,7 +185,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == Cl(None) + assert Cli is Cl def test_get_clw_fix(): @@ -193,4 +196,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == Cl(None) + assert Clw is Cl diff --git a/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1_hr.py b/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1_hr.py index 0ce697764c..fa43c06acf 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1_hr.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cnrm_cm6_1_hr.py @@ -1,5 +1,7 @@ """Test fixes for CNRM-CM6-1-HR.""" from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cl as BaseCl +from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cli as BaseCli +from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Clw as BaseClw from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1_hr import Cl, Cli, Clw from esmvalcore.cmor._fixes.fix import Fix @@ -12,7 +14,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == BaseCl(None) + assert Cl is BaseCl def test_get_cli_fix(): @@ -23,7 +25,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == BaseCl(None) + assert Cli is BaseCli def test_get_clw_fix(): @@ -34,4 +36,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == BaseCl(None) + assert Clw is BaseClw diff --git a/tests/integration/cmor/_fixes/cmip6/test_cnrm_esm2_1.py b/tests/integration/cmor/_fixes/cmip6/test_cnrm_esm2_1.py index 592bb508c3..01ce238529 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_cnrm_esm2_1.py +++ b/tests/integration/cmor/_fixes/cmip6/test_cnrm_esm2_1.py @@ -1,6 +1,8 @@ """Test fixes for CNRM-ESM2-1.""" from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cl as BaseCl from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Clcalipso as BaseClcalipso +from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Cli as BaseCli +from esmvalcore.cmor._fixes.cmip6.cnrm_cm6_1 import Clw as BaseClw from esmvalcore.cmor._fixes.cmip6.cnrm_esm2_1 import Cl, Clcalipso, Cli, Clw from esmvalcore.cmor._fixes.fix import Fix @@ -13,7 +15,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == BaseCl(None) + assert Cl is BaseCl def test_get_clcalipso_fix(): @@ -24,7 +26,7 @@ def test_get_clcalipso_fix(): def test_clcalipso_fix(): """Test fix for ``cl``.""" - assert Clcalipso(None) == BaseClcalipso(None) + assert Clcalipso is BaseClcalipso def test_get_cli_fix(): @@ -35,7 +37,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == BaseCl(None) + assert Cli is BaseCli def test_get_clw_fix(): @@ -46,4 +48,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == BaseCl(None) + assert Clw is BaseClw diff --git a/tests/integration/cmor/_fixes/cmip6/test_fgoals_g3.py b/tests/integration/cmor/_fixes/cmip6/test_fgoals_g3.py index fb5a133ec1..bb0f2060f7 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_fgoals_g3.py +++ b/tests/integration/cmor/_fixes/cmip6/test_fgoals_g3.py @@ -1,6 +1,5 @@ """Tests for the fixes of FGOALS-g3.""" -import unittest - +from esmvalcore.cmor._fixes.cmip5.fgoals_g2 import Cl as BaseCl from esmvalcore.cmor._fixes.cmip6.fgoals_g3 import Cl, Cli, Clw from esmvalcore.cmor.fix import Fix @@ -11,14 +10,9 @@ def test_get_cl_fix(): assert fix == [Cl(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.fgoals_g3.BaseCl.fix_metadata', - autospec=True) -def test_cl_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cl``.""" - fix = Cl(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is BaseCl def test_get_cli_fix(): @@ -27,14 +21,9 @@ def test_get_cli_fix(): assert fix == [Cli(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.fgoals_g3.Cl.fix_metadata', - autospec=True) -def test_cli_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``cli``.""" - fix = Cli(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is BaseCl def test_get_clw_fix(): @@ -43,11 +32,6 @@ def test_get_clw_fix(): assert fix == [Clw(None)] -@unittest.mock.patch( - 'esmvalcore.cmor._fixes.cmip6.fgoals_g3.Cl.fix_metadata', - autospec=True) -def test_clw_fix_metadata(mock_base_fix_metadata): - """Test ``fix_metadata`` for ``clw``.""" - fix = Clw(None) - fix.fix_metadata('cubes') - mock_base_fix_metadata.assert_called_once_with(fix, 'cubes') +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is BaseCl diff --git a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py index 2b359df924..209b2951a6 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py +++ b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py @@ -8,6 +8,7 @@ from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import Cl, Cli, Clw from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info @pytest.fixture @@ -123,7 +124,8 @@ def test_cl_fix_metadata(cl_file): assert not cl_cube.coords('air_pressure') # Apply fix - fix = Cl(None) + vardef = get_var_info('CMIP6', 'Amon', 'cl') + fix = Cl(vardef) fixed_cubes = fix.fix_metadata(cubes) assert len(fixed_cubes) == 1 fixed_cl_cube = fixed_cubes.extract_strict( @@ -145,7 +147,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == Cl(None) + assert Cli is Cl def test_get_clw_fix(): @@ -156,4 +158,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == Cl(None) + assert Clw is Cl diff --git a/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_g.py b/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_g.py index 7be6b91faf..05dff93ef6 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_g.py +++ b/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_g.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_h.py b/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_h.py index 533ed4658c..f8afbeea0a 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_h.py +++ b/tests/integration/cmor/_fixes/cmip6/test_giss_e2_1_h.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_hadgem3_gc31_ll.py b/tests/integration/cmor/_fixes/cmip6/test_hadgem3_gc31_ll.py index 3fe21b3d29..a6543060be 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_hadgem3_gc31_ll.py +++ b/tests/integration/cmor/_fixes/cmip6/test_hadgem3_gc31_ll.py @@ -2,7 +2,8 @@ import iris import pytest -from esmvalcore.cmor._fixes.cmip6.hadgem3_gc31_ll import AllVars +from esmvalcore.cmor._fixes.cmip6.hadgem3_gc31_ll import AllVars, Cl, Cli, Clw +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord from esmvalcore.cmor.fix import Fix @@ -34,3 +35,36 @@ def test_allvars_no_need_tofix_metadata(sample_cubes): assert out_cubes is sample_cubes for cube in out_cubes: assert cube.attributes['parent_time_units'] == 'days since 1850-01-01' + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'HadGEM3-GC31-LL', 'Amon', 'cl') + assert fix == [Cl(None), AllVars(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord + + +def test_get_cli_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'HadGEM3-GC31-LL', 'Amon', 'cli') + assert fix == [Cli(None), AllVars(None)] + + +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is ClFixHybridHeightCoord + + +def test_get_clw_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'HadGEM3-GC31-LL', 'Amon', 'clw') + assert fix == [Clw(None), AllVars(None)] + + +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_ipsl_cm6a_lr.py b/tests/integration/cmor/_fixes/cmip6/test_ipsl_cm6a_lr.py index 2622fe3120..526566a2e6 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_ipsl_cm6a_lr.py +++ b/tests/integration/cmor/_fixes/cmip6/test_ipsl_cm6a_lr.py @@ -4,13 +4,13 @@ import iris import numpy as np import pytest - -from iris.cube import Cube, CubeList from iris.coords import AuxCoord +from iris.cube import Cube, CubeList from iris.exceptions import CoordinateNotFoundError from esmvalcore.cmor._fixes.cmip6.ipsl_cm6a_lr import AllVars, Clcalipso from esmvalcore.cmor._fixes.fix import Fix +from esmvalcore.cmor.table import get_var_info class TestAllVars(unittest.TestCase): @@ -54,7 +54,7 @@ def test_fix_data_other_var(self): def test_get_clcalipso_fix(): """Test getting of fix.""" - fix = Fix.get_fixes('CMIP6', 'IPSL-CM6A-LR', 'Amon', 'clcalipso') + fix = Fix.get_fixes('CMIP6', 'IPSL-CM6A-LR', 'CFmon', 'clcalipso') assert fix == [Clcalipso(None), AllVars(None)] @@ -71,7 +71,8 @@ def clcalipso_cubes(): def test_clcalipso_fix_metadata(clcalipso_cubes): """Test ``fix_metadata`` for ``clcalipso``.""" - fix = Clcalipso(None) + vardef = get_var_info('CMIP6', 'CFmon', 'clcalipso') + fix = Clcalipso(vardef) cubes = fix.fix_metadata(clcalipso_cubes) assert len(cubes) == 1 cube = cubes[0] diff --git a/tests/integration/cmor/_fixes/cmip6/test_kace_1_0_g.py b/tests/integration/cmor/_fixes/cmip6/test_kace_1_0_g.py new file mode 100644 index 0000000000..08187d7bca --- /dev/null +++ b/tests/integration/cmor/_fixes/cmip6/test_kace_1_0_g.py @@ -0,0 +1,37 @@ +"""Tests for the fixes of KACE-1-0-G.""" +from esmvalcore.cmor._fixes.cmip6.kace_1_0_g import Cl, Cli, Clw +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord +from esmvalcore.cmor.fix import Fix + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'KACE-1-0-G', 'Amon', 'cl') + assert fix == [Cl(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord + + +def test_get_cli_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'KACE-1-0-G', 'Amon', 'cli') + assert fix == [Cli(None)] + + +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is ClFixHybridHeightCoord + + +def test_get_clw_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'KACE-1-0-G', 'Amon', 'clw') + assert fix == [Clw(None)] + + +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_mcm_ua_1_0.py b/tests/integration/cmor/_fixes/cmip6/test_mcm_ua_1_0.py index 2239576ec5..58e1cc592f 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_mcm_ua_1_0.py +++ b/tests/integration/cmor/_fixes/cmip6/test_mcm_ua_1_0.py @@ -5,6 +5,7 @@ from esmvalcore.cmor._fixes.cmip6.mcm_ua_1_0 import AllVars, Tas from esmvalcore.cmor.fix import Fix +from esmvalcore.cmor.table import get_var_info @pytest.fixture @@ -80,7 +81,8 @@ def test_tas_fix_metadata(cubes): long_name='height', units=Unit('m'), attributes={'positive': 'up'}) - fix = Tas(None) + vardef = get_var_info('CMIP6', 'Amon', 'tas') + fix = Tas(vardef) # Check fix out_cubes = fix.fix_metadata(cubes) diff --git a/tests/integration/cmor/_fixes/cmip6/test_miroc6.py b/tests/integration/cmor/_fixes/cmip6/test_miroc6.py index 5b52817bbe..7884df9e1f 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_miroc6.py +++ b/tests/integration/cmor/_fixes/cmip6/test_miroc6.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_miroc_es2l.py b/tests/integration/cmor/_fixes/cmip6/test_miroc_es2l.py index 354ea5d5b5..550f01d80c 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_miroc_es2l.py +++ b/tests/integration/cmor/_fixes/cmip6/test_miroc_es2l.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_mpi_esm1_2_hr.py b/tests/integration/cmor/_fixes/cmip6/test_mpi_esm1_2_hr.py index ec0cc5daa0..44acea736d 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_mpi_esm1_2_hr.py +++ b/tests/integration/cmor/_fixes/cmip6/test_mpi_esm1_2_hr.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_mri_esm2_0.py b/tests/integration/cmor/_fixes/cmip6/test_mri_esm2_0.py index 201620fab0..609cd12abc 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_mri_esm2_0.py +++ b/tests/integration/cmor/_fixes/cmip6/test_mri_esm2_0.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_nesm3.py b/tests/integration/cmor/_fixes/cmip6/test_nesm3.py index 040dabc9c6..c1e1fe5f94 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_nesm3.py +++ b/tests/integration/cmor/_fixes/cmip6/test_nesm3.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_sam0_unicon.py b/tests/integration/cmor/_fixes/cmip6/test_sam0_unicon.py index 2e2d79df66..bf2398f790 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_sam0_unicon.py +++ b/tests/integration/cmor/_fixes/cmip6/test_sam0_unicon.py @@ -12,7 +12,7 @@ def test_get_cl_fix(): def test_cl_fix(): """Test fix for ``cl``.""" - assert Cl(None) == ClFixHybridPressureCoord(None) + assert Cl is ClFixHybridPressureCoord def test_get_cli_fix(): @@ -23,7 +23,7 @@ def test_get_cli_fix(): def test_cli_fix(): """Test fix for ``cli``.""" - assert Cli(None) == ClFixHybridPressureCoord(None) + assert Cli is ClFixHybridPressureCoord def test_get_clw_fix(): @@ -34,4 +34,4 @@ def test_get_clw_fix(): def test_clw_fix(): """Test fix for ``clw``.""" - assert Clw(None) == ClFixHybridPressureCoord(None) + assert Clw is ClFixHybridPressureCoord diff --git a/tests/integration/cmor/_fixes/cmip6/test_ukesm1_0_ll.py b/tests/integration/cmor/_fixes/cmip6/test_ukesm1_0_ll.py index fa09029520..f6aceb1211 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_ukesm1_0_ll.py +++ b/tests/integration/cmor/_fixes/cmip6/test_ukesm1_0_ll.py @@ -2,23 +2,27 @@ import iris import pytest -from esmvalcore.cmor._fixes.cmip6.ukesm1_0_ll import AllVars +from esmvalcore.cmor._fixes.cmip6.ukesm1_0_ll import AllVars, Cl, Cli, Clw +from esmvalcore.cmor._fixes.common import ClFixHybridHeightCoord from esmvalcore.cmor.fix import Fix @pytest.fixture def sample_cubes(): + """Sample cubes.""" ta_cube = iris.cube.Cube([1.0], var_name='ta') tas_cube = iris.cube.Cube([3.0], var_name='tas') return iris.cube.CubeList([ta_cube, tas_cube]) def test_get_tas_fix(): + """Test getting of fix.""" fix = Fix.get_fixes('CMIP6', 'UKESM1-0-LL', 'Amon', 'tas') assert fix == [AllVars(None)] def test_allvars_fix_metadata(sample_cubes): + """Test ``fix_metadata`` for all variables.""" for cube in sample_cubes: cube.attributes['parent_time_units'] = 'days since 1850-01-01' out_cubes = AllVars(None).fix_metadata(sample_cubes) @@ -28,9 +32,43 @@ def test_allvars_fix_metadata(sample_cubes): def test_allvars_no_need_tofix_metadata(sample_cubes): + """Test ``fix_metadata`` for all variables.""" for cube in sample_cubes: cube.attributes['parent_time_units'] = 'days since 1850-01-01' out_cubes = AllVars(None).fix_metadata(sample_cubes) assert out_cubes is sample_cubes for cube in out_cubes: assert cube.attributes['parent_time_units'] == 'days since 1850-01-01' + + +def test_get_cl_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'UKESM1-0-LL', 'Amon', 'cl') + assert fix == [Cl(None), AllVars(None)] + + +def test_cl_fix(): + """Test fix for ``cl``.""" + assert Cl is ClFixHybridHeightCoord + + +def test_get_cli_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'UKESM1-0-LL', 'Amon', 'cli') + assert fix == [Cli(None), AllVars(None)] + + +def test_cli_fix(): + """Test fix for ``cli``.""" + assert Cli is ClFixHybridHeightCoord + + +def test_get_clw_fix(): + """Test getting of fix.""" + fix = Fix.get_fixes('CMIP6', 'UKESM1-0-LL', 'Amon', 'clw') + assert fix == [Clw(None), AllVars(None)] + + +def test_clw_fix(): + """Test fix for ``clw``.""" + assert Clw is ClFixHybridHeightCoord diff --git a/tests/integration/cmor/_fixes/test_common.py b/tests/integration/cmor/_fixes/test_common.py index 115030b538..aac258e5ea 100644 --- a/tests/integration/cmor/_fixes/test_common.py +++ b/tests/integration/cmor/_fixes/test_common.py @@ -6,10 +6,13 @@ import pytest from netCDF4 import Dataset -from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord +from esmvalcore.cmor._fixes.common import (ClFixHybridHeightCoord, + ClFixHybridPressureCoord) +from esmvalcore.cmor.table import get_var_info +from esmvalcore.preprocessor._derive._shared import var_name_constraint -def create_cl_file_without_ap(dataset): +def create_hybrid_pressure_file_without_ap(dataset, short_name): """Create dataset without vertical auxiliary coordinate ``ap``.""" dataset.createDimension('time', size=1) dataset.createDimension('lev', size=2) @@ -54,21 +57,19 @@ def create_cl_file_without_ap(dataset): dataset.variables['ps'].units = 'Pa' dataset.variables['ps'].additional_attribute = 'xyz' - # Cl variable - dataset.createVariable('cl', np.float32, + # Variable + dataset.createVariable(short_name, np.float32, dimensions=('time', 'lev', 'lat', 'lon')) - dataset.variables['cl'][:] = np.full((1, 2, 3, 4), 0.0, dtype=np.float32) - dataset.variables['cl'].standard_name = ( + dataset.variables[short_name][:] = np.full((1, 2, 3, 4), 0.0, + dtype=np.float32) + dataset.variables[short_name].standard_name = ( 'cloud_area_fraction_in_atmosphere_layer') - dataset.variables['cl'].units = '%' + dataset.variables[short_name].units = '%' -@pytest.fixture -def cl_file_with_a(tmp_path): - """Create netcdf file with similar issues as ``cl``.""" - nc_path = os.path.join(tmp_path, 'bcc_csm_1_1_cl_a.nc') - dataset = Dataset(nc_path, mode='w') - create_cl_file_without_ap(dataset) +def create_hybrid_pressure_file_with_a(dataset, short_name): + """Create netcdf file with issues in hybrid pressure coordinate.""" + create_hybrid_pressure_file_without_ap(dataset, short_name) dataset.createVariable('a', np.float64, dimensions=('lev',)) dataset.createVariable('a_bnds', np.float64, dimensions=('lev', 'bnds')) dataset.createVariable('p0', np.float64, dimensions=()) @@ -79,16 +80,11 @@ def cl_file_with_a(tmp_path): dataset.variables['lev'].formula_terms = 'p0: p0 a: a b: b ps: ps' dataset.variables['lev_bnds'].formula_terms = ( 'p0: p0 a: a_bnds b: b_bnds ps: ps') - dataset.close() - return nc_path -@pytest.fixture -def cl_file_with_ap(tmp_path): - """Create netcdf file with similar issues as ``cl``.""" - nc_path = os.path.join(tmp_path, 'bcc_csm_1_1_cl_ap.nc') - dataset = Dataset(nc_path, mode='w') - create_cl_file_without_ap(dataset) +def create_hybrid_pressure_file_with_ap(dataset, short_name): + """Create netcdf file with issues in hybrid pressure coordinate.""" + create_hybrid_pressure_file_without_ap(dataset, short_name) dataset.createVariable('ap', np.float64, dimensions=('lev',)) dataset.createVariable('ap_bnds', np.float64, dimensions=('lev', 'bnds')) dataset.variables['ap'][:] = [1.0, 2.0] @@ -97,6 +93,64 @@ def cl_file_with_ap(tmp_path): dataset.variables['lev'].formula_terms = 'ap: ap b: b ps: ps' dataset.variables['lev_bnds'].formula_terms = ( 'ap: ap_bnds b: b_bnds ps: ps') + + +@pytest.fixture +def cl_file_with_a(tmp_path): + """Create netcdf file for ``cl`` with ``a`` coordinate.""" + nc_path = os.path.join(tmp_path, f'cl_a.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_a(dataset, 'cl') + dataset.close() + return nc_path + + +@pytest.fixture +def cl_file_with_ap(tmp_path): + """Create netcdf file for ``cl`` with ``ap`` coordinate.""" + nc_path = os.path.join(tmp_path, f'cl_ap.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_ap(dataset, 'cl') + dataset.close() + return nc_path + + +@pytest.fixture +def cli_file_with_a(tmp_path): + """Create netcdf file for ``cli`` with ``a`` coordinate.""" + nc_path = os.path.join(tmp_path, f'cli_a.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_a(dataset, 'cli') + dataset.close() + return nc_path + + +@pytest.fixture +def cli_file_with_ap(tmp_path): + """Create netcdf file for ``cli`` with ``ap`` coordinate.""" + nc_path = os.path.join(tmp_path, f'cli_ap.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_ap(dataset, 'cli') + dataset.close() + return nc_path + + +@pytest.fixture +def clw_file_with_a(tmp_path): + """Create netcdf file for ``clw`` with ``a`` coordinate.""" + nc_path = os.path.join(tmp_path, f'clw_a.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_a(dataset, 'clw') + dataset.close() + return nc_path + + +@pytest.fixture +def clw_file_with_ap(tmp_path): + """Create netcdf file for ``clw`` with ``ap`` coordinate.""" + nc_path = os.path.join(tmp_path, f'clw_ap.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_pressure_file_with_ap(dataset, 'clw') dataset.close() return nc_path @@ -133,21 +187,20 @@ def cl_file_with_ap(tmp_path): [7.0, 25.0]]]]]) -def test_cl_fix_hybrid_pressure_coord_fix_metadata_with_a(cl_file_with_a): - """Test ``fix_metadata`` for ``cl``.""" - cubes = iris.load(cl_file_with_a) +def hybrid_pressure_coord_fix_metadata(nc_path, short_name, fix): + """Test ``fix_metadata`` of file with hybrid pressure coord.""" + cubes = iris.load(nc_path) # Raw cubes assert len(cubes) == 4 var_names = [cube.var_name for cube in cubes] - assert 'cl' in var_names + assert short_name in var_names assert 'ps' in var_names - assert 'a_bnds' in var_names assert 'b_bnds' in var_names - # Raw cl cube - cl_cube = cubes.extract_strict('cloud_area_fraction_in_atmosphere_layer') - air_pressure_coord = cl_cube.coord('air_pressure') + # Raw cube + cube = cubes.extract_strict(var_name_constraint(short_name)) + air_pressure_coord = cube.coord('air_pressure') assert air_pressure_coord.points is not None assert air_pressure_coord.bounds is None np.testing.assert_allclose(air_pressure_coord.points, AIR_PRESSURE_POINTS) @@ -157,57 +210,184 @@ def test_cl_fix_hybrid_pressure_coord_fix_metadata_with_a(cl_file_with_a): assert ps_cube.attributes == {'additional_attribute': 'xyz'} # Apply fix - fix = ClFixHybridPressureCoord(None) fixed_cubes = fix.fix_metadata(cubes) assert len(fixed_cubes) == 1 - fixed_cl_cube = fixed_cubes.extract_strict( - 'cloud_area_fraction_in_atmosphere_layer') - fixed_air_pressure_coord = fixed_cl_cube.coord('air_pressure') + fixed_cube = fixed_cubes.extract_strict(var_name_constraint(short_name)) + fixed_air_pressure_coord = fixed_cube.coord('air_pressure') assert fixed_air_pressure_coord.points is not None assert fixed_air_pressure_coord.bounds is not None np.testing.assert_allclose(fixed_air_pressure_coord.points, AIR_PRESSURE_POINTS) np.testing.assert_allclose(fixed_air_pressure_coord.bounds, AIR_PRESSURE_BOUNDS) - surface_pressure_coord = fixed_cl_cube.coord(var_name='ps') + surface_pressure_coord = fixed_cube.coord(var_name='ps') assert surface_pressure_coord.attributes == {} + return var_names + + +def test_cl_hybrid_pressure_coord_fix_metadata_with_a(cl_file_with_a): + """Test ``fix_metadata`` for ``cl``.""" + vardef = get_var_info('CMIP6', 'Amon', 'cl') + var_names = hybrid_pressure_coord_fix_metadata( + cl_file_with_a, 'cl', ClFixHybridPressureCoord(vardef)) + assert 'a_bnds' in var_names -def test_cl_fix_hybrid_pressure_coord_fix_metadata_with_ap(cl_file_with_ap): + +def test_cl_hybrid_pressure_coord_fix_metadata_with_ap(cl_file_with_ap): """Test ``fix_metadata`` for ``cl``.""" - cubes = iris.load(cl_file_with_ap) + vardef = get_var_info('CMIP6', 'Amon', 'cl') + var_names = hybrid_pressure_coord_fix_metadata( + cl_file_with_ap, 'cl', ClFixHybridPressureCoord(vardef)) + assert 'ap_bnds' in var_names + + +def create_hybrid_height_file(dataset, short_name): + """Create dataset with hybrid height coordinate.""" + dataset.createDimension('time', size=1) + dataset.createDimension('lev', size=2) + dataset.createDimension('lat', size=1) + dataset.createDimension('lon', size=2) + dataset.createDimension('bnds', size=2) + + # Dimensional variables + dataset.createVariable('time', np.float64, dimensions=('time',)) + dataset.createVariable('lev', np.float64, dimensions=('lev',)) + dataset.createVariable('lev_bnds', np.float64, dimensions=('lev', 'bnds')) + dataset.createVariable('lat', np.float64, dimensions=('lat',)) + dataset.createVariable('lon', np.float64, dimensions=('lon',)) + dataset.variables['time'][:] = [0.0] + dataset.variables['time'].standard_name = 'time' + dataset.variables['time'].units = 'days since 6543-2-1' + dataset.variables['lev'][:] = [1.0, 2.0] + dataset.variables['lev'].bounds = 'lev_bnds' + dataset.variables['lev'].standard_name = ( + 'atmosphere_hybrid_height_coordinate') + dataset.variables['lev'].units = 'm' + dataset.variables['lev'].formula_terms = 'a: lev b: b orog: orog' + dataset.variables['lev_bnds'][:] = [[0.5, 1.5], [1.5, 3.0]] + dataset.variables['lev_bnds'].standard_name = ( + 'atmosphere_hybrid_height_coordinate') + dataset.variables['lev_bnds'].units = '1' + dataset.variables['lev_bnds'].formula_terms = ( + 'a: lev_bnds b: b_bnds orog: orog') + dataset.variables['lat'][:] = [0.0] + dataset.variables['lat'].standard_name = 'latitude' + dataset.variables['lat'].units = 'degrees_north' + dataset.variables['lon'][:] = [30.0, 60.0] + dataset.variables['lon'].standard_name = 'longitude' + dataset.variables['lon'].units = 'degrees_east' + + # Coordinates for derivation of height coordinate + dataset.createVariable('b', np.float64, dimensions=('lev',)) + dataset.createVariable('b_bnds', np.float64, dimensions=('lev', 'bnds')) + dataset.createVariable('orog', np.float64, dimensions=('lat', 'lon')) + dataset.variables['b'][:] = [0.0, 1.0] + dataset.variables['b_bnds'][:] = [[-1.0, 0.5], [0.5, 2.0]] + dataset.variables['orog'][:] = [[0.0, 1.0]] + dataset.variables['orog'].standard_name = 'surface_altitude' + dataset.variables['orog'].units = 'm' + + # Variable + dataset.createVariable(short_name, np.float32, + dimensions=('time', 'lev', 'lat', 'lon')) + dataset.variables[short_name][:] = np.full((1, 2, 1, 2), 0.0, + dtype=np.float32) + dataset.variables[short_name].standard_name = ( + 'cloud_area_fraction_in_atmosphere_layer') + dataset.variables[short_name].units = '%' + + +@pytest.fixture +def cl_file_with_height(tmp_path): + """Create netcdf file for ``cl`` with hybrid height coordinate.""" + nc_path = os.path.join(tmp_path, f'cl_hybrid_height.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_height_file(dataset, 'cl') + dataset.close() + return nc_path + + +@pytest.fixture +def cli_file_with_height(tmp_path): + """Create netcdf file for ``cli`` with hybrid height coordinate.""" + nc_path = os.path.join(tmp_path, f'cli_hybrid_height.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_height_file(dataset, 'cli') + dataset.close() + return nc_path + + +@pytest.fixture +def clw_file_with_height(tmp_path): + """Create netcdf file for ``clw`` with hybrid height coordinate.""" + nc_path = os.path.join(tmp_path, f'clw_hybrid_height.nc') + dataset = Dataset(nc_path, mode='w') + create_hybrid_height_file(dataset, 'clw') + dataset.close() + return nc_path + + +HEIGHT_POINTS = np.array([[[1.0, 1.0]], + [[2.0, 3.0]]]) +HEIGHT_BOUNDS_WRONG = np.array([[[[0.5, 1.5], + [0.5, 1.5]]], + [[[1.5, 3.0], + [2.5, 4.0]]]]) +HEIGHT_BOUNDS_RIGHT = np.array([[[[0.5, 1.5], + [-0.5, 2.0]]], + [[[1.5, 3.0], + [2.0, 5.0]]]]) +PRESSURE_POINTS = np.array([[[101312.98512207, 101312.98512207]], + [[101300.97123885, 101288.95835383]]]) +PRESSURE_BOUNDS = np.array([[[[101318.99243691, 101306.9780559], + [101331.00781103, 101300.97123885]]], + [[[101306.9780559, 101288.95835383], + [101300.97123885, 101264.93559234]]]]) + + +def hybrid_height_coord_fix_metadata(nc_path, short_name, fix): + """Test ``fix_metadata`` of file with hybrid height coord.""" + cubes = iris.load(nc_path) # Raw cubes - assert len(cubes) == 4 + assert len(cubes) == 3 var_names = [cube.var_name for cube in cubes] - assert 'cl' in var_names - assert 'ps' in var_names - assert 'ap_bnds' in var_names + assert short_name in var_names + assert 'orog' in var_names assert 'b_bnds' in var_names - # Raw cl cube - cl_cube = cubes.extract_strict('cloud_area_fraction_in_atmosphere_layer') - air_pressure_coord = cl_cube.coord('air_pressure') - assert air_pressure_coord.points is not None - assert air_pressure_coord.bounds is None - np.testing.assert_allclose(air_pressure_coord.points, AIR_PRESSURE_POINTS) - - # Raw ps cube - ps_cube = cubes.extract_strict('surface_air_pressure') - assert ps_cube.attributes == {'additional_attribute': 'xyz'} + # Raw cube + cube = cubes.extract_strict(var_name_constraint(short_name)) + height_coord = cube.coord('altitude') + assert height_coord.points is not None + assert height_coord.bounds is not None + np.testing.assert_allclose(height_coord.points, HEIGHT_POINTS) + np.testing.assert_allclose(height_coord.bounds, HEIGHT_BOUNDS_WRONG) + assert not np.allclose(height_coord.bounds, HEIGHT_BOUNDS_RIGHT) + assert not cube.coords('air_pressure') # Apply fix - fix = ClFixHybridPressureCoord(None) fixed_cubes = fix.fix_metadata(cubes) assert len(fixed_cubes) == 1 - fixed_cl_cube = fixed_cubes.extract_strict( - 'cloud_area_fraction_in_atmosphere_layer') - fixed_air_pressure_coord = fixed_cl_cube.coord('air_pressure') - assert fixed_air_pressure_coord.points is not None - assert fixed_air_pressure_coord.bounds is not None - np.testing.assert_allclose(fixed_air_pressure_coord.points, - AIR_PRESSURE_POINTS) - np.testing.assert_allclose(fixed_air_pressure_coord.bounds, - AIR_PRESSURE_BOUNDS) - surface_pressure_coord = fixed_cl_cube.coord(var_name='ps') - assert surface_pressure_coord.attributes == {} + fixed_cube = fixed_cubes.extract_strict(var_name_constraint(short_name)) + fixed_height_coord = fixed_cube.coord('altitude') + assert fixed_height_coord.points is not None + assert fixed_height_coord.bounds is not None + np.testing.assert_allclose(fixed_height_coord.points, HEIGHT_POINTS) + np.testing.assert_allclose(fixed_height_coord.bounds, HEIGHT_BOUNDS_RIGHT) + assert not np.allclose(fixed_height_coord.bounds, HEIGHT_BOUNDS_WRONG) + air_pressure_coord = cube.coord('air_pressure') + np.testing.assert_allclose(air_pressure_coord.points, PRESSURE_POINTS) + np.testing.assert_allclose(air_pressure_coord.bounds, PRESSURE_BOUNDS) + assert air_pressure_coord.var_name == 'plev' + assert air_pressure_coord.standard_name == 'air_pressure' + assert air_pressure_coord.long_name == 'pressure' + assert air_pressure_coord.units == 'Pa' + + +def test_cl_hybrid_height_coord_fix_metadata(cl_file_with_height): + """Test ``fix_metadata`` for ``cl``.""" + vardef = get_var_info('CMIP6', 'Amon', 'cl') + hybrid_height_coord_fix_metadata(cl_file_with_height, 'cl', + ClFixHybridHeightCoord(vardef)) diff --git a/tests/integration/cmor/_fixes/test_shared.py b/tests/integration/cmor/_fixes/test_shared.py index 2158f3c27f..9850135ef8 100644 --- a/tests/integration/cmor/_fixes/test_shared.py +++ b/tests/integration/cmor/_fixes/test_shared.py @@ -4,7 +4,10 @@ import pytest from cf_units import Unit -from esmvalcore.cmor._fixes.shared import (add_aux_coords_from_cubes, +from esmvalcore.cmor._fixes.shared import (altitude_to_pressure, + _get_altitude_to_pressure_func, + add_aux_coords_from_cubes, + add_plev_from_altitude, add_scalar_depth_coord, add_scalar_height_coord, add_scalar_typeland_coord, @@ -15,6 +18,21 @@ from esmvalcore.preprocessor._derive._shared import var_name_constraint +@pytest.mark.parametrize('func', [altitude_to_pressure, + _get_altitude_to_pressure_func()]) +def test_altitude_to_pressure_func(func): + """Test altitude to pressure function.""" + assert callable(func) + np.testing.assert_allclose(func(-6000.0), 196968.01058487315) + np.testing.assert_allclose(func(-5000.0), 177687.0) + np.testing.assert_allclose(func(0.0), 101325.0) + np.testing.assert_allclose(func(50.0), 100725.54298598564) + np.testing.assert_allclose(func(80000.0), 0.88628) + np.testing.assert_allclose(func(90000.0), 0.1576523580997673) + np.testing.assert_allclose(func(np.array([0.0, 100.0])), + [101325.0, 100129.0]) + + TEST_ADD_AUX_COORDS_FROM_CUBES = [ ({}, 1), ({'x': ()}, 0), @@ -63,6 +81,42 @@ def test_add_aux_coords_from_cubes(coord_dict, output): assert "got 2" in str(err.value) +ALT_COORD = iris.coords.AuxCoord([0.0], bounds=[[-100.0, 500.0]], + standard_name='altitude', units='m') +ALT_COORD_KM = iris.coords.AuxCoord([0.0], bounds=[[-0.1, 0.5]], + standard_name='altitude', units='km') +P_COORD = iris.coords.AuxCoord([101325.0], bounds=[[102532.0, 95460.8]], + var_name='plev', standard_name='air_pressure', + long_name='pressure', units='Pa') +CUBE_ALT = iris.cube.Cube([1.0], var_name='x', + aux_coords_and_dims=[(ALT_COORD, 0)]) +CUBE_ALT_KM = iris.cube.Cube([1.0], var_name='x', + aux_coords_and_dims=[(ALT_COORD_KM, 0)]) + + +TEST_ADD_PLEV_FROM_ALTITUDE = [ + (CUBE_ALT.copy(), P_COORD.copy()), + (CUBE_ALT_KM.copy(), P_COORD.copy()), + (iris.cube.Cube(0.0), None), +] + + +@pytest.mark.parametrize('cube,output', TEST_ADD_PLEV_FROM_ALTITUDE) +def test_add_plev_from_altitude(cube, output): + """Test adding of pressure level coordinate.""" + if output is None: + with pytest.raises(ValueError) as err: + add_plev_from_altitude(cube) + msg = ("Cannot add 'air_pressure' coordinate, 'altitude' coordinate " + "not available") + assert str(err.value) == msg + return + assert not cube.coords('air_pressure') + add_plev_from_altitude(cube) + air_pressure_coord = cube.coord('air_pressure') + assert air_pressure_coord == output + + DIM_COORD = iris.coords.DimCoord([3.141592], bounds=[[1.23, 4.567891011]], standard_name='latitude') diff --git a/tests/unit/cmor/test_fix.py b/tests/unit/cmor/test_fix.py index 648004bbd5..341f549b23 100644 --- a/tests/unit/cmor/test_fix.py +++ b/tests/unit/cmor/test_fix.py @@ -3,8 +3,8 @@ from unittest import TestCase from unittest.mock import Mock, patch -from esmvalcore.cmor.fix import Fix, fix_data, fix_file, fix_metadata from esmvalcore.cmor.check import CheckLevels +from esmvalcore.cmor.fix import Fix, fix_data, fix_file, fix_metadata class TestFixFile(TestCase): @@ -54,7 +54,9 @@ def setUp(self): self.cube_2 = Mock() self.cube_2.var_name = 'cube2' self.cubes = [self.cube_1, self.cube_2] - self.fix = Fix(None) + vardef = Mock() + vardef.short_name = 'fix' + self.fix = Fix(vardef) def test_get_first_cube(self): """Test selecting first cube."""