Skip to content

Commit

Permalink
Add a step for remapping topography from MALI
Browse files Browse the repository at this point in the history
MALI topogrpahy gets combined with BedMachine Antarctica/GEBCO.

For now, the masks for the grounding line, calving front, etc.
are form BedMachine, not MALI, so that the same horizontal mesh
and mapping files can be used with BedMachine and MALI topogrpahy.
  • Loading branch information
xylar committed Jun 10, 2024
1 parent 22fd694 commit d38268e
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 9 deletions.
7 changes: 5 additions & 2 deletions compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(self, mpas_core):
self._add_tests(mesh_names=['ARRM10to60', 'ARRMwISC10to60'])

self._add_tests(mesh_names=['SO12to30', 'SOwISC12to30'])
self._add_tests(mesh_names=['SOwISC12to30'],
mali_ais_topo='AIS_4to20km')

self._add_tests(mesh_names=['WC14', 'WCwISC14'])

Expand All @@ -65,15 +67,16 @@ def __init__(self, mpas_core):
def _add_tests(self, mesh_names, high_res_topography=True,
include_rk4=False,
include_regression=False, include_phc=False,
include_en4_1900=False):
include_en4_1900=False, mali_ais_topo=None):
""" Add test cases for the given mesh(es) """

default_ic = 'WOA23'
default_time_int = 'split_explicit_ab2'

for mesh_name in mesh_names:
mesh_test = Mesh(test_group=self, mesh_name=mesh_name,
high_res_topography=high_res_topography)
high_res_topography=high_res_topography,
mali_ais_topo=mali_ais_topo)
self.add_test_case(mesh_test)

init_test = Init(test_group=self, mesh=mesh_test,
Expand Down
3 changes: 1 addition & 2 deletions compass/ocean/tests/global_ocean/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def __init__(self, test_group, mesh, initial_condition):
The initial condition dataset to use
"""
name = 'init'
mesh_name = mesh.mesh_name
ic_dir = initial_condition
self.init_subdir = os.path.join(mesh_name, ic_dir)
self.init_subdir = os.path.join(mesh.mesh_subdir, ic_dir)
subdir = os.path.join(self.init_subdir, name)
super().__init__(test_group=test_group, name=name, subdir=subdir)

Expand Down
53 changes: 48 additions & 5 deletions compass/ocean/tests/global_ocean/mesh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from compass.mesh.spherical import (
IcosahedralMeshStep,
QuasiUniformSphericalMeshStep,
Expand All @@ -15,6 +17,9 @@
IcosMeshFromConfigStep,
QUMeshFromConfigStep,
)
from compass.ocean.tests.global_ocean.mesh.remap_mali_topography import (
RemapMaliTopography,
)
from compass.ocean.tests.global_ocean.mesh.rrs6to18 import RRS6to18BaseMesh
from compass.ocean.tests.global_ocean.mesh.so12to30 import SO12to30BaseMesh
from compass.ocean.tests.global_ocean.mesh.wc14 import WC14BaseMesh
Expand All @@ -31,6 +36,13 @@ class Mesh(TestCase):
Attributes
----------
mesh_name : str
The name of the mesh
mesh_subdir : str
The subdirectory within the test group for all test cases with this
mesh and topography
package : str
The python package for the mesh
Expand All @@ -43,8 +55,14 @@ class Mesh(TestCase):
high_res_topography : bool
Whether to remap a high resolution topography data set. A lower
res data set is used for low resolution meshes.
mali_ais_topo : str
Short name for the MALI dataset to use for Antarctic Ice Sheet
topography
"""
def __init__(self, test_group, mesh_name, high_res_topography):

def __init__(self, test_group, mesh_name, # noqa: C901
high_res_topography, mali_ais_topo=None):
"""
Create test case for creating a global MPAS-Ocean mesh
Expand All @@ -59,9 +77,20 @@ def __init__(self, test_group, mesh_name, high_res_topography):
high_res_topography : bool
Whether to remap a high resolution topography data set. A lower
res data set is used for low resolution meshes.
mali_ais_topo : str, optional
Short name for the MALI dataset to use for Antarctic Ice Sheet
topography
"""
name = 'mesh'
subdir = f'{mesh_name}/{name}'
if mali_ais_topo is None:
self.mesh_subdir = mesh_name
else:
self.mesh_subdir = os.path.join(mesh_name,
f'MALI_topo_{mali_ais_topo}')

subdir = os.path.join(self.mesh_subdir, name)

super().__init__(test_group=test_group, name=name, subdir=subdir)

with_ice_shelf_cavities = 'wISC' in mesh_name
Expand All @@ -75,6 +104,7 @@ def __init__(self, test_group, mesh_name, high_res_topography):
self.mesh_config_filename = f'{mesh_lower}.cfg'

self.mesh_name = mesh_name
self.mali_ais_topo = mali_ais_topo
self.with_ice_shelf_cavities = with_ice_shelf_cavities
self.high_res_topography = high_res_topography

Expand Down Expand Up @@ -117,9 +147,15 @@ def __init__(self, test_group, mesh_name, high_res_topography):

self.add_step(base_mesh_step)

remap_step = RemapTopography(test_case=self,
base_mesh_step=base_mesh_step,
mesh_name=mesh_name)
if mali_ais_topo is None:
remap_step = RemapTopography(test_case=self,
base_mesh_step=base_mesh_step,
mesh_name=mesh_name)
else:
remap_step = RemapMaliTopography(
test_case=self, base_mesh_step=base_mesh_step,
mesh_name=mesh_name, mali_ais_topo=mali_ais_topo)

self.add_step(remap_step)

self.add_step(CullMeshStep(
Expand All @@ -142,6 +178,13 @@ def configure(self, config=None):
config.add_from_package('compass.ocean.mesh',
'remap_topography.cfg', exception=True)

if self.mali_ais_topo is not None:
package = 'compass.ocean.tests.global_ocean.mesh.' \
'remap_mali_topography'
config.add_from_package(package,
f'{self.mali_ais_topo.lower()}.cfg',
exception=True)

if not self.high_res_topography:
filename = 'BedMachineAntarctica_v2_and_GEBCO_2022_0.05_degree_20220729.nc' # noqa: E501
description = 'Bathymetry is from GEBCO 2022, combined with ' \
Expand Down
Loading

0 comments on commit d38268e

Please sign in to comment.