Nadir Measurement Simulation

The sampling and SpectralImager can also be applied to Nadir measurements to reduce the radiative transfer costs.

import sasktran as sk
import numpy as np
from ali.util.sampling import SamplingNadir
from ali.util.config import Config
from skretrieval.core.sensor.imager import SpectralImagerFast
from skretrieval.core.lineshape import Gaussian, DeltaFunction
from skretrieval.core import OpticalGeometry
import matplotlib.pyplot as plt


plt.style.use(Config.MATPLOTLIB_STYLE_FILE)


def nadir_simulation():

    # define balloon geometry
    time = '2014-12-07T17:30'
    latitude = 40.0
    longitude = -120.0

    mjd = (np.datetime64(time) - np.datetime64('1858-11-17')) / np.timedelta64(1, 'D')
    wavelengths = np.array([1100.0])

    fwhm = 0.5 * np.pi / 180
    sensor = SpectralImagerFast(wavelengths, spectral_lineshape=DeltaFunction(),
                                pixel_vert_fov=Gaussian(fwhm=fwhm),
                                pixel_horiz_fov=Gaussian(fwhm=fwhm),
                                image_horiz_fov=5.0, image_vert_fov=5.0,
                                num_columns=100, num_rows=100)

    geo = sk.Geodetic()
    geo.from_lat_lon_alt(latitude, longitude, 450_000.0)
    local_up = geo.local_south
    nadir = sk.geometry.NadirGeometry()
    nadir.from_lat_lon(mjd, observer=geo, lats=latitude, lons=longitude)

    optical_geometry = OpticalGeometry(observer=nadir.lines_of_sight[0].observer,
                                       look_vector=nadir.lines_of_sight[0].look_vector,
                                       local_up=local_up,
                                       mjd=mjd)
    geometry = sk.Geometry()
    geometry.lines_of_sight = sensor.measurement_geometry(optical_geometry=optical_geometry)

    atmosphere = sk.Atmosphere()
    atmosphere['ozone'] = sk.Species(sk.O3DBM(), sk.Labow())
    atmosphere['air'] = sk.Species(sk.Rayleigh(), sk.MSIS90())
    atmosphere['aerosol'] = sk.SpeciesAerosolGloSSAC()
    atmosphere.brdf = sk.Lambertian(0.5)

    sampling = SamplingNadir(sensor, optical_axis=optical_geometry)
    sampling.cross_track_resolution_deg = 0.5
    sampling.along_track_resolution_deg = 0.5
    sampling_geometry = sampling.meas_geom()
    sampling.set_weights(sensor)

    # options = {'numordersofscatter': 1}
    engine = sk.EngineHR(geometry=sampling_geometry, atmosphere=atmosphere, wavelengths=wavelengths)
    radiance = engine.calculate_radiance()
    l1 = sensor.model_radiance(optical_geometry=optical_geometry,
                               model_wavel_nm=wavelengths,
                               model_geometry=sampling_geometry,
                               radiance=radiance)

    fig, ax = plt.subplots(1, 2, figsize=(8, 4))
    sampling.plot_samples(sampling.edges, radiance[0], ax=ax[0],
                          vmin=np.min(radiance), vmax=np.max(radiance), cmap=plt.cm.Spectral_r)
    ax[0].set_title('SASKTRAN Radiance')
    ax[0].set_xlabel('Angle')
    ax[0].set_ylabel('Angle')
    ax[1].pcolor(l1.data.radiance.sel(wavelength=wavelengths[0]).values,
                 vmin=np.min(radiance), vmax=np.max(radiance), cmap=plt.cm.Spectral_r)
    ax[1].set_title('Imager Radiance')
    ax[1].set_xlabel('Pixel')
    ax[1].set_ylabel('Pixel')


if __name__ == '__main__':
    nadir_simulation()
../../_images/example_nadir_sampling.png