@@ -61,20 +61,21 @@ def __init__(self):
6161 self ._dy = None
6262 self ._umask = None
6363 self ._vmask = None
64+ self .grid_filename = None
65+ self .grid_date = None
6466
65- @staticmethod
66- def read_nc (varfile , varname , indices = slice (None )):
67+ def read_nc (self , varname , indices = slice (None )):
6768 """
6869 Read data from nectdf file
6970 varname : variable ('temp', 'mask_rho', etc) to read
70- indices : string of index ranges, eg. '[0,:,0]'
71+ indices : slice
7172 """
72- with Dataset (varfile ) as h_nc :
73+ with Dataset (self . grid_filename ) as h_nc :
7374 return h_nc .variables [varname ][:][indices ]
7475
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 :
7879 return h_nc .variables .keys ()
7980
8081 @property
@@ -94,13 +95,13 @@ def view_unpad(self):
9495 return (self .slice_j_unpad ,
9596 self .slice_i_unpad )
9697
97- def read_nc_att (self , varfile , varname , att ):
98+ def read_nc_att (self , varname , att ):
9899 """
99100 Read data attribute from nectdf file
100101 varname : variable ('temp', 'mask_rho', etc) to read
101102 att : string of attribute, eg. 'valid_range'
102103 """
103- with Dataset (varfile ) as h_nc :
104+ with Dataset (self . grid_filename ) as h_nc :
104105 return getattr (h_nc .variables [varname ], att )
105106
106107 @property
@@ -422,17 +423,10 @@ def set_interp_coeffs(self, sla, uspd):
422423 """
423424 Won't work for rotated grid
424425 """
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 )
436430 return self
437431
438432 @staticmethod
0 commit comments