Skip to content

hkwk/gribextractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gribextractor CLI — Usage & Examples 📋

This file documents the common cli usage and examples for extracting timeseries from GRIB2 files.

Flags

  • --probe <lon> <lat> <file.grib2> — probe a single file and print available keys and values at the point
  • --timeseries <param[,param,...]> — request one or multiple timeseries parameters (e.g., 2t, tp, msl)
  • --init YYYYmmddHH — initial time used to match files and to compute timestamps
  • --lon <lon> --lat <lat> — probe location
  • --data-dir <dir> — directory containing GRIB2 files
  • --out-json <file> — write results in JSON format
  • --out-csv <file> — write results in CSV format
  • --verbose / -v — print debug information

Important output behavior ✅

  • --out-json <file> now writes only JSON and will not implicitly create a CSV file.
  • --out-csv <file> explicitly creates CSV output. CSV is generated from the same aligned timeseries data as JSON so the values are consistent between formats.
  • tps values are included only when the tp parameter is requested (either alone or as part of a comma-separated list). When present:
    • JSON: each row will have a tps field (in mm) computed from cumulative tp values (first entry = 0.0, second = first cumulative, subsequent = differences).
    • CSV: an extra tps column is appended (same values as JSON per-row tps).

Examples

  • Probe a single file:
cargo run --bin gribextractor -- --probe 88.363 12.962 ./gribfiles/2t_2025122900_000-024.grib2
  • Single-parameter timeseries printed to console:
cargo run --bin gribextractor -- --timeseries 2t --init 2025122900 --lon 88.363 --lat 12.962 --data-dir gribfiles
  • Generate JSON only:
cargo run --bin gribextractor -- --timeseries 2t,tp --init 2025122900 --lon 88.363 --lat 12.962 --data-dir gribfiles --out-json out.json

The produced out.json will include tps fields because tp was requested.

  • Generate CSV only:
cargo run --bin gribextractor -- --timeseries 2t,tp,msl,10u,10v --init 2025122900 --lon 113.363 --lat 22.962 --data-dir D:\work\realtimeforecast\2025122900 --out-csv out.csv

The produced out.csv will include an extra tps column when tp is in the requested list.

  • Generate both JSON and CSV:
cargo run --bin gribextractor -- --timeseries 2t,tp --init 2025122900 --lon 88.363 --lat 12.962 --data-dir gribfiles --out-json out.json --out-csv out.csv
  • Request a non-tp param (no tps should be present):
cargo run --bin gribextractor -- --timeseries 2t --init 2025122900 --lon 88.363 --lat 12.962 --data-dir gribfiles --out-json out2.json

out2.json will not contain tps fields because tp was not requested.


Notes & Developer info 🔧

  • The timeseries alignment and tps computation have been factored into a reusable internal module gribextractor::timeseries::build_aligned_timeseries so CSV and JSON outputs are generated from the same data source (JSON is used as the authoritative format).
  • If you want me to add examples showing how to read the JSON output programmatically or add more documentation about the internal API, I can add that too.

Happy data extracting! 🚀

About

Rust program for extracting timeseries data from GRIB2 files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages