示例#1
0
文件: io.py 项目: zjuas2016/PyCINRAD
    def get_data(self, tilt:int, drange:Number_T, dtype:str) -> Radial:
        r'''
        Get radar data

        Parameters
        ----------
        tilt: int
            index of elevation angle
        drange: float
            radius of data
        dtype: str
            type of product (REF, VEL, etc.)

        Returns
        -------
        r_obj: cinrad.datastruct.Radial
        '''
        task = getattr(self, 'task_name', None)
        reso = self.Rreso if dtype == 'REF' else self.Vreso
        ret = self.get_raw(tilt, drange, dtype)
        shape = ret[0].shape[1] if isinstance(ret, tuple) else ret.shape[1]
        r_obj = Radial(ret, int(np.round(shape * reso)), self.elev, reso, self.code, self.name, self.scantime, dtype,
                       self.stationlon, self.stationlat, nyquist_velocity=self.nyquist_v[tilt], task=task)
        x, y, z, d, a = self.projection(reso)
        r_obj.add_geoc(x, y, z)
        r_obj.add_polarc(d, a)
        if self.radartype == 'CC':
            r_obj.a_reso = 512
        return r_obj
示例#2
0
文件: io.py 项目: EnboYang/PyCINRAD
    def get_data(self, tilt, drange, dtype):
        r'''
        Get radar raw data

        Parameters
        ----------
        tilt: int
            index of elevation angle
        drange: float
            radius of data
        dtype: str
            type of product (REF, VEL, etc.)

        Returns
        -------
        r_obj: cinrad.datastruct.Radial
        '''
        rf_flag = False
        self.tilt = tilt
        reso = self.Rreso if dtype == 'REF' else self.Vreso
        dmax = np.round(self.data[tilt][dtype][0].shape[0] * reso)
        if dmax < drange:
            warnings.warn('Requested data range exceed max range in this tilt')
        self.drange = drange
        self.elev = self.el[tilt]
        try:
            data = np.ma.array(self.data[tilt][dtype])
        except KeyError:
            raise RadarDecodeError('Invalid product name')
        length = data.shape[1] * reso
        cut = data.T[:int(np.round(drange / reso))]
        shape_diff = np.round(drange / reso) - cut.shape[0]
        append = np.zeros(
            (int(np.round(shape_diff)), cut.shape[1])) * np.ma.masked
        if dtype == 'VEL':
            try:
                rf = self.data[tilt]['RF']
            except KeyError:
                pass
            else:
                rf_flag = True
                rf = rf.T[:int(np.round(drange / reso))]
                rf = np.ma.vstack([rf, append])
        #r = np.ma.array(cut, mask=np.isnan(cut))
        r = np.ma.vstack([cut, append])
        if rf_flag:
            r.mask = np.logical_or(r.mask, ~rf.mask)
            ret = (r.T, rf.T)
        else:
            ret = r.T
        r_obj = Radial(ret, int(np.round(r.shape[0] * reso)), self.elev, reso,
                       self.code, self.name, self.scantime, dtype,
                       self.stationlon, self.stationlat)
        x, y, z, d, a = self.projection(reso)
        r_obj.add_geoc(x, y, z)
        r_obj.add_polarc(d, a)
        if self.radartype == 'CC':
            r_obj.a_reso = 512
        return r_obj