-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgodas_grid.py
More file actions
33 lines (23 loc) · 858 Bytes
/
godas_grid.py
File metadata and controls
33 lines (23 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import netCDF4 as nc
from .grid import Grid
class GodasGrid(Grid):
def __init__(self, grid_def, description=''):
with nc.Dataset(grid_def) as f:
# Select points from double density horizontal grid. Only
# need t-points.
x_t = f.variables['lon'][:]
y_t = f.variables['lat'][:]
try:
z = f.variables['level'][:]
except KeyError:
z = f.variables['depth'][:]
try:
mask = f.variables['pottmp'][0, :].mask[:]
except KeyError:
mask = f.variables['POT'][0, :].mask[:]
super(GodasGrid, self).__init__(x_t, y_t, z, mask, description)
def set_mask(self, new_mask):
self.mask = new_mask[:]