bufr2synop 0.24.0
bufr2tac_x31.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2022 by Guillermo Ballester Valor *
3 * gbv@ogimet.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20/*!
21 \file bufr2tac_x31.c
22 \brief decodes the descriptors with X = 31 (Control)
23*/
24#include "bufr2tac.h"
25
26
27/*!
28 \fn int syn_parse_x31 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
29 \brief Parse a expanded descriptor with X = 31
30 \param syn pointer to a struct \ref synop_chunks where to set the results
31 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
32
33 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
34*/
35int syn_parse_x31 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
36{
37
39 {
40 // 0 31 000 does not have DESCRIPTOR_VALUE_MISSING
41 if (s->a->desc.y != 0)
42 return 0;
43 s->rep = 1;
44 s->k_rep = s->i;
45 }
46
47 if ( syn == NULL )
48 {
49 return 1;
50 }
51
52 switch ( s->a->desc.y )
53 {
54 case 0: // 0 31 000 . Short delayed descriptor replication factor
55 s->rep = s->ival;
56 s->k_rep = s->i;
57 break;
58
59 case 1:
60 s->rep = s->ival;
61 s->k_rep = s->i;
62 break;
63
64 default:
65 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
66 bufr2tac_set_error ( s, 0, "syn_parse_x31()", "Descriptor not parsed" );
67 break;
68 }
69 return 0;
70}
71
72
73/*!
74 \fn int buoy_parse_x31 ( struct buoy_chunks *b, struct bufr2tac_subset_state *s )
75 \brief Parse a expanded descriptor with X = 31
76 \param b pointer to a struct \ref buoy_chunks where to set the results
77 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
78
79 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
80*/
82{
84 {
85 return 0;
86 }
87
88 if ( b == NULL )
89 {
90 return 1;
91 }
92
93 switch ( s->a->desc.y )
94 {
95 case 0: // 0 31 000 . Short delayed descriptor replication factor
96 // It is no meaning here
97 break;
98
99 case 1:
100 s->rep = s->ival;
101 s->k_rep = s->i;
102 break;
103
104 default:
105 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
106 bufr2tac_set_error ( s, 0, "buoy_parse_x31()", "Descriptor not parsed" );
107 break;
108 }
109 return 0;
110}
111
112/*!
113 \fn int temp_parse_x31 ( struct temp_chunks *t, struct bufr2tac_subset_state *s )
114 \brief Parse a expanded descriptor with X = 31
115 \param t pointer to a struct \ref temp_chunks where to set the results
116 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
117
118 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
119*/
121{
122 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
123 {
124 return 0;
125 }
126
127 if ( t == NULL )
128 {
129 return 1;
130 }
131
132 switch ( s->a->desc.y )
133 {
134 case 0: // 0 31 000 . Short delayed descriptor replication factor
135 // It is no meaning here
136 break;
137 case 1: // 0 31 001 . Replicator
138 // It is supposed that it is the extended replicator used when describing
139 // wind shear points in raiosonde
140 // It is the amount of points of wind shear data at pressure level
141 if ( s->ival < TEMP_NMAX_POINTS )
142 {
143 s->itval = s->ival;
144 s->rep = 0; // used to mark it is a share point in sequent descriptors
145 }
146 else
147 {
148 return 1; // too much points
149 }
150 s->k_itval = s->i;
151 s->w->n = 0;
152 break;
153
154 case 2: // 0 31 002 . Extended replicator
155 // It is supposed that it is the extended replicator used when describing
156 // Temperature, dew-point and wind data at a pressure level with radiosonde position
157 // So the integer value of repliactor IS the amount of points
158 s->rep = s->ival; // replications and points we need. Also Used to mark this type of point
159 s->itval = 0;
160 s->k_rep = s->i;
161 s->r->n = 0;
162 break;
163 default:
164 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
165 bufr2tac_set_error ( s, 0, "temp_parse_x31()", "Descriptor not parsed" );
166 break;
167 }
168 return 0;
169}
int BUFR2TAC_DEBUG_LEVEL
Definition: bufr2tac.c:31
Include header file for binary bufr2tac.
int bufr2tac_set_error(struct bufr2tac_subset_state *s, int severity, char *origin, char *explanation)
int syn_parse_x31(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:35
int temp_parse_x31(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:120
int buoy_parse_x31(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 31.
Definition: bufr2tac_x31.c:81
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
Definition: bufrdeco.h:140
#define TEMP_NMAX_POINTS
maximum number of significant points
Definition: mettemp.h:138
stores information needed to parse a sequential list of expanded descriptors for a subset
Definition: bufr2tac.h:246
struct temp_raw_wind_shear_data * w
Definition: bufr2tac.h:286
struct bufr_atom_data * a
Definition: bufr2tac.h:249
struct temp_raw_data * r
Definition: bufr2tac.h:285
uint32_t mask
Definition: bufrdeco.h:437
struct bufr_descriptor desc
Definition: bufrdeco.h:436
contains all possible substrings from a synop report is parsed with success
Definition: metbuoy.h:197
contains all possible substrings from a synop report is parsed with success
Definition: metsynop.h:293
Store the whole TEMP report.
Definition: mettemp.h:511
size_t n
Definition: mettemp.h:214