| Crates.io | grib_tables |
| lib.rs | grib_tables |
| version | 0.1.1 |
| created_at | 2024-11-19 16:21:28.556664+00 |
| updated_at | 2024-11-19 17:00:05.291678+00 |
| description | Retrieve details of each GRIB parameter from the parameter abbreviation or from the numeric identifier |
| homepage | https://github.com/JackKelly/hypergrib |
| repository | https://github.com/JackKelly/hypergrib/tree/main/crates/grib_tables |
| max_upload_size | |
| id | 1453493 |
| size | 608,920 |
Retrieve details of each GRIB parameter from the parameter abbreviation (e.g. "TMP") or from the numeric identifier.
grib_tables loads the GDAL CSV files into memory and allows the user to:
use grib_tables::{Abbrev, MASTER_TABLE_VERSION, NumericId, Parameter, ParameterDatabase};
# fn main() -> anyhow::Result<()> {
// Get a ParameterDatabase populated with the GRIB tables stored in the included CSV files:
let param_db = ParameterDatabase::new().populate()?;
// Get the numeric IDs and params associated with the abbreviation "TMP":
let abbrev = Abbrev::from("TMP");
let params: Vec<(&NumericId, &Parameter)> = param_db.abbrev_to_parameter(&abbrev);
// `params` is a `Vec` because some abbreviations are associated with multiple parameters.
// (The type of `params` can be deduced by the compiler. The type is written out in
// this example to make it easier to follow the documentation!)
// "TMP" is associated with exactly one parameter:
assert_eq!(params.len(), 1);
// Let's get the `&NumericId` and `&Parameter` associated with the "TMP" abbreviation:
let (temperature_numeric_id, temperature_param) = params.first().as_ref().unwrap();
// Let's get the `name` and `unit` of the `Parameter`:
assert_eq!(temperature_param.name(), "Temperature");
assert_eq!(temperature_param.unit(), "K");
// Let's investigate the `NumericId` associated with "TMP":
assert_eq!(temperature_numeric_id.product_discipline(), 0);
assert_eq!(temperature_numeric_id.parameter_category(), 0);
assert_eq!(temperature_numeric_id.parameter_number(), 0);
assert_eq!(
temperature_numeric_id.master_table_version(),
MASTER_TABLE_VERSION
);
// `MAX` values indicate missing values in the GRIB spec.
// "TMP" is part of the GRIB master tables, and so is not
// from a local originating center:
assert_eq!(temperature_numeric_id.originating_center(), u16::MAX);
assert_eq!(temperature_numeric_id.subcenter(), u8::MAX);
assert_eq!(temperature_numeric_id.local_table_version(), u8::MAX);
# Ok(())
# }
grib_tables exist?To build hypergrib, we need to be able to decode GRIB .idx files.
We're aware of two awesome existing GRIB readers implemented in Rust (gribberish and grib-rs) but, at the time of writing, neither can decode .idx files.
Hence grib_tables exists to enable hypergrib to decode GRIB .idx files.
.csv files in GDAL. See the README for that directory.