Skip to content

Commit

Permalink
Add standalone test for creating wave mesh from existing ocean mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrus89 committed Sep 6, 2024
1 parent 66bb5c9 commit acc78b6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
3 changes: 2 additions & 1 deletion compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def __init__(self, mpas_core):
# A test case for making E3SM support files from an existing mesh
self.add_test_case(FilesForE3SM(test_group=self))

# Create waves mesh
# Test cases for creating waves mesh
self.add_test_case(WaveMesh(test_group=self))
self._add_tests(mesh_names=['Icos'], include_wave_mesh=True)

def _add_tests(self, mesh_names, high_res_topography=True,
Expand Down
8 changes: 6 additions & 2 deletions compass/ocean/tests/global_ocean/wave_mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WaveMesh(TestCase):
Attributes
----------
"""
def __init__(self, test_group, ocean_mesh, ocean_init):
def __init__(self, test_group, ocean_mesh=None, ocean_init=None):
"""
Create test case for creating a global MPAS-Ocean mesh
Expand All @@ -38,7 +38,11 @@ def __init__(self, test_group, ocean_mesh, ocean_init):
"""
name = 'wave_mesh'
subdir = f'{ocean_mesh.mesh_name}/{name}'
if ocean_mesh is not None:
subdir = f'{ocean_mesh.mesh_name}/{name}'
else:
subdir = name

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

self.package = 'compass.ocean.tests.global_ocean.wave_mesh'
Expand Down
24 changes: 16 additions & 8 deletions compass/ocean/tests/global_ocean/wave_mesh/base_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,32 @@ def setup(self):
self.opts.init_file = 'init.msh'

# Set links to base mesh
if self.config.has_option('wave_mesh', 'ocean_base_mesh'):
ocean_base_mesh_path = self.config.get('wave_mesh',
'ocean_base_mesh')
else:
if self.ocean_base_mesh is not None:
mesh_path = self.ocean_base_mesh.steps['base_mesh'].path
ocean_base_mesh_path = f'{mesh_path}/base_mesh.nc'
else:
if self.config.has_option('wave_mesh', 'ocean_base_mesh'):
ocean_base_mesh_path = self.config.get('wave_mesh',
'ocean_base_mesh')
else:
raise ValueError('ocean_base_mesh option required '
'in wave_mesh section in cfg file')

self.add_input_file(
filename='ocean_base_mesh.nc',
work_dir_target=ocean_base_mesh_path)

# Set links to culled mesh
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
ocean_culled_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
if self.ocean_culled_mesh is not None:
mesh_path = self.ocean_culled_mesh.steps['initial_state'].path
ocean_culled_mesh_path = f'{mesh_path}/initial_state.nc'
else:
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
ocean_culled_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
raise ValueError('ocean_culled_mesh option required '
'in wave_mesh section in cfg file')

self.add_input_file(
filename='ocean_culled_mesh.nc',
Expand Down
12 changes: 8 additions & 4 deletions compass/ocean/tests/global_ocean/wave_mesh/cull_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ def setup(self):

super().setup()

if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
culled_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
if self.ocean_mesh is not None:
mesh_path = self.ocean_mesh.steps['initial_state'].path
culled_mesh_path = f'{mesh_path}/initial_state.nc'
else:
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
culled_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
raise ValueError('ocean_culled_mesh option required '
'in wave_mesh section in cfg file')

self.add_input_file(
filename='ocean_culled_mesh.nc',
Expand Down
12 changes: 8 additions & 4 deletions compass/ocean/tests/global_ocean/wave_mesh/scrip_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ def setup(self):

super().setup()

if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
ocean_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
if self.ocean_mesh is not None:
mesh_path = self.ocean_mesh.steps['initial_state'].path
ocean_mesh_path = f'{mesh_path}/initial_state.nc'
else:
if self.config.has_option('wave_mesh', 'ocean_culled_mesh'):
ocean_mesh_path = self.config.get('wave_mesh',
'ocean_culled_mesh')
else:
raise ValueError('ocean_culled_mesh option required '
'in wave_mesh section in cfg file')

self.add_input_file(
filename='ocean_mesh.nc',
Expand Down

0 comments on commit acc78b6

Please sign in to comment.