Skip to content

Commit

Permalink
Merge pull request #2 from aidanheerdegen/master
Browse files Browse the repository at this point in the history
Removed requirement for mask file with MOM output
  • Loading branch information
nichannah authored Oct 6, 2017
2 parents be42675 + 863229d commit 70d1dce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
9 changes: 6 additions & 3 deletions mom_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ def __init__(self, h_grid_def, v_grid_def, mask_file, description):
# Only take cell centres.
z = f.variables['zeta'][1::2]

with nc.Dataset(mask_file) as f:
mask = np.zeros_like(f.variables['mask'], dtype=bool)
mask[f.variables['mask'][:] == 0.0] = True
if mask_file is None:
mask = np.zeros_like(x_t, dtype=bool)
else:
with nc.Dataset(mask_file) as f:
mask = np.zeros_like(f.variables['mask'], dtype=bool)
mask[f.variables['mask'][:] == 0.0] = True

super(MomGrid, self).__init__(x_t, y_t, z, mask, description)

Expand Down
7 changes: 0 additions & 7 deletions regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,6 @@ def do_regridding(src_name, src_hgrids, src_vgrid, src_data_file, src_var,

temp_or_salt = is_var_temp_or_salt(src_var, dest_var)

# Destination grid
if 'MOM' in dest_name:
if dest_mask is None:
print('\n Error: please provide a --dest_mask when regridding to MOM.\n',
file=sys.stderr)
return None

if dest_name == 'MOM':
title = 'MOM tripolar 0.25 degree t-cell grid'
dest_grid = MomGrid(dest_hgrid, dest_vgrid, dest_mask, title)
Expand Down
4 changes: 2 additions & 2 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def create_mom_output(ocean_grid, filename, start_date, history):
zt = f.createVariable('ZT', 'f8', ('ZT'))
zt.long_name = 'zt'
zt.units = 'meters'
zt.positive = 'downdown'
zt.positive = 'down'
zt.point_spacing = 'uneven'
zt.axis = 'Z'
zt[:] = ocean_grid.z[:]
Expand All @@ -134,7 +134,7 @@ def write_mom_output_at_time(filename, var_name, var_longname, var_units,
if not var_name in f.variables:
var = f.createVariable(var_name, 'f8',
('time', 'ZT', 'GRID_Y_T', 'GRID_X_T'),
fill_value=-1.e+34)
fill_value=-1.e+34, zlib=True, complevel=5, shuffle=True)
var.missing_value = -1.e+34
var.long_name = var_longname
var.units = var_units
Expand Down

0 comments on commit 70d1dce

Please sign in to comment.