Skip to article frontmatterSkip to article content

High rate SEVIRI Level 1.5 Image Data MSG - Data Access

This notebook demonstrates how to access SEVIRI data using HDA and how to read, process and visualize it.

🚀 Launch in JupyterHub
Prerequisites:
  • To search and access DEDL data a DestinE user account is needed

  • References:
  • DestinE Data Lake (DEDL) Harmonized Data Access (HDA) documentation

  • High Rate SEVIRI Level 1.5 Image Data - MSG - 0 degree

  • Credit:
    This notebook uses Satpy
    © 2014–2025 PyTroll community
    Licensed under PyGNU GPL v3

    This notebook demonstrates how to search and access MSG data using HDA and how to read, process and visualize it using satpy

    The Spinning Enhanced Visible and InfraRed Imager (SEVIRI) is MSG’s primary instrument and has the capacity to observe the Earth in 12 spectral channels.

    Throughout this notebook, you will learn:

    1. Authenticate: How to authenticate for searching and access DEDL collections.

    2. Search: How to search DEDL data using datetime and bbox filters.

    3. Download: How to download DEDL data through HDA.

    4. Read and visualize MSG data: How to load process and visualize MSG data using Satpy.

    Authenticate

    import destinelab as deauth
    import requests
    import json
    import os
    import zipfile
    import datetime
    import shutil
    from getpass import getpass
    DESP_USERNAME = input("Please input your DESP username or email: ")
    DESP_PASSWORD = getpass("Please input your DESP password: ")
    
    auth = deauth.AuthHandler(DESP_USERNAME, DESP_PASSWORD)
    access_token = auth.get_token()
    if access_token is not None:
        print("DEDL/DESP Access Token Obtained Successfully")
    else:
        print("Failed to Obtain DEDL/DESP Access Token")
    
    auth_headers = {"Authorization": f"Bearer {access_token}"}

    HDA endpoint

    HDA API is based on the Spatio Temporal Asset Catalog specification (STAC), it is convenient define a costant with its endpoint.

    HDA_STAC_ENDPOINT="https://hda.data.destination-earth.eu/stac/v2"
    COLLECTION_ID = "EO.EUM.DAT.MSG.HRSEVIRI"
    response = requests.post(HDA_STAC_ENDPOINT+"/search", headers=auth_headers, json={
        "collections": [COLLECTION_ID],
        "datetime": "2023-08-06T08:00:00Z/2023-08-07T00:00:00Z"
    })
    
    from IPython.display import JSON
    
    product = response.json()["features"][0]
    JSON(product)

    Download

    from tqdm import tqdm
    import time
    
    # Define a list of assets to download
    #assets = ["Oa08_radiance.nc", "Oa06_radiance.nc", "Oa02_radiance.nc"]
    assets = ["downloadLink"]
    
    for asset in assets:
        download_url = product["assets"][asset]["href"]
        print(download_url)
        filename = asset
        print(filename)
        response = requests.get(download_url, headers=auth_headers)
        total_size = int(response.headers.get("content-length", 0))
    
        print(f"downloading {filename}")
    
        with tqdm(total=total_size, unit="B", unit_scale=True) as progress_bar:
            with open(filename, 'wb') as f:
                for data in response.iter_content(1024):
                    progress_bar.update(len(data))
                    f.write(data)
    zf=zipfile.ZipFile(filename)
    with zipfile.ZipFile(filename, 'r') as zip_ref:
        zip_ref.extractall('.')

    Satpy

    The Python package satpy supports reading and loading data from many input files. For MSG data and the Native format, we can use the satpy reader 'seviri_l1b_native.

    pip install --quiet satpy

    Import required libraries

    from satpy.scene import Scene
    from satpy.composites import GenericCompositor
    from satpy.writers import to_image
    from satpy.resample import get_area_def
    from satpy import available_readers
    
    import warnings
    warnings.filterwarnings('ignore')
    warnings.simplefilter(action = "ignore", category = RuntimeWarning)
    file='MSG3-SEVI-MSG15-0100-NA-20230806081241.839000000Z-NA.nat'

    Read and load data

    We use the Scene constructor from the satpy library, a Scene object represents a single geographic region of data. Once loaded we can list all the available bands (spectral channel) for that scene.

    # read the file
    scn = Scene(reader='seviri_l1b_native', filenames=[file])
    # print available datasets
    scn.available_dataset_names()

    With the function load(), you can specify an individual band by name. If you then select the loaded band, you see the xarray.DataArray band object

    # load bands 
    scn.load(['HRV','IR_108'])
    scn['IR_108']
    scn['IR_108'].attrs.keys()
    scn['IR_108'].attrs['wavelength']

    Visualize data combining bands

    The Satpy function available_composite_ids() returns a list of available composite IDs.

    scn = Scene(reader="seviri_l1b_native", 
                 filenames=[file])
    scn.available_composite_ids()
    composite_id = ["natural_color"]
    scn.load(composite_id, upper_right_corner="NE")
    
    scn_cropped = scn.crop(ll_bbox=(-5, 31, 20, 51))
    scn_cropped.show("natural_color")
    
    composite_id = ["colorized_ir_clouds"]
    scn.load(composite_id, upper_right_corner="NE")
    scn_cropped = scn.crop(ll_bbox=(-5, 31, 20, 51))
    scn_cropped.show("colorized_ir_clouds")