Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_angles(self, vis):
"""Get the sun and satellite angles from the current dataarray."""
from pyorbital.astronomy import get_alt_az, sun_zenith_angle
from pyorbital.orbital import get_observer_look
lons, lats = vis.attrs['area'].get_lonlats(chunks=vis.data.chunks)
sunalt, suna = get_alt_az(vis.attrs['start_time'], lons, lats)
suna = np.rad2deg(suna)
sunz = sun_zenith_angle(vis.attrs['start_time'], lons, lats)
sat_lon, sat_lat, sat_alt = get_satpos(vis)
sata, satel = get_observer_look(
sat_lon,
sat_lat,
sat_alt / 1000.0, # km
vis.attrs['start_time'],
lons, lats, 0)
satz = 90 - satel
return sata, satz, suna, sunz
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'])
def get_angles(self, vis):
"""Get sun and satellite angles to use in crefl calculations."""
from pyorbital.astronomy import get_alt_az, sun_zenith_angle
from pyorbital.orbital import get_observer_look
lons, lats = vis.attrs['area'].get_lonlats(chunks=vis.data.chunks)
lons = da.where(lons >= 1e30, np.nan, lons)
lats = da.where(lats >= 1e30, np.nan, lats)
suna = get_alt_az(vis.attrs['start_time'], lons, lats)[1]
suna = np.rad2deg(suna)
sunz = sun_zenith_angle(vis.attrs['start_time'], lons, lats)
sat_lon, sat_lat, sat_alt = get_satpos(vis)
sata, satel = get_observer_look(
sat_lon,
sat_lat,
sat_alt / 1000.0, # km
vis.attrs['start_time'],
lons, lats, 0)
satz = 90 - satel
return sata, satz, suna, sunz