from compass.mesh.spherical import (
IcosahedralMeshStep,
QuasiUniformSphericalMeshStep,
)
from compass.ocean.mesh.cull import CullMeshStep
from compass.ocean.mesh.remap_topography import RemapTopography
from compass.ocean.tests.global_ocean.mesh.arrm10to60 import ARRM10to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.ec30to60 import EC30to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.fris01to60 import FRIS01to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.fris02to60 import FRIS02to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.fris04to60 import FRIS04to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.fris08to60 import FRIS08to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.kuroshio import KuroshioBaseMesh
from compass.ocean.tests.global_ocean.mesh.qu import (
IcosMeshFromConfigStep,
QUMeshFromConfigStep,
)
from compass.ocean.tests.global_ocean.mesh.rrs6to18 import RRS6to18BaseMesh
from compass.ocean.tests.global_ocean.mesh.so12to60 import SO12to60BaseMesh
from compass.ocean.tests.global_ocean.mesh.wc14 import WC14BaseMesh
from compass.ocean.tests.global_ocean.metadata import (
get_author_and_email_from_git,
)
from compass.testcase import TestCase
from compass.validate import compare_variables
[docs]
class Mesh(TestCase):
"""
A test case for creating a global MPAS-Ocean mesh
Attributes
----------
package : str
The python package for the mesh
mesh_config_filename : str
The name of the mesh config file
with_ice_shelf_cavities : bool
Whether the mesh includes ice-shelf cavities
high_res_topography : bool
Whether to remap a high resolution topography data set. A lower
res data set is used for low resolution meshes.
"""
[docs]
def __init__(self, test_group, mesh_name, high_res_topography):
"""
Create test case for creating a global MPAS-Ocean mesh
Parameters
----------
test_group : compass.ocean.tests.global_ocean.GlobalOcean
The global ocean test group that this test case belongs to
mesh_name : str
The name of the mesh
high_res_topography : bool
Whether to remap a high resolution topography data set. A lower
res data set is used for low resolution meshes.
"""
name = 'mesh'
subdir = f'{mesh_name}/{name}'
super().__init__(test_group=test_group, name=name, subdir=subdir)
with_ice_shelf_cavities = 'wISC' in mesh_name
mesh_lower = mesh_name.lower()
if with_ice_shelf_cavities:
mesh_lower = mesh_lower.replace('wisc', '')
if 'icos' in mesh_lower:
mesh_lower = mesh_lower.replace('icos', 'qu')
self.package = f'compass.ocean.tests.global_ocean.mesh.{mesh_lower}'
self.mesh_config_filename = f'{mesh_lower}.cfg'
self.mesh_name = mesh_name
self.with_ice_shelf_cavities = with_ice_shelf_cavities
self.high_res_topography = high_res_topography
name = 'base_mesh'
subdir = None
if mesh_name in ['Icos240', 'IcoswISC240']:
base_mesh_step = IcosahedralMeshStep(
self, name=name, subdir=subdir, cell_width=240)
elif mesh_name in ['QU240', 'QUwISC240']:
base_mesh_step = QuasiUniformSphericalMeshStep(
self, name=name, subdir=subdir, cell_width=240)
elif mesh_name in ['Icos', 'IcoswISC']:
base_mesh_step = IcosMeshFromConfigStep(
self, name=name, subdir=subdir)
elif mesh_name in ['QU', 'QUwISC']:
base_mesh_step = QUMeshFromConfigStep(
self, name=name, subdir=subdir)
elif mesh_name in ['EC30to60', 'ECwISC30to60']:
base_mesh_step = EC30to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['ARRM10to60', 'ARRMwISC10to60']:
base_mesh_step = ARRM10to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['RRS6to18', 'RRSwISC6to18']:
base_mesh_step = RRS6to18BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['SO12to60', 'SOwISC12to60']:
base_mesh_step = SO12to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['FRIS01to60', 'FRISwISC01to60']:
base_mesh_step = FRIS01to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['FRIS02to60', 'FRISwISC02to60']:
base_mesh_step = FRIS02to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['FRIS04to60', 'FRISwISC04to60']:
base_mesh_step = FRIS04to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['FRIS08to60', 'FRISwISC08to60']:
base_mesh_step = FRIS08to60BaseMesh(self, name=name, subdir=subdir)
elif mesh_name.startswith('Kuroshio'):
base_mesh_step = KuroshioBaseMesh(self, name=name, subdir=subdir)
elif mesh_name in ['WC14', 'WCwISC14']:
base_mesh_step = WC14BaseMesh(self, name=name, subdir=subdir)
else:
raise ValueError(f'Unknown mesh name {mesh_name}')
self.add_step(base_mesh_step)
remap_step = RemapTopography(test_case=self,
base_mesh_step=base_mesh_step,
mesh_name=mesh_name)
self.add_step(remap_step)
self.add_step(CullMeshStep(
test_case=self, base_mesh_step=base_mesh_step,
with_ice_shelf_cavities=self.with_ice_shelf_cavities,
remap_topography=remap_step))
def validate(self):
"""
Test cases can override this method to perform validation of variables
and timers
"""
variables = ['xCell', 'yCell', 'zCell']
compare_variables(test_case=self, variables=variables,
filename1='cull_mesh/culled_mesh.nc')
def get_cull_mesh_path(self):
"""
Get the path of the cull mesh step (for input files)
Returns
-------
cull_mesh_path : str
The path to the work directory of the cull mesh step.
"""
return self.steps['cull_mesh'].path