ecmwf-opendata (Rust)
Rust client for ECMWF Open Data.
API documentation (docs.rs): https://docs.rs/ecmwf-opendata
This crate is a Rust re-implementation of the core functionality of the upstream Python project ecmwf-opendata:
- Build MARS-like requests (keyword/value pairs)
- Resolve request → data URLs
- Download whole files, or download selected fields via the
.indexsidecar using HTTPRangerequests
Chinese documentation: see README.zh-CN.md.
Install
Library usage
1) Python-like Client(...) options
Python:
=
Rust:
use ;
let opts = ClientOptions ;
let client = new?;
# Ok::
source can be a known mirror ("ecmwf", "aws", "azure", "google") or a custom base URL ("https://...").
2) Request builder (kwargs-ish)
use ;
let client = new?;
let req = new
.r#type
.param
.step
.target;
let result = client.retrieve_request?;
println!;
# Ok::
3) retrieve_pairs: strongest “kwargs/dict” feel
use ;
let client = new?;
let result = client.retrieve_pairs?;
println!;
# Ok::
4) Macro: closest to Python client.retrieve(time=..., ...)
use ;
let client = new?;
let steps: = .step_by.collect;
let result = retrieve!?;
println!;
# Ok::
5) GUI/config style: string key/value inputs
If your UI stores values as strings, build a request with Request::from_str_pairs.
use ;
let client = new?;
// Example: values come from text fields
let req = from_str_pairs;
let result = client.retrieve_request?;
println!;
# Ok::
CLI
This repository also includes a small CLI example (as a Cargo example target).
Example: realtime_forecast 🔁
A convenience example that mirrors a typical operational script: it spawns threads to download several meteorological variables for grouped forecast step ranges and writes files named
<variable>_<YYYYmmddHH>_<start>-<end>.grib2 under <main_dir>/realtimeforecast/<YYYYmmddHH>/.
Usage:
- If
<YYYYmmddHH>is omitted the example picks the nearest 00/12 UTC cycle automatically. - The example downloads the following (variable, levtype) pairs in parallel:
10u/srf,10v/srf,2t/srf,msl/srf,tp/srf,gh/pl,u/pl,v/pl. - Forecast steps are grouped into six bands (0-24, 27-48, 51-72, 75-96, 99-120, 123-144 hours) and each group is written to an individual file named with the group's start/end hours.
- The program skips existing non-empty files and prints errors for failed downloads; you can edit the example to enable retries or change the source mirror.
Notes:
- The example constructs a
ClientusingClientOptions(see the source inexamples/realtime_forecast.rs); edit thesourceor other fields there to change behavior (e.g.source = "ecmwf" | "aws" | "azure" | "google"). - The example is intentionally minimal; feel free to adapt it to add retries, timeouts, logging, or a command-line flag to select the source.
Notes / limitations
- This is intentionally a “core features” port; it does not aim to fully replicate every upstream Python feature.
latest()probing depends on endpoint availability. If it fails, specifydate/timeexplicitly.- Data usage is subject to ECMWF Open Data terms (including attribution requirements).