Lidar¶
This welcome notebook shows how to load and handle aerosol lidar data. The data comes from the ACTRIS ARES database (EARLINET, the European Aerosol Research Lidar Network) and is downloaded with the gathering package.
It uses the ELPP product: SCC (Single Calculus Chain) Level 1 pre-processed signals, which give the time-height range-corrected signal of each lidar channel.
| Notebook | data_access/instruments/Lidar.ipynb (welcome-notebooks repository) |
| Data source | ACTRIS ARES, open access |
| Gatherer | Task.actris_ares |
| Station | Bucharest, Romania (INOE, ARES station ID INO) |
| Date | 19 January 2023 |
| Product | elpp (SCC Level 1 pre-processed signals) |
Before you start¶
The first cell installs the gathering package from the wheel shipped next to the notebook and imports what the notebook needs (xarray to read the NetCDF files):
!pip install gathering-0.4.2-py3-none-any.whl
from datetime import timedelta
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import xarray as xr
from matplotlib.ticker import ScalarFormatter
from gathering import Pipeline, Task
1. Downloading the data¶
An actris_ares task with the product, the station and the date range is run through a Pipeline. The files are cached, so running the cell again does not download them again:
task = Task.actris_ares(
product="elpp", # SCC Level 1 pre-processed signals
station="INO", # Bucharest, Romania (INOE)
start_date="2023-01-19",
end_date="2023-01-19",
)
results = Pipeline([task]).run()
files = results.to_dataframe()["files"].iloc[0]
The result is a list of NetCDF files with names like EARLINET_AerRemSen_ino_ELPP_000_0354_202301191443_202301191559_v01_qc03.nc.
2. Reading the elastic channels¶
ELPP files are delivered per measurement and per SCC product. Product 003 contains the elastic backscatter channels at 355, 532 and 1064 nm, so the notebook picks the files of each channel by their name:
channels = {
"355 nm": "_ELPP_003_0354_",
"532 nm": "_ELPP_003_0532_",
"1064 nm": "_ELPP_003_1064_",
}
The 532 nm files have two polarisation channels (532p and 532s); the notebook keeps the parallel one (532p, the first channel of the file).
For each channel, load_channel opens its files, takes the range_corrected_signal, replaces the range levels by their altitude and concatenates the measurements along time:
def load_channel(pattern):
profiles = []
for f in sorted(str(f) for f in files if pattern in Path(f).name):
ds = xr.open_dataset(f)
altitude = ds["altitude"].isel(time=0).values
rcs = (
ds["range_corrected_signal"]
.isel(channel=0)
.drop_vars("altitude")
.assign_coords(altitude=("level", altitude))
.swap_dims(level="altitude")
)
profiles.append(rcs)
return xr.concat(profiles, dim="time")
The three channels are then stacked into a single (time, altitude, channel) array. join="inner" keeps only the altitudes shared by all channels:
lidar = xr.concat(
[load_channel(pattern) for pattern in channels.values()],
dim=pd.Index(list(channels), name="channel"),
join="inner",
).transpose("time", "altitude", "channel")
time = pd.to_datetime(lidar["time"].values)
heights = lidar["altitude"].values
range_corrected_signal = lidar.values
For this day the array has 6 profiles, 1794 altitude levels and 3 channels. A cell prints the time range, the heights and the signal range, to inspect the dataset.
3. Time-height plot¶
The range-corrected signal at 355 nm is plotted as a function of time and altitude (up to 15 km), with the colour scale capped at the 99th percentile. ELPP profiles are time averages of about 30 minutes, so the time resolution is coarse.
4. Selecting a region¶
The notebook then selects a sub-region of the signal: 45 minutes on each side of 15:50 UTC, and altitudes between 200 and 7000 m. It plots the 532 nm channel of that selection:
center_time = pd.Timestamp("2023-01-19 15:50:00")
time_mask = (time[:] < center_time - timedelta(minutes=45)) | (
time[:] > center_time + timedelta(minutes=45)
)
heights_mask = (heights[:] < 200) | (heights[:] > 7000)
range_corrected_signal_selection = range_corrected_signal[~time_mask, :, :]
range_corrected_signal_selection = range_corrected_signal_selection[:, ~heights_mask, :]
5. Mean profiles¶
Averaging the selection over time gives one profile per channel. The signals are not calibrated, so each channel has its own scale; a logarithmic axis makes them comparable:
6. Smoothing¶
Finally, the profiles are smoothed with a running mean over a fixed vertical window of about 150 m. The number of bins of the window depends on the vertical resolution of the data:
vertical_resolution = heights[~heights_mask][1] - heights[~heights_mask][0]
window = max(1, int(np.rint(150 / vertical_resolution)))
df = pd.DataFrame(
range_corrected_signal_profiles,
index=heights[~heights_mask],
columns=list(channels),
)
df_smooth = df.rolling(window=window, center=True).mean().dropna()
Going further¶
- Change the station (ARES station ID), the dates or the product to explore other EARLINET stations and processing levels.
- The other instrument notebooks follow the same pattern: Photometer, Ceilometer, Radar and Spectrometer.