-
Notifications
You must be signed in to change notification settings - Fork 40
Add inactive top cell global ocean test case #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dadeb44
1da84c9
83233de
c059ee5
5d7e757
c7a8094
95e0ca2
c75a01b
98061df
ba3b04a
0bcab9a
2a15e8f
2a41fe5
84aef87
8308c57
c123941
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
|
||
import xarray | ||
from mpas_tools.io import write_netcdf | ||
|
||
|
||
def remove_inactive_top_cells_output(in_filename, out_filename=None, | ||
mesh_filename=None): | ||
""" | ||
Remove inactive top cells from the output netCDF file | ||
|
||
Parameters | ||
---------- | ||
in_filename : str | ||
Filename for the netCDF file to be cropped | ||
|
||
out_filename : str, optional | ||
Filename for the netCDF file after cropping. Tbe default name is the | ||
original file name with ``_crop`` appended before the extension | ||
|
||
mesh_filename : str, optional | ||
Filename for an MPAS mesh if not included in the file to be cropped | ||
|
||
""" | ||
if not os.path.exists(in_filename): | ||
raise OSError(f'File {in_filename} does not exist.') | ||
|
||
if out_filename is None: | ||
basename, ext = os.path.splitext(in_filename) | ||
out_filename = f'{basename}_crop{ext}' | ||
|
||
with xarray.open_dataset(in_filename) as ds_in: | ||
if mesh_filename is None: | ||
ds_mesh = ds_in | ||
else: | ||
ds_mesh = xarray.open_dataset(mesh_filename) | ||
minLevelCell = ds_mesh.minLevelCell | ||
minval = minLevelCell.min().values | ||
maxval = minLevelCell.max().values | ||
if minval != maxval: | ||
raise ValueError('Expected minLevelCell to have a constant ' | ||
'value for inactive top cell tests') | ||
ds_out = ds_in.isel(nVertLevels=slice(minval - 1, None)) | ||
|
||
write_netcdf(ds_out, out_filename) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ocean/global_ocean/QU240/mesh | ||
ocean/global_ocean/QU240/WOA23/init | ||
ocean/global_ocean/QU240/WOA23/init_inactive_top | ||
ocean/global_ocean/QU240/WOA23/performance_test | ||
ocean/global_ocean/QU240/WOA23/performance_test_inactive_top | ||
ocean/global_ocean/QU240/WOA23/RK4/performance_test | ||
ocean/global_ocean/QU240/WOA23/RK4/performance_test_inactive_top |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Options related to the vertical grid | ||
[vertical_grid] | ||
|
||
# no inactive top cells by default | ||
inactive_top_cells = 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ min_layer_thickness = 3.0 | |
# The maximum layer thickness | ||
max_layer_thickness = 500.0 | ||
|
||
# Number of inactive top cell layers | ||
inactive_top_cells = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be the default for all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this more, it seems like it only belongs in |
||
|
||
|
||
# options for spherical meshes | ||
[spherical_mesh] | ||
|
Uh oh!
There was an error while loading. Please reload this page.