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

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 overview

Tutorial

What it shows

Writes under output/

Expected result

Needs

01 Reading geostationary products

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

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA_nat

  • msg-seviri-cdr/W_XX-EUMETSAT-Darmstadt,VIS+IR+HRV+IMAGERY,MSG2+SEVIRI_C_EUMG_20220118121510Z_20220118122742Z_1_OR_FES_E0000_0100

  • msg-seviri-cdr/W_XX-EUMETSAT-Darmstadt,VIS+IR+HRV+IMAGERY,MSG3+SEVIRI_C_EUMG_20191101122916_0100.nc

  • mtg-fci-l1c-fdhsi/W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--x-x---x_C_EUMT_20251215090305_IDPFI_OPE_20251215090007_20251215090923_N__O_0055_0000/ (40 CHK-BODY chunks)

  • mtg-fci-l1c-hrfi/W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-HRFI-FD--x-x---x_C_EUMT_20251215090305_IDPFI_OPE_20251215090007_20251215090923_N__O_0055_0000/ (40 chunks)

  • mtg-li-lfl/W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+LI-2-LFL--FD--x-x--ARC-x_C_EUMT_20251210071016_L2PF_OPE_20251210070000_20251210071000_N__O_0043_0000_nat.nc

02 Reading polar-orbiter products

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

  • metop-avhrr-l1b/AVHR_xxx_1B_M01_20251231075503Z_20251231093703Z_N_O_20251231084335Z.nat

  • metop-hirs-fdr/FDR_L1C_HIRS4_METOPB_20221231105621_20221231123735_R02.0.nc

  • metop-ascat-szf/ASCA_SZF_1B_M02_20120622220000Z_20120622234159Z_R_O_20130828134436Z_0200.nat

  • sentinel3-olci-efr/S3B_OL_1_EFR____20260425T094557_20260425T094857_20260426T121647_0179_119_193_2160_MAR_O_NT_004.SEN3

  • sentinel3-slstr-frp/S3A_SL_2_FRP____20250808T092333_20250808T092833_20250808T112937_0299_129_093______MAR_O_NR_003.SEN3

03 The Common Data Model

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

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626111243.441000000Z-NA.nat

04 Reprojection targets

One MSG granule onto EPSG:4326, HEALPix and Lambert Conformal Conic.

  • 01_native_geostationary.png

  • 02_epsg4326_geographic.png

  • 03_healpix_mollweide.png

  • 03b_healpix_orthographic.png

  • 04_lambert_europe.png

  • 05_projection_comparison.png

The EPSG:4326 grid asserts finite and north-up, announced grid-mapping skip warnings.

  • healpy

  • cartopy

Reads

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626111243.441000000Z-NA.nat

05 Faster reads with Dask

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:

  • _20251215090923_N__O_0055_0000

  • _20251215091923_N__O_0056_0000

  • _20251215092923_N__O_0057_0000

06 Collocating geostationary and polar-orbiter data

MSG SEVIRI, Metop AVHRR and Sentinel-3 SLSTR aligned onto one grid, then the whole disc.

  • geo_leo_native.png

  • geo_leo_cube_epsg4326.png

  • geo_leo_cube_geostationary.png

  • geo_leo_three_instruments.png

  • geo_leo_disc_footprints.png

  • geo_leo_cube.zarr

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

  • msg-seviri-l15/msg_f997b2b630fc42_MSG3-SEVI-MSG15-0100-NA-20251210102744.394000000Z-NA.nat

  • metop-avhrr-l1b/AVHR_xxx_1B_M01_20251210101003Z_20251210114903Z_N_O_20251210105813Z

  • sentinel3-slstr-rbt/S3B_SL_1_RBT____20251210T102103_20251210T102403_20251211T151934_0179_114_179_2700_MAR_O_NT_004.SEN3

07 Building a Zarr cube with a pipeline

Read, crop, filter, reproject and write as chained calls, then the same steps as a YAML workflow, validated and previewed with a dry run.

  • msg_europe_cube.zarr

  • msg_europe_cube.yaml

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

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626111243.441000000Z-NA.nat

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626112743.658000000Z-NA.nat

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626125743.160000000Z-NA.nat

08 Data sources

Object storage, a streamed multi-granule write, a local file, and the HDA route.

  • processed/msg_mediterranean.zarr

  • MSG3-SEVI-MSG15-0100-NA-20260626111243.441000000Z-NA.nat (the 271 MB local copy)

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:

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626111243.441000000Z-NA.nat

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626112743.658000000Z-NA.nat

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20260626125743.160000000Z-NA.nat

The local-file cell copies the first granule to output/ and reads the copy.

09 Writing PNG, NetCDF and GeoTIFF

The raster and tabular writers, and what the rasters and the NetCDF file keep.

  • raster_writers/ with GeoTIFF, PNG, JPEG and 16-bit PNG per product

  • raster_writers/sst.nc

  • sst.csv

  • sst.h5

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

  • msg-seviri-l15/MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA_nat

  • osisaf-metop-glbsst/S-OSI_-FRA_-MTOP-GLBSST_FIELD-202508010000Z

10 Interoperability

The same dataset in satpy, resampled with pyresample, and in earthkit.

  • overview_raw_euro4.png

A 3 by 1024 by 1024 satpy composite, the earthkit round trip returns the same object (asserted).

  • Python 3.11 or newer

  • satpy

  • pyresample

  • earthkit-data

Reads

  • msg-seviri-l15/msg_f997b2b630fc42_MSG3-SEVI-MSG15-0100-NA-20251210102744.394000000Z-NA.nat

  • osisaf-metop-glbsst/S-OSI_-FRA_-MTOP-GLBSST_FIELD-202508010000Z

AI use case

MSG, MTG and ERA5 on one grid, then a cloud-mask U-Net trained and run.

  • collocation_ai/msg_mtg_era5_msggrid.zarr

  • collocation_ai/ai_cloudmask_input.zarr

  • collocation_ai/cloud_model.pt

  • collocation_ai/collocation_3panel.png

  • collocation_ai/prediction_vs_truth.png

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.

  • defair-ai-demo

  • PyTorch

  • cartopy

  • About 1 GB per scene on the synchronous scheduler

A CPU is enough.

Reads

  • 12 MSG granules under msg-seviri-l15/

  • 18 FCI scenes under mtg-fci-l1c-fdhsi/

  • era5/3d6b83d3fda49621dcb46fe1cd91256d.grib

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.zarr before writing it. The dry run in its last cell validates the YAML and prints the plan without reading data, so output/msg_europe_cube_from_yaml.zarr is never written.

  • 09’s final cell walks output/raster_writers/ with rglob, 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: in source="s3", in load_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 its local_granule to 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 hda source. 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.