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.

Spectral Kernel Models — A Visual Guide for Earth-System Priors

Open In Colab

This notebook is a visual survey of stationary spectral kernels — the building blocks behind every Bayesian-spectral layer in pyrox.nn. The companion Kernel Approximation notebook pins down why random Fourier features approximate a kernel; here we step back and ask which kernel we should approximate in the first place, with a particular focus on physically-motivated priors for ocean / land / atmosphere data.

Three things you will see, all by drawing samples from the prior — no inference, no fitting:

  1. The zoo. Side-by-side 1D and 2D realisations of RBF, Matérn-1/2 (Laplace), Matérn-3/2, Matérn-5/2, and the non-stationary ArcCosine [^chosaul2009] kernel. Same lengthscale, same seed family. Differences in regularity, tail content, and stationarity become immediately legible.
  2. A practical decision table. When does each kernel make physical sense, and when does it fail? Five rows, four axes, one paragraph each.
  3. Three earth-system worked examples. A representative kernel choice for each of ocean (SSH-like), land (precipitation-like), and atmosphere (synoptic-temperature-like) signals, with sample paths and 2D fields to ground the recommendation.

Cross-references throughout point to the literature; numbered footnotes collect full citations at the end.

Setup

Helpers. All sample paths in this notebook follow the same recipe:

  1. Build a pyrox.nn spectral layer with MM frequencies on a fixed lengthscale.
  2. Trace it under numpyro.handlers.seed to materialise a single Ω draw.
  3. Combine it linearly with β∼N(0,I)\beta \sim \mathcal{N}(0, I) — that gives a GP prior sample f(x)=β⊤ϕ(x)f(x) = \beta^\top \phi(x) whose covariance is the Monte-Carlo Bochner kernel of the layer.

Vectorising the β draw over a leading axis gives independent path samples. Fixed lengthscale across kernels keeps the comparison purely about regularity and tail behaviour.

1. The spectral-kernel zoo

Five kernels, all on the same 1D grid, same lengthscale, same number of features. Three sample paths per kernel.

<Figure size 1100x900 with 5 Axes>

Walking down the figure: RBF and Matérn-5/2 are visually almost indistinguishable — both are smooth enough that mean-square derivatives of every order (RBF) or up to order 2 (Matérn-5/2) exist. Matérn-3/2 has visible kinks (one m.s. derivative). Matérn-1/2 (Laplace, equivalently the Ornstein-Uhlenbeck process) is continuous but nowhere differentiable — pure jagged texture. ArcCosine-1, by contrast, is not stationary: the ReLU-rectified random projections produce piecewise-affine sample paths whose roughness changes across xx — a fundamentally different prior, useful when the field has localised abrupt transitions [^chosaul2009].

1.1 Empirical Gram and spectral density

Two more views of the same five kernels. The Gram matrix shows correlation structure as ∥x−x′∥\|x - x'\| grows. The spectral density p(ω)p(\omega) — what the random Fourier features actually sample from — is what makes the differences predictable: heavy-tailed densities admit high-frequency content and produce rougher fields; light-tailed densities band-limit the signal.

<Figure size 1300x450 with 2 Axes>

ArcCosine has no Bochner spectral density (it is not shift-invariant), so it is omitted from the right panel. For the four stationary kernels the right panel tells the whole story: the Cauchy spectrum of Matérn-1/2 falls off as ω−2\omega^{-2} — heavy enough that all polynomial moments diverge, hence sample paths are continuous but nowhere differentiable. RBF’s Gaussian spectrum drops super-exponentially — sample paths are C∞C^\infty. Matérn-3/2 and 5/2 sit in between (Student-t3t_3 / t5t_5), giving exactly ν−12\nu - \tfrac12 Hölder regularity. This is the qualitative knob for kernel selection.

1.2 The same kernels in 2D

Same lengthscale, same kernels, samples on a 2D grid. The 2D view is what one usually wants for spatial fields (maps).

<Figure size 1600x360 with 5 Axes>

In 2D the regularity story is even more obvious. RBF and Matérn-5/2 give smooth, ridge-and-trough patterns. Matérn-3/2 retains the same coherence but with sharper detail. Matérn-1/2 is salt-and-pepper at the small scale yet still globally correlated — the right prior when fronts and discontinuities are real. ArcCosine produces blocky, hyperplane-bounded regions characteristic of ReLU networks.

2. Why use one over another — a decision table

Four practical axes on a single line each.

KernelPath regularitySpectrum tailStationary?Use when…
RBFC∞C^\infty — analyticalsuper-exponential (Gaussian)yesthe field is genuinely smooth and bandlimited (laboratory data, idealised PDEs)
Matérn-5/22 m.s. derivativesStudent-t5t_5yes“smooth-ish” geophysical fields where you don’t trust C∞C^\infty — synoptic atmosphere, large-scale SST [^stein1999][^williamsrasmussen2006]
Matérn-3/21 m.s. derivativeStudent-t3t_3yesthe default geostatistics workhorse — mesoscale ocean, soil properties, kriging [^stein1999]
Matérn-1/2 (Laplace)continuous, nowhere diff.Cauchyyesrough / mean-reverting fields — turbulence, precipitation, ocean colour patches [^cressiewikle2011]
ArcCosine-1piecewise-affinen/a (non-stationary)nolocalised abrupt transitions, learned representations, function classes that benefit from ReLU-NN structure [^chosaul2009]

Quick rules of thumb.

  • Don’t reach for RBF by default. Stein 1999 [^stein1999] §2.7 makes the now-standard argument: real geophysical fields are almost never C∞C^\infty, and Matérn-3/2 or 5/2 is usually a better default. The classic worry is that RBF over-confidently extrapolates because its prior bandwidth is genuinely tiny.
  • Pick ν based on physical regularity. Quasi-geostrophic flows admit two-three derivatives → ν∈{1.5,2.5}\nu \in \{1.5, 2.5\}. Turbulent / intermittent fields → ν=0.5\nu = 0.5.
  • Heavy spectral tails ⇒ rough samples. If you suspect the data spectrum decays as ∣ω∣−α|\omega|^{-\alpha} for small α, choose Matérn-ν with ν≈(α−d)/2\nu \approx (\alpha - d) / 2 — that matches the asymptotic spectrum [^stein1999].
  • ArcCosine and friends are for non-stationary structure. If you need amplitude / wavelength to depend on xx (e.g., bathymetry-dependent SSH variance, orographic precipitation), a stationary Matérn is wrong; reach for ArcCosine, deep RFFs Cutajar et al. 2017, or the spectral-mixture kernels of Wilson & Adams [^wilsonadams2013].

3. Physics-informed priors for the Earth system

A pocket reference for kernel choices in three Earth-system tiers. Each table cell is a prior recommendation — what the data tend to look like when you sample from a candidate prior — not a fitted result.

Ocean

VariableKernelWhyRefs
SSH (sea surface height, mesoscale eddies)Matérn-3/2 (anisotropic)known mesoscale length scales (~50–100 km); turbulent cascade slope ∼k−2\sim k^{-2} to k−3k^{-3} in the inertial range[^ubelmann2014][^letraon2003]
SST (sea surface temperature)Matérn-3/2 to 5/2thermal smoothing dominates; submesoscale fronts add roughness[^banzon2016]
SSS (sea surface salinity)Matérn-3/2river-plume / mixing fronts; intermediate regularity[^reul2020]
Ocean colour (chl-a, CDOM)Matérn-1/2 + log transformpatchy, intermittent, log-normal in amplitude[^doney2007]

Demo: an SSH-flavoured field. A Matérn-3/2 prior on a 2D patch with anisotropic lengthscales (longer in zonal direction) — what mesoscale eddy fields on a satellite altimetry track look like before any data lands.

<Figure size 1500x360 with 4 Axes>

Eddy-shaped highs and lows of the right qualitative size, anisotropy aligned with xx. A Matérn-1/2 prior in the same setting would give salt-and-pepper noise; an RBF prior would give over-smooth blobs without sharp eddy edges. Matérn-3/2 is the consensus altimetry choice [^ubelmann2014].

More ocean variables — SST, SSS, ocean colour. Three more 2D priors at qualitatively different smoothness levels. Each panel uses the kernel and lengthscale recommended in the table: Matérn-5/2 (long ℓ\ell) for SST’s broad thermal patches, Matérn-3/2 (medium ℓ\ell) for SSS where river-plume / mixing fronts add sharper structure, and Matérn-1/2 (short ℓ\ell) followed by a log-normal transform for ocean-colour patchiness.

<Figure size 1400x400 with 6 Axes>

Reading the panels left-to-right: SST shows broad warm/cool anomalies, the kind of thermal structure one would see in a monthly anomaly map; SSS has tighter fronts where freshwater plumes / shelf-break mixing intersect; ocean colour, after the log transform, becomes a positive heavy-tailed field with isolated high-concentration patches surrounded by low-chlorophyll background — the qualitative signature of bloom and oligotrophic regions [^doney2007][^reul2020][^banzon2016]. Without the transform, ocean colour drawn directly from a Gaussian prior would be physically meaningless (negative concentrations).

Land

VariableKernelWhyRefs
Air temperatureMatérn-5/2smooth, large coherence length (~100s of km)[^hengl2018]
Soil moistureMatérn-3/2mixed boundary-layer + subsurface processes[^vereecken2008]
PrecipitationMatérn-1/2 + log transformintermittent, heavy-tailed, on/off [^cressiewikle2011][^sun2018]
Wind / orographicMatérn-3/2 + nonstationaritydirection- and elevation-dependent[^gneiting2002]

Demo: a precipitation-flavoured 1D track. Matérn-1/2 sample paths captures the jagged spatial structure of rain rates along a transect — though for true precipitation one would also need a positivity transform (log or square-root) and possibly a Cox-process zero-inflation [^sun2018].

<Figure size 1100x400 with 1 Axes>

Atmosphere

VariableKernelWhyRefs
Temperature, pressure (synoptic)Matérn-5/2quasi-geostrophic ⇒ at least two derivatives[^daley1991][^gaspari1999]
Windbivariate Matérn / divergence-freecomponents share length scale; physical constraint[^gneiting2010]
Trace gases (CO₂, CH₄)Matérn-1/2 to 3/2 + non-Gaussianplumes / sources are intermittent[^ganesan2014]

Demo: a synoptic-temperature-flavoured 2D field. A Matérn-5/2 prior with a relatively long lengthscale gives the broad, smooth highs and lows characteristic of synoptic-scale temperature anomaly maps.

<Figure size 1500x360 with 4 Axes>

Long-wavelength dipoles and tripoles, smooth but not analytically so — exactly the qualitative content one expects in a 500 hPa temperature anomaly field at synoptic scale. A Matérn-1/2 prior would be wrong here; an RBF prior over-smooths the fronts.

Wind speed — vector magnitude from independent Matérn components. Wind has two components (u,v)(u, v), each well-modelled by a Matérn-3/2 prior with similar lengthscale [^gneiting2010]. The speed ∥u,v∥=u2+v2\|u, v\| = \sqrt{u^2 + v^2} is positive and (when u,vu, v are zero-mean Gaussian) follows a Rayleigh-like distribution at each location — the classical empirical fit for surface-wind histograms. Drawing uu and vv independently from the same kernel, then taking the magnitude, gives a quick visual prior over wind-speed maps without ever sampling a non-Gaussian field directly.

<Figure size 1400x400 with 6 Axes>

The two component panels are zero-mean Gaussian, so they look like unsigned anomaly maps. The magnitude panel is positive everywhere and shows the speed maxima at the boundaries between sign changes in either component — the qualitative signature of jet-like and frontal wind structure. A more rigorous prior over wind would use a bivariate Matérn cross-covariance (Gneiting et al. JASA 2010 [^gneiting2010]) so that uu and vv share lengthscale and a physical correlation; the independent-components shortcut here is the cheapest visual prior that still respects the right marginals.

Summary

  • Spectral kernels are priors over functions, parameterised by a spectral density. Choose by reasoning about (a) regularity, (b) spectral tail, (c) stationarity. The decision table in §2 collapses these into a single look-up.
  • For Earth-system data, Matérn-ν is almost always the right family. ν=5/2\nu = 5/2 for synoptic temperature / smooth land variables, 3/23/2 for mesoscale ocean / kriging defaults, 1/21/2 for turbulent / intermittent / heavy-tailed fields. RBF is rarely the right default [^stein1999].
  • Non-stationary structure needs a different machinery. ArcCosine [^chosaul2009] is the simplest entry point; deep RFFs and spectral-mixture kernels [^wilsonadams2013] go further.
  • Use the prior as a sanity check before fitting. The 2D fields above are what you should expect from your model before any data; if the prior samples don’t look like plausible realisations of your domain, the kernel choice is wrong, no matter how good the marginal-likelihood number.

Where to next: with a kernel chosen, the Random Fourier Features regression notebook shows how to do inference (MAP / SSGP / VSSGP) using exactly these spectral layers. The Deep Random Feature Expansions notebook covers the hierarchical / non-stationary extensions.

References