diff --git a/cdds/cdds/common/plugins/cmip7/cmip7_grid.py b/cdds/cdds/common/plugins/cmip7/cmip7_grid.py index eb2f638e9..202f46ca1 100644 --- a/cdds/cdds/common/plugins/cmip7/cmip7_grid.py +++ b/cdds/cdds/common/plugins/cmip7/cmip7_grid.py @@ -40,7 +40,7 @@ def from_name(cls, name: str) -> 'GridLabel': NATIVE = 'native', 'g100', False NATIVE_ZONAL = 'native-zonal', 'g100z', False REGRIDDED = 'regridded', 'g100', False - GLOBAL_MEAN = 'global-mean', 'g100m', False + GLOBAL_MEAN = 'global-mean', 'g100', False UGRID = 'ugrid', 'g100', True VGRID = 'vgrid', 'g100', True UVGRID = 'uvgrid', 'g100', True diff --git a/mip_convert/mip_convert/plugins/base/data/processors.py b/mip_convert/mip_convert/plugins/base/data/processors.py index 2de3b2fdc..3a47462d0 100644 --- a/mip_convert/mip_convert/plugins/base/data/processors.py +++ b/mip_convert/mip_convert/plugins/base/data/processors.py @@ -1172,6 +1172,11 @@ def calc_zostoga(thetao, thkcello, areacello, zfullo_0, so_0, rho_0_mean, deptho Intercomparison Project. Geoscientific Model Development, 9(9), pp.3231-3296. """ + # Ensure the vertical coordinate is named consistently before processing + for cube in [thetao, thkcello]: + if not cube.coords('depth'): + _z_axis(cube).rename('depth') + rho_mean = iris.cube.CubeList() so_0 = iris.util.squeeze(so_0) diff --git a/mip_convert/mip_convert/save/cmor/cmor_wrapper.py b/mip_convert/mip_convert/save/cmor/cmor_wrapper.py index 745edfdeb..56c5a6463 100644 --- a/mip_convert/mip_convert/save/cmor/cmor_wrapper.py +++ b/mip_convert/mip_convert/save/cmor/cmor_wrapper.py @@ -113,5 +113,5 @@ def zfactor(self, *args, **kwargs): cmor.zfactor(*args, **kwargs) def set_frequency(self, frequency, **kwargs): - self._debug_on_args('frequency', frequency, kwargs) + self._debug_on_args('frequency', [frequency], kwargs) cmor.cmor.set_cur_dataset_attribute('frequency', frequency) diff --git a/mip_convert/mip_convert/tests/test_functional/test_functional_cmip7/test_cmip7_mon_zostoga_tavg_u_hm_sea.py b/mip_convert/mip_convert/tests/test_functional/test_functional_cmip7/test_cmip7_mon_zostoga_tavg_u_hm_sea.py new file mode 100644 index 000000000..3a1bfbfab --- /dev/null +++ b/mip_convert/mip_convert/tests/test_functional/test_functional_cmip7/test_cmip7_mon_zostoga_tavg_u_hm_sea.py @@ -0,0 +1,64 @@ +# (C) British Crown Copyright 2026, Met Office. +# Please see LICENSE.md for license details. +import os + +import pytest + +from mip_convert.tests.test_functional.test_command_line import AbstractFunctionalTests +from mip_convert.tests.test_functional.utils.configurations import Cmip7TestData, SpecificInfo +from mip_convert.tests.test_functional.utils.directories import (ROOT_ANCIL_TESTING_DIR, get_cmor_log, get_output_dir, + MODEL_OUTPUT_DIR, + ROOT_OUTPUT_CASES_DIR) + + +class TestCmip7_zostoga_tavg_u_hm_sea(AbstractFunctionalTests): + + def get_test_data(self): + test_location = os.path.join(ROOT_OUTPUT_CASES_DIR, 'test_CMIP7_ocean_zostoga_tavg-u-hm-sea') + return Cmip7TestData( + mip_table='ocean', + variables=['zostoga_tavg-u-hm-sea'], + specific_info=SpecificInfo( + common={ + 'test_location': test_location + }, + cmor_setup={ + 'cmor_log_file': get_cmor_log(test_location), + }, + cmor_dataset={ + 'output_dir': get_output_dir(test_location), + 'model_id': 'UKCM2-0-LL', + 'parent_model_id': 'UKCM2-0-LL', + 'variant_label': 'r2i1p1f1', + 'calendar': 'standard', + 'branch_date_in_child': "1850-01-01T00:00:00", + 'branch_date_in_parent': "1850-01-01T00:00:00", + }, + request={ + 'ancil_files': ' '.join([ + os.path.join(ROOT_ANCIL_TESTING_DIR, 'UKCM2-0-LL', 'ocean_zostoga.nc'), + os.path.join(ROOT_ANCIL_TESTING_DIR, 'UKCM2-0-LL', 'ocean_constants.nc') + ]), + 'model_output_dir': MODEL_OUTPUT_DIR, + 'run_bounds': '1900-01-01T00:00:00 1900-02-01T00:00:00', + 'suite_id': 'u-dv623', + 'mip_convert_plugin': 'UKCM2' + }, + streams={ + 'onm': {'CMIP7_ocean@mon': 'zostoga_tavg-u-hm-sea'} + }, + halo_removal={ + 'onm': '1:-1,1:-1' + }, + other={ + 'reference_version': 'v1', + 'filenames': ['zostoga_tavg-u-hm-sea_mon_glb_g100_UKCM2-0-LL_1pctCO2_r2i1p1f1_190001-190001.nc'], + 'ignore_history': True, + } + ) + ) + + @pytest.mark.slow + def test_cmip7_mon_zostoga(self): + self.maxDiff = True + self.check_convert(plugin_id="CMIP7") diff --git a/mip_convert/mip_convert/tests/test_functional/utils/directories.py b/mip_convert/mip_convert/tests/test_functional/utils/directories.py index 50abbd82d..b041b9d92 100644 --- a/mip_convert/mip_convert/tests/test_functional/utils/directories.py +++ b/mip_convert/mip_convert/tests/test_functional/utils/directories.py @@ -12,6 +12,7 @@ TEST_DIR_NAME_TEMPLATE = 'test_{project}_{mip_table}_{variable}' ROOT_ANCIL_DIR = os.path.join(CDDS_ETC, 'ancil') +ROOT_ANCIL_TESTING_DIR = os.path.join(CDDS_ETC, 'ancil_testing') ROOT_MIP_TABLES_DIR = os.path.join(CDDS_ETC, 'mip_tables') CORDEX_MIP_TABLE_DIR = '{}/CORDEX/cordex-cmip6-cmor-tables/Tables'.format(ROOT_MIP_TABLES_DIR)