Reading Retrieval Products#
A column retrieval comes as a product file, such as a TROPOMI orbit, an
OCO-2 Lite file, a TCCON site file, or a day of EM27/SUN measurements from
GGG or PROFFAST.
The readers in stilt.observations turn each of these into a table
with one row per sounding. The columns are the same for every instrument
(SOUNDING_SCHEMA), so the rest
of the workflow (Tutorial: A Satellite Column, Start To Finish) is too.
from stilt.observations import read_tropomi_ch4
df = read_tropomi_ch4(
"S5P_OFFL_L2__CH4____20231019T192749_20231019T210918_31176_03_020500_20231021T113213.nc",
lon_range=(-113.5, -110.5), lat_range=(39.5, 42.0),
)
df = df[df.good]
The readers#
Reader |
Files |
Tested on |
|---|---|---|
Operational Sentinel-5P L2 CH4 orbits ( |
A 2023 operational orbit (processor 2.5) and a 2018 blended file. |
|
OCO-2 and OCO-3 L2 Lite XCO2 files ( |
OCO-2 Lite FP v11.2r and OCO-3 Lite FP v11r files of 2026-02-08 (nadir and target-mode soundings). |
|
TCCON GGG2020 public site files from CaltechDATA
( |
The Indianapolis GGG2020.R0 file. |
|
GGG2020 |
Real EM27/SUN days. The committed test file is synthetic. |
|
GGG2020 netCDF files: the |
The public layout on a real TCCON file. The private layout only on a synthetic file. |
|
COCCON GEOMS HDF5 files ( |
Files PROFFASTpylot wrote for KIT’s example data. The committed test file is synthetic. |
|
A PROFFASTpylot run: its |
A run on KIT’s example data, whose kernels and priors match its GEOMS files. The committed test run is synthetic. |
The satellite readers take lon_range and lat_range to keep only the
pixels inside a box. Use them on a whole orbit. The GGG and EM27/SUN readers take a
species (xco2, xch4, xco, …), and the netCDF readers also
take a time_range for multi-year site files. The readers do not filter
anything else. Quality flags become the good column, and you decide
what to keep.
EM27/SUN#
Which reader to use depends on how the retrievals were made:
GGG, as EGI delivers it.
read_ggg_oof()reads the soundings of one.ooffile. That file has no averaging kernel or prior, so theak,ak_pressureandpressure_levelscolumns are left out. Take the kernels from the same run’s*.private.ncwithread_ggg_netcdf(), or from a site kernel table keyed by solar zenith angle; Slant Columns shows both.COCCON’s GEOMS files, from PROFFAST.
read_coccon()reads one site-day. The kernel is already interpolated to each measurement’s solar zenith angle, soakis per row, as for the satellites. The files hold only measurements that passed COCCON’s quality filter, sogoodis True everywhere.Your own PROFFASTpylot run.
read_proffast()takes the run’scomb_invparmsCSV and finds each day’s kernel and prior files next to it. You get every spectrum, withgoodset by COCCON’s screen (solar zenith angle at most 75 degrees,XAIRbetween 0.98 and 1.02), the values before any instrument calibration, and COCCON’s alternative retrievals (xco2_str,xch4_s5p). PROFFAST reports no error for a single spectrum, souncertaintyis NaN.
Use COCCON’s release when it has your site’s data, because it is calibrated and screened, and a PROFFASTpylot run when you need what it leaves out.
To read a campaign as one table, read each day and concatenate:
from pathlib import Path
import pandas as pd
from stilt.observations import read_coccon, read_ggg_oof
days = sorted(Path("EM27_oof/ha").glob("ha*.vav.ada.aia.oof"))
df = pd.concat([read_ggg_oof(p, "xch4") for p in days], ignore_index=True)
df = df[df.good]
days = sorted(Path("coccon").glob("groundbased_ftir.coccon_*.h5"))
df = pd.concat([read_coccon(p, "xch4") for p in days], ignore_index=True)
The columns#
Vertical arrays run from the surface upward. Pressures are in hPa and
altitudes in meters above mean sea level. Azimuths are degrees clockwise
from north, pointing from the ground toward the instrument or the sun. This
is the convention slant_points() uses.
Every reader returns these columns:
Column |
Meaning |
|---|---|
|
A string that identifies the sounding within the product. |
|
UTC time of the sounding, timezone-naive. |
|
Pixel center or station location, degrees. |
|
Surface (or station) altitude, m MSL. |
|
Surface pressure the retrieval used, hPa. |
|
The column-average dry-air mole fraction and its one-sigma error. |
|
The gas ( |
|
The product’s recommended quality screen, as a boolean. |
All readers except read_ggg_oof() also return:
Column |
Meaning |
|---|---|
|
The averaging kernel and the pressures it is given at, one array per
row. For a layer product (TROPOMI) the pressures are the layer
midpoints. Pass both to
|
|
The retrieval’s own pressure grid, for
|
Some columns appear only when the product has them:
Column |
Meaning |
|---|---|
|
The viewing geometry for a slant path. For a satellite these are the sensor angles toward the satellite. For a ground-based spectrometer they are the solar angles. The blended TROPOMI files have neither. |
|
The solar angles. In GGG files they equal |
|
The heights of |
|
The prior profile as a mole fraction in |
|
The prior column value (OCO-2). |
|
Pixel corners, one array per row, for
|
Other columns keep the product’s own names, for example qa_value,
quality_flag, operation_mode, xch4_uncorrected, flag,
zmin, and the other x<gas> columns of a GGG file. A private GGG file
adds ak_extrapolated. It is true where the spectrum’s slant xgas fell
outside GGG’s kernel table.
From a file to releases#
releases_from_soundings() makes a release for
each sounding and the table of their averaging kernels. Here each TROPOMI
sounding becomes a slant release on the retrieval’s own levels, up to
3 km above the surface:
import stilt
from stilt.observations import read_tropomi_ch4, releases_from_soundings
project = stilt.Project("./xch4") # made with stilt init or Project.init
df = read_tropomi_ch4(path, lon_range=(-113.5, -110.5), lat_range=(39.5, 42.0))
releases, kernels = releases_from_soundings(df[df.good], "slant", top=3000)
project.add_releases(releases)
project.add_table("kernels", kernels) # tables/kernels.parquet
project.run()
Each release keeps its sounding_id as a column of releases.csv,
so the results join back to the soundings. The footprint’s block under
stages: lists two transforms, the first reading the kernels by the
table’s name:
transforms:
- kind: averaging_kernel
table: kernels
coordinate: pres
- kind: pressure_weighting
A few products need a change to this recipe:
For a nadir column, pass
"column": aColumnReleasefrom the ground up totop.OCO-2 files give pressures but no heights. Add
altitude_levelsfrompressure_altitudes()before a slant release.A TCCON prior grid starts at sea level, below the station. Drop the levels below
surface_altitudeand putsurface_altitudefirst, so the path starts at the instrument.
Adding an instrument#
Copy the reader module closest to your product from
stilt/observations/readers/. Use tropomi.py for a swath product and
ggg.py for a ground station. The reader holds all of the product’s
conventions, and its output must have the columns above, which
SOUNDING_SCHEMA lists in code.
Keep it a plain function that returns the table.
Add a small slice of a real file under tests/observations/data/products,
and a test that calls check_soundings() on the
table and checks the units and that the vertical arrays start at the
surface. tests/observations/data/products/make_samples.py shows how
the existing slices were cut. Readers for MethaneAIR and MethaneSAT are
welcome. The maintainers have no files to write them
against.