Ejemplo n.º 1
0
 def _get_lon_slice(self, rlon=None):
     if rlon is None:
         lon_slice = slice(None)
     else:
         if not isinstance(rlon, tuple):
             raise ValueError("rlon must be a tuple")
         else:
             vlon1, vlon2 = rlon
             lon_index = mathex.ndarray_get_index_by_interval(
                 self.lon, (vlon1, vlon2))[0]
             begin = np.min(lon_index)
             end = np.max(lon_index)
             lon_slice = slice(begin, end + 1)
     return lon_slice
Ejemplo n.º 2
0
 def _get_lat_slice(self, rlat=None):
     if rlat is None:
         lat_slice = slice(None)
     else:
         if not isinstance(rlat, tuple):
             raise ValueError("rlat must be a tuple")
         else:
             vlat1, vlat2 = rlat
             lat_index = mathex.ndarray_get_index_by_interval(
                 self.lat, (vlat1, vlat2))[0]
             begin = np.min(lat_index)
             end = np.max(lat_index)
             lat_slice = slice(begin, end + 1)
     return lat_slice
Ejemplo n.º 3
0
    def _get_time_slice(self, time=None):
        if time is None:
            time_slice = slice(None)
        else:
            if not isinstance(time, tuple):
                raise ValueError("time slice must be a tuple")
            else:
                if isinstance(self.taxis, np.ndarray):
                    time_index = mathex.ndarray_get_index_by_interval(
                        self.taxis, (time[0], time[1]))[0]
                    begin = np.min(time_index)
                    end = np.max(time_index)
                    time_slice = slice(begin, end + 1)

                elif isinstance(self.taxis, pa.DatetimeIndex):
                    begin = self.taxis.get_loc(time[0])
                    end = self.taxis.get_loc(time[1])
                    time_slice = slice(begin, end + 1)
                else:
                    raise TypeError("time axis type error.")
        return time_slice