@@ -61,20 +61,21 @@ def __init__(self):
61
61
self ._dy = None
62
62
self ._umask = None
63
63
self ._vmask = None
64
+ self .grid_filename = None
65
+ self .grid_date = None
64
66
65
- @staticmethod
66
- def read_nc (varfile , varname , indices = slice (None )):
67
+ def read_nc (self , varname , indices = slice (None )):
67
68
"""
68
69
Read data from nectdf file
69
70
varname : variable ('temp', 'mask_rho', etc) to read
70
- indices : string of index ranges, eg. '[0,:,0]'
71
+ indices : slice
71
72
"""
72
- with Dataset (varfile ) as h_nc :
73
+ with Dataset (self . grid_filename ) as h_nc :
73
74
return h_nc .variables [varname ][:][indices ]
74
75
75
- @staticmethod
76
- def nc_variables (varfile ):
77
- with Dataset (varfile ) as h_nc :
76
+ @property
77
+ def nc_variables (self ):
78
+ with Dataset (self . grid_filename ) as h_nc :
78
79
return h_nc .variables .keys ()
79
80
80
81
@property
@@ -94,13 +95,13 @@ def view_unpad(self):
94
95
return (self .slice_j_unpad ,
95
96
self .slice_i_unpad )
96
97
97
- def read_nc_att (self , varfile , varname , att ):
98
+ def read_nc_att (self , varname , att ):
98
99
"""
99
100
Read data attribute from nectdf file
100
101
varname : variable ('temp', 'mask_rho', etc) to read
101
102
att : string of attribute, eg. 'valid_range'
102
103
"""
103
- with Dataset (varfile ) as h_nc :
104
+ with Dataset (self . grid_filename ) as h_nc :
104
105
return getattr (h_nc .variables [varname ], att )
105
106
106
107
@property
@@ -422,17 +423,10 @@ def set_interp_coeffs(self, sla, uspd):
422
423
"""
423
424
Won't work for rotated grid
424
425
"""
425
- if 'AVISO' in self .product :
426
- self .sla_coeffs = interpolate .RectBivariateSpline (
427
- self .lat [:, 0 ], self .lon [0 ], sla , kx = 1 , ky = 1 )
428
- self .uspd_coeffs = interpolate .RectBivariateSpline (
429
- self .lat [:, 0 ], self .lon [0 ], uspd , kx = 1 , ky = 1 )
430
- elif 'ROMS' in self .product :
431
- points = np .array ([self .lon .ravel (), self .lat .ravel ()]).T
432
- self .sla_coeffs = interpolate .CloughTocher2DInterpolator (
433
- points , sla .ravel ())
434
- self .uspd_coeffs = interpolate .CloughTocher2DInterpolator (
435
- points , uspd .ravel ())
426
+ self .sla_coeffs = interpolate .RectBivariateSpline (
427
+ self .lat [:, 0 ], self .lon [0 ], sla , kx = 1 , ky = 1 )
428
+ self .uspd_coeffs = interpolate .RectBivariateSpline (
429
+ self .lat [:, 0 ], self .lon [0 ], uspd , kx = 1 , ky = 1 )
436
430
return self
437
431
438
432
@staticmethod
0 commit comments