示例#1
0
    def get_rad(self):
        """
        return rad
        """
        data = dict()
        if self.resolution == 4000:  # 分辨率为 1000
            satellite_type1 = ['FY4A']
            tbbs = self.get_tbb()
            central_wave_numbers = self.get_central_wave_number()
            lut = self.get_lut_bt()
            #             lut = None
            if self.satellite in satellite_type1:

                for i in xrange(self.channels):
                    band = 'CH_{:02d}'.format(i + 1)
                    if i >= 7:
                        tbb = tbbs[band]
                        central_wave_number = central_wave_numbers[band]
                        if lut:
                            print 'f4 lut'
                            rad = np.interp(tbb, lut['tbb'], lut['rad'][band])
                        else:
                            print 'f4 plank'
                            rad = planck_t2r(tbb, central_wave_number)
                        data[band] = rad
            else:
                raise ValueError('Cant read this satellite`s data.: {}'.format(
                    self.satellite))
        else:
            raise ValueError(
                'Cant read this data, please check its resolution: {}'.format(
                    self.in_file))
        return data
示例#2
0
    def get_rad_test2(self):
        """
        return rad
        """
        data = dict()
        if self.resolution == 4000:  # 分辨率为 1000
            satellite_type1 = ['FY4A']
            tbbs = self.get_tbb()
            central_wave_numbers = self.get_central_wave_number()

            if self.satellite in satellite_type1:

                for i in xrange(self.channels):
                    band = 'CH_{:02d}'.format(i + 1)
                    if i >= 7:
                        tbb = 250
                        central_wave_number = central_wave_numbers[band]
                        rad = planck_t2r(tbb, central_wave_number)
                        data[band] = rad
            else:
                raise ValueError('Cant read this satellite`s data.: {}'.format(
                    self.satellite))
        else:
            raise ValueError(
                'Cant read this data, please check its resolution: {}'.format(
                    self.in_file))
        return data
示例#3
0
    def get_rad(self):
        """
           经非线性校正后的RAD
        :return:
        """
        data = dict()
        if self.resolution == 17000:  # 分辨率为 17000
            satellite_type1 = ['FY3A', 'FY3B', 'FY3C']
            if self.satellite in satellite_type1:
                tbbs = self.get_tbb()
                central_wave_numbers = self.get_central_wave_number()

                for i in xrange(self.channels):
                    band = 'CH_{:02d}'.format(i + 1)
                    if band in tbbs:
                        tbb = tbbs[band]
                        central_wave_number = central_wave_numbers[band]
                        rad = pb_sat.planck_t2r(tbb, central_wave_number)
                        data[band] = rad
        else:
            raise ValueError(
                'Cant read this data, please check its resolution: {}'.format(self.in_file))
        return data
示例#4
0
    def Load(self, L1File):

        #################### 读取L1文件 ######################
        print u'读取 L1所有数据信息...... %s ' % L1File
        try:

            h5File_R = h5py.File(L1File, 'r')
            ary_ch26_dn = h5File_R.get('/Data/IRAS_DN')[:]
            ary_ch26_tb = h5File_R.get('/Data/IRAS_TB')[:]
            ary_day = h5File_R.get('/Data/Scnlin_daycnt')[:]
            ary_time = h5File_R.get('/Data/Scnlin_mscnt')[:]

            ary_satz = h5File_R.get('/Geolocation/SensorZenith')[:]
            ary_sata = h5File_R.get('/Geolocation/SensorAzimuth')[:]
            ary_sunz = h5File_R.get('/Geolocation/SolarZenith')[:]
            ary_suna = h5File_R.get('/Geolocation/SolarAzimuth')[:]
            ary_lon = h5File_R.get('/Geolocation/Longitude')[:]
            ary_lat = h5File_R.get('/Geolocation/Latitude')[:]
            ary_LandCover = h5File_R.get('/Geolocation/LandCover')[:]
            ary_LandSeaMask = h5File_R.get('/Geolocation/LandSeaMask')[:]

        except Exception as e:
            print str(e)
            return

        finally:
            h5File_R.close()
        # 通道的中心波数和光谱响应
        for i in xrange(self.Band):
            BandName = 'CH_%02d' % (i + 1)
            srfFile = os.path.join(
                MainPath, 'SRF',
                '%s_%s_SRF_CH%02d_Pub.txt' % (self.sat, self.sensor, (i + 1)))
            dictWave = np.loadtxt(srfFile,
                                  dtype={
                                      'names': ('num', 'rad'),
                                      'formats': ('f4', 'f4')
                                  })
            waveNum = dictWave['num']
            waveRad = dictWave['rad']
            self.waveNum[BandName] = waveNum
            self.waveRad[BandName] = waveRad
        ############### 数据大小 使用经度维度 ###############
        dshape = ary_lon.shape

        ##################可见光数据进行定标 ########

        for i in xrange(self.Band):
            BandName = 'CH_%02d' % (i + 1)
            # DN值存放无效值用nan填充
            DN = np.full(dshape, np.nan)
            idx = np.logical_and(ary_ch26_dn[i] < 4095, ary_ch26_dn[i] > -4095)
            DN[idx] = ary_ch26_dn[i][idx]
            self.Dn[BandName] = DN

            # Tbb值存放无效值用nan填充
            Tbb = np.full(dshape, np.nan)
            idx = np.logical_and(ary_ch26_tb[i] < 350, ary_ch26_tb[i] > 150)
            Tbb[idx] = ary_ch26_tb[i][idx]
            self.Tbb[BandName] = Tbb
            # Rad值存放无效值用nan填充
            Rad = np.full(dshape, np.nan)
            Rad = pb_sat.planck_t2r(Tbb, self.WN[BandName])
            self.Rad[BandName] = Rad

        # 全局信息赋值 ############################
        # 对时间进行赋值合并
        v_ymd2seconds = np.vectorize(fy3_ymd2seconds)
        T1 = v_ymd2seconds(ary_day, ary_time)

        Time = np.full(dshape, -999)
        for i in xrange(ary_lon.shape[0]):
            Time[i, :] = T1[i]
        if self.Time == []:
            self.Time = Time
        else:
            self.Time = np.concatenate((self.Time, Time))

        # SV, BB
        for i in xrange(self.Band):
            BandName = 'CH_%02d' % (i + 1)
            SV = np.full(dshape, np.nan)
            BB = np.full(dshape, np.nan)

            if BandName not in self.SV.keys():
                self.SV[BandName] = SV
                self.BB[BandName] = BB
            else:
                self.SV[BandName] = np.concatenate((self.SV[BandName], SV))
                self.BB[BandName] = np.concatenate((self.BB[BandName], BB))

        # 土地覆盖
        ary_LandCover_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_LandCover >= 0, ary_LandCover <= 254)
        ary_LandCover_idx[condition] = ary_LandCover[condition]

        if self.LandCover == []:
            self.LandCover = ary_LandCover_idx
        else:
            self.LandCover = np.concatenate(
                (self.LandCover, ary_LandCover_idx))

        # 海陆掩码
        ary_LandSeaMask_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_LandSeaMask >= 0, ary_LandSeaMask <= 7)
        ary_LandSeaMask_idx[condition] = ary_LandSeaMask[condition]

        if self.LandSeaMask == []:
            self.LandSeaMask = ary_LandSeaMask_idx
        else:
            self.LandSeaMask = np.concatenate(
                (self.LandSeaMask, ary_LandSeaMask_idx))

        # 经纬度
        ary_lon_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_lon > -180., ary_lon < 180.)
        ary_lon_idx[condition] = ary_lon[condition]
        if self.Lons == []:
            self.Lons = ary_lon_idx
        else:
            self.Lons = np.concatenate((self.Lons, ary_lon_idx))

        ary_lat_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_lat > -90., ary_lat < 90.)
        ary_lat_idx[condition] = ary_lat[condition]
        if self.Lats == []:
            self.Lats = ary_lat_idx
        else:
            self.Lats = np.concatenate((self.Lats, ary_lat_idx))

        # 卫星方位角 天顶角
        ary_sata_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_sata > -18000, ary_sata < 18000)
        ary_sata_idx[condition] = ary_sata[condition]

        if self.satAzimuth == []:
            self.satAzimuth = ary_sata_idx / 100.
        else:
            self.satAzimuth = np.concatenate(
                (self.satAzimuth, ary_sata_idx / 100.))

        ary_satz_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_satz > 0, ary_satz < 18000)
        ary_satz_idx[condition] = ary_satz[condition]
        if self.satZenith == []:
            self.satZenith = ary_satz_idx / 100.
        else:
            self.satZenith = np.concatenate(
                (self.satZenith, ary_satz_idx / 100.))

        # 太阳方位角 天顶角
        ary_suna_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_suna > -18000, ary_suna < 18000)
        ary_suna_idx[condition] = ary_suna[condition]

        if self.sunAzimuth == []:
            self.sunAzimuth = ary_suna_idx / 100.
        else:
            self.sunAzimuth = np.concatenate(
                (self.sunAzimuth, ary_suna_idx / 100.))

        ary_sunz_idx = np.full(dshape, np.nan)
        condition = np.logical_and(ary_sunz > 0, ary_sunz < 18000)
        ary_sunz_idx[condition] = ary_sunz[condition]

        if self.sunZenith == []:
            self.sunZenith = ary_sunz_idx / 100.
        else:
            self.sunZenith = np.concatenate(
                (self.sunZenith, ary_sunz_idx / 100.))
        print self.sunZenith