-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This involves breaking the `initial_state` step into 4 steps: * convert base mesh * compute initial condition (including land mask) on base mesh * cull mesh * compute initial condition on culled mesh
- Loading branch information
Showing
6 changed files
with
166 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import xarray | ||
|
||
from mpas_tools.io import write_netcdf | ||
from mpas_tools.mesh.conversion import convert | ||
|
||
from compass.step import Step | ||
|
||
|
||
class BaseMesh(Step): | ||
""" | ||
A step for converting a base mesh to MPAS format for SOMA test cases | ||
Attributes | ||
---------- | ||
resolution : str | ||
The resolution of the test case | ||
""" | ||
|
||
def __init__(self, test_case, resolution): | ||
""" | ||
Create the step | ||
Parameters | ||
---------- | ||
test_case : compass.TestCase | ||
The test case this step belongs to | ||
resolution : str | ||
The resolution of the test case | ||
""" | ||
self.resolution = resolution | ||
|
||
super().__init__(test_case=test_case, name='base_mesh') | ||
|
||
mesh_filenames = {'32km': 'SOMA_32km_grid.161202.nc', | ||
'16km': 'SOMA_16km_grid.161202.nc', | ||
'8km': 'SOMA_8km_grid.161202.nc', | ||
'4km': 'SOMA_4km_grid.161202.nc'} | ||
if resolution not in mesh_filenames: | ||
raise ValueError(f'Unexpected SOMA resolution: {resolution}') | ||
|
||
self.add_input_file(filename='base_mesh.nc', | ||
target=mesh_filenames[resolution], | ||
database='mesh_database') | ||
|
||
for file in ['mesh.nc', 'base_graph.info']: | ||
self.add_output_file(filename=file) | ||
|
||
def run(self): | ||
""" | ||
Convert the base mesh to MPAS format | ||
""" | ||
ds_mesh = convert(xarray.open_dataset('base_mesh.nc'), | ||
graphInfoFileName='base_graph.info', | ||
logger=self.logger) | ||
write_netcdf(ds_mesh, 'mesh.nc') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import xarray | ||
|
||
from mpas_tools.io import write_netcdf | ||
from mpas_tools.mesh.conversion import cull | ||
|
||
from compass.step import Step | ||
|
||
|
||
class CulledMesh(Step): | ||
""" | ||
A step for culling the base mesh for SOMA test cases | ||
""" | ||
|
||
def __init__(self, test_case): | ||
""" | ||
Create the step | ||
Parameters | ||
---------- | ||
test_case : compass.TestCase | ||
The test case this step belongs to | ||
""" | ||
super().__init__(test_case=test_case, name='culled_mesh') | ||
|
||
self.add_input_file(filename='masked_initial_state.nc', | ||
target='../init_on_base_mesh/initial_state.nc') | ||
|
||
for file in ['culled_mesh.nc', 'culled_graph.info']: | ||
self.add_output_file(filename=file) | ||
|
||
def run(self): | ||
""" | ||
Run this step of the test case | ||
""" | ||
ds_mesh = cull(xarray.open_dataset('masked_initial_state.nc'), | ||
graphInfoFileName='culled_graph.info', | ||
logger=self.logger) | ||
write_netcdf(ds_mesh, 'culled_mesh.nc') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters