Read your first product
Read one MSG SEVIRI image, select a channel, crop it to a region and save the result as a Zarr dataset. This example downloads the image through the Destination Earth Harmonised Data Access (HDA) service, which requires a Destination Earth account.
Prerequisites
No. 1 DEFAIR installed
Install DEFAIR with pip, on Python 3.10 or newer, as described in
Install DEFAIR. The folder you run from must be
writable, because the results go under output/. To use a product
other than the sample, see Use your own
product.
No. 2 An account for the sample download
Create a DestinE Platform (DESP) account by following How to create a DestinE Platform account. This example uses your account’s username and password to download the sample through HDA.
To download the sample from the EUMETSAT Data Store instead of HDA, use an EUMETSAT account and follow Download an MSG SEVIRI native product from EUMETSAT for DEFAIR. Keep the extracted product in your working folder and continue at Read the file.
Note
The examples below show each piece of code followed by its output. At the end of the article, you can download the complete Python script to run the reading, filtering, writing and output checks together.
Get the sample
The sample is one full-disc MSG SEVIRI image from the HDA collection
EO.EUM.DAT.MSG.HRSEVIRI, product
MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.
Make a working folder for this page and the next, and give DEFAIR your Destination Earth credentials:
mkdir defair-first-steps
cd defair-first-steps
export DESTINE_USERNAME=your-username
export DESTINE_PASSWORD=your-password
In a notebook, export does not reach the kernel. Pass the
credentials in code instead:
load_source("hda", username="...", password="...").
Run the following Python code from that folder with your DEFAIR environment active. It downloads the product, unpacks it and keeps the image file:
from defair.logging import setup_logging
from defair.plugin_manager import load_source
from defair_data.sources.hda import StacAssetRef
setup_logging(log_level="WARNING")
hda = load_source("hda") # reads DESTINE_USERNAME and DESTINE_PASSWORD
sample = StacAssetRef(
collection_id="EO.EUM.DAT.MSG.HRSEVIRI",
item_id="MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA",
asset_name="downloadLink",
)
[path] = hda.open_download_link(sample, extract_dir=".")
print(path.name)
2026-09-25 12:58:53 | WARNING | [d8d28317] defair_data.sources.hda.hda_stac_plugin:open_download_link:1058 - WARNING: downloadLink assets require downloading the entire zip archive to local disk.
This may require significant disk space and processes data only after the full download completes.
It is recommended to use individual assets directly instead of downloadLink
when available.
MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.nat
The warning is expected. This product only comes as a zip file, so DEFAIR downloads all of it, about 160 MB, and unpacks the 271 MB image into the folder. It took about 35 seconds on a fast connection (your mileage may vary).
Any other image from the same collection works too. The outputs printed on this page and the next come from this one.
Run the rest of the code on this page from the same folder.
Read the file
Read the sample:
from defair.logging import setup_logging
from defair_data import Dataset
setup_logging(log_level="WARNING") # keep progress messages out of the way
dataset = Dataset.from_source(
"MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.nat",
use_channel_names=True,
)
print(list(dataset.data.data_vars))
print(dict(dataset.data.sizes))
2026-09-24 00:13:41 | WARNING | [2cc6d065] defair_data.readers.msg15.msg15_native_reader_plugin:_resolve_channels_and_calibrations:548 - HRV is not part of the default MSG channel selection: it is opt-in because it uses its own 1 km grid. Request it explicitly with channels=["HRV", ...] (the output variable is named "HRV" with use_channel_names=True, otherwise "ch12").
['VIS006', 'VIS008', 'IR_016', 'IR_039', 'WV_062', 'WV_073', 'IR_087', 'IR_097', 'IR_108', 'IR_120', 'IR_134', 'geostationary']
{'time': 1, 'y': 3712, 'x': 3712, 'bnds': 2}
The first line is a warning, not an error, and its date and the code in brackets change from run to run. The high-resolution HRV channel sits on a grid of its own, so DEFAIR leaves it out unless you ask for it.
DEFAIR looked at the file name, chose the msg15nat reader and built
a dataset with eleven channels on a 3712 by 3712 grid. bnds belongs
to time_bnds, the start and end of the 15 minutes the image covers.
use_channel_names=True names the channels as EUMETSAT does; without
it they are ch1 to ch11. geostationary is not a channel. It
records the map projection of the image: a geostationary satellite stays
over one point of the equator and sees the Earth as a disk.
Nothing has been read from disk yet apart from the file’s header.
dataset.data["IR_108"] is a Dask array, and Dask, the Python library
that lets you work on arrays too large for memory, reads values only
when something asks for them.
Keep one channel and crop it
Transformations are called by name on the dataset, and each one returns a new dataset:
ir = dataset.transform("content_filter", include_vars=["IR_108"])
region = ir.transform("spatial_filter", lat_min=35, lat_max=45, lon_min=-10, lon_max=5)
print(dict(region.data.sizes))
{'time': 1, 'y': 246, 'x': 440, 'bnds': 2}
content_filter keeps the channels you name. spatial_filter keeps
the pixels inside a latitude and longitude box, here the Iberian
peninsula. Still nothing has been computed: the dataset now describes a
246 by 440 window that will be read when you write it.
Write it to Zarr
Zarr is a storage format that keeps a large array as many small files, so a program can read one piece without loading all of it. It is the usual choice for machine learning.
region.to_file("output/first-product.zarr", writer="zarrv2", mode="w")
This is the moment the pixels are read from the file, cropped and written. It takes a few seconds.
Look at the result
Open the store with xarray, the standard Python container for labelled arrays, to check what was written:
import xarray as xr
stored = xr.open_zarr("output/first-product.zarr")
print(stored)
print(float(stored["IR_108"].mean()))
<xarray.Dataset> Size: 2MB
Dimensions: (time: 1, y: 246, x: 440, bnds: 2)
Coordinates:
* time (time) datetime64[ns] 8B 2025-10-16T17:15:00
source_file (time) object 8B dask.array<chunksize=(1,), meta=np.ndarray>
* y (y) float64 2kB 4.243e+06 4.24e+06 ... 3.51e+06 3.507e+06
* x (x) float64 4kB -8.761e+05 -8.731e+05 ... 4.381e+05 4.411e+05
lat (y, x) float64 866kB dask.array<chunksize=(125, 440), meta=np.ndarray>
lon (y, x) float64 866kB dask.array<chunksize=(125, 440), meta=np.ndarray>
time_bnds (time, bnds) datetime64[ns] 16B dask.array<chunksize=(1, 2), meta=np.ndarray>
spatial_ref int64 8B ...
Dimensions without coordinates: bnds
Data variables:
geostationary int32 4B ...
IR_108 (time, y, x) float32 433kB dask.array<chunksize=(1, 125, 440), meta=np.ndarray>
Attributes: (12/22)
Conventions: CF-1.13
title: MSG SEVIRI Level 1.5 Native Format Data
institution: EUMETSAT
source: MSG SEVIRI Native Format
sensor: SEVIRI
format: MSG 1.5 Native
... ...
summary: Meteosat Second Generation (MSG) SEVIRI ...
references: https://www.eumetsat.int/meteosat-second...
history: 2026-09-23T22:13:41.131128+00:00: Read o...
_spatial_filter_bounds: [-10, 35, 5, 45]
defair_cdm: {"schema_version":3,"reader":"msg15","pr...
date_created: 2026-09-23T22:13:44.633896+00:00
78.0468521118164
The store holds the channel, its time and time bounds, the projection
coordinates x and y, and a latitude and longitude for every
pixel, which the writer added. The history and date_created
attributes record when you ran it. The value is a radiance in the units
the product declares.
Use your own product
Point Dataset.from_source() at any product DEFAIR reads, on disk or
in cloud storage, and the same three steps apply.
What to do next
Continue with Run your first workflow to run the same reading, filtering and writing steps from a YAML file.
For other input products and authentication options:
Reader catalogue lists supported products and their download locations.
Read from S3 covers S3 and HDA access, including other ways to provide HDA credentials.
The notebooks in Run the tutorials provide more examples:
Reading geostationary products shows how to read MSG SEVIRI and MTG data.
Data sources shows how to read a file from your disk or object storage.
Building a Zarr cube with a pipeline shows how to filter data, change its map projection and save it. It demonstrates these steps in Python and as a YAML workflow.
The tutorials read their products from the public demo bucket of the
DestinE Data Lake, with no credentials, and you can point them at your
own data or at products you got through HDA instead. Follow the setup
instructions on the tutorials page. Download a notebook from its page
and open it with the defair kernel from Install
DEFAIR.
Download the first test script
Download defair_first_test.py to run
the reading, filtering, writing and output checks together. The script
uses the sample MSG SEVIRI product
MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.nat that you
downloaded in Get the sample.
Save the script in defair-first-steps, the working folder that holds
the sample. With your DEFAIR environment active, run it from that
folder:
python3 defair_first_test.py
The script writes output/first-product.zarr, replacing an existing
store at that path, then reopens it and prints the dataset and the mean
of IR_108.