How to read and plot ASTER image data from AERIS

Posted on Do 06 August 2020 in code examples • by Theresa Mieslinger

open in binder
view on github
download notebook

In [1]:
#!pip install pydap --user
#!pip install git+https://github.com/atmtools/typhon.git --user

How to get a single ASTER image from AERIS and plot it on a map

In [2]:
%pylab inline
%matplotlib inline

import cartopy.crs as ccrs
import warnings
warnings.simplefilter("ignore")
import xarray as xr
from cartopy.mpl.gridliner import (LONGITUDE_FORMATTER, LATITUDE_FORMATTER)

import typhon as ty
Populating the interactive namespace from numpy and matplotlib
In [3]:
plt.style.use(ty.plots.styles.get('typhon'))

Get the file

In [4]:
url='https://observations.ipsl.fr/thredds/dodsC/EUREC4A/SATELLITES/TERRA/ASTER/nc/TERRA_ASTER_processed_20200205_142719.nc'

store = xr.backends.PydapDataStore.open(url)
ds = xr.open_dataset(store)
In [5]:
ds
Out[5]:
Show/Hide data repr Show/Hide attributes
xarray.Dataset
    • latlon: 2
    • pixel_acrosstrack_TIR: 830
    • pixel_acrosstrack_VNIR: 4980
    • pixel_alongtrack_TIR: 700
    • pixel_alongtrack_VNIR: 4200
      • latitudesVNIR
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        units :
        degrees_north
        long_name :
        Latitude
        description :
        Latitudes on pixel level for VNIR radiometer data
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • longitudesVNIR
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        units :
        degrees_east
        long_name :
        Longitude
        description :
        Longitudes on pixel level for VNIR radiometer data
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • latitudesTIR
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        units :
        degrees_north
        long_name :
        Latitude
        description :
        Latitudes on pixel level for TIR radiometer data
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • longitudesTIR
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        long_name :
        Longitude
        description :
        Longitudes on pixel level for TIR radiometer data
        units :
        degrees_east
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • radiance_band1
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 0.52 to 0.6 µm
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • radiance_band2
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 0.63 to 0.69 µm
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • radiance_band3N
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 0.78 to 0.86 µm
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • radiance_band10
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 8.125 to 8.475 µm
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • radiance_band11
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        long_name :
        Spectral radiance values at TOA at 8.475 to 8.825 µm
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • radiance_band12
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 8.925 to 9.275 µm
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • radiance_band13
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 10.25 to 10.95 µm
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • radiance_band14
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        standard_name :
        toa_outgoing_radiance_per_unit_wavelength
        units :
        W m-2 sr-1 um-1
        long_name :
        Spectral radiance values at TOA at 10.95 to 11.65 µm
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • cloudmask
        (pixel_alongtrack_VNIR, pixel_acrosstrack_VNIR)
        float32
        ...
        description :
        ASTER cloud mask according to Werner et al., 2016.
        flag_meanings :
        confidently_clear probably _clear probably_cloudy confidently_cloudy
        flag_values :
        [2, 3, 4, 5]
        valid_range :
        [2.0, 5.0]
        long_name :
        ASTER cloud mask
        units :
        unitless
        _ChunkSizes :
        [840, 996]
        [20916000 values with dtype=float32]
      • cloudtopheight
        (pixel_alongtrack_TIR, pixel_acrosstrack_TIR)
        float32
        ...
        standard_name :
        height_at_effective_cloud_top_defined_by_infrared_radiation
        units :
        m
        long_name :
        Cloud top height
        description :
        IR cloud top height estimates following Baum et al., 2012.
        _ChunkSizes :
        [700, 830]
        [581000 values with dtype=float32]
      • SunZenith
        ()
        float32
        ...
        description :
        sun zenith angle of central pixel
        units :
        degree
        standard_name :
        solar_zenith_angle
        long_name :
        Sun zenith angle
        array(34.015377, dtype=float32)
      • SunAzimuth
        ()
        float32
        ...
        standard_name :
        solar_azimuth_angle
        long_name :
        Sun azimuth angle
        description :
        sun azimuth angle of central pixel
        units :
        degree
        array(136.55537, dtype=float32)
      • SceneCenter
        (latlon)
        float32
        ...
        long_name :
        Central pixel (latitude, longitude)
        description :
        units :
        degree
        array([  8.959212, -57.06218 ], dtype=float32)
    • _NCProperties :
      version=1|netcdflibversion=4.6.1|hdf5libversion=1.10.4
      title :
      ASTER image data and geolocation information.
      history :
      Created Fri Jun 26 12:48:16 2020
      author :
      Theresa Mieslinger: theresa.mieslinger@mpimet.mpg
      description :
      This file contains ASTER L1B radiances, together with geolocation information, a cloud mask, and cloud top height estimates. Only bands from the visual near-infrared (VNIR) and thermal infrared (TIR) radiometers are available since 2007. The data is converted and processed from HDF4 files provided by NASA EOSDIS.
      original_file :
      AST_L1B_00302052020142719_20200225034108_32110.hdf
      datetime :
      2020-02-05 14:27:19.748000

    Plot one variable

    In [6]:
    projection = ccrs.Mercator()
    data_crs = ccrs.PlateCarree()
    
    In [7]:
    fig, ax = plt.subplots(subplot_kw=dict(projection=projection))
    features = ty.plots.get_cfeatures_at_scale(scale='50m')
    ax.add_feature(features.BORDERS)
    ax.add_feature(features.COASTLINE)
    
    im = ax.pcolormesh(ds.longitudesVNIR, ds.latitudesVNIR, ds.radiance_band3N,
                       cmap='Greys_r',
                       transform=data_crs,
                       alpha=1,
                       rasterized=True,
                       label='ASTER',
                       zorder=0)
    
    # colorbar
    cb = fig.colorbar(im, orientation='vertical')
    cb.set_label('Radiance (W m-2 sr-1)')
    
    # gridlines
    gl = ax.gridlines(draw_labels=True, color='lightgrey')
    gl.xformatter, gl.yformatter = LONGITUDE_FORMATTER, LATITUDE_FORMATTER
    gl.xlabels_top = gl.ylabels_right = False
    
    ax.set_title(f"ASTER radiance 0.82mu {ds.datetime[:-7]}")
    ax.set_xlabel("Longitude")
    ax.set_ylabel("Latitude")
    
    Out[7]:
    Text(0, 0.5, 'Latitude')

    ...enjoy the fluffy clouds :)