One day of Earth observation¶
Take one day of a methane-observing satellite and follow the numbers. An imaging spectrometer records radiance in a few hundred channels, and each channel is an integral of the spectrum against the instrument’s spectral response. The retrieval turns the radiance into a column of methane, which is an integral of the mole fraction over pressure. The level-3 product averages the columns onto a map, and the global mean of that map is an integral over the sphere weighted by the cosine of latitude. The ocean model that the same group runs reports the heat content of the upper ocean, an integral of temperature over depth. Finally, the emission rate of a plume comes with an uncertainty, and that uncertainty is an expectation, which is an integral against a posterior density.
So one day of data has at least five integrals in it, over five different domains: wavelength, pressure, the sphere, depth and a parameter space. They look very different, but they are the same object, and integrix treats them with the same few operations. In this chapter we write that object down once, so that the rest of the section can be about how we compute it.
The definition¶
Let be a domain (an interval of wavelength, a column of pressure, the sphere, a parameter space) with coordinates , and let be a measure on it. The integral of a function is
where is a number. When the measure has a density with respect to the ordinary volume element (length, area, volume), (1.1) is . The density is where most of the geoscience hides: the of an area on the sphere, the spectral response of a channel, the posterior density of an emission rate.
A function can carry extra axes that are not integrated (channels, time steps, ensemble members), so and are integrated entry by entry. integrix calls these the batch axes.
Five integrals, one form¶
The five integrals of the day all fit (1.1). For each one we write the full form, then read off its domain , its measure and the integrand that is left inside, and name the integrix function that computes it. Table 1.1 collects the physical symbols.
Table 1.1:The physical symbols of this page, with their shapes and units.
| Symbol | Shape, units | Meaning |
|---|---|---|
| , nm | wavelength, in the spectral domain | |
| , | , radiance units | the spectrum and the band radiance of channel |
| the spectral response of channel | ||
| , | , hPa | pressure and surface pressure |
| , ppb | the methane dry-air mole fraction | |
| , | radians | latitude and longitude |
| , | K, °C | surface temperature and ocean potential temperature |
| , | m | height (negative below the sea surface) and the depth of the layer |
| , | kg m⁻³, J kg⁻¹ K⁻¹ | reference density and heat capacity of seawater |
| , | kg h⁻¹, | the emission rate and the observations it is inferred from |
| , h kg⁻¹ | the posterior density of the emission rate, labelled because is pressure on this page |
Band radiance. An imaging spectrometer never sees the spectrum itself, since each channel sees the spectrum averaged under its own spectral response. We have the full form
where the domain is the spectral window , the integrand is the spectrum , and the measure is the normalised response . It is a ratio of two integrals with the same measure, so integrix computes it with weighted_mean, which uses the same weights for both sums. If the two sums used different weights, the ratio would drift for a reason that has nothing to do with the spectrum.
Column average. A retrieval reports methane as a column-averaged dry-air mole fraction, which is what a model column has to be compared with. Assuming dry air and a constant gravity, a pressure interval is proportional to the mass of air in it, and we have the full form
where the domain is the column from the top of the atmosphere to the surface, the integrand is the mole fraction , and the measure is , the fraction of the column’s air in each pressure interval. It is a plain integrate over the levels. A real retrieval adds water vapour and an averaging kernel on top, which change the weights but not the form.
Global mean. A level-3 map is averaged to one number per day, and every cell has to count by its area, not by its index. We have the full form
where the domain is the unit sphere in latitude and longitude , the integrand is the surface temperature , and the measure is the area element divided by the sphere’s area . The measure is a product of one factor per axis, so integrix computes it with integrate and a tensor rule, one rule in latitude and one in longitude.
Ocean heat content. The heat stored in the upper ocean is the quantity behind most statements about ocean warming, and it comes from a temperature profile. We have the full form
where the domain is the layer from depth to the sea surface, the integrand is the potential temperature , and the measure is , the heat capacity of each slab of water. The total is an integrate over depth, and the heat content above every depth, a profile instead of a number, is a cumulative scan.
Expected emission rate. An inversion does not return one emission rate for a plume but a posterior over rates, and the number we report is its mean, with an uncertainty from the same posterior. We have the full form
where the domain is the positive rates , the integrand is the rate itself, and the measure is the posterior given the observations . We can usually sample the posterior but not write it down, so integrix computes this with monte_carlo on posterior samples, or with qmc when the rate is a transform of uniform variables.
Three properties we lean on¶
The integral is a linear functional, and we lean on three of its properties over and over again.
Linearity. for scalars . Every rule in this section is linear in the samples too, which is what makes its gradient a vector of weights (chapter 9).
Positivity. If then . A rule with positive weights keeps this, and a rule with negative weights can return a negative column of methane from a positive profile (chapter 2).
Additivity over the domain. If with no overlap, then . This is the property behind composite rules, scans and every finite-volume budget, and it is the start of the global and local thread of chapter 3.
Here , , are tiles that cover without overlap: grid cells, pressure layers or time steps.
In code¶
The column and the band radiance of the day, on toy data. A linear methane profile on 21 pressure levels has the exact column average 1750 ppb, and the trapezoid rule (chapter 2) gets it exactly, because the rule is exact for straight lines.
import jax.numpy as jnp
from integrix import rule
from jaxtyping import Array, Float
# Shapes: N_P = 21 pressure levels; N_S = 401 wavelengths; N nodes of a rule
# user
def trapezoid_weights(nodes: Float[Array, "node"]) -> Float[Array, "node"]:
"""wₙ = (sₙ₊₁ − sₙ₋₁)/2 inside, half a spacing at each end."""
# hₙ = sₙ₊₁ − sₙ
widths = jnp.diff(nodes) # (N,) → (N - 1,)
# padding for the two ends, where one neighbour is missing
zero = jnp.zeros(1, dtype=nodes.dtype) # → (1,)
# rₙ = hₙ, with r_N = 0
right = jnp.concatenate([widths, zero]) # (N - 1,) → (N,)
# lₙ = hₙ₋₁, with l₁ = 0
left = jnp.concatenate([zero, widths]) # (N - 1,) → (N,)
# wₙ = (rₙ + lₙ)/2
return 0.5 * (right + left)
# pₙ from the top of the atmosphere to the surface, hPa
pressure = jnp.linspace(0.0, 1013.0, 21) # → (N_P,)
# 300 pₙ
slope_term = 300.0 * pressure # (N_P,) → (N_P,)
# c(pₙ) = 1600 + 300 pₙ/p_s, ppb
methane = 1600.0 + slope_term / 1013.0 # (N_P,) → (N_P,)
# wₙ = (pₙ₊₁ − pₙ₋₁)/2
pressure_weights = trapezoid_weights(pressure) # (N_P,) → (N_P,)
# today (integrix)
# I = ∑ₙ wₙ c(pₙ)
column_integral = rule.integrate(pressure_weights, methane) # → ()
# XCH₄ = I / p_s
column_average = column_integral.value / pressure[-1] # → ()
print(f"XCH4 = {float(column_average):.1f} ppb")XCH4 = 1750.0 ppbThe band radiance is a weighted mean: a toy spectrum with one absorption line at 2300 nm, seen by a channel with a Gaussian response 5 nm wide.
# Shapes: N_S = 401 wavelengths
# λₙ, nm
wavelength = jnp.linspace(2280.0, 2320.0, 401) # → (N_S,)
# δₙ = λₙ − 2300
offset = wavelength - 2300.0 # (N_S,) → (N_S,)
# gₙ = exp(−δₙ²/2)
line_shape = jnp.exp(-0.5 * offset**2) # (N_S,) → (N_S,)
# L(λₙ) = 1 − 0.4 gₙ
spectrum = 1.0 - 0.4 * line_shape # (N_S,) → (N_S,)
# uₙ = δₙ/5
scaled = offset / 5.0 # (N_S,) → (N_S,)
# R_c(λₙ) = exp(−uₙ²/2)
response = jnp.exp(-0.5 * scaled**2) # (N_S,) → (N_S,)
# wₙ = (λₙ₊₁ − λₙ₋₁)/2
spectral_weights = trapezoid_weights(wavelength) # (N_S,) → (N_S,)
# today (integrix)
# L_c = ∑ₙ wₙ Rₙ Lₙ / ∑ₙ wₙ Rₙ
band_radiance = rule.weighted_mean( # → ()
spectral_weights, spectrum, weight=response
)
print(f"L_c = {float(band_radiance):.3f}")L_c = 0.922The line takes about 8 % of the light in the channel, since its width (1 nm) is a fifth of the response’s. Everything in the rest of the section is about the line rule.integrate(weights, samples): where the weights come from, how good they are, and what happens when we cannot write them down in advance.