Collocating geostationary and polar-orbiter data
Note
Download the executable 06_geo_leo_collocation.ipynb to run this tutorial in JupyterLab.
A geostationary imager watches one face of the Earth continuously; a polar orbiter crosses it on a swath, at its own time, on its own grid. Putting the two together means deciding which pixels correspond, and being honest about the fact that they were not measured at the same instant.
This tutorial collocates MSG SEVIRI with Metop AVHRR. It aligns the swath onto a shared EPSG:4326 grid, shows what the time coordinate means afterwards, keeps the geostationary grid instead in a second pass, adds a third instrument to the same grid, and writes the EPSG:4326 cube as Zarr.
Before running this notebook, complete the shared setup in Tutorials.
Prerequisites
No. 1 Input data
The notebook reads these products from the public demo bucket of the DestinE Data Lake, without an account or credentials:
MSG SEVIRI native data
Metop AVHRR Level-1B
Sentinel-3 SLSTR Level-1B radiances
To use your own files instead, change ROOT and the paths in
MSG_PATH, AVHRR_PATH and SLSTR_PATH and follow Prepare data access for DEFAIR. It explains how to
read them from your own object store, from a local disk or through HDA.
No. 2 Memory for the full-disc alignment
Allow for the following resource use:
The alignment onto the full disc near the end takes about 75 s and 4 GB of memory.
The first code cell starts a one-worker Dask client with a 12 GB limit.
Set up the notebook
from pathlib import Path
import numpy as np
import xarray as xr
from defair_data.core import Dataset
from defair_data.dask_manager import get_dask_client, close_dask_client
from defair.notebook_helpers import viz
viz.quiet()
get_dask_client(n_workers=1, threads_per_worker=4, memory_limit="12GB", processes=False)
OUTPUT = Path("output"); OUTPUT.mkdir(exist_ok=True)
# The public Data Lake demo bucket, which needs no credentials.
PUBLIC_S3 = {"endpoint_url": "https://s3.central.data.destination-earth.eu", "anon": True}
ROOT = "s3://datalake-demo-data/defair-notebook-data"
MSG_PATH = f"{ROOT}/msg-seviri-l15/msg_f997b2b630fc42_MSG3-SEVI-MSG15-0100-NA-20251210102744.394000000Z-NA.nat"
AVHRR_PATH = f"{ROOT}/metop-avhrr-l1b/AVHR_xxx_1B_M01_20251210101003Z_20251210114903Z_N_O_20251210105813Z"
SLSTR_PATH = f"{ROOT}/sentinel3-slstr-rbt/S3B_SL_1_RBT____20251210T102103_20251210T102403_20251211T151934_0179_114_179_2700_MAR_O_NT_004.SEN3"
# Study box over the eastern Atlantic and north-west Africa (lon_min, lon_max,
# lat_min, lat_max). The Metop-B pass crosses it while SEVIRI is scanning it.
BOX = (-35.0, 5.0, -10.0, 42.0)
Read both instruments
Two readers, two grids, one call each.
# The whole disc and the whole orbit are kept: the last section goes back to them uncropped,
# and reading a granule again costs as much as the first read.
msg_disc = Dataset.from_source(
MSG_PATH,
reader="msg15nat",
source="s3",
source_kwargs=PUBLIC_S3,
channels=["IR_108"],
use_channel_names=True,
calibration="brightness_temperature",
)
avhrr_orbit = Dataset.from_source(
AVHRR_PATH,
reader="metop_avhrrl1",
source="s3",
source_kwargs=PUBLIC_S3,
bands=["brightness_temperature_4", "latitude", "longitude"],
).transform("content_filter", include_vars=["brightness_temperature_4"])
msg = msg_disc.transform("spatial_filter", lon_min=BOX[0], lon_max=BOX[1], lat_min=BOX[2], lat_max=BOX[3])
avhrr = avhrr_orbit.transform("spatial_filter", lon_min=BOX[0], lon_max=BOX[1], lat_min=BOX[2], lat_max=BOX[3])
for label, ds in [("SEVIRI", msg), ("AVHRR", avhrr)]:
print(f" {label:6s} dims={dict(ds.data.sizes)} vars={list(ds.data.data_vars)}")
SEVIRI dims={'time': 1, 'y': 1713, 'x': 1363, 'bnds': 2} vars=['IR_108', 'geostationary']
AVHRR dims={'time': 1, 'y': 5968, 'x': 2048, 'bnds': 2} vars=['brightness_temperature_4']
# One colour range for every comparison in this tutorial, taken from the geostationary
# field. Letting each panel autoscale its own spread draws the same brightness temperature
# in a different colour on each side of a comparison, which is the one thing a collocation
# figure must not do. Every instrument here measures the same 10.8 um window, so one range
# fits them all.
BT_RANGE = viz.vrange(msg.data["IR_108"].isel(time=0).values)
print(f"shared display range: {BT_RANGE[0]:.1f} to {BT_RANGE[1]:.1f} K")
viz.show_panels(
[
{"ds": msg, "var": "IR_108", "kind": "grid", "cmap": "RdYlBu_r",
"title": "MSG SEVIRI (grid)\nIR_108, 10.8 um brightness temperature",
"vmin": BT_RANGE[0], "vmax": BT_RANGE[1]},
{"ds": avhrr, "var": "brightness_temperature_4", "kind": "swath", "cmap": "RdYlBu_r",
"title": "Metop-B AVHRR (swath)\nchannel 4, 10.3 to 11.3 um brightness temperature",
"label": "K", "extent": [BOX[0], BOX[1], BOX[2], BOX[3]],
"vmin": BT_RANGE[0], "vmax": BT_RANGE[1]},
],
suptitle="Native inputs, two geometries over the same region (2025-12-10)",
save=OUTPUT / "geo_leo_native.png",
figsize=(15, 6),
)
shared display range: 227.9 to 306.5 K
What “at the same time” means here
The geostationary granule has one timestamp for the repeat cycle. The
polar granule has a timestamp per scanline. Collocation cannot make
those identical, and the cube keeps neither pair: temporal matching
works on the granule-level time coordinate, and with
time_bounds="base" the output carries the SEVIRI slot alone. The
per-scanline times are indexed by the swath’s own spatial dimension, so
resampling onto the target grid drops them. The cell below is where the
two granule labels are visible, before that happens.
msg_time = msg.data["time"].values[0]
avhrr_time = avhrr.data["time"].values[0]
scanline_times = avhrr.data["time_mdr"].values
offset_s = (msg_time - avhrr_time) / np.timedelta64(1, "s")
print(f"SEVIRI repeat cycle nominal start : {msg_time}")
print(f"AVHRR granule sensing start : {avhrr_time}")
print(f"gap between the granule labels : {offset_s:.0f} s")
print(f"AVHRR scanlines in the crop span : {scanline_times.min()} -> {scanline_times.max()}")
print(f"SEVIRI slot inside that span : {scanline_times.min() < msg_time < scanline_times.max()}")
SEVIRI repeat cycle nominal start : 2025-12-10T10:15:00.000000000
AVHRR granule sensing start : 2025-12-10T10:10:03.000000000
gap between the granule labels : 297 s
AVHRR scanlines in the crop span : 2025-12-10T10:13:04.418000000 -> 2025-12-10T10:29:38.918000000
SEVIRI slot inside that span : True
Keeping the reference product’s own grid
The section above put both products on a common EPSG:4326 target. Naming a reference dataset instead keeps that product’s native grid and resamples the others onto it, so the SEVIRI pixels come back untouched. The choice belongs to whoever knows which grid the downstream work needs.
cube_geos = msg.transform(
"alignment",
datasets=[avhrr],
reference_dataset=msg,
spatial_method="nearest",
temporal_method="nearest",
time_tolerance="10min",
time_bounds="base",
)
print(f" dims : {dict(cube_geos.data.sizes)}")
print(f" variables : {list(cube_geos.data.data_vars)}")
print(f" grid kept : x and y identical to the SEVIRI input -> "
f"{np.array_equal(cube_geos.data['x'].values, msg.data['x'].values)}")
viz.show_panels(
[
{"ds": cube_geos, "var": MSG_VAR, "kind": "grid", "cmap": "RdYlBu_r",
"title": "SEVIRI, its own pixels",
"vmin": BT_RANGE[0], "vmax": BT_RANGE[1]},
{"ds": cube_geos, "var": AVHRR_VAR, "kind": "grid", "cmap": "RdYlBu_r",
"title": "AVHRR resampled onto SEVIRI pixels",
"vmin": BT_RANGE[0], "vmax": BT_RANGE[1]},
],
suptitle="Collocated onto the native geostationary grid",
save=OUTPUT / "geo_leo_cube_geostationary.png",
figsize=(15, 6),
)
dims : {'time': 1, 'x': 1363, 'y': 1713}
variables : ['msg_seviri_native_format_IR_108', 'ds1_brightness_temperature_4']
grid kept : x and y identical to the SEVIRI input -> True
Three instruments, one grid
Sentinel-3B’s SLSTR crossed the same box at 10:21 UTC, six minutes after
the SEVIRI slot and inside the 10:13 to 10:29 window the Metop-B
scanlines cover it. It is a polar swath like AVHRR, but a conical
scanner on its own infrared grid, so it arrives with a third layout
again. alignment takes a list of datasets, so a third instrument is
one more entry.
The read prints the SLSTR reader’s own metadata notices, which are about
the product’s flag declarations rather than its data, and one notice
worth reading: Could not determine bounds for dataset 2. The granule
carries finite 2-D latitude and longitude, so it does have an
extent to offer, and the message reports how alignment looks for one
rather than a property of a conical scan. Its bounds discovery asks
rio.bounds() first; that call raises whenever the spatial dimensions
carry no 1-D coordinates of their own, which is what rows and
columns are here, and the 2-D coordinates are never consulted
afterwards. AVHRR escapes the same gap only because spatial_filter
stamped its own bounds onto that dataset earlier. So
bounds_mode="intersection" intersects the two datasets whose bounds
it could read, which is why the cube below keeps the same 800 by 1040
grid as the two-source cube above. The SLSTR values are still resampled
onto that grid; only its extent is decided without them.
All three measure a thermal infrared window channel and report brightness temperature in kelvin, which is what makes the last panel worth drawing. The overlay paints SEVIRI into red, AVHRR into green and SLSTR into blue on one shared kelvin scale wide enough that nothing clips, so the colour of a cell says what the three instruments make of it:
neutral, white through grey, is agreement: all three read the same temperature there;
a tint is a disagreement, and names the instrument reading warmest;
a saturated colour is absence rather than disagreement, because a channel with no data at a cell contributes nothing to it. The yellow over most of the box is where SLSTR does not reach, the red bands down both edges are where the Metop-B swath ends too, and the magenta block is the part of the SLSTR scan that falls outside that swath.
That last point is the honest limit of collocating three instruments from one morning. The region where all three actually saw the same place is the overlap of a disc, a swath and a scan, which here is the pale strip over Mauritania and Mali, not the whole box.
slstr = Dataset.from_source(
SLSTR_PATH, reader="sentinel3_sl_1_rbt", source="s3", source_kwargs=PUBLIC_S3, grid="in"
).transform("content_filter", include_vars=["S8_BT_in"])
cube3 = msg.transform(
"alignment",
datasets=[avhrr, slstr],
target="EPSG:4326",
target_resolution=0.05,
spatial_method="nearest",
temporal_method="nearest",
time_tolerance="10min",
time_bounds="base",
bounds_mode="intersection",
)
# Each source keeps its own prefix in the cube, so name the panels by substring rather than
# by a prefix this cell would have to guess.
SOURCES = [
("IR_108", "MSG SEVIRI"),
("brightness_temperature_4", "Metop-B AVHRR"),
("S8_BT_in", "Sentinel-3B SLSTR"),
]
print(f" dims : {dict(cube3.data.sizes)}")
print(f" variables : {list(cube3.data.data_vars)}")
extremes = []
for substring, label in SOURCES:
name, array = viz.pick(cube3, substring)
field = np.asarray(array.isel(time=0).values, dtype=float)
finite = field[np.isfinite(field)]
extremes += [finite.min(), finite.max()]
print(
f" {label:18s} {name:34s} covers {np.isfinite(field).mean():6.1%} of the grid, "
f"{finite.min():.1f} to {finite.max():.1f} K"
)
# The overlay needs a range nothing falls outside, because a clipped channel draws two
# different temperatures in the same colour and the panel's whole claim is that colour
# means temperature. The panels keep the percentile stretch above, which has the contrast.
BT_FULL = (min(extremes), max(extremes))
print(f" overlay range: {BT_FULL[0]:.1f} to {BT_FULL[1]:.1f} K, against {BT_RANGE[0]:.1f} to {BT_RANGE[1]:.1f} K for the panels")
dims : {'time': 1, 'lon': 800, 'lat': 1040}
variables : ['msg_seviri_native_format_IR_108', 'ds1_brightness_temperature_4', 'ipf-sl-1_06.22_S8_BT_in']
MSG SEVIRI msg_seviri_native_format_IR_108 covers 100.0% of the grid, 194.1 to 314.7 K
Metop-B AVHRR ds1_brightness_temperature_4 covers 71.3% of the grid, 195.4 to 305.5 K
Sentinel-3B SLSTR ipf-sl-1_06.22_S8_BT_in covers 7.0% of the grid, 226.5 to 312.3 K
overlay range: 194.1 to 314.7 K, against 227.9 to 306.5 K for the panels
viz.show_collocation_grid(
cube3,
panels=[(substring, "RdYlBu_r", label) for substring, label in SOURCES],
rgb=tuple(substring for substring, _ in SOURCES),
rgb_title="Qualitative overlay\nR=SEVIRI G=AVHRR B=SLSTR",
rgb_vmin=BT_FULL[0],
rgb_vmax=BT_FULL[1],
extent=[BOX[0], BOX[1], BOX[2], BOX[3]],
suptitle="Three instruments on one EPSG:4326 grid, all in kelvin",
save=OUTPUT / "geo_leo_three_instruments.png",
vmin=BT_RANGE[0],
vmax=BT_RANGE[1],
)
Tightening the time tolerance
The tolerance decides which granules are close enough in time to be paired, and it compares the two granule labels rather than the observation times of individual pixels. The cell above shows the difference that makes: the AVHRR scanlines over the box contain the SEVIRI slot, so the observations are minutes apart, while the labels are the gap printed there. A bound shorter than that label gap pairs nothing, so the swath variable survives in the cube with no values in it. That is the trade made explicit.
cube_strict = msg.transform(
"alignment",
datasets=[avhrr],
target="EPSG:4326",
target_resolution=0.05, # the same grid as the generous cube, so only the tolerance changes
spatial_method="nearest",
temporal_method="nearest",
time_tolerance="1min",
time_bounds="base",
bounds_mode="intersection",
)
# Membership first: reading the variable would raise before the line below could print False.
print(f"variable still present in the strict cube: {AVHRR_VAR in cube_strict.data.data_vars}")
strict = np.asarray(cube_strict.data[AVHRR_VAR].isel(time=0).values, dtype=float)
generous = np.asarray(cube.data[AVHRR_VAR].isel(time=0).values, dtype=float)
print(f"time_tolerance='10min' (longer than the {offset_s:.0f} s label gap): "
f"{np.isfinite(generous).mean():.1%} of the grid populated")
print(f"time_tolerance='1min' (shorter than it) : "
f"{np.isfinite(strict).mean():.1%} of the grid populated")
variable still present in the strict cube: True
time_tolerance='10min' (longer than the 297 s label gap): 71.3% of the grid populated
time_tolerance='1min' (shorter than it) : 0.0% of the grid populated
Write the cube
zarr_path = OUTPUT / "geo_leo_cube.zarr"
cube.to_file(str(zarr_path), writer="zarrv2", mode="w", consolidated=True)
check = xr.open_zarr(str(zarr_path), consolidated=True)
print(f"Wrote {zarr_path.name}")
print(f" dims : {dict(check.sizes)}")
print(f" variables : {list(check.data_vars)}")
print(f" crs : {check.rio.crs}")
print(f" history : {check.attrs.get('history', '(none)')[:200]}")
Wrote geo_leo_cube.zarr
dims : {'time': 1, 'lat': 1040, 'lon': 800}
variables : ['ds1_brightness_temperature_4', 'msg_seviri_native_format_IR_108']
crs : EPSG:4326
history : 2026-10-04T18:40:13.962824+00:00: Read operation [DEFAIR v0.4.3:MSG15NativeReaderPlugin, channels=['IR_108'], source='s3://datalake-demo-data/defair-notebook-data/ms...']
2026-10-04T18:40:16.367763+00
Who saw what, on the whole disc
Every figure so far has been cropped to the study box, which is where the three instruments have something to compare. The last one answers a different question, and the one a planner asks first: over the whole disc SEVIRI watches, which parts did the other two see, and when.
Nothing new is read: the geostationary field and the polar granule were
kept uncropped at the start, and alignment is called once more, now
with the full disc as its reference. Expect it to cost more than
anything above. So that it fits a notebook server with 4 GB of memory,
the cell first drops the cropped cubes and hands their memory back, and
resamples every second Metop line and pixel, which a footprint does not
miss: the thinned orbit is still finer than the 3 km grid it lands on.
On a half-core, 4 GB server the cell took about two minutes.
A tint here means presence, not value. The grey underneath is SEVIRI’s brightness temperature over its own full range, warm white to cold dark, so the meteorology stays readable through both footprints. Three things the picture does not say for itself:
the northern edge of the Metop band is where the granule starts, not where the swath ends, and the cyan across the polar rim above it is the same granule coming back over the disc after the pole, 99 minutes of orbit later;
the Sentinel-3 footprint is one three-minute granule, a fraction of the pass that crossed the disc that morning;
the two tints are drawn one over the other, so the Sentinel-3 box is a slightly different shade where it lies over the Metop band, and the straight edge inside it is the swath boundary rather than anything about Sentinel-3.
# The same three products without their crops: the disc and the orbit kept from the first
# read, and the SLSTR granule. The cropped cubes above are no longer needed, and
# release_read_handles hands the memory they held back to the operating system.
from defair_data import release_read_handles
del cube, cube_geos, cube3, cube_strict
release_read_handles()
# A footprint needs presence, not full resolution: every second AVHRR line and pixel is still
# finer than the 3 km SEVIRI grid it lands on, and a quarter of the orbit to resample.
avhrr_footprint = avhrr_orbit.isel(y=slice(None, None, 2), x=slice(None, None, 2))
disc = msg_disc.transform(
"alignment",
datasets=[avhrr_footprint, slstr],
reference_dataset=msg_disc,
spatial_method="nearest",
temporal_method="nearest",
time_tolerance="10min",
time_bounds="base",
)
# Computed once: the coverage figures and the plot below all read from this one result.
disc = disc.data.compute()
print(f" dims : {dict(disc.sizes)}")
print(f" variables : {list(disc.data_vars)}")
# SEVIRI is the reference, so it covers the disc by definition; the other two are the question.
seviri = np.isfinite(np.asarray(viz.pick(disc, "IR_108")[1].isel(time=0).values, dtype=float))
for substring, label in SOURCES[1:]:
field = np.asarray(viz.pick(disc, substring)[1].isel(time=0).values, dtype=float)
print(f" {label:18s} covers {(np.isfinite(field) & seviri).sum() / seviri.sum():6.1%} of the disc")
viz.show_disk_footprints(
disc,
base=("IR_108", "MSG SEVIRI IR_108, 10:15 UTC repeat-cycle slot"),
overlays=[
("brightness_temperature_4", "#19d9f2", 0.42, "Metop-B AVHRR ch4, 10:10 to 11:49 pass"),
("S8_BT_in", "#ff40d9", 0.60, "Sentinel-3B SLSTR S8, 10:21 to 10:24 granule"),
],
title="One disc, three footprints, 2025-12-10\nMSG SEVIRI IR_108 brightness temperature in grey",
label="brightness temperature (K)",
save=OUTPUT / "geo_leo_disc_footprints.png",
)
dims : {'time': 1, 'x': 3712, 'y': 3712}
variables : ['msg_seviri_native_format_IR_108', 'ds1_brightness_temperature_4', 'ipf-sl-1_06.22_S8_BT_in']
Metop-B AVHRR covers 27.8% of the disc
Sentinel-3B SLSTR covers 1.8% of the disc
What to do next
The pipeline tutorial builds a Zarr cube from a single instrument with filtering and reprojection in between. See Match products in time for the full temporal semantics of an aligned cube.
close_dask_client()