Tutorials
The tutorials are Jupyter notebooks published with their recorded results. Read an article on this site, or download its notebook and run it in your own DEFAIR environment, from any folder. If you are new to DEFAIR, follow the numbered tutorials in order. The final tutorial is an end-to-end AI use case.
Note
Read each tutorial article as a learning guide before running its notebook. Runtime warnings, diagnostic logs and ANSI terminal formatting have been removed from the article versions. The printed output is kept as the notebook recorded it, so it can show file paths from the machine that ran it. The warnings and logs can appear again when you run the notebook yourself.
Start here
Tutorial 01 is the simplest complete example: one
Dataset.from_source call per product, a quicklook of each, nothing
else. Tutorial 03 explains the data model every reader fills in, with a
small synthetic reader you can read in one screen before it does the
same thing to a real granule. The rest build on those two, but every
notebook is standalone: none depends on another’s output, none needs a
Dask Gateway, and each can be run on its own.
The documentation has three kinds of example, and it helps to know which
one you are reading. The notebooks here are executed end to end and
published with their outputs. The YAML fragments on the workflow
examples page are
configuration to hand to defair run rather than code to execute in a
kernel. The plugin skeletons in the reader,
writer and
transformation plugin guides are
starting points for your own code, not runnable examples.
Prerequisites
No. 1 DEFAIR with the notebook dependencies
Use Install DEFAIR locally or
Run DEFAIR on the DEDL JupyterHub to prepare
your environment with the notebooks extra:
python -m pip install --upgrade pip --index-url https://pypi.org/simple
python -m pip install --index-url https://pypi.org/simple "defair[notebooks]==0.4.3" "numpy==2.3.4" "xarray==2025.11.0"
The extra adds what the tutorials import on top of DEFAIR: cartopy, earthkit-data, healpy, matplotlib, ipykernel, and satpy on Python 3.11 and newer. Tutorial 10 therefore needs Python 3.11 or newer. The AI use case also needs its own package and PyTorch. On Linux, install only the CPU PyTorch wheel from its own index, then resolve the AI package and its dependencies from PyPI:
python -m pip install --no-deps "torch==2.14.1+cpu" --index-url https://download.pytorch.org/whl/cpu
python -m pip install --index-url https://pypi.org/simple "defair-ai-demo==0.4.3"
python -m pip check
All eleven notebooks completed with DEFAIR 0.4.3 and the pinned versions above on Fedora 44 with Python 3.12 on 5 October 2026. Follow the linked installation guide for macOS or other PyTorch builds.
No. 2 A Jupyter kernel for that environment
With the environment active, register it as a Jupyter kernel, then pick the
defair kernel when you open a notebook:
python -m ipykernel install --user --name defair
No. 3 A writable folder for the notebooks
Download each notebook from its article into any folder you can write to. No
source checkout is needed. Every notebook writes its results into an
output/ folder beside itself. Tutorial 08 also copies a 271 MB granule
there, so allow about 300 MB of free disk for it.
No. 4 Data: the public demo bucket of the DestinE Data Lake
Every tutorial reads its products from the public demo bucket of the DestinE Data Lake, which anyone can read, so the tutorials run as they are. The Prerequisites section of each tutorial names its products and the variables that hold their paths. To run a tutorial with your own files from object storage, a local disk or HDA, follow the instructions in Data. Prepare data access for DEFAIR explains the routes and their access requirements. The fixture manifest names every object the tutorials read, with its size and checksum.
No. 5 Credentials: none for the tutorials
The tutorials read the public demo bucket anonymously, by passing
source_kwargs={"endpoint_url": "https://s3.central.data.destination-earth.eu", "anon": True},
so they need no credentials, even on hosted notebook platforms such as the DEDL
Stack that set AWS_* variables for their own object store. To read your own
store instead, set PUBLIC_S3 = {} and put the store’s credentials
in a file named .env beside the notebook or in any folder above it:
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_ENDPOINT_URL=https://...
AWS_ENDPOINT_URL is required, because there is no default endpoint. Add
AWS_SESSION_TOKEN when your store issues one. Load the file in the
notebook’s first cell with load_dotenv(override=True), so the values in
.env replace variables already set in the kernel. The AI use case has
further options, described in its own Prerequisites section.
Tutorials
- Reading geostationary products: MSG SEVIRI, MTG FCI and the Lightning Imager
- Reading polar-orbiter products: Metop and Sentinel-3
- The Common Data Model
- Reprojecting to EPSG:4326, HEALPix and Lambert
- Faster reads with Dask
- Collocating geostationary and polar-orbiter data
- Building a Zarr cube with a pipeline
- Data sources: object storage, local files and the HDA
- Writing PNG, NetCDF and GeoTIFF
- Interoperability: DEFAIR datasets in satpy and earthkit
- Three sources on one grid, then an AI cloud mask
Benchmarks
Runtime and peak memory were measured on 2026-09-23 on a Linux
x86_64 machine shared with CI jobs, from a plain wheel install, each
notebook on its own in a fresh kernel. taskset limited each run to 1
or 4 cores, and Dask sized its thread pool from that, as it does on a
notebook server with that many cores. Peak memory is the highest
combined resident size of the kernel and any process it started. A
Jupyter server with no kernel adds about 0.1 GB. The times depend on the
load and on your link to the object store.
Note
These memory and runtime measurements are for comparison only. Run similar tests in your own working environment to determine its memory requirements and expected runtimes.
Notebook |
Runtime, 4 cores |
Peak memory, 1 core |
Peak memory, 4 cores |
stack-jupyter-low (2 GB) |
|---|---|---|---|---|
01 Reading geostationary products |
96 s |
3.4 GB |
3.4 GB |
out of memory |
02 Reading polar orbiter products |
70 s |
2.9 GB |
2.9 GB |
runs |
03 Common data model |
11 s |
0.6 GB |
0.7 GB |
runs |
04 Reprojection targets |
74 s |
3.1 GB |
3.5 GB |
out of memory |
05 Parallel reads with Dask |
77 s |
1.8 GB |
1.8 GB |
runs |
06 Geo LEO collocation |
234 s |
3.8 GB |
4.1 GB |
out of memory |
07 Zarr cube pipeline |
18 s |
1.0 GB |
1.1 GB |
runs |
08 Data sources |
30 s |
0.6 GB |
0.8 GB |
runs |
09 Writing output formats |
175 s |
2.2 GB |
2.6 GB |
out of memory |
10 Interoperability |
36 s |
2.4 GB |
2.4 GB |
out of memory |
AI use case |
512 s |
3.7 GB |
3.9 GB |
not tested |
Peak memory grows with the number of cores Dask sees. From one core to sixteen, 06 went from 3.8 to 4.8 GB, 04 from 3.1 to 4.3 GB and 09 from 2.2 to 3.1 GB, while 05, 07 and 10 barely moved. On one core every tutorial stayed under 4 GB, and a run on a 4 GB notebook server with half a core completed all ten tutorials. At four cores 06 reached 4.1 GB, so give 04 and 06 about 6 GB on a server with four cores or more. Tutorial 06 configures a Dask worker with a 12 GB limit, which is a ceiling, not a need.
Tested on the DEDL JupyterHub’s stack-jupyter-low profile (2 cores,
2 GB): tutorials 02, 03, 05, 07 and 08 run to completion, and 01, 04,
06, 09 and 10 are stopped by the 2 GB memory limit, as the last column
of the table shows. The peaks in the table come from another machine, so
they do not predict the Hub result exactly: 02 peaked at 2.9 GB there
and still runs on the Hub, although it uses the whole 2 GB and has no
room to spare. Run DEFAIR on the DEDL
JupyterHub describes the install on the Hub.
Tutorials at a glance
The table compares each tutorial’s processing steps, inputs, outputs and
requirements. Input paths are relative to
s3://datalake-demo-data/defair-notebook-data/. Notebook outputs are saved
in an output/ folder beside the notebook.
Tutorial |
What it shows |
Writes under output/ |
Expected result |
Needs |
|---|---|---|---|---|
One call reads MSG SEVIRI, the MSG SEVIRI Climate Data Record in Full Disk and Rapid Scan, MTG FCI at both resolutions, and Lightning Imager point data. |
Nothing. |
Six inventories, five quicklooks, MSG and FCI rows north-first (asserted), a scatter of 2064 flashes. |
cartopy for the coastlines. |
|
Reads
|
||||
The same call on five swath products from Metop and Sentinel-3. |
Nothing. |
Five inventories and maps, 26 fire detections, three announced FRP metadata notices. |
cartopy for the coastlines. |
|
Reads
|
||||
A synthetic reader, then the dispatch key following a real granule through filter and reprojection. |
Nothing. |
Dispatch key goes from ('gridded', 'geostationary') to ('gridded', 'geographic'), one announced grid-mapping skip warning. |
Nothing beyond the install. |
|
Reads
|
||||
One MSG granule onto EPSG:4326, HEALPix and Lambert Conformal Conic. |
|
The EPSG:4326 grid asserts finite and north-up, announced grid-mapping skip warnings. |
|
|
Reads
|
||||
The same lazy dataset computed under the single-threaded and threaded schedulers. |
Nothing. |
Both schedulers give the same mean (asserted). The printed speed-up was 1.0x to 1.1x on our runs, because one stream fills the link to the store. |
Nothing beyond the install. |
|
Reads The 120 CHK-BODY chunks of three scenes under mtg-fci-l1c-fdhsi/, with names ending in:
|
||||
MSG SEVIRI, Metop AVHRR and Sentinel-3 SLSTR aligned onto one grid, then the whole disc. |
|
AVHRR covers 71.3 percent of the 800 by 1040 grid at a 10 minute tolerance and none at 1 minute, one announced “Could not determine bounds for dataset 2” notice. |
A one-worker Dask client with a 12 GB limit, the full-disc alignment takes about 50 s. |
|
Reads
|
||||
Read, crop, filter, reproject and write as chained calls, then the same steps as a YAML workflow, validated and previewed with a dry run. |
|
A cube of 3 time steps on a 500 by 800 grid, chunked (1, 500, 512), and a dry-run plan. |
Nothing beyond the install. |
|
Reads
|
||||
Object storage, a streamed multi-granule write, a local file, and the HDA route. |
|
The streamed store has 3 time steps (asserted). |
About 300 MB of free disk for the local copy. |
|
Reads The same three granules as tutorial 07:
The local-file cell copies the first granule to output/ and reads the copy. |
||||
The raster and tabular writers, and what the rasters and the NetCDF file keep. |
|
The nodata mask loses and gains no pixel and no valid pixel collides with the nodata code (asserted), every raster carries a CRS and bounds. |
Nothing beyond the install. |
|
Reads
|
||||
The same dataset in satpy, resampled with pyresample, and in earthkit. |
|
A 3 by 1024 by 1024 satpy composite, the earthkit round trip returns the same object (asserted). |
|
|
Reads
|
||||
MSG, MTG and ERA5 on one grid, then a cloud-mask U-Net trained and run. |
These outputs are beside the notebook in packages/defair-ai-demo/. |
The output sits on the requested grid (asserted), every channel carries data (asserted), four epochs of training and a predicted mask. |
A CPU is enough. |
|
Reads
Each input is selected by its exact file name. |
||||
Outputs and re-runs
The notebooks write beside themselves, into output/, and never back
to the bucket. What a second run does to that folder differs by
notebook:
01, 02, 03 and 05 write nothing. 01, 02 and 05 create the empty
output/folder.04, 09 and 10 overwrite their PNGs silently.
06 and 08 write their Zarr stores with
mode="w", which replaces the store.08 copies its first granule into
output/once and reads that copy on later runs. Delete the 271 MB file to fetch it again.07 deletes
output/msg_europe_cube.zarrbefore writing it. The dry run in its last cell validates the YAML and prints the plan without reading data, sooutput/msg_europe_cube_from_yaml.zarris never written.09’s final cell walks
output/raster_writers/withrglob, so files from earlier runs appear in its listing.The AI notebook deletes its two Zarr stores before writing them.
To keep a result, rename or copy output/ before running the notebook
again.
Data
Every tutorial reads the public demo bucket of the DestinE Data Lake, so they all run as they are, with no account and no credentials. To run a tutorial on your own files, or on other products of the same types, first change the paths listed in its Prerequisites section. Then follow the steps for where your files are:
In your own object store. Set
PUBLIC_S3 = {}where the notebook defines it (SOURCE_KWARGS = {}in the AI notebook). DEFAIR then signs in with your own credentials instead of reading anonymously. Prepare data access for DEFAIR explains how to provide them.On a local disk. Use absolute paths, not paths relative to the notebook folder. The notebooks check that each file exists by comparing full paths, so a relative path fails that check even when the file is there. Then set
PUBLIC_S3 = {}and replace"s3"with"local"wherever the notebook says where to read from: insource="s3", inload_source("s3", **PUBLIC_S3)and, in tutorial 07, in the workflow’s"fs_type": "s3". Tutorial 08 is the exception: it shows the different places DEFAIR can read from, so keep its inputs in object storage and set itslocal_granuleto a file of your own instead. The AI notebook has its own local mode, described in its Prerequisites section.Through HDA. With a Destination Earth account, download each product through the Destination Earth Harmonised Data Access (HDA) service and read the local copy as above, or read it through DEFAIR’s
hdasource. HDA does not support streaming, so DEFAIR downloads every product in full before reading it. HDA does not carry FCI Level 1c (tutorials 01 and 05 and the AI notebook) or the full disk SEVIRI Climate Data Record (tutorial 01): get those from the EUMETSAT Data Store.
Prepare data access for DEFAIR explains each route. Each notebook names the files it reads and checks that they are present, so a missing file stops the notebook with a message naming it rather than reading something else. The fixture manifest lists every object with its size and checksum.
One input is local rather than in object storage. The
COLLOCATION_SOURCE=local branch of the AI notebook reads from a
test-data/ folder that nothing provisions. It assumes you have
copied the products there yourself, and it checks the same pinned names
as the S3 branch.
Additional community examples
Two DEFAIR user examples show DEFAIR output feeding a training pipeline:
What to do next
Start with Reading geostationary products to read MSG SEVIRI and MTG products and plot the results. For the dataset structure shared by the readers, continue to The Common Data Model.