Skip to article frontmatterSkip to article content

Amazon S3 Buckets


ECMWF open data can be retrieved from the Amazon S3 buckets using the earthkit or ecmwf-opendata Python libraries.

The earthkit and ecmwf-opendata package

Below, two examples for downloading data from the Amazon’s AWS location.

# !pip3 install earthkit ecmwf-opendata
from ecmwf.opendata import Client

client = Client(source="aws")
request = {
    "time": 0,
    "type": "fc",
    "step": 24,
    "param": "2t",
}
client.retrieve(request, "aws_2t_data.grib2")
da_2t = ekd.from_source("file", "aws_2t_data.grib2")
da_2t.ls()
import earthkit.data as ekd

data = ekd.from_source("s3", {
    "endpoint": "s3.amazonaws.com",
    "region": "eu-central-1",
    "bucket": "ecmwf-forecasts",
    "objects": "20230118/00z/0p4-beta/oper/20230118000000-0h-oper-fc.grib2"
}, anon=True)
ds = data.to_xarray()
ds

Retrieve data for only one parameter

To download the single 2t parameter, we read the _offset and _length values from the corresponding index file.

index_file = ekd.from_source("s3",
                             {"endpoint": "s3.amazonaws.com",
                              "region": "eu-central-1",
                              "bucket": "ecmwf-forecasts",
                              "objects": "20250430/12z/aifs-single/0p25/oper/20250430120000-12h-oper-fc.index",
                             }, anon=True)
index_file = index_file.to_pandas()
value = index_file.iloc[[42]].to_string(index=False, header=False)
value
req = {"endpoint": "s3.amazonaws.com",
       "region": "eu-central-1",
       "bucket": "ecmwf-forecasts",
       "objects": { "object": "20250430/12z/aifs-single/0p25/oper/20250430120000-12h-oper-fc.grib2", "parts": (34015908, 560208)},
   }

data = ekd.from_source("s3", req, anon=True)
data.ls()