1use grib_template_derive::{Dump, TryFromSlice, WriteToBuffer};
2
3#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
6pub struct Template4_0 {
7 pub param: param_set::ProductParam,
8 pub generating_process: param_set::GeneratingProcess,
9 #[dump(doc(
10 cutoff_hours = "Hours of observational data cutoff after reference time (see Note 1)",
11 cutoff_minutes = "Minutes of observational data cutoff after reference time",
12 ))]
13 pub forecast_time: param_set::ForecastTime,
14 pub horizontal: param_set::Horizontal,
15}
16
17#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
21pub struct Template4_1 {
22 pub param: param_set::ProductParam,
23 #[dump(doc(
24 process_id = "Forecast generating process identifier (defined by originating centre).",
25 ))]
26 pub generating_process: param_set::GeneratingProcess,
27 pub forecast_time: param_set::ForecastTime,
28 pub horizontal: param_set::Horizontal,
29 pub emsemble_forecast: param_set::EnsembleForecast,
30}
31
32#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
35pub struct Template4_2 {
36 pub param: param_set::ProductParam,
37 #[dump(doc(
38 process_id = "Forecast generating process identifier (defined by originating centre).",
39 ))]
40 pub generating_process: param_set::GeneratingProcess,
41 pub forecast_time: param_set::ForecastTime,
42 pub horizontal: param_set::Horizontal,
43 pub derived_forecast: param_set::DerivedForecast,
44}
45
46#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
49pub struct Template4_5 {
50 pub param: param_set::ProductParam,
51 #[dump(doc(
52 process_id = "Forecast generating process identifier (defined by originating centre).",
53 ))]
54 pub generating_process: param_set::GeneratingProcess,
55 pub forecast_time: param_set::ForecastTime,
56 pub horizontal: param_set::Horizontal,
57 pub probability_forecasts: param_set::ProbabilityForecasts,
58}
59
60#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
63pub struct Template4_6 {
64 pub param: param_set::ProductParam,
65 pub generating_process: param_set::GeneratingProcess,
66 pub forecast_time: param_set::ForecastTime,
67 pub horizontal: param_set::Horizontal,
68 pub percentile_forecasts: param_set::PercentileForecasts,
69}
70
71#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
148pub struct Template4_8 {
149 pub param: param_set::ProductParam,
150 pub generating_process: param_set::GeneratingProcess,
151 pub forecast_time: param_set::ForecastTime,
152 pub horizontal: param_set::Horizontal,
153 pub time_interval: param_set::Statistical,
154}
155
156#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
160pub struct Template4_9 {
161 pub param: param_set::ProductParam,
162 #[dump(doc(
163 process_id = "Forecast generating process identifier (defined by originating centre).",
164 ))]
165 pub generating_process: param_set::GeneratingProcess,
166 pub forecast_time: param_set::ForecastTime,
167 pub horizontal: param_set::Horizontal,
168 pub probability_forecasts: param_set::ProbabilityForecasts,
169 pub time_interval: param_set::Statistical,
170}
171
172#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
176pub struct Template4_10 {
177 pub param: param_set::ProductParam,
178 #[dump(doc(
179 process_id = "Forecast generating process identifier (defined by originating centre).",
180 ))]
181 pub generating_process: param_set::GeneratingProcess,
182 pub forecast_time: param_set::ForecastTime,
183 pub horizontal: param_set::Horizontal,
184 pub percentile_forecasts: param_set::PercentileForecasts,
185 pub time_interval: param_set::Statistical,
186}
187
188#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
192pub struct Template4_11 {
193 pub param: param_set::ProductParam,
194 #[dump(doc(
195 process_id = "Forecast generating process identifier (defined by originating centre).",
196 ))]
197 pub generating_process: param_set::GeneratingProcess,
198 pub forecast_time: param_set::ForecastTime,
199 pub horizontal: param_set::Horizontal,
200 pub emsemble_forecast: param_set::EnsembleForecast,
201 pub time_interval: param_set::Statistical,
202}
203
204#[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
208pub struct Template4_12 {
209 pub param: param_set::ProductParam,
210 #[dump(doc(
211 process_id = "Forecast generating process identifier (defined by originating centre).",
212 ))]
213 pub generating_process: param_set::GeneratingProcess,
214 pub forecast_time: param_set::ForecastTime,
215 pub horizontal: param_set::Horizontal,
216 pub derived_forecast: param_set::DerivedForecast,
217 pub time_interval: param_set::Statistical,
218}
219
220pub(crate) mod param_set {
221 use grib_template_derive::{Dump, TryFromSlice, WriteToBuffer};
222
223 use super::super::template::param_set::{DateTime, ScaledValue, TimeRange};
224
225 #[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
226 pub struct ProductParam {
227 pub category: u8,
229 pub num: u8,
231 }
232
233 #[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
234 pub struct GeneratingProcess {
235 pub process_type: u8,
237 pub background_process: u8,
240 pub process_id: u8,
243 }
244
245 #[derive(Debug, PartialEq, Clone, TryFromSlice, WriteToBuffer, Dump)]
246 pub struct ForecastTime {
247 pub cutoff_hours: u16,
249 pub cutoff_minutes: u8,
251 #[dump(doc(
253 unit = "Indicator of unit of time range (see Code Table 4.4).",
254 len = "Forecast time in units defined by octet 18.",
255 ))]
256 pub time: TimeRange<i32>,
257 }
258
259 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
260 pub struct Horizontal {
261 #[dump(doc(
262 surface_type = "Type of first fixed surface (see Code Table 4.5).",
263 value(
264 scale_factor = "Scale factor of first fixed surface.",
265 scaled_value = "Scaled value of first fixed surface.",
266 ),
267 ))]
268 pub first_surface: FixedSurface,
269 #[dump(doc(
270 surface_type = "Type of second fixed surface (see Code Table 4.5).",
271 value(
272 scale_factor = "Scale factor of second fixed surface.",
273 scaled_value = "Scaled value of second fixed surface.",
274 ),
275 ))]
276 pub second_surface: FixedSurface,
277 }
278
279 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
280 pub struct FixedSurface {
281 pub surface_type: u8,
283 pub value: ScaledValue<i8, i32>,
285 }
286
287 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
288 pub struct EnsembleForecast {
289 pub ensemble_forecast_type: u8,
291 pub perturbation_num: u8,
293 pub num_forecasts: u8,
295 }
296
297 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
298 pub struct DerivedForecast {
299 pub derived_forecast_type: u8,
301 pub num_forecasts: u8,
303 }
304
305 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
306 pub struct ProbabilityForecasts {
307 pub forecast_probability_num: u8,
309 pub total_num_forecast_probabilities: u8,
311 pub probability_type: u8,
313 #[dump(doc(
315 scale_factor = "Scale factor of lower limit.",
316 scaled_value = "Scaled value of lower limit.",
317 ))]
318 pub lower_limit: ScaledValue<i8, i32>,
319 #[dump(doc(
321 scale_factor = "Scale factor of upper limit.",
322 scaled_value = "Scaled value of upper limit.",
323 ))]
324 pub upper_limit: ScaledValue<i8, i32>,
325 }
326
327 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
328 pub struct PercentileForecasts {
329 pub percentile_value: u8,
331 }
332
333 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
334 pub struct Statistical {
335 pub end_of_overall_time_interval: DateTime,
337 pub num_time_ranges: u8,
340 pub num_missing: u32,
342 #[grib_template(len = "num_time_ranges")]
343 pub time_ranges: Vec<StatisticalProcess>,
344 }
345
346 #[derive(Debug, PartialEq, Eq, Clone, TryFromSlice, WriteToBuffer, Dump)]
347 pub struct StatisticalProcess {
348 pub statistical_process_type: u8,
352 pub time_increment_type: u8,
355 #[dump(doc(
357 unit = "Indicator of unit of time for time range over which statistical processing is done (see Code Table 4.4).",
358 len = "Length of the time range over which statistical processing is done, in units defined by the previous octet.",
359 ))]
360 pub time_range: TimeRange<u32>,
361 #[dump(doc(
363 unit = "Indicator of unit of time for the increment between the successive fields used (see Code Table 4.4).",
364 len = "Time increment between successive fields, in units defined by the previous octet (see Notes 3 and 4).",
365 ))]
366 pub time_increment: TimeRange<u32>,
367 }
368}