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

1#![cfg_attr(feature = "nightly", coverage(off))]
2
3/// # GRIB2 - TABLE 5.0 - DATA REPRESENTATION TEMPLATE NUMBER
4///
5/// **Details**:
6/// - **Section**: 5
7/// - **Octets**: 10-11
8/// - **Revised**: 07/01/2022
9///
10/// **Reserved Ranges**:
11/// - `5-39`: Reserved
12/// - `43-49`: Reserved
13/// - `52`: Reserved
14/// - `54-60`: Reserved
15/// - `62-199`: Reserved
16/// - `201-49151`: Reserved
17/// - `49152-65534`: Reserved for Local Use
18///
19/// **Special Value**:
20/// - `65535`: Missing
21///
22/// ## Notes
23#[repr(u16)]
24#[allow(missing_docs)]
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum Grib2Table5_0 {
27    GridPointDataSimplePacking = 0,
28    MatrixValueAtGridPointSimplePacking = 1,
29    GridPointDataComplexPacking = 2,
30    GridPointDataComplexPackingAndSpatialDifferencing = 3,
31    GridPointDataIeeeFloatingPointData = 4,
32    GridPointDataJpeg2000CodeStreamFormat = 40,
33    GridPointDataPortableNetworkGraphicsPng = 41,
34    GridPointDataCcsdsRecommendedLosslessCompression = 42,
35    SpectralDataSimplePacking = 50,
36    SpectralDataComplexPacking = 51,
37    SpectralDataForLimitedAreaModelsComplexPacking = 53,
38    GridPointDataSimplePackingWithLogarithmPreProcessing = 61,
39    RunLengthPackingWithLevelValues = 200,
40    GridPointDataJpeg2000CodeStreamFormatAndSpatialDifferencing = 40000,
41    Missing = 65535,
42}
43impl From<u16> for Grib2Table5_0 {
44    fn from(val: u16) -> Self {
45        match val {
46            0 => Self::GridPointDataSimplePacking,
47            1 => Self::MatrixValueAtGridPointSimplePacking,
48            2 => Self::GridPointDataComplexPacking,
49            3 => Self::GridPointDataComplexPackingAndSpatialDifferencing,
50            4 => Self::GridPointDataIeeeFloatingPointData,
51            40 => Self::GridPointDataJpeg2000CodeStreamFormat,
52            41 => Self::GridPointDataPortableNetworkGraphicsPng,
53            42 => Self::GridPointDataCcsdsRecommendedLosslessCompression,
54            50 => Self::SpectralDataSimplePacking,
55            51 => Self::SpectralDataComplexPacking,
56            53 => Self::SpectralDataForLimitedAreaModelsComplexPacking,
57            61 => Self::GridPointDataSimplePackingWithLogarithmPreProcessing,
58            200 => Self::RunLengthPackingWithLevelValues,
59            40000 => Self::GridPointDataJpeg2000CodeStreamFormatAndSpatialDifferencing,
60            _ => Self::Missing,
61        }
62    }
63}
64impl core::fmt::Display for Grib2Table5_0 {
65    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
66        let desc = match self {
67            Self::GridPointDataSimplePacking => {
68                "Grid Point Data - Simple Packing (see Template 5.0)"
69            }
70            Self::MatrixValueAtGridPointSimplePacking => {
71                "Matrix Value at Grid Point - Simple Packing (see Template 5.1)"
72            }
73            Self::GridPointDataComplexPacking => {
74                "Grid Point Data - Complex Packing (see Template 5.2)"
75            }
76            Self::GridPointDataComplexPackingAndSpatialDifferencing => {
77                "Grid Point Data - Complex Packing and Spatial Differencing (see Template 5.3)"
78            }
79            Self::GridPointDataIeeeFloatingPointData => {
80                "Grid Point Data - IEEE Floating Point Data (see Template 5.4)"
81            }
82            Self::GridPointDataJpeg2000CodeStreamFormat => {
83                "Grid point data - JPEG 2000 code stream format (see Template 5.40)"
84            }
85            Self::GridPointDataPortableNetworkGraphicsPng => {
86                "Grid point data - Portable Network Graphics (PNG) (see Template 5.41)"
87            }
88            Self::GridPointDataCcsdsRecommendedLosslessCompression => {
89                "Grid point data - CCSDS recommended lossless compression (see Template 5.42)"
90            }
91            Self::SpectralDataSimplePacking => "Spectral Data - Simple Packing (see Template 5.50)",
92            Self::SpectralDataComplexPacking => {
93                "Spectral Data - Complex Packing (see Template 5.51)"
94            }
95            Self::SpectralDataForLimitedAreaModelsComplexPacking => {
96                "Spectral data for limited area models - complex packing (see Template 5.53)"
97            }
98            Self::GridPointDataSimplePackingWithLogarithmPreProcessing => {
99                "Grid Point Data - Simple Packing With Logarithm Pre-processing (see Template 5.61)"
100            }
101            Self::RunLengthPackingWithLevelValues => {
102                "Run Length Packing With Level Values (see Template 5.200)"
103            }
104            Self::GridPointDataJpeg2000CodeStreamFormatAndSpatialDifferencing => {
105                "Grid point data - JPEG 2000 code stream format and spatial differencing (see \
106                 Template 5.40000)"
107            }
108            Self::Missing => "Missing",
109        };
110        f.write_str(desc)
111    }
112}
113
114/// # GRIB2 - TABLE 5.1 - TYPE OF ORIGINAL FIELD VALUES
115///
116/// **Details**:
117/// - **Created**: 05/16/2005
118///
119/// **Reserved Ranges**:
120/// - `2-191`: Reserved
121/// - `192-254`: Reserved for Local Use
122///
123/// **Special Value**:
124/// - `255`: Missing
125#[repr(u8)]
126#[allow(missing_docs)]
127#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128pub enum Grib2Table5_1 {
129    FloatingPoint = 0,
130    Integer = 1,
131    Missing = 255,
132}
133impl From<u8> for Grib2Table5_1 {
134    fn from(val: u8) -> Self {
135        match val {
136            0 => Self::FloatingPoint,
137            1 => Self::Integer,
138            _ => Self::Missing,
139        }
140    }
141}
142impl core::fmt::Display for Grib2Table5_1 {
143    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
144        let desc = match self {
145            Self::FloatingPoint => "Floating Point",
146            Self::Integer => "Integer",
147            Self::Missing => "Missing",
148        };
149        f.write_str(desc)
150    }
151}
152
153/// # GRIB2 - TABLE 5.2 - MATRIX COORDINATE VALUE FUNCTION DEFINITION
154///
155/// **Details**:
156/// - **Revised**: 05/16/2005
157///
158/// **Reserved Ranges**:
159/// - `2-10`: Reserved
160/// - `12-191`: Reserved
161/// - `192-254`: Reserved for Local Use
162///
163/// **Special Value**:
164/// - `255`: Missing
165#[repr(u8)]
166#[allow(missing_docs)]
167#[derive(Debug, Clone, Copy, PartialEq, Eq)]
168pub enum Grib2Table5_2 {
169    ExplicitCoordinateValuesSet = 0,
170    LinearCoordinates = 1,
171    GeometricCoordinates = 11,
172    Missing = 255,
173}
174impl From<u8> for Grib2Table5_2 {
175    fn from(val: u8) -> Self {
176        match val {
177            0 => Self::ExplicitCoordinateValuesSet,
178            1 => Self::LinearCoordinates,
179            11 => Self::GeometricCoordinates,
180            _ => Self::Missing,
181        }
182    }
183}
184impl core::fmt::Display for Grib2Table5_2 {
185    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
186        let desc = match self {
187            Self::ExplicitCoordinateValuesSet => "Explicit Coordinate Values Set",
188            Self::LinearCoordinates => "Linear Coordinates: f(1) = C1, f(n) = f(n-1) + C2",
189            Self::GeometricCoordinates => "Geometric Coordinates: f(1) = C1, f(n) = C2 x f(n-1)",
190            Self::Missing => "Missing",
191        };
192        f.write_str(desc)
193    }
194}
195
196/// # GRIB2 - TABLE 5.3 - MATRIX COORDINATE PARAMETER
197///
198/// **Details**:
199/// - **Created**: 05/16/2005
200///
201/// **Reserved Ranges**:
202/// - `4-191`: Reserved
203/// - `192-254`: Reserved for Local Use
204///
205/// **Special Value**:
206/// - `255`: Missing
207#[repr(u8)]
208#[allow(missing_docs)]
209#[derive(Debug, Clone, Copy, PartialEq, Eq)]
210pub enum Grib2Table5_3 {
211    DirectionDegreesTrue = 1,
212    FrequencyS1 = 2,
213    RadialNumber2piLambdaM1 = 3,
214    Missing = 255,
215}
216impl From<u8> for Grib2Table5_3 {
217    fn from(val: u8) -> Self {
218        match val {
219            1 => Self::DirectionDegreesTrue,
220            2 => Self::FrequencyS1,
221            3 => Self::RadialNumber2piLambdaM1,
222            _ => Self::Missing,
223        }
224    }
225}
226impl core::fmt::Display for Grib2Table5_3 {
227    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
228        let desc = match self {
229            Self::DirectionDegreesTrue => "Direction Degrees True",
230            Self::FrequencyS1 => "Frequency (s-1)",
231            Self::RadialNumber2piLambdaM1 => "Radial Number (2pi/lambda) (m-1)",
232            Self::Missing => "Missing",
233        };
234        f.write_str(desc)
235    }
236}
237
238/// # GRIB2 - TABLE 5.4 - GROUP SPLITTING METHOD
239///
240/// **Details**:
241/// - **Created**: 05/16/2005
242///
243/// **Reserved Ranges**:
244/// - `2-191`: Reserved
245/// - `192-254`: Reserved for Local Use
246///
247/// **Special Value**:
248/// - `255`: Missing
249#[repr(u8)]
250#[allow(missing_docs)]
251#[derive(Debug, Clone, Copy, PartialEq, Eq)]
252pub enum Grib2Table5_4 {
253    RowByRowSplitting = 0,
254    GeneralGroupSplitting = 1,
255    Missing = 255,
256}
257impl From<u8> for Grib2Table5_4 {
258    fn from(val: u8) -> Self {
259        match val {
260            0 => Self::RowByRowSplitting,
261            1 => Self::GeneralGroupSplitting,
262            _ => Self::Missing,
263        }
264    }
265}
266impl core::fmt::Display for Grib2Table5_4 {
267    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
268        let desc = match self {
269            Self::RowByRowSplitting => "Row by Row Splitting",
270            Self::GeneralGroupSplitting => "General Group Splitting",
271            Self::Missing => "Missing",
272        };
273        f.write_str(desc)
274    }
275}
276
277/// # GRIB2 - TABLE 5.5 - MISSING VALUE MANAGEMENT FOR COMPLEX PACKING
278///
279/// **Details**:
280/// - **Created**: 05/16/2005
281///
282/// **Reserved Ranges**:
283/// - `3-191`: Reserved
284/// - `192-254`: Reserved for Local Use
285///
286/// **Special Value**:
287/// - `255`: Missing
288#[repr(u8)]
289#[allow(missing_docs)]
290#[derive(Debug, Clone, Copy, PartialEq, Eq)]
291pub enum Grib2Table5_5 {
292    NoExplicitMissingValues = 0,
293    PrimaryMissingValuesIncluded = 1,
294    PrimaryAndSecondaryMissingValuesIncluded = 2,
295    Missing = 255,
296}
297impl From<u8> for Grib2Table5_5 {
298    fn from(val: u8) -> Self {
299        match val {
300            0 => Self::NoExplicitMissingValues,
301            1 => Self::PrimaryMissingValuesIncluded,
302            2 => Self::PrimaryAndSecondaryMissingValuesIncluded,
303            _ => Self::Missing,
304        }
305    }
306}
307impl core::fmt::Display for Grib2Table5_5 {
308    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
309        let desc = match self {
310            Self::NoExplicitMissingValues => {
311                "No explicit missing values included within the data values"
312            }
313            Self::PrimaryMissingValuesIncluded => {
314                "Primary missing values included within the data values"
315            }
316            Self::PrimaryAndSecondaryMissingValuesIncluded => {
317                "Primary and secondary missing values included within the data values"
318            }
319            Self::Missing => "Missing",
320        };
321        f.write_str(desc)
322    }
323}
324
325/// # GRIB2 - TABLE 5.6 - ORDER OF SPATIAL DIFFERENCING
326///
327/// **Details**:
328/// - **Created**: 05/16/2005
329///
330/// **Reserved Ranges**:
331/// - `3-191`: Reserved
332/// - `192-254`: Reserved for Local Use
333///
334/// **Special Value**:
335/// - `255`: Missing
336#[repr(u8)]
337#[allow(missing_docs)]
338#[derive(Debug, Clone, Copy, PartialEq, Eq)]
339pub enum Grib2Table5_6 {
340    FirstOrderSpatialDifferencing = 1,
341    SecondOrderSpatialDifferencing = 2,
342    Missing = 255,
343}
344impl From<u8> for Grib2Table5_6 {
345    fn from(val: u8) -> Self {
346        match val {
347            1 => Self::FirstOrderSpatialDifferencing,
348            2 => Self::SecondOrderSpatialDifferencing,
349            _ => Self::Missing,
350        }
351    }
352}
353impl core::fmt::Display for Grib2Table5_6 {
354    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
355        let desc = match self {
356            Self::FirstOrderSpatialDifferencing => "First-Order Spatial Differencing",
357            Self::SecondOrderSpatialDifferencing => "Second-Order Spatial Differencing",
358            Self::Missing => "Missing",
359        };
360        f.write_str(desc)
361    }
362}
363
364/// # GRIB2 - TABLE 5.7 - PRECISION OF FLOATING POINT NUMBERS
365///
366/// **Details**:
367/// - **Created**: 05/16/2005
368///
369/// **Reserved Ranges**:
370/// - `4-254`: Reserved
371///
372/// **Special Value**:
373/// - `255`: Missing
374#[repr(u8)]
375#[allow(missing_docs)]
376#[derive(Debug, Clone, Copy, PartialEq, Eq)]
377pub enum Grib2Table5_7 {
378    Ieee32Bit = 1,
379    Ieee64Bit = 2,
380    Ieee128Bit = 3,
381    Missing = 255,
382}
383impl From<u8> for Grib2Table5_7 {
384    fn from(val: u8) -> Self {
385        match val {
386            1 => Self::Ieee32Bit,
387            2 => Self::Ieee64Bit,
388            3 => Self::Ieee128Bit,
389            _ => Self::Missing,
390        }
391    }
392}
393impl core::fmt::Display for Grib2Table5_7 {
394    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
395        let desc = match self {
396            Self::Ieee32Bit => "IEEE 32-bit (I=4 in Section 7)",
397            Self::Ieee64Bit => "IEEE 64-bit (I=8 in Section 7)",
398            Self::Ieee128Bit => "IEEE 128-bit (I=16 in Section 7)",
399            Self::Missing => "Missing",
400        };
401        f.write_str(desc)
402    }
403}
404
405/// # GRIB2 - TABLE 5.25 - TYPE OF BI-FOURIER SUBTRUNCATION
406///
407/// **Details**:
408/// - **Created**: 05/29/2019
409///
410/// **Reserved Ranges**:
411/// - `0-76`: Reserved
412/// - `78-87`: Reserved
413/// - `89-98`: Reserved
414/// - `100-254`: Reserved for Local Use
415///
416/// **Special Value**:
417/// - `255`: Missing
418#[repr(u8)]
419#[allow(missing_docs)]
420#[derive(Debug, Clone, Copy, PartialEq, Eq)]
421pub enum Grib2Table5_25 {
422    Rectangular = 77,
423    Elliptic = 88,
424    Diamond = 99,
425    Missing = 255,
426}
427impl From<u8> for Grib2Table5_25 {
428    fn from(val: u8) -> Self {
429        match val {
430            77 => Self::Rectangular,
431            88 => Self::Elliptic,
432            99 => Self::Diamond,
433            _ => Self::Missing,
434        }
435    }
436}
437impl core::fmt::Display for Grib2Table5_25 {
438    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
439        let desc = match self {
440            Self::Rectangular => "Rectangular",
441            Self::Elliptic => "Elliptic",
442            Self::Diamond => "Diamond",
443            Self::Missing => "Missing",
444        };
445        f.write_str(desc)
446    }
447}
448
449/// # GRIB2 - TABLE 5.26 - PACKING MODE FOR AXES
450///
451/// **Details**:
452/// - **Created**: 05/29/2019
453///
454/// **Reserved Ranges**:
455/// - `2-254`: Reserved for Local Use
456///
457/// **Special Value**:
458/// - `255`: Missing
459#[repr(u8)]
460#[allow(missing_docs)]
461#[derive(Debug, Clone, Copy, PartialEq, Eq)]
462pub enum Grib2Table5_26 {
463    SpectralCoefficientsForAxesArePacked = 0,
464    SpectralCoefficientsForAxesIncludedInUnpackedSubset = 1,
465    Missing = 255,
466}
467impl From<u8> for Grib2Table5_26 {
468    fn from(val: u8) -> Self {
469        match val {
470            0 => Self::SpectralCoefficientsForAxesArePacked,
471            1 => Self::SpectralCoefficientsForAxesIncludedInUnpackedSubset,
472            _ => Self::Missing,
473        }
474    }
475}
476impl core::fmt::Display for Grib2Table5_26 {
477    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
478        let desc = match self {
479            Self::SpectralCoefficientsForAxesArePacked => {
480                "Spectral coefficients for axes are packed"
481            }
482            Self::SpectralCoefficientsForAxesIncludedInUnpackedSubset => {
483                "Spectral coefficients for axes included in the unpacked subset"
484            }
485            Self::Missing => "Missing",
486        };
487        f.write_str(desc)
488    }
489}
490
491/// # GRIB2 - TABLE 5.40 - TYPE OF COMPRESSION
492///
493/// **Details**:
494/// - **Created**: 02/14/2006
495///
496/// **Reserved Ranges**:
497/// - `2-254`: Reserved
498///
499/// **Special Value**:
500/// - `255`: Missing
501#[repr(u8)]
502#[allow(missing_docs)]
503#[derive(Debug, Clone, Copy, PartialEq, Eq)]
504pub enum Grib2Table5_40 {
505    Lossless = 0,
506    Lossy = 1,
507    Missing = 255,
508}
509impl From<u8> for Grib2Table5_40 {
510    fn from(val: u8) -> Self {
511        match val {
512            0 => Self::Lossless,
513            1 => Self::Lossy,
514            _ => Self::Missing,
515        }
516    }
517}
518impl core::fmt::Display for Grib2Table5_40 {
519    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
520        let desc = match self {
521            Self::Lossless => "Lossless",
522            Self::Lossy => "Lossy",
523            Self::Missing => "Missing",
524        };
525        f.write_str(desc)
526    }
527}