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.

Along-Track SSH — Composition, Filtering, and Co-location with Gridded Products

Tour of the along-track SSH transformations in xrtoolz.ocn. We load a real CMEMS L3 along-track product (AltiKa, 5 days, Gulf Stream box), build sea-surface height from the altimetry convention, compare filtered against unfiltered, co-locate against the gridded L4 DUACS product, look at the spectrum the L3 filter resolves, derive a cross-track geostrophic velocity, and finally evaluate the GLORYS reanalysis diagnostics along the same track.

Each diagnostic gets the same five-part block as the kinematics notebook: ELI5 → formal definition → continuous equation → discretisation → interpretation.

Companion notebooks in this PR cover the gridded kinematics (ocean_kinematics_glorys_duacs.ipynb) and stratification (ocean_stratification_glorys.ipynb).

1 — Load the three datasets

  • L3 along-track: AltiKa drifting-phase observations over [-70, -50] × [30, 45], 2023-06-01 → 06-05. One row per 1-Hz sample with (sla_filtered, sla_unfiltered, mdt, lwe).

  • L4 gridded (DUACS): the merged-altimetry, daily 1/8° product adt. We use it as the standard reference for “what altimetry says SSH is on a regular grid” — itself constructed from a multi-mission L3 ensemble that includes data like our AltiKa subset.

  • GLORYS12 3D: the prognostic reanalysis we use in § 9 to show how to evaluate model diagnostics at the same alongtrack sample points.

L3: {'track': 1359} ['sla_filtered', 'sla_unfiltered', 'mdt', 'lwe']
L4 DUACS: {'time': 5, 'lat': 120, 'lon': 160} ['adt']
GLORYS: {'time': 5, 'lat': 181, 'lon': 241} ['uo', 'vo', 'thetao', 'so', 'zos']

Track geometry

AltiKa is a sun-synchronous drifting-phase mission, so the ground track sweeps gradually through the basin over the 5-day window. We split the 1359 observations into discrete passes by detecting time gaps > 60 s (one orbit revisits a lat band roughly every 100 min).

identified 8 passes; lengths: [243, 13, 123, 236, 215, 243, 204, 82]
<Figure size 750x450 with 1 Axes>

2 — Altimetry convention preamble

A satellite altimeter does not measure SSH directly — it measures the range between the spacecraft and the ocean surface, then subtracts known geophysical corrections. The product chain delivers three quantities the user is meant to recombine:

  • SLA (sea-level anomaly): the deviation from a long-term mean SSH. Two flavours are shipped: sla_unfiltered (raw 1-Hz) and sla_filtered (Lanczos-style high-pass + low-pass that suppresses noise above the geophysical signal).

  • MDT (mean dynamic topography): the time-mean of SSH from a separate climatology — typically the CNES-CLS MDT product, derived from in-situ + altimetry + GRACE.

  • LWE (loading water equivalent): a barotropic loading correction (essentially equivalent water depth from large-scale ocean tides + atmosphere). Subtracting it gives the dynamic ocean topography.

The two L3 transformations in xrtoolz.ocn each implement the standard altimetry composition formula, differing only in which SLA they consume:

η=SLA+MDT−LWE.\eta = \mathrm{SLA} + \mathrm{MDT} - \mathrm{LWE}.

Numerical methods. Pure pointwise arithmetic — no derivatives are taken in this section. The complexity is conventional, not numerical: knowing which products to add and which to subtract.

3 — calculate_ssh_alongtrack

ELI5. Take the satellite’s bumpiness reading (filtered SLA), add the time-mean topography (MDT), subtract the tide loading correction (LWE). What you get is the actual sea-surface height along the track.

What it is. The Layer-1 operator that composes filtered alongtrack SSH from the three altimetry building blocks. By default reads sla_filtered, mdt, lwe and writes ssh.

Continuous formulation.

ηfiltered(t,λ,φ)=SLAfiltered(t,λ,φ)+MDT(λ,φ)−LWE(t,λ,φ).\eta_{\text{filtered}}(t, \lambda, \varphi) = \mathrm{SLA}_{\text{filtered}}(t, \lambda, \varphi) + \mathrm{MDT}(\lambda, \varphi) - \mathrm{LWE}(t, \lambda, \varphi).

Discretisation. None — the operator is a sum of three Datasets evaluated at the same alongtrack samples. The output gains attributes units="m", standard_name="sea_surface_height", long_name="Sea Surface Height".

Interpretation. The filtered alongtrack SSH is the observation — the cleanest signal a single-mission altimeter delivers. It still has an irregular time/lat/lon footprint (one number per orbit-Hz sample), so it must be co-located with model output before quantitative comparison.

after alongtrack: ['sla_filtered', 'sla_unfiltered', 'mdt', 'lwe', 'ssh']
ssh: mean 0.397 m, std 0.421 m
<Figure size 1000x450 with 2 Axes>

4 — calculate_ssh_unfiltered

ELI5. Same recipe, but with the raw 1-Hz SLA (no smoothing applied at L3 production). Keeps the small-scale wiggles — both the real sub-mesoscale signal and the instrument noise.

What it is. The pure-function (Tier-A) variant pointing at sla_unfiltered instead of sla_filtered. There is no separate Operator wrapper because in practice you usually want one or the other in a pipeline, not both.

Continuous formulation.

ηunfiltered=SLAunfiltered+MDT−LWE.\eta_{\text{unfiltered}} = \mathrm{SLA}_{\text{unfiltered}} + \mathrm{MDT} - \mathrm{LWE}.

Discretisation. Same pointwise sum, different SLA input.

Interpretation. Unfiltered SSH is closer to the raw observation but inherits the high-frequency noise floor of the altimeter (~ 2 cm RMS at 1 Hz for AltiKa). The L3 filter is a Lanczos-style finite-impulse-response that removes scales below ~ 60 km — a deliberate trade between spatial resolution and noise. The variance budget below quantifies the trade.

<Figure size 1000x360 with 1 Axes>

5 — Filter residual: variance budget

ELI5. Subtract the smooth signal from the noisy one. What’s left over is what the L3 filter removed.

What it is. The residual ηunfiltered−ηfiltered\eta_{\text{unfiltered}} - \eta_{\text{filtered}} isolates the small-scale variance the L3 production pipeline judges to be below the geophysical signal floor. Computing its variance ratio against the filtered signal quantifies the trade-off between spatial resolution and noise.

Continuous formulation.

r(s)=ηunfiltered(s)−ηfiltered(s),ρnoise=Var rVar ηfiltered.r(s) = \eta_{\text{unfiltered}}(s) - \eta_{\text{filtered}}(s), \qquad \rho_{\text{noise}} = \frac{\mathrm{Var}\,r}{\mathrm{Var}\,\eta_{\text{filtered}}}.

Discretisation. Pointwise difference; variances over the full sample.

Interpretation. A small noise ratio (typical: 5-15 %) means the filter discards mostly noise. A large one indicates the filter is throwing away real signal — usually a hint that the configured cut-off is too aggressive for the regime of interest (sub-mesoscale fronts in the Gulf Stream, for instance, can sit right at the filter’s stop band).

Var(filtered SSH) = 0.17727 m²
Var(residual)     = 0.00020 m²
noise/signal var ratio = 0.114%
<Figure size 1000x300 with 1 Axes>

6 — Co-location with the L4 gridded DUACS product

ELI5. For every alongtrack point, pick the closest L4 grid cell at the same time. Compare. The L3 sees what one satellite saw at one instant; the L4 is a multi-mission analysis on a regular grid.

What it is. The standard altimetry-validation pattern: bilinear-interpolate the gridded L4 product onto the irregular (t, \text{lat}, \text{lon}) of the L3 observations and compute pointwise difference statistics.

Continuous formulation. With Π\Pi the bilinear-interpolation operator on the L4 grid:

ηL4 at L3(ti,λi,φi)=Π[ηL4](ti,λi,φi).\eta_{\text{L4 at L3}}(t_i, \lambda_i, \varphi_i) = \Pi\bigl[\eta_{\text{L4}}\bigr](t_i, \lambda_i, \varphi_i).

Discretisation. xr.Dataset.interp(time=..., lat=..., lon=...) runs xarray’s vectorised bilinear interpolation. We then compute RMSE and correlation between the two SSH fields. We de-mean each side first because the L3 SSH carries an absolute reference (MDT included) while DUACS adt is on a slightly different geoid — the meaningful comparison is variance-relative, not absolute.

<Figure size 1000x360 with 2 Axes>

7 — Power spectrum along the orbit

ELI5. Take one continuous orbit pass, expand it into sine waves of different wavelengths, and plot how much energy sits at each wavelength. Long wavelengths are gyres and basin-scale flow; short wavelengths are eddies and sub-mesoscale fronts.

What it is. A 1-D power spectrum of η(s)\eta(s) along arc length ss. The L3 filter’s cut-off shows up as a clear roll-off at small wavelengths (high wavenumbers); the L4 (gridded reconstruction) has even less energy at the smallest scales because the optimal-interpolation analysis smears information across crossing tracks.

Continuous formulation.

η^(k)=∫η(s) e−i2πks ds,P(k)=∣η^(k)∣2.\hat{\eta}(k) = \int \eta(s)\,e^{-i 2\pi k s}\,\mathrm{d}s, \qquad P(k) = |\hat{\eta}(k)|^2.

Discretisation. We pick one continuous pass, compute arc-length sis_i via the haversine formula between consecutive points, resample onto a uniform ss grid (FFT requires uniform sampling), then call xrft.power_spectrum.

Interpretation. The expected slope is ≈ k−2k^{-2} in the mesoscale band (50-500 km wavelength) for a quasi-geostrophic ocean — diagnostic of the mesoscale energy cascade. A spectrum that flattens at small scales indicates the noise floor is being reached; a steepening flag indicates an over-aggressive filter.

<Figure size 750x450 with 1 Axes>

8 — Cross-track geostrophic velocity

ELI5. Ride along the satellite’s path. The slope of SSH along the track tells you which way the water is flowing across the track, and how fast.

What it is. The geostrophic velocity component perpendicular to the satellite ground track, derived from the alongtrack SSH gradient. A single altimeter cannot resolve both uu and vv at a point — only the cross-track component is observable from one pass; recovering the full vector requires crossing tracks (the L4 product solves this via optimal interpolation).

Continuous formulation. Let ss be arc length along the track and n^\hat{n} the unit cross-track normal. Then

v⊥(s)=gf(φ(s)) ∂η∂s,v_\perp(s) = \frac{g}{f(\varphi(s))}\,\frac{\partial \eta}{\partial s},

with g=9.80665g = 9.80665 m/s² and f(φ)f(\varphi) from coriolis_parameter.

Discretisation. We use the same haversine arc length as § 7 and np.gradient(eta, s) for ∂η/∂s\partial\eta/\partial s — equivalent to a central finite difference on a possibly non-uniform grid. The same operation applied to the unfiltered SSH amplifies its noise floor: differentiation in physical space is a high-pass filter, so any small high-frequency wiggle in η\eta becomes a much larger wiggle in ∂η/∂s\partial\eta/\partial s. This is exactly why the L3 filter exists.

xrtoolz.ocn.geostrophic_velocities is not used here because it operates on 2-D lat/lon grids; for irregular 1-D tracks an arc-length-aware helper is the right tool. If this pattern recurs, it’s a candidate for promotion to the library as alongtrack_geostrophic_velocity.

Interpretation. Cross-track velocity is the standard observable for altimetry-based skill scores — model evaluation reports often quote “RMS error in cross-track velocity” rather than “RMS error in SSH”. Fronts show up as sharp spikes in v⊥v_\perp; eddies as oscillations of alternating sign as the track crosses them.

<Figure size 1000x600 with 3 Axes>

9 — Co-locate gridded GLORYS kinematic diagnostics along the track

ELI5. Take the model. Build all the diagnostics from the kinematics notebook (vorticity, KE, Okubo-Weiss, …). Then ask the model: “what does each of those diagnostics look like at the exact place and time the satellite was when it took its observation?” That’s how you compare a continuous model field to a sparse, irregular satellite track.

What it is. The standard model-vs-observation evaluation pipeline. A Sequential of Augment(diagnostic) ops is applied to GLORYS once, producing a Dataset with vorticity, KE, divergence, Okubo-Weiss, etc. as additional variables. The whole augmented Dataset is then sampled at each L3 alongtrack point via xr.Dataset.interp. The resulting alongtrack series of model diagnostics can be compared to the observed cross-track velocity (§ 8) or to any other alongtrack-derived signal.

Continuous formulation. With D\mathcal{D} a diagnostic operator (e.g. relative vorticity) and Π\Pi bilinear interpolation:

Dmodel along track(si)=Π[D(umodel)](ti,λi,φi).\mathcal{D}_{\text{model along track}}(s_i) = \Pi\bigl[\mathcal{D}(\mathbf{u}_{\text{model}})\bigr](t_i, \lambda_i, \varphi_i).

Discretisation. Three steps:

  1. Regrid GLORYS to a 0.25° lat/lon target via regrid_like (consistent with the kinematics notebook).

  2. Build the diagnostics in one pass with Sequential([Augment(RelativeVorticity()), Augment(Divergence()), Augment(KineticEnergy()), Augment(StrainMagnitude()), Augment(OkuboWeiss())]).

  3. augmented.interp(time=…, lat=…, lon=…) over the alongtrack (time, lat, lon) arrays — vectorised xarray bilinear interpolation.

Interpretation. This is the same diagnostic suite used to evaluate models against drifters, gliders, ARGO floats, and altimeters. The L3 alongtrack co-location is the cleanest test for SSH-related diagnostics; for velocity diagnostics, model bias against the observed cross-track velocity (§ 8 vs § 9) directly reflects the model’s ability to reproduce the geostrophic mesoscale.

Sequential (5 ops)
├── Augment(inner={'class': 'RelativeVorticity', 'config': {'u': 'u', 'v': 'v'}})
├── Augment(inner={'class': 'Divergence', 'config': {'u': 'u', 'v': 'v'}})
├── Augment(inner={'class': 'KineticEnergy', 'config': {'u': 'u', 'v': 'v'}})
├── Augment(inner={'class': 'StrainMagnitude', 'config': {'u': 'u', 'v': 'v'}})
└── Augment(inner={'class': 'OkuboWeiss', 'config': {'u': 'u', 'v': 'v'}})

Sequential (5 ops)
Step  Operator                                  Input Signature                  Output Signature               
----  ----------------------------------------  -------------------------------  -------------------------------
0     Augment(RelativeVorticity(u='u', v='v'))  (lat=61, lon=81); dtype=float64  (lat=61, lon=81); dtype=float64
1     Augment(Divergence(u='u', v='v'))         (lat=61, lon=81); dtype=float64  (lat=61, lon=81); dtype=float64
2     Augment(KineticEnergy(u='u', v='v'))      (lat=61, lon=81); dtype=float64  (lat=61, lon=81); dtype=float64
3     Augment(StrainMagnitude(u='u', v='v'))    (lat=61, lon=81); dtype=float64  (lat=61, lon=81); dtype=float64
4     Augment(OkuboWeiss(u='u', v='v'))         (lat=61, lon=81); dtype=float64  (lat=61, lon=81); dtype=float64
GLORYS augmented columns: ['ssh', 'u', 'v', 'vort_r', 'div', 'ke', 'strain', 'ow']
GLORYS-at-track diagnostics: ['ssh', 'u', 'v', 'vort_r', 'div', 'ke', 'strain', 'ow']
<Figure size 1000x600 with 3 Axes>

10 — Bonus: a Sequential ingest pipeline

The standard L3 alongtrack ingest collapses to one Sequential: compose SSH, augment with the unfiltered SSH for downstream filter-budget work, and a Tap to log basic stats — fully reusable across any L3 product that ships the conventional (sla_*, mdt, lwe) variables.

Sequential (2 ops)
├── Augment(inner={'class': 'CalculateSSHAlongtrack', 'config': {'variable': 'ssh', 'sla': 'sla_filtered', 'mdt': 'mdt', 'lwe': 'lwe'}})
└── Tap(name='ssh_stats', side_effect='<callable>')

Sequential (2 ops)
Step  Operator                                                                                   Input Signature              Output Signature           
----  -----------------------------------------------------------------------------------------  ---------------------------  ---------------------------
0     Augment(CalculateSSHAlongtrack(variable='ssh', sla='sla_filtered', mdt='mdt', lwe='lwe'))  (track=1359); dtype=float64  (track=1359); dtype=float64
1     Tap(name='ssh_stats')                                                                      (track=1359); dtype=float64  (track=1359); dtype=float64
Running ingest:
  ssh: mean 0.397 m, std 0.421 m, n=1359

11 — Bonus: Graph DAG with one Input(name='l3')

Same ingest expressed as a DAG with one input and two terminal SSH nodes (filtered and unfiltered) — convenient when downstream code needs each output as its own object instead of merged into the input.

Graph(inputs=['l3'], outputs=['filtered', 'unfiltered'])
Loading...

12 — Rebuilding the L3 cache

import copernicusmarine as cm
import pandas as pd, numpy as np, xarray as xr

df = cm.read_dataframe(
    dataset_id="cmems_obs-sl_glo_phy-ssh_my_alg-l3-duacs_PT1S",
    variables=["sla_filtered", "sla_unfiltered", "mdt", "lwe"],
    minimum_longitude=-70.0, maximum_longitude=-50.0,
    minimum_latitude=30.0,   maximum_latitude=45.0,
    start_datetime="2023-06-01", end_datetime="2023-06-05",
)
wide = df.pivot_table(
    index=["time", "longitude", "latitude"], columns="variable", values="value"
).reset_index()
wide["time"] = pd.to_datetime(wide["time"])
wide = wide.sort_values("time").reset_index(drop=True)

ds = xr.Dataset(
    {col: (("track",), wide[col].values)
     for col in ["sla_filtered", "sla_unfiltered", "mdt", "lwe"]},
    coords={
        "track": np.arange(len(wide)),
        "time": (("track",), wide["time"].values),
        "longitude": (("track",), wide["longitude"].values),
        "latitude": (("track",), wide["latitude"].values),
    },
)
ds.to_netcdf(".cache/cmems_l3_alongtrack_gulfstream_2023-06.nc")