dmap/formats/
snd.rs

1//! The [SND file format](https://github.com/SuperDARN/rst/pull/315).
2
3use crate::record::create_record_type;
4use crate::types::{Fields, Type};
5use lazy_static::lazy_static;
6
7static SCALAR_FIELDS: [(&str, Type); 37] = [
8    ("radar.revision.major", Type::Char),
9    ("radar.revision.minor", Type::Char),
10    ("origin.code", Type::Char),
11    ("origin.time", Type::String),
12    ("origin.command", Type::String),
13    ("cp", Type::Short),
14    ("stid", Type::Short),
15    ("time.yr", Type::Short),
16    ("time.mo", Type::Short),
17    ("time.dy", Type::Short),
18    ("time.hr", Type::Short),
19    ("time.mt", Type::Short),
20    ("time.sc", Type::Short),
21    ("time.us", Type::Int),
22    ("nave", Type::Short),
23    ("lagfr", Type::Short),
24    ("smsep", Type::Short),
25    ("noise.search", Type::Float),
26    ("noise.mean", Type::Float),
27    ("channel", Type::Short),
28    ("bmnum", Type::Short),
29    ("bmazm", Type::Float),
30    ("scan", Type::Short),
31    ("rxrise", Type::Short),
32    ("intt.sc", Type::Short),
33    ("intt.us", Type::Int),
34    ("nrang", Type::Short),
35    ("frang", Type::Short),
36    ("rsep", Type::Short),
37    ("xcf", Type::Short),
38    ("tfreq", Type::Short),
39    ("noise.sky", Type::Float),
40    ("combf", Type::String),
41    ("fitacf.revision.major", Type::Int),
42    ("fitacf.revision.minor", Type::Int),
43    ("snd.revision.major", Type::Short),
44    ("snd.revision.minor", Type::Short),
45];
46
47static SCALAR_FIELDS_OPT: [(&str, Type); 0] = [];
48
49static VECTOR_FIELDS: [(&str, Type); 0] = [];
50
51static VECTOR_FIELDS_OPT: [(&str, Type); 10] = [
52    ("slist", Type::Short),
53    ("qflg", Type::Char),
54    ("gflg", Type::Char),
55    ("v", Type::Float),
56    ("v_e", Type::Float),
57    ("p_l", Type::Float),
58    ("w_l", Type::Float),
59    ("x_qflg", Type::Char),
60    ("phi0", Type::Float),
61    ("phi0_e", Type::Float),
62];
63
64static MATCHED_VECS: [[&str; 10]; 1] = [[
65    "slist", "qflg", "gflg", "v", "v_e", "p_l", "w_l", "x_qflg", "phi0", "phi0_e",
66]];
67
68static DATA_FIELDS: [&str; 10] = [
69    "slist", "qflg", "gflg", "v", "v_e", "p_l", "w_l", "x_qflg", "phi0", "phi0_e",
70];
71
72lazy_static! {
73    static ref SND_FIELDS: Fields<'static> = Fields {
74        all_fields: {
75            let mut fields: Vec<&str> = vec![];
76            fields.extend(SCALAR_FIELDS.clone().into_iter().map(|x| x.0));
77            fields.extend(SCALAR_FIELDS_OPT.clone().into_iter().map(|x| x.0));
78            fields.extend(VECTOR_FIELDS.clone().into_iter().map(|x| x.0));
79            fields.extend(VECTOR_FIELDS_OPT.clone().into_iter().map(|x| x.0));
80            fields
81        },
82        scalars_required: SCALAR_FIELDS.to_vec(),
83        scalars_optional: SCALAR_FIELDS_OPT.to_vec(),
84        vectors_required: VECTOR_FIELDS.to_vec(),
85        vectors_optional: VECTOR_FIELDS_OPT.to_vec(),
86        vector_dim_groups: MATCHED_VECS.to_vec().iter().map(|x| x.to_vec()).collect(),
87        data_fields: DATA_FIELDS.to_vec(),
88    };
89}
90
91create_record_type!(snd, SND_FIELDS);