def __call__(self, projectables, optional_datasets=None, **info): """Get the atmospherical correction. Uses pyspectral. """ from pyspectral.atm_correction_ir import AtmosphericalCorrection band = projectables[0] if optional_datasets: satz = optional_datasets[0] else: from pyorbital.orbital import get_observer_look lons, lats = band.attrs['area'].get_lonlats_dask(CHUNK_SIZE) try: dummy, satel = get_observer_look( band.attrs['satellite_longitude'], band.attrs['satellite_latitude'], band.attrs['satellite_altitude'], band.attrs['start_time'], lons, lats, 0) except KeyError: raise KeyError('Band info is missing some meta data!') satz = 90 - satel del satel LOG.info('Correction for limb cooling') corrector = AtmosphericalCorrection(band.attrs['platform_name'], band.attrs['sensor']) atm_corr = corrector.get_correction(satz, band.attrs['name'], band) proj = band - atm_corr proj.attrs = band.attrs self.apply_modifier_info(band, proj) return proj
def __call__(self, projectables, optional_datasets=None, **info): """Get the atmospherical correction. Uses pyspectral. """ from pyspectral.atm_correction_ir import AtmosphericalCorrection band = projectables[0] if optional_datasets: satz = optional_datasets[0] else: satz = get_satellite_zenith_angle(band) satz = satz.data # get dask array underneath logger.info('Correction for limb cooling') corrector = AtmosphericalCorrection(band.attrs['platform_name'], band.attrs['sensor']) atm_corr = da.map_blocks(_call_mapped_correction, satz, band.data, corrector=corrector, band_name=band.attrs['name'], meta=np.array((), dtype=band.dtype)) proj = xr.DataArray(atm_corr, attrs=band.attrs, dims=band.dims, coords=band.coords) self.apply_modifier_info(band, proj) return proj
def __call__(self, projectables, optional_datasets=None, **info): """Get the atmospherical correction. Uses pyspectral. """ from pyspectral.atm_correction_ir import AtmosphericalCorrection band = projectables[0] if optional_datasets: satz = optional_datasets[0] else: from pyorbital.orbital import get_observer_look lons, lats = band.attrs['area'].get_lonlats( chunks=band.data.chunks) sat_lon, sat_lat, sat_alt = get_satpos(band) try: dummy, satel = get_observer_look( sat_lon, sat_lat, sat_alt / 1000.0, # km band.attrs['start_time'], lons, lats, 0) except KeyError: raise KeyError('Band info is missing some meta data!') satz = 90 - satel del satel logger.info('Correction for limb cooling') corrector = AtmosphericalCorrection(band.attrs['platform_name'], band.attrs['sensor']) atm_corr = corrector.get_correction(satz, band.attrs['name'], band) proj = xr.DataArray(atm_corr, attrs=band.attrs, dims=band.dims, coords=band.coords) self.apply_modifier_info(band, proj) return proj
def __call__(self, projectables, optional_datasets=None, **info): """Get the atmospherical correction. Uses pyspectral. """ from pyspectral.atm_correction_ir import AtmosphericalCorrection band = projectables[0] if optional_datasets: satz = optional_datasets[0] else: from pyorbital.orbital import get_observer_look lons, lats = band.attrs['area'].get_lonlats_dask(CHUNK_SIZE) try: dummy, satel = get_observer_look(band.attrs['satellite_longitude'], band.attrs[ 'satellite_latitude'], band.attrs[ 'satellite_altitude'], band.attrs['start_time'], lons, lats, 0) except KeyError: raise KeyError( 'Band info is missing some meta data!') satz = 90 - satel del satel LOG.info('Correction for limb cooling') corrector = AtmosphericalCorrection(band.attrs['platform_name'], band.attrs['sensor']) atm_corr = corrector.get_correction(satz, band.attrs['name'], band) proj = band - atm_corr proj.attrs = band.attrs self.apply_modifier_info(band, proj) return proj
def test_get_correction(self): """Test getting the atm correction.""" this = AtmosphericalCorrection('EOS-Terra', 'modis') atm_corr = this.get_correction(SATZ, None, TBS) np.testing.assert_almost_equal(RES, atm_corr)
def test_get_correction(self): """Test getting the atm correction""" this = AtmosphericalCorrection('EOS-Terra', 'modis') atm_corr = this.get_correction(SATZ, None, TBS) assertNumpyArraysEqual(TBS, atm_corr)
def test_get_correction(self): """Test getting the atm correction (dask data).""" this = AtmosphericalCorrection('EOS-Terra', 'modis') atm_corr = this.get_correction(da.from_array(SATZ), None, da.from_array(TBS)) np.testing.assert_almost_equal(RES, atm_corr)