gistools/readers/grib2/sections/_1/
tables.rs

1#![cfg_attr(feature = "nightly", coverage(off))]
2
3/// # Table 1.0 - GRIB Master Tables
4///
5/// **Details**:
6/// - **Section**: 1
7/// - **Octet**: 10 (index 9)
8///
9/// **Reserved Ranges**:
10/// - `34-254`: Future Version
11///
12/// **Special Value**:
13/// - `255`: Missing
14///
15/// ## Description
16/// This table defines the version numbers used in GRIB2 Master Tables,
17/// providing context for interpreting the data's versioning information.
18///
19/// ## Links
20/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)
21///
22/// ## Notes
23/// - Revised 12/07/2023
24#[repr(u8)]
25#[allow(missing_docs)]
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub enum Grib2Table1_0 {
28    Experimental = 0,
29    Version20011107 = 1,
30    Version20031104 = 2,
31    Version20051102 = 3,
32    Version20071107 = 4,
33    Version20091104 = 5,
34    Version20100915 = 6,
35    Version20110504 = 7,
36    Version20111108 = 8,
37    Version20120502 = 9,
38    Version20121107 = 10,
39    Version20130508 = 11,
40    Version20131114 = 12,
41    Version20140507 = 13,
42    Version20141105 = 14,
43    Version20150506 = 15,
44    Version20151111 = 16,
45    Version20160504 = 17,
46    Version20161102 = 18,
47    Version20170503 = 19,
48    Version20171108 = 20,
49    Version20180502 = 21,
50    Version20181107 = 22,
51    Version20190515 = 23,
52    Version20191106 = 24,
53    Version20200506 = 25,
54    Version20201116 = 26,
55    Version20210616 = 27,
56    Version20211115 = 28,
57    Version20220515 = 29,
58    Version20221115 = 30,
59    Version20230615 = 31,
60    Version20231130 = 32,
61    PreOperationalNextAmendment = 33,
62    Missing = 255,
63}
64impl From<u8> for Grib2Table1_0 {
65    fn from(val: u8) -> Self {
66        match val {
67            0 => Self::Experimental,
68            1 => Self::Version20011107,
69            2 => Self::Version20031104,
70            3 => Self::Version20051102,
71            4 => Self::Version20071107,
72            5 => Self::Version20091104,
73            6 => Self::Version20100915,
74            7 => Self::Version20110504,
75            8 => Self::Version20111108,
76            9 => Self::Version20120502,
77            10 => Self::Version20121107,
78            11 => Self::Version20130508,
79            12 => Self::Version20131114,
80            13 => Self::Version20140507,
81            14 => Self::Version20141105,
82            15 => Self::Version20150506,
83            16 => Self::Version20151111,
84            17 => Self::Version20160504,
85            18 => Self::Version20161102,
86            19 => Self::Version20170503,
87            20 => Self::Version20171108,
88            21 => Self::Version20180502,
89            22 => Self::Version20181107,
90            23 => Self::Version20190515,
91            24 => Self::Version20191106,
92            25 => Self::Version20200506,
93            26 => Self::Version20201116,
94            27 => Self::Version20210616,
95            28 => Self::Version20211115,
96            29 => Self::Version20220515,
97            30 => Self::Version20221115,
98            31 => Self::Version20230615,
99            32 => Self::Version20231130,
100            33 => Self::PreOperationalNextAmendment,
101            _ => Self::Missing,
102        }
103    }
104}
105impl core::fmt::Display for Grib2Table1_0 {
106    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
107        let desc = match self {
108            Self::Experimental => "Experimental",
109            Self::Version20011107 => "Version Implemented on 7 November 2001",
110            Self::Version20031104 => "Version Implemented on 4 November 2003",
111            Self::Version20051102 => "Version Implemented on 2 November 2005",
112            Self::Version20071107 => "Version Implemented on 7 November 2007",
113            Self::Version20091104 => "Version Implemented on 4 November 2009",
114            Self::Version20100915 => "Version Implemented on 15 September 2010",
115            Self::Version20110504 => "Version Implemented on 4 May 2011",
116            Self::Version20111108 => "Version Implemented on 8 November 2011",
117            Self::Version20120502 => "Version Implemented on 2 May 2012",
118            Self::Version20121107 => "Version Implemented on 7 November 2012",
119            Self::Version20130508 => "Version Implemented on 8 May 2013",
120            Self::Version20131114 => "Version Implemented on 14 November 2013",
121            Self::Version20140507 => "Version Implemented on 7 May 2014",
122            Self::Version20141105 => "Version Implemented on 5 November 2014",
123            Self::Version20150506 => "Version Implemented on 6 May 2015",
124            Self::Version20151111 => "Version Implemented on 11 November 2015",
125            Self::Version20160504 => "Version Implemented on 4 May 2016",
126            Self::Version20161102 => "Version Implemented on 2 November 2016",
127            Self::Version20170503 => "Version Implemented on 3 May 2017",
128            Self::Version20171108 => "Version Implemented on 8 November 2017",
129            Self::Version20180502 => "Version Implemented on 2 May 2018",
130            Self::Version20181107 => "Version Implemented on 7 November 2018",
131            Self::Version20190515 => "Version Implemented on 15 May 2019",
132            Self::Version20191106 => "Version Implemented on 06 November 2019",
133            Self::Version20200506 => "Version Implemented on 06 May 2020",
134            Self::Version20201116 => "Version Implemented on 16 November 2020",
135            Self::Version20210616 => "Version Implemented on 16 June 2021",
136            Self::Version20211115 => "Version Implemented on 15 November 2021",
137            Self::Version20220515 => "Version Implemented on 15 May 2022",
138            Self::Version20221115 => "Version Implemented on 15 November 2022",
139            Self::Version20230615 => "Version Implemented on 15 June 2023",
140            Self::Version20231130 => "Version Implemented on 30 November 2023",
141            Self::PreOperationalNextAmendment => {
142                "Pre-operational to be implemented by next amendment"
143            }
144            Self::Missing => "Missing",
145        };
146        f.write_str(desc)
147    }
148}
149
150/// # Table 1.1 - GRIB Local Tables Version Number
151///
152/// **Details**:
153/// - **Section**: 1
154/// - **Octet**: 11 (index 10)
155///
156/// **Used Ranges**:
157/// - `1-254`: Number of local table versions used
158///
159/// **Special Values**:
160/// - `0`: Local tables not used. Only table entries and templates from the current master table are valid.
161/// - `255`: Missing
162///
163/// ## Description
164/// This table defines the version numbers used in GRIB2 Local Tables,
165/// providing context for interpreting the data's versioning information.
166///
167/// ## Links
168/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)
169///
170/// ## Notes
171/// - Created 05/11/2005
172#[repr(u8)]
173#[allow(missing_docs)]
174#[derive(Debug, Clone, Copy, PartialEq, Eq)]
175pub enum Grib2Table1_1 {
176    LocalTablesNotUsed = 0,
177    Missing = 255,
178}
179impl From<u8> for Grib2Table1_1 {
180    fn from(val: u8) -> Self {
181        match val {
182            0 => Self::LocalTablesNotUsed,
183            _ => Self::Missing,
184        }
185    }
186}
187impl core::fmt::Display for Grib2Table1_1 {
188    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
189        let desc = match self {
190            Self::LocalTablesNotUsed => {
191                "Local tables not used. Only table entries and templates from the current master \
192                 table are valid."
193            }
194            Self::Missing => "Missing",
195        };
196        f.write_str(desc)
197    }
198}
199
200/// # Table 1.2 - Significance of Reference Time
201///
202/// **Details**:
203/// - **Section**: 1
204/// - **Octet**: 12 (index 11)
205///
206/// **Reserved Ranges**:
207/// - `6-191`: Reserved
208/// - `192-254`: Reserved for Local Use
209///
210/// **Special Value**:
211/// - `255`: Missing
212///
213/// ## Description
214/// This table defines the significance of the reference time in GRIB2 files,
215/// providing context for interpreting the data's temporal meaning.
216///
217/// ## Links
218/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)
219///
220/// ## Notes
221/// - Revised 06/16/2022
222#[repr(u8)]
223#[allow(missing_docs)]
224#[derive(Debug, Clone, Copy, PartialEq, Eq)]
225pub enum Grib2Table1_2 {
226    Analysis = 0,
227    StartOfForecast = 1,
228    VerifyingTimeOfForecast = 2,
229    ObservationTime = 3,
230    LocalTime = 4,
231    SimulationStart = 5,
232    Missing = 255,
233}
234impl From<u8> for Grib2Table1_2 {
235    fn from(val: u8) -> Self {
236        match val {
237            0 => Self::Analysis,
238            1 => Self::StartOfForecast,
239            2 => Self::VerifyingTimeOfForecast,
240            3 => Self::ObservationTime,
241            4 => Self::LocalTime,
242            5 => Self::SimulationStart,
243            _ => Self::Missing,
244        }
245    }
246}
247impl core::fmt::Display for Grib2Table1_2 {
248    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
249        let desc = match self {
250            Self::Analysis => "Analysis",
251            Self::StartOfForecast => "Start of Forecast",
252            Self::VerifyingTimeOfForecast => "Verifying Time of Forecast",
253            Self::ObservationTime => "Observation Time",
254            Self::LocalTime => "Local Time",
255            Self::SimulationStart => "Simulation start",
256            Self::Missing => "Missing",
257        };
258        f.write_str(desc)
259    }
260}
261
262/// # Table 1.3 - Production Status of Data
263///
264/// **Details**:
265/// - **Section**: 1
266/// - **Octet**: 20 (index 19)
267///
268/// **Reserved Ranges**:
269/// - `14-191`: Reserved
270/// - `192-254`: Reserved for Local Use
271///
272/// **Special Value**:
273/// - `255`: Missing
274///
275/// ## Description
276/// This table defines the production status of data in GRIB2 files,
277/// providing context for interpreting the data's operational and research status.
278///
279/// ## Links
280/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)
281///
282/// ## Notes
283/// - Revised 07/12/2024
284#[repr(u8)]
285#[allow(missing_docs)]
286#[derive(Debug, Clone, Copy, PartialEq, Eq)]
287pub enum Grib2Table1_3 {
288    OperationalProducts = 0,
289    OperationalTestProducts = 1,
290    ResearchProducts = 2,
291    ReAnalysisProducts = 3,
292    ThorpexInteractiveGrandGlobalEnsembleTigge = 4,
293    ThorpexInteractiveGrandGlobalEnsembleTiggeTest = 5,
294    S2sOperationalProducts = 6,
295    S2sTestProducts = 7,
296    UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerra = 8,
297    UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerraTest = 9,
298    CopernicusRegionalReanalysis = 10,
299    CopernicusRegionalReanalysisTest = 11,
300    DestinationEarth = 12,
301    DestinationEarthTest = 13,
302    Missing = 255,
303}
304impl From<u8> for Grib2Table1_3 {
305    fn from(val: u8) -> Self {
306        match val {
307            0 => Self::OperationalProducts,
308            1 => Self::OperationalTestProducts,
309            2 => Self::ResearchProducts,
310            3 => Self::ReAnalysisProducts,
311            4 => Self::ThorpexInteractiveGrandGlobalEnsembleTigge,
312            5 => Self::ThorpexInteractiveGrandGlobalEnsembleTiggeTest,
313            6 => Self::S2sOperationalProducts,
314            7 => Self::S2sTestProducts,
315            8 => Self::UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerra,
316            9 => Self::UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerraTest,
317            10 => Self::CopernicusRegionalReanalysis,
318            11 => Self::CopernicusRegionalReanalysisTest,
319            12 => Self::DestinationEarth,
320            13 => Self::DestinationEarthTest,
321            _ => Self::Missing,
322        }
323    }
324}
325impl core::fmt::Display for Grib2Table1_3 {
326    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
327        let desc = match self {
328            Self::OperationalProducts => "Operational Products",
329            Self::OperationalTestProducts => "Operational Test Products",
330            Self::ResearchProducts => "Research Products",
331            Self::ReAnalysisProducts => "Re-Analysis Products",
332            Self::ThorpexInteractiveGrandGlobalEnsembleTigge => {
333                "THORPEX Interactive Grand Global Ensemble (TIGGE)"
334            }
335            Self::ThorpexInteractiveGrandGlobalEnsembleTiggeTest => {
336                "THORPEX Interactive Grand Global Ensemble (TIGGE) test"
337            }
338            Self::S2sOperationalProducts => "S2S Operational Products",
339            Self::S2sTestProducts => "S2S Test Products",
340            Self::UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerra => {
341                "Uncertainties in ensembles of regional reanalysis project (UERRA)"
342            }
343            Self::UncertaintiesInEnsemblesOfRegionalReanalysisProjectUerraTest => {
344                "Uncertainties in ensembles of regional reanalysis project (UERRA) Test"
345            }
346            Self::CopernicusRegionalReanalysis => "Copernicus Regional Reanalysis",
347            Self::CopernicusRegionalReanalysisTest => "Copernicus Regional Reanalysis Test",
348            Self::DestinationEarth => "Destination Earth",
349            Self::DestinationEarthTest => "Destination Earth test",
350            Self::Missing => "Missing",
351        };
352        f.write_str(desc)
353    }
354}
355
356/// # Table 1.4 - TYPE OF DATA
357///
358/// **Details**:
359/// - **Section**: 1
360/// - **Octet**: 21 (index 20)
361///
362/// **Reserved Ranges**:
363/// - `9-191`: Reserved
364/// - `192-254`: Reserved for Local Use
365///
366/// **Special Values**:
367/// - `192`: Experimental Products
368/// - `255`: Missing
369///
370/// ## Description
371/// This table defines the types of data in GRIB2 files,
372/// providing context for interpreting the data's nature, whether operational, research, or experimental.
373///
374/// ## Links
375/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)
376///
377/// ## Notes
378/// - Revised 08/23/2023
379#[repr(u8)]
380#[allow(missing_docs)]
381#[derive(Debug, Clone, Copy, PartialEq, Eq)]
382pub enum Grib2Table1_4 {
383    AnalysisProducts = 0,
384    ForecastProducts = 1,
385    AnalysisAndForecastProducts = 2,
386    ControlForecastProducts = 3,
387    PerturbedForecastProducts = 4,
388    ControlAndPerturbedForecastProducts = 5,
389    ProcessedSatelliteObservations = 6,
390    ProcessedRadarObservations = 7,
391    EventProbability = 8,
392    ExperimentalProducts = 192,
393    Missing = 255,
394}
395impl From<u8> for Grib2Table1_4 {
396    fn from(val: u8) -> Self {
397        match val {
398            0 => Self::AnalysisProducts,
399            1 => Self::ForecastProducts,
400            2 => Self::AnalysisAndForecastProducts,
401            3 => Self::ControlForecastProducts,
402            4 => Self::PerturbedForecastProducts,
403            5 => Self::ControlAndPerturbedForecastProducts,
404            6 => Self::ProcessedSatelliteObservations,
405            7 => Self::ProcessedRadarObservations,
406            8 => Self::EventProbability,
407            192 => Self::ExperimentalProducts,
408            _ => Self::Missing,
409        }
410    }
411}
412impl core::fmt::Display for Grib2Table1_4 {
413    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
414        let desc = match self {
415            Self::AnalysisProducts => "Analysis Products",
416            Self::ForecastProducts => "Forecast Products",
417            Self::AnalysisAndForecastProducts => "Analysis and Forecast Products",
418            Self::ControlForecastProducts => "Control Forecast Products",
419            Self::PerturbedForecastProducts => "Perturbed Forecast Products",
420            Self::ControlAndPerturbedForecastProducts => "Control and Perturbed Forecast Products",
421            Self::ProcessedSatelliteObservations => "Processed Satellite Observations",
422            Self::ProcessedRadarObservations => "Processed Radar Observations",
423            Self::EventProbability => "Event Probability",
424            Self::ExperimentalProducts => "Experimental Products",
425            Self::Missing => "Missing",
426        };
427        f.write_str(desc)
428    }
429}
430
431/// # Table 1.5 - IDENTIFICATION TEMPLATE NUMBER
432///
433/// **Details**:
434/// - **Section**: 1
435/// - **Octet**: 21 (index 20)
436///
437/// **Reserved Ranges**:
438/// - `3-32767`: Reserved
439/// - `32768-65534`: Reserved for Local Use
440///
441/// **Special Value**:
442/// - `65535`: Missing
443///
444/// ## Description
445/// This table defines the identification template numbers in GRIB2 files,
446/// providing context for interpreting the data's template classifications.
447///
448/// ## Links
449/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-5.shtml)
450///
451/// ## Notes
452/// - Created 07/01/2014
453#[repr(u16)]
454#[allow(missing_docs)]
455#[derive(Debug, Clone, Copy, PartialEq, Eq)]
456pub enum Grib2Table1_5 {
457    CalendarDefinition = 0,
458    PaleontologicalOffset = 1,
459    CalendarDefinitionAndPaleontologicalOffset = 2,
460    Missing = 65535,
461}
462impl From<u16> for Grib2Table1_5 {
463    fn from(val: u16) -> Self {
464        match val {
465            0 => Self::CalendarDefinition,
466            1 => Self::PaleontologicalOffset,
467            2 => Self::CalendarDefinitionAndPaleontologicalOffset,
468            _ => Self::Missing,
469        }
470    }
471}
472impl core::fmt::Display for Grib2Table1_5 {
473    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
474        let desc = match self {
475            Self::CalendarDefinition => "Calendar Definition",
476            Self::PaleontologicalOffset => "Paleontological Offset",
477            Self::CalendarDefinitionAndPaleontologicalOffset => {
478                "Calendar Definition and Paleontological Offset"
479            }
480            Self::Missing => "Missing",
481        };
482        f.write_str(desc)
483    }
484}
485
486/// # Table 1.6 - TYPE OF CALENDAR
487///
488/// **Details**:
489/// - **Section**: 1
490/// - **Octet**: 21 (index 20)
491///
492/// **Reserved Ranges**:
493/// - `4-191`: Reserved
494/// - `192-254`: Reserved for Local Use
495///
496/// **Special Value**:
497/// - `255`: Missing
498///
499/// ## Description
500/// This table defines the types of calendars in GRIB2 files,
501/// providing context for interpreting the data's calendar classifications.
502///
503/// ## Links
504/// - [Read more...](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-6.shtml)
505///
506/// ## Notes
507/// - (1). Essentially a non-leap year
508/// - (2). Extends the Gregorian calendar indefinitely in the past
509#[repr(u8)]
510#[allow(missing_docs)]
511#[derive(Debug, Clone, Copy, PartialEq, Eq)]
512pub enum Grib2Table1_6 {
513    Gregorian = 0,
514    Day360 = 1,
515    Day365 = 2,             // (see Note 1)
516    ProlepticGregorian = 3, // (see Note 2)
517    Missing = 255,
518}
519impl From<u8> for Grib2Table1_6 {
520    fn from(val: u8) -> Self {
521        match val {
522            0 => Self::Gregorian,
523            1 => Self::Day360,
524            2 => Self::Day365,
525            3 => Self::ProlepticGregorian,
526            _ => Self::Missing,
527        }
528    }
529}
530impl core::fmt::Display for Grib2Table1_6 {
531    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
532        let desc = match self {
533            Self::Gregorian => "Gregorian",
534            Self::Day360 => "360-day",
535            Self::Day365 => "365-day (see Note 1)",
536            Self::ProlepticGregorian => "Proleptic Gregorian (see Note 2)",
537            Self::Missing => "Missing",
538        };
539        f.write_str(desc)
540    }
541}