def __init__(self, h_grid_def, v_grid_def, mask_file, description):
with nc.Dataset(h_grid_def) as f:
# Select points from double density horizontal grid. Only
# need t-points.
x_t = f.variables['x'][1::2,1::2]
y_t = f.variables['y'][1::2,1::2]
self.x_vt = f.variables['x'][:]
self.y_vt = f.variables['y'][:]
with nc.Dataset(v_grid_def) as f:
# Only take cell centres.
z = f.variables['zeta'][1::2]
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)
评论列表
文章目录