pub fn grib1_parameter_name(table_version: u8, number: u8) -> &'static str {
match (table_version, number) {
(_, 1) => "PRES",
(_, 2) => "PRMSL",
(_, 7) => "HGT",
(_, 11) => "TMP",
(_, 17) => "DPT",
(_, 33) => "UGRD",
(_, 34) => "VGRD",
(_, 39) => "VVEL",
(_, 52) => "RH",
(_, 54) => "PWAT",
(_, 61) => "APCP",
(_, 71) => "TCDC",
_ => "unknown",
}
}
pub fn grib1_parameter_description(table_version: u8, number: u8) -> &'static str {
match (table_version, number) {
(_, 1) => "Pressure",
(_, 2) => "Pressure reduced to mean sea level",
(_, 7) => "Geopotential height",
(_, 11) => "Temperature",
(_, 17) => "Dew point temperature",
(_, 33) => "U-component of wind",
(_, 34) => "V-component of wind",
(_, 39) => "Vertical velocity",
(_, 52) => "Relative humidity",
(_, 54) => "Precipitable water",
(_, 61) => "Total precipitation",
(_, 71) => "Total cloud cover",
_ => "Unknown parameter",
}
}
pub fn parameter_name(discipline: u8, category: u8, number: u8) -> &'static str {
match (discipline, category, number) {
(0, 0, 0) => "TMP", (0, 0, 1) => "VTMP", (0, 0, 2) => "POT", (0, 0, 4) => "TMAX", (0, 0, 5) => "TMIN", (0, 0, 6) => "DPT", (0, 1, 0) => "SPFH", (0, 1, 1) => "RH", (0, 1, 3) => "PWAT", (0, 1, 8) => "APCP", (0, 2, 0) => "WDIR", (0, 2, 1) => "WIND", (0, 2, 2) => "UGRD", (0, 2, 3) => "VGRD", (0, 2, 22) => "GUST", (0, 3, 0) => "PRES", (0, 3, 1) => "PRMSL", (0, 3, 5) => "HGT", (0, 4, 7) => "DSWRF", (0, 5, 3) => "DLWRF", (0, 6, 1) => "TCDC", (0, 7, 6) => "CAPE", (0, 7, 7) => "CIN",
(10, 0, 3) => "HTSGW", (10, 0, 4) => "WVDIR", (10, 0, 5) => "WVPER", (10, 3, 0) => "WTMP",
_ => "unknown",
}
}
pub fn parameter_description(discipline: u8, category: u8, number: u8) -> &'static str {
match (discipline, category, number) {
(0, 0, 0) => "Temperature",
(0, 0, 1) => "Virtual temperature",
(0, 0, 2) => "Potential temperature",
(0, 0, 4) => "Maximum temperature",
(0, 0, 5) => "Minimum temperature",
(0, 0, 6) => "Dew point temperature",
(0, 1, 0) => "Specific humidity",
(0, 1, 1) => "Relative humidity",
(0, 1, 3) => "Precipitable water",
(0, 1, 8) => "Total precipitation",
(0, 2, 0) => "Wind direction",
(0, 2, 1) => "Wind speed",
(0, 2, 2) => "U-component of wind",
(0, 2, 3) => "V-component of wind",
(0, 2, 22) => "Wind gust",
(0, 3, 0) => "Pressure",
(0, 3, 1) => "Pressure reduced to MSL",
(0, 3, 5) => "Geopotential height",
(0, 4, 7) => "Downward short-wave radiation flux",
(0, 5, 3) => "Downward long-wave radiation flux",
(0, 6, 1) => "Total cloud cover",
(0, 7, 6) => "Convective available potential energy",
(0, 7, 7) => "Convective inhibition",
(10, 0, 3) => "Significant height of combined wind waves and swell",
(10, 0, 4) => "Direction of wind waves",
(10, 0, 5) => "Mean period of wind waves",
(10, 3, 0) => "Water temperature",
_ => "Unknown parameter",
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn known_parameters() {
assert_eq!(grib1_parameter_name(2, 11), "TMP");
assert_eq!(grib1_parameter_name(2, 33), "UGRD");
assert_eq!(parameter_name(0, 0, 0), "TMP");
assert_eq!(parameter_name(0, 2, 2), "UGRD");
assert_eq!(parameter_name(0, 3, 5), "HGT");
assert_eq!(parameter_name(10, 0, 3), "HTSGW");
assert_eq!(parameter_description(0, 0, 2), "Potential temperature");
assert_eq!(parameter_description(10, 3, 0), "Water temperature");
}
#[test]
fn unknown_parameter() {
assert_eq!(parameter_name(255, 255, 255), "unknown");
}
}