ecmwf / earthkit-data

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

Implement parts for file source for GRIB and BUFR data #293

Closed sandorkertesz closed 5 months ago

sandorkertesz commented 5 months ago

Fixes #292

This PR enables the file source to use parts (byte ranges) in the same way as implemented for the url source. At the moment, it works for GRIB and BUFR files.

Documentation was added for both the sources.

Notebook example: https://earthkit-data.readthedocs.io/en/develop/examples/grib_file_parts.html

Examples:

ds = earthkit.data.from_source("file", "my.grib", parts=(0, 150))
ds = earthkit.data.from_source("file", "my.grib", parts=[(0, 150), (400, 160)])

ds = earthkit.data.from_source("file", [
    ("a.grib", (0, 150)),
    ("b.grib", (240, 120)),
    ("c.grib", None),
    ("d.grib", [(240, 120), (720, 120)])
    ])