Matched filter for hyperspectral methane retrieval¶
Ported from plumax 0.1.2 (28f257e); module and link paths updated for radtrax.
The matched filter (MF) is the maximum-SNR linear detector for a known target signature in additive Gaussian noise. In hyperspectral methane retrieval it is the workhorse baseline: it is fast, it has a closed form, and it is surprisingly competitive with full variational retrievals when the signal is weak and the scene is statistically homogeneous. This note derives the MF from scratch, lays out the four covariance flavours implemented in radtrax
The derivation borrows from Funk et al. [1], Theiler & Foy [2] and Thompson et al. [3]; the operator-based implementation follows the structured linear algebra of Golub & Van Loan [4] and the Woodbury-friendly design of gaussx.
Symbols
| Symbol | Meaning | Shape | Unit |
|---|---|---|---|
| number of instrument bands | scalar | dimensionless | |
| number of background pixels the clutter is estimated from | scalar | dimensionless | |
| one pixel’s band radiance (the observation) | radiance | ||
| mean of plume-free spectra (the background mean) | radiance | ||
| covariance of plume-free spectra (the background clutter: noise, surface variability, calibration residual) | radiance² | ||
| the pixel’s departure from the background mean | radiance | ||
| plume strength (the unknown) | unit of the target, e.g. mol/m² | ||
| target signature: the change in per unit , a one-column Jacobian of the forward model | radiance per unit | ||
| unit absorption spectrum, at ; negative where the gas absorbs | m²/mol | ||
| the matched-filter score, an estimate of | scalar | unit of | |
| characteristic plume strength, the score’s standard deviation under the null | scalar | unit of | |
| , | the precomputed filter and its energy | , scalar | dimensionless |
| standard normal CDF | dimensionless |
The symbols of §4 are those of the 3D-Var page and are defined where they first appear.
1. The signal model¶
We observe one radiance spectrum per pixel of the scene. The additive model says that a plume of strength adds a fixed multiple of the target signature to the background, so we will have:
where is the background mean spectrum (what we would observe at a pixel free of any plume enhancement), is the target signature (the spectral shape that a unit enhancement leaves in ), is the plume strength (pixels with are background, is a plume) and is the background clutter covariance, assumed Gaussian. Under this model the log-likelihood of a pixel is, up to additive constants,
Setting gives the maximum-likelihood estimator of the strength:
1.1 The SNR and detection threshold¶
Under the null () the score is , and under an alternative with strength it is . So the detection SNR is
and the Gaussian threshold on for a false-alarm rate (FAR) is
Both are implemented in matched_filter.core as matched_filter_snr and detection_threshold.
The score’s standard deviation under the null, , is what Theiler [5] calls the characteristic plume strength: a plume of strength is an -sigma detection, . It also shows how much whitening buys. At the radiance itself changes by a fraction , which is below 10-3 on Theiler’s AVIRIS-NG and OMI scenes and about on the synthetic EMIT-like scene of Absorptive plume detection. So plumes that are invisible in the raw spectra are clear in the matched-filter map.
The same standard deviation becomes a map once the background varies, and a plume fit needs it to weight each pixel’s score by its own noise. score_std returns for one global background, cluster_score_std gives each pixel the of its cluster’s covariance, and adaptive_score_std gives each pixel from its window’s band variances and the ridge ; the geo operators return the map as a second band, std, with return_std=True, and matched_filter_snr and detection_threshold are and . All of these assume the true . With the sample covariance of pixels in bands, the expected output SNR is lower by the factor (Reed, Mallett and Brennan, 1974), so the plug-in is too small by roughly the inverse square root of that factor: 0.3 % for 60 bands on 104 pixels, and 19 % for 60 bands on a 200-pixel cluster. A shrunk or low-rank covariance has no closed form for the factor, and the functions return the plug-in value.
1.2 What the score recovers¶
The filter is unbiased only for a pixel whose spectrum responds like the target. The score is linear in the spectrum, so adding an enhancement to pixel shifts its score by exactly for a fixed background, where the sensitivity is
with and the radiance change of the pixel. With the unit absorption spectrum, Beer–Lambert gives , and as the sensitivity tends to .
Two effects follow. The first is the albedo effect: with the radiance target and a pixel that is the mean scaled by a brightness , , the sensitivity is , so a pixel twice as bright as the scene reports twice the enhancement. The second is saturation: expanding the exponential,
and the second term is negative for an absorbing gas when the filter weights follow the absorption, so the sensitivity falls as the plume strengthens. A plume fit compares times its modelled enhancement with the score, . score_sensitivity computes (7) in the Beer–Lambert form (with enhancement= for the saturated value), response_sensitivity takes any from a forward model, cluster_score_sensitivity uses each pixel’s cluster covariance, and the geo operator MatchedFilterSensitivity returns the map on the input’s carrier. With the log-radiance form of the filter (a cube of and target ) the response is for every pixel and , so the map matters only for the radiance form. The definition holds and fixed; a plume that covers much of the scene also enters the background statistics, which does not see.
2. Practical decomposition: precompute once, apply per pixel¶
Equation (4) is deceptively cheap. Per pixel it is a dot product of length , except that appears. Done naively we would invert a matrix once, but that throws away the chance to exploit any structure in . The right decomposition precomputes the filter and its energy once per scene, so we will have:
and then, per pixel,
That is one linear solve and one dot product per scene, followed by one dot product per pixel (a single BLAS call when vectorised over the image). This is what apply_image in core.py does; the sketch below leaves out its check that , and it gives the same scores as apply_image to the last bit on a random cube:
import gaussx_linalg
import gaussx_sketch
import jax.numpy as jnp
import lineax as lx
from jaxtyping import Array, Float
# Shapes: H, W image rows and columns; B bands
def apply_image(
cube: Float[Array, "H W B"],
mean: Float[Array, " B"],
cov_op: lx.AbstractLinearOperator,
target: Float[Array, " B"],
) -> Float[Array, "H W"]:
# today (gaussx)
# w = Σ_y⁻¹ J_h, one structured solve per scene
w = gaussx_linalg.solve(cov_op, target) # (B,) → (B,)
# z = J_hᵀ Σ_y⁻¹ J_h
z = jnp.dot(target, w) # (B,) → ()
# r = y − μ_y, for every pixel
residual = cube - mean # (H, W, B) → (H, W, B)
# α̂ = rᵀ w / z
scores = jnp.einsum("hwb,b->hw", residual, w) # (H, W, B) → (H, W)
return scores / z # (H, W) → (H, W)The key move is gaussx_linalg.solve(cov_op, target). Since cov_op is an abstract lineax.AbstractLinearOperator, the solve dispatches on structure: a dense operator triggers a Cholesky, a diagonal operator a per-element divide, and a low-rank update triggers Woodbury, with no change to the kernel above.
3. Four flavours of ¶
The four reference files in jej_vc_snippets/methane_retrieval/ originally wrote out four separate implementations of (4), one per covariance model. In the operator-based view they collapse into four estimation routines that all return the same type, a lineax.AbstractLinearOperator. Below, for are the background pixels, is the shrinkage weight, holds the top spectral directions with variances , is the Tikhonov floor (the tikhonov argument) and is the number of clusters.
Covariance estimators and the operators they produce.
Estimator | Formula | Operator type | Per-pixel cost |
|---|---|---|---|
|
| once, then | |
|
| same | |
| , from a randomised SVD |
| once, then |
| per GMM cluster | list of the operators above, one per cluster | per-cluster amortised |
The Ledoit–Wolf and OAS estimators come from sklearn.covariance, and both shrink toward the scaled identity in the table; the randomised SVD of the low-rank estimator is gaussx_sketch.randomized_svd (Halko–Martinsson–Tropp, in JAX). The background estimation is off the JAX gradient path (the background is treated as a fixed input), so we lean on scikit-learn freely there. Only the per-pixel application stays in JAX, vectorised with jax.vmap or einsum for GPU-friendly batching.
3.1 Why low-rank plus Tikhonov matters¶
For and a homogeneous scene, the spectral covariance is close to low rank: a handful of surface-reflectance principal components explain most of the variance. Writing lets us apply Woodbury, so we will have:
The inner inverse is , so costs instead of . For a typical hyperspectral methane setup (, ) this is a ~1000× speedup on the MF precompute, which the user only sees in that estimate_cov_lowrank returns a gaussx_linalg.LowRankUpdate instead of a dense operator.
4. Relationship to 3D-Var¶
In the notation of the 3D-Var page, is the state with prior mean and covariance , the observations with error covariance , the observation operator and its tangent-linear, the innovation and the increment. (Here and are the sizes of the state and of the observations, written and on that page; on this page counts background pixels.) Incremental 3D-Var minimises
and the PSAS (dual) path solves for a dual variable in observation space, then maps it back to the state:
The MF is the PSAS analysis of a one-dimensional state, the plume strength itself, under a flat prior. Let’s take , so the tangent-linear is the target signature, , and the innovation of one pixel is . Let’s also take the prior variance and the observation error . Then (14) is a rank-one update of , and the Sherman–Morrison formula solves it in closed form, so we will have:
As the in the denominator vanishes and is the matched filter (4) at . For a finite the same algebra gives the matched filter shrunk toward zero by its prior, which is the one-pixel version of what the full retrieval does. So the MF is not a heuristic: it is the exact, closed-form, flat-prior dual 3D-Var solution, and for this one-dimensional problem the dual solve needs no iterations at all; the SNR and threshold formulas follow without further work. run_dual_psas solves the same system with CG for a full field.
The corollary is that when is not flat, i.e. when we have real prior information about the VMR field (spatial smoothness, a climatological mean, etc.), the full 3D-Var retrieval uses information the MF throws away, and it does better whenever that prior is right. See plumax’s 01_mf_vs_3dvar.ipynb for a numerical comparison on the same scene (it lives in plumax because it simulates the plume).
5. Where the target signature comes from¶
For methane, is the spectral signature of a unit VMR enhancement. Let’s write the Beer–Lambert forward model per wavenumber as , where is the background radiance and the absorption per unit enhancement. Its Taylor expansion at the background state gives
where is the unit absorption at that wavenumber, so the target is the background radiance times the unit absorption. Rather than hard-coding this, we take the JVP of the existing observation operator: linear_target_from_obs differentiates the forward model with jax.jvp along a perturbation pattern of the state and reads the result at one output pixel.
from radtrax.retrieval.matched_filter import linear_target_from_obs
# Shapes: H, W rows and columns of the state grid; B bands
# today (radtrax)
# J_h = ∂h(μ_x + α δx) / ∂α at α = 0, with δx uniform over the scene
target = linear_target_from_obs( # (H, W) → (B,)
obs, vmr_background, pattern="uniform"
)This guarantees the target is exactly consistent with whatever forward model (PSF, GSD, SRF) the retrieval uses, so there is no drift between a “target generator” and the forward model. For strong plumes, where Beer–Lambert saturation matters, nonlinear_target_from_obs(obs, vmr_background, amplitude=α) computes the exact finite-amplitude response instead. That turns the filter into the additive approximation of the clairvoyant detector at , the optimal detector when the strength is known (Absorptive plume detection, Step 4), which is best near the chosen amplitude and not uniformly.
5.1 Three targets for one gas¶
On the layered ForwardModel, unit_absorption_target returns the gas’s unit absorption in log radiance, with , which is negative where the gas absorbs. Since Beer–Lambert is multiplicative, the additive target built from it depends on what the filter is applied to, and Theiler [5] and Schaum [6] compare three:
Matched-filter targets for an absorbing gas.
Target | Applied to | Assumes | radtrax |
|---|---|---|---|
on radiance (“t”) | a spectrally flat background |
| |
(“Tμ”) | every pixel’s plume direction is the mean pixel’s |
| |
on log radiance | lognormal clutter, so the plume is a shift in log space |
|
The Tμ target beat the flat one on every scene in both papers, and the Beer–Lambert target (19) above is of the Tμ kind. The log-space filter is uniformly most powerful when the clutter is lognormal, but band integration and additive sensor noise break that model; on Theiler’s real scenes its fattened variants (log-ACE, log-EC) did well, while on the synthetic EMIT-like scene the plain Tμ filter beat it. Beyond Gaussian clutter has the details.
6. Summary¶
The pieces of radtrax.retrieval.matched_filter:
Module | Role |
|---|---|
| |
| |
| |
| |
| |
|
The two companion notebooks:
01_mf_vs_3dvar.ipynb: the MF against full 3D-Var on the same HAPI methane scene used in the assimilation tutorial, so we can see where the flat-prior MF gives up information.02_covariance_flavours.ipynb: dense, shrunk, low-rank and GMM-clustered on a heterogeneous scene, comparing detection power and runtime.
Funk, C. C., Theiler, J., Roberts, D. A., & Borel, C. C. (2001). Clustering to improve matched filter detection of weak gas plumes in hyperspectral thermal imagery. IEEE TGRS, 39(7).
Theiler, J. & Foy, B. R. (2006). Effect of signal contamination in matched-filter detection of the signal on a cluttered background. IEEE GRSL, 3(1).
Thompson, D. R., et al. (2015). Real-time remote detection and measurement for airborne imaging spectroscopy: a case study with methane. AMT, 8.
Golub, G. H. & Van Loan, C. F. (2013). Matrix Computations (4th ed.). Johns Hopkins.