Skip to content

Commit

Permalink
Add remapping ice shelf melt to files_for_e3sm
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Apr 29, 2023
1 parent e4dcc88 commit fc473c9
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 12 deletions.
26 changes: 16 additions & 10 deletions compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ def _add_tests(self, mesh_names, DynamicAdjustment, remap_topography=True,
time_integrator=time_integrator))

if mesh_test.with_ice_shelf_cavities:
self.add_test_case(
DataIceShelfMelt(
test_group=self, mesh=mesh_test, init=init_test,
time_integrator=time_integrator))
data_melt_test = DataIceShelfMelt(
test_group=self, mesh=mesh_test, init=init_test,
time_integrator=time_integrator)
self.add_test_case(data_melt_test)
else:
data_melt_test = None

dynamic_adjustment_test = DynamicAdjustment(
test_group=self, mesh=mesh_test, init=init_test,
Expand All @@ -143,7 +145,8 @@ def _add_tests(self, mesh_names, DynamicAdjustment, remap_topography=True,
self.add_test_case(
FilesForE3SM(
test_group=self, mesh=mesh_test, init=init_test,
dynamic_adjustment=dynamic_adjustment_test))
dynamic_adjustment=dynamic_adjustment_test,
data_ice_shelf_melt=data_melt_test))

if include_rk4:
time_integrator = 'RK4'
Expand Down Expand Up @@ -184,10 +187,12 @@ def _add_tests(self, mesh_names, DynamicAdjustment, remap_topography=True,
time_integrator=time_integrator))

if mesh_test.with_ice_shelf_cavities:
self.add_test_case(
DataIceShelfMelt(
test_group=self, mesh=mesh_test, init=init_test,
time_integrator=time_integrator))
data_melt_test = DataIceShelfMelt(
test_group=self, mesh=mesh_test, init=init_test,
time_integrator=time_integrator)
self.add_test_case(data_melt_test)
else:
data_melt_test = None

dynamic_adjustment_test = DynamicAdjustment(
test_group=self, mesh=mesh_test, init=init_test,
Expand All @@ -197,7 +202,8 @@ def _add_tests(self, mesh_names, DynamicAdjustment, remap_topography=True,
self.add_test_case(
FilesForE3SM(
test_group=self, mesh=mesh_test, init=init_test,
dynamic_adjustment=dynamic_adjustment_test))
dynamic_adjustment=dynamic_adjustment_test,
data_ice_shelf_melt=data_melt_test))

if include_bgc:
# BGC tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
config_check_ssh_consistency = .false.
config_land_ice_flux_mode = 'prescribed'
config_land_ice_flux_mode = 'data'
16 changes: 15 additions & 1 deletion compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_mesh import ( # noqa: E501
OceanMesh,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.remap_ice_shelf_melt import ( # noqa: E501
RemapIceShelfMelt,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.scrip import Scrip
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_graph_partition import ( # noqa: E501
SeaiceGraphPartition,
Expand Down Expand Up @@ -50,9 +53,12 @@ class FilesForE3SM(TestCase):
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
data_ice_shelf_melt : compass.ocean.tests.global_ocean.data_ice_shelf_melt.DataIceShelfMelt
A test case for remapping observed melt rates to the MPAS grid
""" # noqa: E501
def __init__(self, test_group, mesh=None, init=None,
dynamic_adjustment=None):
dynamic_adjustment=None, data_ice_shelf_melt=None):
"""
Create test case for creating a global MPAS-Ocean mesh
Expand All @@ -70,6 +76,9 @@ def __init__(self, test_group, mesh=None, init=None,
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment, optional
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
data_ice_shelf_melt : compass.ocean.tests.global_ocean.data_ice_shelf_melt.DataIceShelfMelt, optional
A test case for remapping observed melt rates to the MPAS grid
""" # noqa: E501
name = 'files_for_e3sm'
if dynamic_adjustment is not None:
Expand All @@ -83,6 +92,7 @@ def __init__(self, test_group, mesh=None, init=None,
self.mesh = mesh
self.init = init
self.dynamic_adjustment = dynamic_adjustment
self.data_ice_shelf_melt = data_ice_shelf_melt

# add metadata if we're running this on an existing mesh
add_metadata = (dynamic_adjustment is None)
Expand All @@ -98,6 +108,10 @@ def __init__(self, test_group, mesh=None, init=None,
self.add_step(DiagnosticMaps(test_case=self))
self.add_step(DiagnosticMasks(test_case=self))

self.add_step(RemapIceShelfMelt(
test_case=self,
data_ice_shelf_melt=data_ice_shelf_melt))

def configure(self):
"""
Modify the configuration options for this test case
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import os

from compass.io import symlink
from compass.ocean.tests.global_ocean.data_ice_shelf_melt.remap_ice_shelf_melt import ( # noqa: E501
remap_adusumilli,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class RemapIceShelfMelt(FilesForE3SMStep):
"""
A step for for remapping observed melt rates to the MPAS grid and staging
them in ``assembled_files``
Attributes
----------
data_ice_shelf_melt : compass.ocean.tests.global_ocean.data_ice_shelf_melt.DataIceShelfMelt
A test case where remapping has already occurred
""" # noqa: E501
def __init__(self, test_case, data_ice_shelf_melt):
"""
Create a new step
Parameters
----------
test_case : compass.TestCase
The test case this step belongs to
data_ice_shelf_melt : compass.ocean.tests.global_ocean.data_ice_shelf_melt.DataIceShelfMelt
A test case where remapping has already occurred
""" # noqa: E501
super().__init__(test_case, name='remap_ice_shelf_melt', ntasks=512,
min_tasks=1)
self.data_ice_shelf_melt = data_ice_shelf_melt
filename = 'prescribed_ismf_adusumilli2020.nc'
if data_ice_shelf_melt is None:
self.add_input_file(
filename='Adusumilli_2020_iceshelf_melt_rates_2010-2018_v0.h5',
target='Adusumilli_2020_iceshelf_melt_rates_2010-2018_v0.h5',
database='initial_condition_database',
url='http://library.ucsd.edu/dc/object/bb0448974g/_3_1.h5')

self.add_output_file(filename=filename)
else:
melt_path = \
data_ice_shelf_melt.steps['remap_ice_shelf_melt'].path

self.add_input_file(
filename=filename,
work_dir_target=f'{melt_path}/{filename}')

def run(self):
"""
Run this step of the test case
"""
super().run()

data_ice_shelf_melt = self.data_ice_shelf_melt

prefix = 'prescribed_ismf_adusumilli2020'
suffix = f'{self.mesh_short_name}.{self.creation_date}'

remapped_filename = f'{prefix}.nc'
dest_filename = f'{prefix}.{suffix}.nc'

if data_ice_shelf_melt is None:
logger = self.logger
config = self.config
ntasks = self.ntasks
in_filename = 'Adusumilli_2020_iceshelf_melt_rates_2010-2018_v0.h5'

parallel_executable = config.get('parallel', 'parallel_executable')

mesh_filename = 'initial_state.nc'
mesh_name = self.mesh_short_name
land_ice_mask_filename = 'initial_state.nc'

remap_adusumilli(in_filename, mesh_filename, mesh_name,
land_ice_mask_filename, remapped_filename,
logger=logger, mpi_tasks=ntasks,
parallel_executable=parallel_executable)

symlink(
os.path.abspath(remapped_filename),
f'{self.ocean_inputdata_dir}/{dest_filename}')

0 comments on commit fc473c9

Please sign in to comment.