コード例 #1
0
ファイル: dataset.py プロジェクト: blazetopher/paegan
 def sub_coords(self, var, zbounds=None, bbox=None,
     timebounds=None, zinds=None, timeinds=None):
     assert var in self._current_variables
     coord_dict = self.get_coord_dict(var)
     names = self.get_coord_names(var)
     x, y, z, time = None, None, None, None
     if names['tname'] != None:
         #tname = names['tname']
         if timebounds != None:
             timeinds = self.get_tind_from_bounds(var, timebounds)
         time = coord_dict['time'][timeinds[0]:timeinds[-1]+1]
     if names['zname'] != None:
         #zname = names['zname']
         if zbounds != None:
             zinds = self.get_zind_from_bounds(var, zbounds)
         z = coord_dict['z'][zinds[0]:zinds[-1]+1]
     xinds, yinds = self.get_xyind_from_bbox(var, bbox)
     xy = coord_dict['xy']
     if names['xname'] != None:
         #xname = names['xname']
         if len(xy._xarray.shape) == 2:
             x = xy._xarray[xinds[0][0]:xinds[0][-1]+1, xinds[1][0]:xinds[1][-1]+1]
         elif len(xy.xarray.shape) == 1:
             x = xy._xarray[np.squeeze(xinds)]
     if names['yname'] != None:
         #yname = names['yname']
         if len(xy._yarray.shape) == 2:
             y = xy._yarray[yinds[0][0]:yinds[0][-1]+1, yinds[1][0]:yinds[1][-1]+1]
         elif len(xy.yarray.shape) == 1:
             y = xy._yarray[np.squeeze(yinds)]
     return subs(x=x, y=y, z=z, time=time)
コード例 #2
0
ファイル: dataset.py プロジェクト: ocefpaf/paegan
 def sub_coords(self, var, zbounds=None, bbox=None, timebounds=None, zinds=None, timeinds=None):
     assert var in self._current_variables
     ncvar = self.nc.variables[var]
     coord_dict = self.get_coord_dict(var)
     names = self.get_coord_names(var)
     dims = ncvar.dimensions
     x, y, z, time = None, None, None, None
     positions = dict()
     for i in names:
         name = names[i]
         if i == "tname":
             common_name = "time"
         elif i == "zname":
             common_name = "z"
         elif i == "xname":
             common_name = "x"
         elif i == "yname":
             common_name = "y"
         else:
             common_name = None
         if common_name is not None:
             positions[common_name] = None
             if name is not None:
                 positions[common_name] = []
                 cdims = self.nc.variables[name].dimensions
                 for cdim in cdims:
                     try:
                         positions[common_name].append(dims.index(cdim))
                     except Exception:
                         pass
     if names['tname'] is not None:
         #tname = names['tname']
         if timebounds is not None:
             timeinds = self.get_tind_from_bounds(var, timebounds)[0]
         elif timeinds is None:
             timeinds = np.arange(0, ncvar.shape[positions["time"][0]]+1)
         time = coord_dict['time'][timeinds[0]:timeinds[-1]+1]
     if names['zname'] is not None:
         #zname = names['zname']
         if zbounds is not None:
             zinds = self.get_zind_from_bounds(var, zbounds)[0]
         elif zinds is None:
             zinds = np.arange(0, ncvar.shape[positions["z"][0]]+1)
         z = coord_dict['z'][zinds[0]:zinds[-1]+1]
     xinds, yinds = self.get_xyind_from_bbox(var, bbox)
     xy = coord_dict['xy']
     if names['xname'] is not None:
         #xname = names['xname']
         if len(xy._xarray.shape) == 2:
             x = xy._xarray[xinds[0][0]:xinds[0][-1]+1, xinds[1][0]:xinds[1][-1]+1]
         elif len(xy._xarray.shape) == 1:
             x = xy._xarray[np.squeeze(xinds)]
     if names['yname'] is not None:
         #yname = names['yname']
         if len(xy._yarray.shape) == 2:
             y = xy._yarray[yinds[0][0]:yinds[0][-1]+1, yinds[1][0]:yinds[1][-1]+1]
         elif len(xy._yarray.shape) == 1:
             y = xy._yarray[np.squeeze(yinds)]
     return subs(x=x, y=y, z=z, time=time)
コード例 #3
0
ファイル: dataset.py プロジェクト: blazetopher/paegan
 def sub_coords(self,
                var,
                zbounds=None,
                bbox=None,
                timebounds=None,
                zinds=None,
                timeinds=None):
     assert var in self._current_variables
     coord_dict = self.get_coord_dict(var)
     names = self.get_coord_names(var)
     x, y, z, time = None, None, None, None
     if names['tname'] != None:
         #tname = names['tname']
         if timebounds != None:
             timeinds = self.get_tind_from_bounds(var, timebounds)
         time = coord_dict['time'][timeinds[0]:timeinds[-1] + 1]
     if names['zname'] != None:
         #zname = names['zname']
         if zbounds != None:
             zinds = self.get_zind_from_bounds(var, zbounds)
         z = coord_dict['z'][zinds[0]:zinds[-1] + 1]
     xinds, yinds = self.get_xyind_from_bbox(var, bbox)
     xy = coord_dict['xy']
     if names['xname'] != None:
         #xname = names['xname']
         if len(xy._xarray.shape) == 2:
             x = xy._xarray[xinds[0][0]:xinds[0][-1] + 1,
                            xinds[1][0]:xinds[1][-1] + 1]
         elif len(xy.xarray.shape) == 1:
             x = xy._xarray[np.squeeze(xinds)]
     if names['yname'] != None:
         #yname = names['yname']
         if len(xy._yarray.shape) == 2:
             y = xy._yarray[yinds[0][0]:yinds[0][-1] + 1,
                            yinds[1][0]:yinds[1][-1] + 1]
         elif len(xy.yarray.shape) == 1:
             y = xy._yarray[np.squeeze(yinds)]
     return subs(x=x, y=y, z=z, time=time)