From 19595301bc7950bcfca6d6ea5aa758a16a7deb9b Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Mon, 8 Jul 2024 07:23:40 -0500 Subject: [PATCH] Handle MALI IC without attributes Move ocean_density and sea_level to config options --- .../mesh/remap_mali_topography/__init__.py | 17 +++-------------- .../mesh/remap_mali_topography/ais_2to10km.cfg | 10 ++++++++++ .../mesh/remap_mali_topography/ais_4to20km.cfg | 10 ++++++++++ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/__init__.py b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/__init__.py index 6bf7ceb88..80d1b3c2a 100644 --- a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/__init__.py +++ b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/__init__.py @@ -109,28 +109,17 @@ def _remap_mali_topo(self): thickness = ds_mali.thickness ice_density = config.getfloat('remap_topography', 'ice_density') - - mali_ice_density = ds_mali.attrs['config_ice_density'] - mali_ocean_density = ds_mali.attrs['config_ocean_density'] - sea_level = ds_mali.attrs['config_sea_level'] + ocean_density = config.getfloat('remap_topography', 'ocean_density') + sea_level = config.getfloat('remap_topography', 'sea_level') g = constants['SHR_CONST_G'] - ocean_density = constants['SHR_CONST_RHOSW'] - - if ice_density != mali_ice_density: - raise ValueError('Ice density from the config option in ' - '[remap_topography] does not match the value ' - 'from MALI config_ice_density') - if ocean_density != mali_ocean_density: - logger.warn('\nWARNING: Ocean density from SHR_CONST_RHOSW does ' - 'not match the value from MALI config_ocean_density\n') draft = - (ice_density / ocean_density) * thickness ice_mask = ds_mali.thickness > 0 floating_mask = np.logical_and( ice_mask, - ice_density / mali_ocean_density * thickness <= sea_level - bed) + ice_density / ocean_density * thickness <= sea_level - bed) grounded_mask = np.logical_and(ice_mask, np.logical_not(floating_mask)) ocean_mask = np.logical_and(np.logical_not(grounded_mask), bed < sea_level) diff --git a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_2to10km.cfg b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_2to10km.cfg index cc0d81f95..c6e62d22b 100644 --- a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_2to10km.cfg +++ b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_2to10km.cfg @@ -1,3 +1,13 @@ +# config options related to remapping topography to an MPAS-Ocean mesh +[remap_topography] + +# the density of ocean water (kg/m^3), equivalent to config_ocean_density in MALI +ocean_density = 1028.0 + +# the elevation of sea level, equivalent to config_sea_level in MALI +sea_level = 0.0 + + # config options related to remapping MALI topography to an MPAS-Ocean mesh [remap_mali_topography] diff --git a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_4to20km.cfg b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_4to20km.cfg index e85b4a0ea..5294391e8 100644 --- a/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_4to20km.cfg +++ b/compass/ocean/tests/global_ocean/mesh/remap_mali_topography/ais_4to20km.cfg @@ -1,3 +1,13 @@ +# config options related to remapping topography to an MPAS-Ocean mesh +[remap_topography] + +# the density of ocean water (kg/m^3), equivalent to config_ocean_density in MALI +ocean_density = 1028.0 + +# the elevation of sea level, equivalent to config_sea_level in MALI +sea_level = 0.0 + + # config options related to remapping MALI topography to an MPAS-Ocean mesh [remap_mali_topography]