Skip to content

Photometer

This welcome notebook shows how to load and plot sun photometer data from AERONET (NASA Aerosol Robotic Network). It downloads two kinds of data with the gathering package:

  • Level 1 sky radiances: almucantar scans, in which the photometer measures the sky radiance at fixed angles from the sun.
  • Level 2 aerosol optical depth (AOD): the AOD of every channel along the day.
Notebook data_access/instruments/Photometer.ipynb (welcome-notebooks repository)
Data source AERONET, open access
Gatherer Task.aeronet
Station Granada
Date 2 June 2020
Products ALM00 (almucantar sky radiances) and TOT15 (total optical depth, level 1.5, with the AOD of every channel)

Before you start

The first cell installs the gathering package from the wheel shipped next to the notebook and imports what the notebook needs:

!pip install gathering-0.4.2-py3-none-any.whl

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import re

from gathering import Pipeline, Task

Downloaded files are cached by gathering, so running a cell again does not download them again.

1. Level 1: almucantar sky radiances

An AERONET task needs the station, the product and the date range. averaging=False keeps every measurement instead of daily averages:

task = Task.aeronet(
    station="Granada",
    product="ALM00",
    start_date="2020-06-02",
    end_date="2020-06-02",
    averaging=False,
)
results = Pipeline([task]).run()

files = results.to_dataframe()["files"].iloc[0]

The AERONET file is a CSV with a text header. The notebook reads it with pandas, skipping the header lines (skiprows=8), replaces the AERONET fill value -999 with NaN, and builds a time index from the Date(dd:mm:yyyy) and Time(hh:mm:ss) columns:

almucantars_file = pd.read_csv(str(files[0]), delimiter=",", skiprows=8)
almucantars_file = almucantars_file.replace(-999, np.nan)
almucantars_file.index = pd.to_datetime(
    almucantars_file["Date(dd:mm:yyyy)"] + " " + almucantars_file["Time(hh:mm:ss)"],
    format="%d:%m:%Y %H:%M:%S",
)
almucantars_file = almucantars_file.sort_index()

Plotting one almucantar

Each channel of an almucantar is stored as a separate row, so a full almucantar has as many rows as channels. The sky radiance of each row is spread over one column per scattering angle, on both sides of the sun (2.000000, -2.000000, ..., 180.000000).

The notebook keeps the rows with a valid Nominal_Wavelength(nm), takes the first four (the first complete almucantar), and plots the radiance of each channel against the angle, with the left branch on negative angles and the right one on positive angles:

pos_angles_list = [2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0,
                   16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.0,
                   70.0, 80.0, 90.0, 100.0, 120.0, 140.0, 160.0, 180.0]

measurements_df = almucantars_file[
    pd.to_numeric(almucantars_file["Nominal_Wavelength(nm)"], errors="coerce") > 0
].copy()
first_scan_df = measurements_df.iloc[0:4]

Each curve is labelled with the exact wavelength of its channel (Exact_Wavelength(um), converted to nm).

2. Level 2: aerosol optical depth

The same kind of task downloads the TOT15 file of the same day. It is read in the same way, this time with skiprows=5:

task = Task.aeronet(
    station="Granada",
    product="TOT15",
    start_date="2020-06-02",
    end_date="2020-06-02",
    averaging=False,
)
results = Pipeline([task]).run()

files = results.to_dataframe()["files"].iloc[0]
aod_file = pd.read_csv(str(files[0]), delimiter=",", skiprows=5)
aod_file = aod_file.replace(-999, np.nan)

AOD time series

The file has one AOD column per channel, named like AOD_440nm-AOD. The notebook selects them with a strict regular expression, so metadata columns are left out, then drops the channels without data on that day and sorts the rest by wavelength:

raw_aod_cols = [c for c in aod_file.columns if re.search(r"^AOD_\d+nm-AOD$", str(c))]
aod_columns = [col for col in raw_aod_cols if aod_file[col].dropna().shape[0] > 0]
aod_columns = sorted(aod_columns, key=lambda x: int(re.search(r"\d+", x).group()))

All the channels are then plotted as time series (time in UTC), with one legend entry per wavelength.

Spectral dependence

For a single timestamp (the first measurement of the day), the notebook plots the AOD as a function of the wavelength, in micrometres. This spectral dependence is what tells fine particles (AOD decreasing quickly with wavelength) from coarse ones (flatter spectrum).

first_row = aod_file[aod_columns].iloc[0].dropna()
wl_um = np.array([int(re.search(r"\d+", col).group()) for col in first_row.index]) / 1000.0

Going further

  • Change station, the dates or the product (ALM15, ALM20, AOD15, AOD20, ...) to explore other sites and processing levels.
  • The other instrument notebooks follow the same pattern: Lidar, Ceilometer, Radar and Spectrometer.