EUMETSAT Data Tailor Example (MTG-FCI)
This example demonstrates how to:
Authenticate to the EUMETSAT Data Store (EUMDAC),
Search for MTG-FCI Level 1C High Resolution products,
Submit a Data Tailor customisation request (GeoTIFF export),
Download the customised product,
Open the GeoTIFF with
rioxarrayand visualise it,Analyse the radiance statistics using
visusat.utils.stats_dataset().
Note
This example uses operational MTG-FCI data and requires a valid EUMDAC
API key stored locally in inputs/id_EUMETSAT.json.
A template version is available in inputs/id_EUMETSAT_template.json.
Example script for downloading and plotting MTG-FCI data via the EUMETSAT Data Tailor.
1"""
2Example: Request a custom MTG-FCI product via EUMETSAT Data Tailor,
3download the generated GeoTIFF, compute basic statistics, and plot the radiance.
4
5This example demonstrates:
6- Authentication using a local credential file,
7- Product search on a temporal window,
8- Submission and monitoring of a Data Tailor customisation,
9- Reading GeoTIFF outputs with rioxarray,
10- Basic radiance visualisation and statistics.
11
12Requirements:
13 pip install rioxarray matplotlib numpy
14"""
15
16import logging
17import os
18import sys
19from datetime import datetime
20from pathlib import Path
21
22import eumdac
23import matplotlib.pyplot as plt
24import rioxarray
25
26from visusat import eumetsat, utils
27from visusat.eumetsat_products_registry import PRODUCTS, load_registry
28
29# ===============================================================
30# Logging configuration
31# ===============================================================
32LOG_FILE = Path(__file__).with_suffix(".log")
33script_name = os.path.basename(__file__)
34logging.basicConfig(
35 level=logging.INFO,
36 format="%(asctime)s [%(levelname)s] %(name)s.%(funcName)s:%(lineno)d - %(message)s",
37 handlers=[
38 logging.FileHandler(LOG_FILE, encoding="utf-8", mode="w"),
39 logging.StreamHandler(sys.stdout),
40 ],
41 force=True,
42)
43logger = logging.getLogger(Path(__file__).stem)
44logger.info("Program launched.")
45
46# Collection required :
47load_registry()
48required_collection = "EO:EUM:DAT:0665"
49product = PRODUCTS[required_collection]
50
51# ===============================================================
52# Authenticate & search Data Store product
53# ===============================================================
54token = eumetsat.get_token()
55datastore = eumdac.DataStore(token)
56
57collection = datastore.get_collection(required_collection)
58
59start = datetime(2025, 1, 26, 19, 30)
60end = datetime(2025, 1, 26, 23, 30)
61
62product = collection.search(dtstart=start, dtend=end).first()
63
64if product is None:
65 raise RuntimeError("No matching product found in this time window.")
66
67logger.info(f"Found product: {product}")
68
69# ===============================================================
70# Define Data Tailor chain
71# ===============================================================
72chain = eumdac.tailor_models.Chain(
73 product="FCIL1HRFI",
74 format="geotiff",
75 filter={"bands": ["ir_38_hr_effective_radiance"]},
76 projection="geographic",
77 roi="western_europe",
78)
79logger.info("Launching customisation request...")
80output_file, customisation = eumetsat.customisation(product, chain)
81
82
83# ===============================================================
84# Read GeoTIFF using rioxarray
85# ===============================================================
86logger.info(f"Opening GeoTIFF: {output_file}")
87ds = rioxarray.open_rasterio(output_file)
88
89logger.info(ds)
90
91# Replace FillValue by NaN if available
92fill_value = ds.attrs.get("_FillValue", None)
93if fill_value is not None:
94 ds = ds.where(ds != fill_value)
95
96band0 = ds.isel(band=0)
97
98# ===============================================================
99# Compute dataset statistics (custom util)
100# ===============================================================
101logger.info("Computing dataset statistics...")
102utils.plot_dataset_stats(band0, cmap="jet")
103
104
105# ===============================================================
106# Display radiance image
107# ===============================================================
108plt.figure(figsize=(8, 8))
109band0.plot(cmap="gray")
110plt.title("MTG-FCI GeoTIFF radiance (Band 1)")
111plt.tight_layout()
112plt.show()
113
114logger.info("End of program.")