Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Swaths — an EMIT granule and TROPOMI averaging kernels on GeoSwath

Open In Colab

Imaging spectrometers and trace-gas sounders deliver their data in sensor geometry: rows along track, columns across, each pixel with its own latitude and longitude. Orthorectifying first would resample the very radiances a retrieval needs. geoarray.GeoSwath carries them as they are: the data with named dims, and lat/lon as pytree leaves, so a new granule of the same shape reuses a compiled program.

The data here are synthetic, shaped like the real products, so the notebook runs offline.

What you’ll learn:

  1. Build an EMIT-like swath with a SpectralAxis of 285 bands and select bands by name.

  2. Reduce over the swath with pipekit-array’s dim-level functions, and see why a per-column statistic is a DimArray, not a swath.

  3. Apply TROPOMI-style averaging kernels on a GeoSwathProfile with one KernelOp, eagerly and under jit.

  4. Cross to xarray with 2-D lat/lon coordinates and back.

1. An EMIT-like granule

EMIT measures 285 bands from 381 nm to 2493 nm. A small granule of 64 × 48 pixels, on a track tilted across the Permian Basin: the latitude and longitude of every pixel are leaves of the carrier.

GeoSwath(numpy float32 (285, 64, 48), crs=EPSG:4326, fill_value=nan, attrs=(), dims=('band', 'row', 'col'))

It is a GeoSwathImage: a swath with dims band row col. Bands are selected by name; the result is still a swath, on the same geolocation. The names of the bands nearest 2300 nm (in the methane window) and 2150 nm (outside it) come from the SpectralAxis wavelengths.

b258 b238
<Figure size 1000x400 with 3 Axes>

2. Reductions: what stays a swath

The adapter keeps the geolocation while it still describes the result. A mean over band is a swath; a mean over row (one value per column, a classic destriping statistic) has no geolocation left, so it is a plain DimArray with the band labels.

GeoSwath ('row', 'col')
DimArray ('band', 'col')

3. TROPOMI averaging kernels

A trace-gas retrieval reports, per pixel, an averaging kernel A on its retrieval layers and the prior profile x_a. To compare a model profile x with the retrieved column, apply the kernel:

c^=ca+∑khk Ak (xk−xa,k)\hat{c} = c_a + \sum_k h_k \, A_k \, (x_k - x_{a,k})

where hkh_k is the pressure weight of layer kk (∑khk=1\sum_k h_k = 1), so c^\hat{c} is a column-averaged mixing ratio. This example gives the 12 layers equal pressure thickness, hk=1/12h_k = 1/12; a real retrieval reads hh from the product.

TROPOMI’s CH₄ product has 12 layers in pressure. The kernels and priors are GeoSwathProfiles: swaths with a level dim and a VerticalAxis.

One L1 kernel, written on plain arrays with the layer axis last, wrapped once as a KernelOp. The carriers must share their geolocation exactly; the dispatch checks it and never aligns.

GeoSwath ('row', 'col')

The same KernelOp runs on JAX carriers under jit. A second granule with the same shape and new lat/lon reuses the compiled program: the geolocation is a leaf, not part of the cache key.

traces: 1
<Figure size 1000x400 with 4 Axes>

4. Crossing to xarray

to_xarray() writes the swath as a DataArray with 2-D lat / lon auxiliary coordinates and a CF spatial_ref, and from_xarray() reads it back exactly. The level coordinate carries its CF units and positive.

('row', 'col') {'units': 'hPa', 'positive': 'down', 'vertical_kind': 'pressure', 'standard_name': 'air_pressure'}
Loading...

Recap

  • A swath stays in sensor geometry: data with named dims, lat/lon as leaves, coordinates (SpectralAxis, VerticalAxis) as static labels.

  • pipekit-array’s functions and KernelOps run on it; a result that consumed row or col is a DimArray.

  • Under jit, new geolocation of the same shape costs no recompile.

Next: When to jit and Cross to xarray.