From 9d3279540cc54f201fc9d88287d4b9e16387702d Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Wed, 21 Jun 2023 14:41:08 +0200 Subject: [PATCH 01/11] add custom vars --- esmvalcore/cmor/tables/custom/CMOR_ctp.dat | 19 +++++++++++++++++++ esmvalcore/cmor/tables/custom/CMOR_reff.dat | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 esmvalcore/cmor/tables/custom/CMOR_ctp.dat create mode 100644 esmvalcore/cmor/tables/custom/CMOR_reff.dat diff --git a/esmvalcore/cmor/tables/custom/CMOR_ctp.dat b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat new file mode 100644 index 0000000000..9423e41184 --- /dev/null +++ b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat @@ -0,0 +1,19 @@ +SOURCE: CMIP6 +!============ +variable_entry: ctp +!============ +modeling_realm: atmos +!---------------------------------- +! Variable attributes: +!---------------------------------- +standard_name: +units: hPa +cell_methods: time: mean +cell_measures: area: areacella +long_name: Cloud top pressure +!---------------------------------- +! Additional variable information: +!---------------------------------- +dimensions: longitude latitude time +type: real +!---------------------------------- diff --git a/esmvalcore/cmor/tables/custom/CMOR_reff.dat b/esmvalcore/cmor/tables/custom/CMOR_reff.dat new file mode 100644 index 0000000000..f91a3452c8 --- /dev/null +++ b/esmvalcore/cmor/tables/custom/CMOR_reff.dat @@ -0,0 +1,19 @@ +SOURCE: CMIP6 +!============ +variable_entry: reff +!============ +modeling_realm: atmos +!---------------------------------- +! Variable attributes: +!---------------------------------- +standard_name: +units: um +cell_methods: time: mean +cell_measures: area: areacella +long_name: Cloud effective radius +!---------------------------------- +! Additional variable information: +!---------------------------------- +dimensions: longitude latitude time +type: real +!---------------------------------- From 818fdac34b7e53f6e9e30721e805ded681ad90dc Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Wed, 2 Aug 2023 10:44:52 +0200 Subject: [PATCH 02/11] add p500 coordinate --- esmvalcore/cmor/_fixes/native6/era5.py | 4 +++- esmvalcore/cmor/_fixes/shared.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/esmvalcore/cmor/_fixes/native6/era5.py b/esmvalcore/cmor/_fixes/native6/era5.py index 3c621b7d45..a5540998b7 100644 --- a/esmvalcore/cmor/_fixes/native6/era5.py +++ b/esmvalcore/cmor/_fixes/native6/era5.py @@ -8,7 +8,7 @@ from esmvalcore.iris_helpers import date2num from ..fix import Fix -from ..shared import add_scalar_height_coord +from ..shared import add_scalar_height_coord, add_scalar_pressure_coord from ...table import CMOR_TABLES logger = logging.getLogger(__name__) @@ -358,6 +358,8 @@ def _fix_coordinates(self, cube): add_scalar_height_coord(cube, 2.) if 'height10m' in self.vardef.dimensions: add_scalar_height_coord(cube, 10.) + if 'p500'in self.vardef.dimensions: + add_scalar_pressure_coord(cube, 500.) for coord_def in self.vardef.coordinates.values(): axis = coord_def.axis diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index 0e4dfead08..aee8fbbc27 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -199,6 +199,22 @@ def add_scalar_lambda550nm_coord(cube): return cube +def add_scalar_pressure_coord(cube, pressure=500.): + """Add scalar coordinate 'height' with value of `pressure`hPa.""" + logger.debug("Adding pressure coordinate (%shPa)", pressure) + pressure_coord = iris.coords.AuxCoord(pressure, + var_name='height', + standard_name='height', + long_name='height', + units=Unit('hPa'), + attributes={'positive': 'up'}) + try: + cube.coord('pressure') + except iris.exceptions.CoordinateNotFoundError: + cube.add_aux_coord(pressure_coord, ()) + return cube + + def add_scalar_typeland_coord(cube, value='default'): """Add scalar coordinate 'typeland' with value of `value`.""" logger.debug("Adding typeland coordinate (%s)", value) From 7c2a0d6ac54bc6601e1317bd6a1fe53e93601f2c Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Mon, 14 Aug 2023 14:50:16 +0200 Subject: [PATCH 03/11] add zg500 fix --- esmvalcore/cmor/_fixes/native6/era5.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/esmvalcore/cmor/_fixes/native6/era5.py b/esmvalcore/cmor/_fixes/native6/era5.py index a5540998b7..150362095f 100644 --- a/esmvalcore/cmor/_fixes/native6/era5.py +++ b/esmvalcore/cmor/_fixes/native6/era5.py @@ -339,6 +339,16 @@ def fix_metadata(self, cubes): return cubes +class Zg500(Fix): + """Fixes for Geopotential.""" + + def fix_metadata(self, cubes): + """Fix metadata.""" + for cube in cubes: + divide_by_gravity(cube) + return cubes + + class AllVars(Fix): """Fixes for all variables.""" From 7e3fa6c459e11aef46657261ae01d6ac883783a7 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Mon, 13 Nov 2023 10:03:13 +0100 Subject: [PATCH 04/11] add p700 and p850 --- esmvalcore/cmor/_fixes/native6/era5.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esmvalcore/cmor/_fixes/native6/era5.py b/esmvalcore/cmor/_fixes/native6/era5.py index 2e5fee82b8..af37c42cce 100644 --- a/esmvalcore/cmor/_fixes/native6/era5.py +++ b/esmvalcore/cmor/_fixes/native6/era5.py @@ -375,6 +375,10 @@ def _fix_coordinates(self, cube): add_scalar_height_coord(cube, 10.) if 'p500'in self.vardef.dimensions: add_scalar_pressure_coord(cube, 500.) + if 'p700'in self.vardef.dimensions: + add_scalar_pressure_coord(cube, 700.) + if 'p850'in self.vardef.dimensions: + add_scalar_pressure_coord(cube, 850.) for coord_def in self.vardef.coordinates.values(): axis = coord_def.axis From 3eb3b642db620a4205ce178a5c581c99fe72eaf2 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Fri, 1 Dec 2023 10:53:48 +0100 Subject: [PATCH 05/11] add custom variable ta1000 --- esmvalcore/cmor/_fixes/native6/era5.py | 2 ++ esmvalcore/cmor/tables/custom/CMOR_ta1000.dat | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 esmvalcore/cmor/tables/custom/CMOR_ta1000.dat diff --git a/esmvalcore/cmor/_fixes/native6/era5.py b/esmvalcore/cmor/_fixes/native6/era5.py index af37c42cce..67a6c099df 100644 --- a/esmvalcore/cmor/_fixes/native6/era5.py +++ b/esmvalcore/cmor/_fixes/native6/era5.py @@ -379,6 +379,8 @@ def _fix_coordinates(self, cube): add_scalar_pressure_coord(cube, 700.) if 'p850'in self.vardef.dimensions: add_scalar_pressure_coord(cube, 850.) + if 'p1000'in self.vardef.dimensions: + add_scalar_pressure_coord(cube, 1000.) for coord_def in self.vardef.coordinates.values(): axis = coord_def.axis diff --git a/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat b/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat new file mode 100644 index 0000000000..913917eba5 --- /dev/null +++ b/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat @@ -0,0 +1,21 @@ +SOURCE: CMIP5 +!============ +variable_entry: ta1000 +!============ +modeling_realm: atmos +!---------------------------------- +! Variable attributes: +!---------------------------------- +standard_name: air_temperature +units: K +cell_methods: time: mean +cell_measures: area: areacella +long_name: Air Temperature +!---------------------------------- +! Additional variable information: +!---------------------------------- +dimensions: longitude latitude time p1000 +out_name: ta1000 +type: real +!---------------------------------- +! From 29f5b80ee64571c073a0cf6ed0054296d7988879 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Thu, 7 Dec 2023 10:01:42 +0100 Subject: [PATCH 06/11] add wap700 --- .../cmor/tables/custom/CMOR_coordinates.dat | 44 +++++++++++++++++++ esmvalcore/cmor/tables/custom/CMOR_wap700.dat | 22 ++++++++++ 2 files changed, 66 insertions(+) create mode 100644 esmvalcore/cmor/tables/custom/CMOR_wap700.dat diff --git a/esmvalcore/cmor/tables/custom/CMOR_coordinates.dat b/esmvalcore/cmor/tables/custom/CMOR_coordinates.dat index 490ddab6f5..6f704c9b2e 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_coordinates.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_coordinates.dat @@ -104,3 +104,47 @@ type: double must_have_bounds: yes !---------------------------------- ! + +!============ +axis_entry: p700 +!============ +!---------------------------------- +! Axis attributes: +!---------------------------------- +standard_name: air_pressure +units: Pa +axis: Z ! X, Y, Z, T (default: undeclared) +positive: down ! up or down (default: undeclared) +long_name: pressure +!---------------------------------- +! Additional axis information: +!---------------------------------- +out_name: plev +stored_direction: decreasing +type: double +value: 70000. ! of scalar (singleton) dimension +must_have_bounds: no +!---------------------------------- +! + +!============ +axis_entry: p1000 +!============ +!---------------------------------- +! Axis attributes: +!---------------------------------- +standard_name: air_pressure +units: Pa +axis: Z ! X, Y, Z, T (default: undeclared) +positive: down ! up or down (default: undeclared) +long_name: pressure +!---------------------------------- +! Additional axis information: +!---------------------------------- +out_name: plev +stored_direction: decreasing +type: double +value: 100000. ! of scalar (singleton) dimension +must_have_bounds: no +!---------------------------------- +! diff --git a/esmvalcore/cmor/tables/custom/CMOR_wap700.dat b/esmvalcore/cmor/tables/custom/CMOR_wap700.dat new file mode 100644 index 0000000000..9be5be4c61 --- /dev/null +++ b/esmvalcore/cmor/tables/custom/CMOR_wap700.dat @@ -0,0 +1,22 @@ +SOURCE: CMIP5 +!============ +variable_entry: wap700 +!============ +modeling_realm: atmos +!---------------------------------- +! Variable attributes: +!---------------------------------- +standard_name: lagrangian_tendency_of_air_pressure +units: Pa s-1 +cell_methods: time: mean +cell_measures: area: areacella +long_name: omega (=dp/dt) +comment: at 700 hPa level; commonly referred to as ""omega"", this represents the vertical component of velocity in pressure coordinates (positive down) +!---------------------------------- +! Additional variable information: +!---------------------------------- +dimensions: longitude latitude time p700 +out_name: wap700 +type: real +!---------------------------------- +! From 4a78723034cd521f248fd6691e6579c8ba248280 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Tue, 11 Jun 2024 10:00:59 +0200 Subject: [PATCH 07/11] change to CMIP5 table --- esmvalcore/cmor/tables/custom/CMOR_ctp.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esmvalcore/cmor/tables/custom/CMOR_ctp.dat b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat index 9423e41184..05b64c099d 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_ctp.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat @@ -1,4 +1,4 @@ -SOURCE: CMIP6 +SOURCE: CMIP5 !============ variable_entry: ctp !============ From e80e11b74ca7c65f5fb3f74bb0b9a1e196c81f21 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Tue, 16 Jul 2024 18:29:56 +0200 Subject: [PATCH 08/11] added tests --- esmvalcore/cmor/_fixes/native6/era5.py | 21 +------------------ esmvalcore/cmor/_fixes/shared.py | 16 -------------- esmvalcore/cmor/tables/custom/CMOR_ctp.dat | 2 +- esmvalcore/cmor/tables/custom/CMOR_reff.dat | 2 +- esmvalcore/cmor/tables/custom/CMOR_ta1000.dat | 2 +- esmvalcore/cmor/tables/custom/CMOR_wap700.dat | 2 +- 6 files changed, 5 insertions(+), 40 deletions(-) diff --git a/esmvalcore/cmor/_fixes/native6/era5.py b/esmvalcore/cmor/_fixes/native6/era5.py index 5a79f31799..6c67494aaa 100644 --- a/esmvalcore/cmor/_fixes/native6/era5.py +++ b/esmvalcore/cmor/_fixes/native6/era5.py @@ -9,8 +9,7 @@ from ...table import CMOR_TABLES from ..fix import Fix -from ..shared import add_scalar_height_coord, add_scalar_pressure_coord -from ...table import CMOR_TABLES +from ..shared import add_scalar_height_coord logger = logging.getLogger(__name__) @@ -345,16 +344,6 @@ def fix_metadata(self, cubes): return cubes -class Zg500(Fix): - """Fixes for Geopotential.""" - - def fix_metadata(self, cubes): - """Fix metadata.""" - for cube in cubes: - divide_by_gravity(cube) - return cubes - - class AllVars(Fix): """Fixes for all variables.""" @@ -374,14 +363,6 @@ def _fix_coordinates(self, cube): add_scalar_height_coord(cube, 2.) if 'height10m' in self.vardef.dimensions: add_scalar_height_coord(cube, 10.) - if 'p500'in self.vardef.dimensions: - add_scalar_pressure_coord(cube, 500.) - if 'p700'in self.vardef.dimensions: - add_scalar_pressure_coord(cube, 700.) - if 'p850'in self.vardef.dimensions: - add_scalar_pressure_coord(cube, 850.) - if 'p1000'in self.vardef.dimensions: - add_scalar_pressure_coord(cube, 1000.) for coord_def in self.vardef.coordinates.values(): axis = coord_def.axis diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index bc7051c9bc..3ec14d05ab 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -216,22 +216,6 @@ def add_scalar_lambda550nm_coord(cube): return cube -def add_scalar_pressure_coord(cube, pressure=500.): - """Add scalar coordinate 'height' with value of `pressure`hPa.""" - logger.debug("Adding pressure coordinate (%shPa)", pressure) - pressure_coord = iris.coords.AuxCoord(pressure, - var_name='height', - standard_name='height', - long_name='height', - units=Unit('hPa'), - attributes={'positive': 'up'}) - try: - cube.coord('pressure') - except iris.exceptions.CoordinateNotFoundError: - cube.add_aux_coord(pressure_coord, ()) - return cube - - def add_scalar_typeland_coord(cube, value='default'): """Add scalar coordinate 'typeland' with value of `value`.""" logger.debug("Adding typeland coordinate (%s)", value) diff --git a/esmvalcore/cmor/tables/custom/CMOR_ctp.dat b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat index 05b64c099d..1073118275 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_ctp.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_ctp.dat @@ -10,7 +10,7 @@ standard_name: units: hPa cell_methods: time: mean cell_measures: area: areacella -long_name: Cloud top pressure +long_name: Cloud Top Pressure !---------------------------------- ! Additional variable information: !---------------------------------- diff --git a/esmvalcore/cmor/tables/custom/CMOR_reff.dat b/esmvalcore/cmor/tables/custom/CMOR_reff.dat index f91a3452c8..284670fc77 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_reff.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_reff.dat @@ -10,7 +10,7 @@ standard_name: units: um cell_methods: time: mean cell_measures: area: areacella -long_name: Cloud effective radius +long_name: Cloud Effective Radius !---------------------------------- ! Additional variable information: !---------------------------------- diff --git a/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat b/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat index 913917eba5..7193a96b2e 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_ta1000.dat @@ -10,7 +10,7 @@ standard_name: air_temperature units: K cell_methods: time: mean cell_measures: area: areacella -long_name: Air Temperature +long_name: Air Temperature at 1000hPa !---------------------------------- ! Additional variable information: !---------------------------------- diff --git a/esmvalcore/cmor/tables/custom/CMOR_wap700.dat b/esmvalcore/cmor/tables/custom/CMOR_wap700.dat index 9be5be4c61..3061fc2cd0 100644 --- a/esmvalcore/cmor/tables/custom/CMOR_wap700.dat +++ b/esmvalcore/cmor/tables/custom/CMOR_wap700.dat @@ -10,7 +10,7 @@ standard_name: lagrangian_tendency_of_air_pressure units: Pa s-1 cell_methods: time: mean cell_measures: area: areacella -long_name: omega (=dp/dt) +long_name: Omega (=dp/dt) at 700hPa comment: at 700 hPa level; commonly referred to as ""omega"", this represents the vertical component of velocity in pressure coordinates (positive down) !---------------------------------- ! Additional variable information: From 016e7a4df515e5df26dc9b2aeef4500a3f16a46d Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Fri, 19 Jul 2024 10:14:12 +0200 Subject: [PATCH 09/11] add tests --- tests/integration/cmor/test_table.py | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/integration/cmor/test_table.py b/tests/integration/cmor/test_table.py index 680e5b4c01..5dec40506f 100644 --- a/tests/integration/cmor/test_table.py +++ b/tests/integration/cmor/test_table.py @@ -494,6 +494,42 @@ def test_get_variable_tosStderr(self): 'Sea Surface Temperature Error') self.assertEqual(var.units, 'K') + def test_get_variable_ctp(self): + """Get ctp variable.""" + CustomInfo() + var = self.variables_info.get_variable('day', 'ctp') + self.assertEqual(var.short_name, 'ctp') + self.assertEqual(var.long_name, + 'Cloud Top Pressure') + self.assertEqual(var.units, 'hPa') + + def test_get_variable_reff(self): + """Get reff variable.""" + CustomInfo() + var = self.variables_info.get_variable('day', 'reff') + self.assertEqual(var.short_name, 'reff') + self.assertEqual(var.long_name, + 'Cloud Effective Radius') + self.assertEqual(var.units, 'um') + + def test_get_variable_ta1000(self): + """Get ta1000 variable.""" + CustomInfo() + var = self.variables_info.get_variable('day', 'ta1000') + self.assertEqual(var.short_name, 'ta1000') + self.assertEqual(var.long_name, + 'Air Temperaturea at 1000hPa') + self.assertEqual(var.units, 'K') + + def test_get_variable_wap700(self): + """Get wap700 variable.""" + CustomInfo() + var = self.variables_info.get_variable('day', 'wap700') + self.assertEqual(var.short_name, 'wap700') + self.assertEqual(var.long_name, + 'Omega (=dp/dt) at 700hPa' + self.assertEqual(var.units, 'Pa s-1') + @pytest.mark.parametrize( 'project,mip,short_name,frequency', From 82192f6684bdbd90f741e9e20b5572f251ca7c91 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Fri, 19 Jul 2024 10:29:37 +0200 Subject: [PATCH 10/11] fix --- tests/integration/cmor/test_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cmor/test_table.py b/tests/integration/cmor/test_table.py index 5dec40506f..b890f43d8a 100644 --- a/tests/integration/cmor/test_table.py +++ b/tests/integration/cmor/test_table.py @@ -527,7 +527,7 @@ def test_get_variable_wap700(self): var = self.variables_info.get_variable('day', 'wap700') self.assertEqual(var.short_name, 'wap700') self.assertEqual(var.long_name, - 'Omega (=dp/dt) at 700hPa' + 'Omega (=dp/dt) at 700hPa') self.assertEqual(var.units, 'Pa s-1') From 0f6c30f3fc729964ed1c0f701542e8cfde1a4a20 Mon Sep 17 00:00:00 2001 From: Lisa Bock Date: Fri, 19 Jul 2024 10:37:13 +0200 Subject: [PATCH 11/11] fix --- tests/integration/cmor/test_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cmor/test_table.py b/tests/integration/cmor/test_table.py index b890f43d8a..c76fa82b96 100644 --- a/tests/integration/cmor/test_table.py +++ b/tests/integration/cmor/test_table.py @@ -518,7 +518,7 @@ def test_get_variable_ta1000(self): var = self.variables_info.get_variable('day', 'ta1000') self.assertEqual(var.short_name, 'ta1000') self.assertEqual(var.long_name, - 'Air Temperaturea at 1000hPa') + 'Air Temperature at 1000hPa') self.assertEqual(var.units, 'K') def test_get_variable_wap700(self):