Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using url source as a stream #273

Merged
merged 4 commits into from
Jan 2, 2024
Merged

Conversation

sandorkertesz
Copy link
Collaborator

@sandorkertesz sandorkertesz commented Dec 19, 2023

This PR enables using GRIB data from a URL or multiple URLs as a stream.

import earthkit.data

ds = earthkit.data.from_source("url",
                       ["https://get.ecmwf.int/repository/test-data/earthkit-data/examples/test.grib",
                        "https://get.ecmwf.int/repository/test-data/earthkit-data/examples/test4.grib"], 
                        stream=True, batch_size=3)

for f in ds:
    # f is a fieldlist
    print(type(f))
    print(f"len={len(f)}")
    for g in f:
        print(f" {g}")
<class 'earthkit.data.readers.grib.memory.GribFieldListInMemory'>
len=3
 GribField(2t,None,20200513,1200,0,0)
 GribField(msl,None,20200513,1200,0,0)
 GribField(t,500,20070101,1200,0,0)
<class 'earthkit.data.readers.grib.memory.GribFieldListInMemory'>
len=3
 GribField(z,500,20070101,1200,0,0)
 GribField(t,850,20070101,1200,0,0)
 GribField(z,850,20070101,1200,0,0)

Example: https://earthkit-data.readthedocs.io/en/develop/examples/grib_url_stream.html

@sandorkertesz sandorkertesz marked this pull request as draft December 19, 2023 14:07
@sandorkertesz sandorkertesz marked this pull request as ready for review January 2, 2024 11:45
@sandorkertesz sandorkertesz changed the title WIP: enable using url source as a stream Enable using url source as a stream Jan 2, 2024
@sandorkertesz sandorkertesz merged commit 68753a3 into develop Jan 2, 2024
52 checks passed
@sandorkertesz sandorkertesz deleted the feature/url-stream branch January 2, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant