1pub fn grib1_parameter_name(table_version: u8, number: u8) -> &'static str {
7 match (table_version, number) {
8 (_, 1) => "PRES",
9 (_, 2) => "PRMSL",
10 (_, 7) => "HGT",
11 (_, 11) => "TMP",
12 (_, 17) => "DPT",
13 (_, 33) => "UGRD",
14 (_, 34) => "VGRD",
15 (_, 39) => "VVEL",
16 (_, 52) => "RH",
17 (_, 54) => "PWAT",
18 (_, 61) => "APCP",
19 (_, 71) => "TCDC",
20 _ => "unknown",
21 }
22}
23
24pub fn grib1_parameter_description(table_version: u8, number: u8) -> &'static str {
26 match (table_version, number) {
27 (_, 1) => "Pressure",
28 (_, 2) => "Pressure reduced to mean sea level",
29 (_, 7) => "Geopotential height",
30 (_, 11) => "Temperature",
31 (_, 17) => "Dew point temperature",
32 (_, 33) => "U-component of wind",
33 (_, 34) => "V-component of wind",
34 (_, 39) => "Vertical velocity",
35 (_, 52) => "Relative humidity",
36 (_, 54) => "Precipitable water",
37 (_, 61) => "Total precipitation",
38 (_, 71) => "Total cloud cover",
39 _ => "Unknown parameter",
40 }
41}
42
43pub fn parameter_name(discipline: u8, category: u8, number: u8) -> &'static str {
45 match (discipline, category, number) {
46 (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",
88 }
89}
90
91pub fn parameter_description(discipline: u8, category: u8, number: u8) -> &'static str {
93 match (discipline, category, number) {
94 (0, 0, 0) => "Temperature",
95 (0, 0, 1) => "Virtual temperature",
96 (0, 0, 2) => "Potential temperature",
97 (0, 0, 4) => "Maximum temperature",
98 (0, 0, 5) => "Minimum temperature",
99 (0, 0, 6) => "Dew point temperature",
100 (0, 1, 0) => "Specific humidity",
101 (0, 1, 1) => "Relative humidity",
102 (0, 1, 3) => "Precipitable water",
103 (0, 1, 8) => "Total precipitation",
104 (0, 2, 0) => "Wind direction",
105 (0, 2, 1) => "Wind speed",
106 (0, 2, 2) => "U-component of wind",
107 (0, 2, 3) => "V-component of wind",
108 (0, 2, 22) => "Wind gust",
109 (0, 3, 0) => "Pressure",
110 (0, 3, 1) => "Pressure reduced to MSL",
111 (0, 3, 5) => "Geopotential height",
112 (0, 4, 7) => "Downward short-wave radiation flux",
113 (0, 5, 3) => "Downward long-wave radiation flux",
114 (0, 6, 1) => "Total cloud cover",
115 (0, 7, 6) => "Convective available potential energy",
116 (0, 7, 7) => "Convective inhibition",
117 (10, 0, 3) => "Significant height of combined wind waves and swell",
118 (10, 0, 4) => "Direction of wind waves",
119 (10, 0, 5) => "Mean period of wind waves",
120 (10, 3, 0) => "Water temperature",
121 _ => "Unknown parameter",
122 }
123}
124
125#[cfg(test)]
126mod tests {
127 use super::*;
128
129 #[test]
130 fn known_parameters() {
131 assert_eq!(grib1_parameter_name(2, 11), "TMP");
132 assert_eq!(grib1_parameter_name(2, 33), "UGRD");
133 assert_eq!(parameter_name(0, 0, 0), "TMP");
134 assert_eq!(parameter_name(0, 2, 2), "UGRD");
135 assert_eq!(parameter_name(0, 3, 5), "HGT");
136 assert_eq!(parameter_name(10, 0, 3), "HTSGW");
137 assert_eq!(parameter_description(0, 0, 2), "Potential temperature");
138 assert_eq!(parameter_description(10, 3, 0), "Water temperature");
139 }
140
141 #[test]
142 fn unknown_parameter() {
143 assert_eq!(parameter_name(255, 255, 255), "unknown");
144 }
145}