ecmwf / earthkit-data

A format-agnostic Python interface for geospatial data
Apache License 2.0
47 stars 9 forks source link

Implement parts for url stream #276

Closed sandorkertesz closed 5 months ago

sandorkertesz commented 5 months ago

This PR makes parts (only single parts) work for url streams:

# the remote file contains 6 GRIB messages. 
# We only read the first 2 (between bytes offset=0 and lenght=480).
ds = from_source(
        "url",
       "https://get.ecmwf.int/repository/test-data/earthkit-data/examples/test6.grib",
        parts=[(0, 480)],
        stream=True,
    )

for f in ds:
    # f is a field
    print(f)

output:

GribField(t,1000,20180801,1200,0,0)
GribField(u,1000,20180801,1200,0,0)