bufr2synop 0.24.0
bufr2tac_x02.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_x02.c
22 \brief decodes the descriptors with X = 02 (intrumentation and station type)
23 */
24#include "bufr2tac.h"
25
26/*!
27 \fn int syn_parse_x02 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
28 \brief Parse a expanded descriptor with X = 02
29 \param syn pointer to a struct \ref synop_chunks where to set the results
30 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
31
32 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
33*/
34int syn_parse_x02 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
35{
36
37
38 switch ( s->a->desc.y )
39 {
40 case 1: // 0 02 001 Type of station
42 {
43 strcpy ( syn->s1.ix,"/" );
44 return 0;
45 }
46 s->type = s->ival;
48 break;
49 case 2: // 0 02 002 . Type of instrumentation for wind measurement
51 return 0;
52 if ( s->ival == 0 )
53 strcpy ( syn->s0.iw, "0" );
54 else if ( s->ival == 8 )
55 strcpy ( syn->s0.iw, "1" );
56 else if ( s->ival == 4 )
57 strcpy ( syn->s0.iw, "3" );
58 else if ( s->ival == 12 )
59 strcpy ( syn->s0.iw, "4" );
60
61 /*
62 if ( s->ival & 4 )
63 strcpy ( syn->s0.iw, "4" );
64 else
65 strcpy ( syn->s0.iw, "1" );*/
66 break;
67 default:
68 if ( BUFR2TAC_DEBUG_LEVEL > 1 && (s->a->mask & DESCRIPTOR_VALUE_MISSING) == 0 )
69 bufr2tac_set_error ( s, 0, "syn_parse_x02()", "Descriptor not parsed" );
70 break;
71 }
72 return 0;
73}
74
75/*!
76 \fn int buoy_parse_x02 ( struct buoy_chunks *b, struct bufr2tac_subset_state *s )
77 \brief Parse a expanded descriptor with X = 02
78 \param b pointer to a struct \ref buoy_chunks where to set the results
79 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
80
81 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
82*/
84{
85 char caux[16];
87 return 0;
88
89 switch ( s->a->desc.y )
90 {
91 case 1: // 0 02 001 . Type of station
92 s->type = s->ival;
94 break;
95
96 case 2: // 0 02 002 . Type of instrumentation for wind measurement
97 if ( s->ival & 4 )
98 strcpy ( b->s0.iw, "4" );
99 else
100 strcpy ( b->s0.iw, "1" );
101 break;
102
103 case 31: // 0 02 031 . Duration and time of current measurement
104 if ( b->s3.k3[0] == 0 && s->ival < 10 )
105 {
106 sprintf ( caux, "%d", s->ival );
107 b->s3.k3[0] = caux[0];
108 b->s3.k3[1] = 0;
109 }
110 b->mask |= BUOY_SEC3;
111 break;
112
113 case 33: // 0 02 033 . Method of salinity depth measure
114 sprintf ( caux, "%d", s->ival );
115 b->s3.k2[0] = caux[0];
116 b->s3.k2[1] = 0;
117 b->mask |= BUOY_SEC3;
118 break;
119
120 case 40: // 0 02 040 .Method of removing velocity and motion of platform from current
121 if ( b->s3.k6[0] == 0 )
122 {
123 sprintf ( caux, "%d", s->ival );
124 b->s3.k6[0] = caux[0];
125 b->s3.k6[1] = 0;
126 }
127 b->mask |= BUOY_SEC3;
128 break;
129
130 default:
131 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
132 bufr2tac_set_error ( s, 0, "buoy_parse_x02()", "Descriptor not parsed" );
133 break;
134 }
135 return 0;
136}
137
138/*!
139 \fn int climat_parse_x02 ( struct climat_chunks *c, struct bufr2tac_subset_state *s )
140 \brief Parse a expanded descriptor with X = 02
141 \param c pointer to a struct \ref climat_chunks where to set the results
142 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
143
144 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
145*/
147{
148 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
149 return 0;
150
151 if ( c == NULL )
152 return 1;
153
154 switch ( s->a->desc.y )
155 {
156 case 1: // 0 02 001 . Type of station
157 s->type = s->ival;
159 break;
160
161 case 2: // 0 02 002 . Type of instrumentation for wind measurement
162 if ( s->ival & 4 )
163 strcpy ( c->s4.iw, "4" );
164 else
165 strcpy ( c->s4.iw, "1" );
166 break;
167
168 case 51: // 0 02 051 . Observing method for extreme temperatures
169 sprintf ( c->s4.iy,"%d",s->ival );
170 break;
171 default:
172 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
173 bufr2tac_set_error ( s, 0, "climat_parse_x02()", "Descriptor not parsed" );
174 break;
175 }
176 return 0;
177}
178
179/*!
180 \fn int temp_parse_x02 ( struct temp_chunks *t, struct bufr2tac_subset_state *s )
181 \brief Parse a expanded descriptor with X = 02
182 \param t pointer to a struct \ref temp_chunks where to set the results
183 \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis
184
185 It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
186*/
188{
189 if ( t == NULL )
190 return 1;
191
192 switch ( s->a->desc.y )
193 {
194 case 3: // 0 02 003 . Type of measuring equipment used
195 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
196 {
197 sprintf ( t->b.s1.a4,"/" );
198 return 0;
199 }
200 switch ( s->ival )
201 {
202 case 0:
203 case 1:
204 case 2:
205 case 3:
206 sprintf ( t->b.s1.a4,"%d", s->ival );
207 break;
208 case 4:
209 case 5:
210 case 6:
211 case 7:
212 sprintf ( t->b.s1.a4,"%d", s->ival + 1 );
213 break;
214 default:
215 strcpy ( t->b.s1.a4, "9" ); // reserved
216 break;
217 }
218 break;
219
220 case 11: // 0 02 011 . Radiosonde type
221 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
222 {
223 sprintf ( t->a.s7.rara, "//" );
224 sprintf ( t->b.s7.rara, "//" );
225 sprintf ( t->c.s7.rara, "//" );
226 sprintf ( t->d.s7.rara, "//" );
227 return 0;
228 }
229 if ( s->ival >= 0 )
230 {
231 sprintf ( t->a.s7.rara, "%02d", s->ival % 100 );
232 sprintf ( t->b.s7.rara, "%02d", s->ival % 100 );
233 sprintf ( t->c.s7.rara, "%02d", s->ival % 100 );
234 sprintf ( t->d.s7.rara, "%02d", s->ival % 100 );
235 }
236 break;
237
238 case 13: // 0 02 013 . Solar and infrared radiation correction
239 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
240 {
241 strcpy ( t->a.s7.sr, "/" );
242 strcpy ( t->b.s7.sr, "/" );
243 strcpy ( t->c.s7.sr, "/" );
244 strcpy ( t->d.s7.sr, "/" );
245 return 0;
246
247 }
248 if ( s->ival >= 0 && s->ival <= 7 )
249 {
250 sprintf ( t->a.s7.sr, "%d", s->ival );
251 sprintf ( t->b.s7.sr, "%d", s->ival );
252 sprintf ( t->c.s7.sr, "%d", s->ival );
253 sprintf ( t->d.s7.sr, "%d", s->ival );
254 }
255 else
256 {
257 // case of missing data
258 strcpy ( t->a.s7.sr, "/" );
259 strcpy ( t->b.s7.sr, "/" );
260 strcpy ( t->c.s7.sr, "/" );
261 strcpy ( t->d.s7.sr, "/" );
262 }
263 break;
264
265 case 14: // 0 02 014 . Tracking technique/status of system used
266 if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
267 {
268 strcpy ( t->a.s7.sasa, "//" );
269 strcpy ( t->b.s7.sasa, "//" );
270 strcpy ( t->c.s7.sasa, "//" );
271 strcpy ( t->d.s7.sasa, "//" );
272 return 0;
273 }
274 if ( s->ival >= 0 && s->ival < 100 )
275 {
276 sprintf ( t->a.s7.sasa, "%02d", s->ival );
277 sprintf ( t->b.s7.sasa, "%02d", s->ival );
278 sprintf ( t->c.s7.sasa, "%02d", s->ival );
279 sprintf ( t->d.s7.sasa, "%02d", s->ival );
280 }
281 else
282 {
283 strcpy ( t->a.s7.sasa, "//" );
284 strcpy ( t->b.s7.sasa, "//" );
285 strcpy ( t->c.s7.sasa, "//" );
286 strcpy ( t->d.s7.sasa, "//" );
287 }
288 break;
289
290 default:
291 if ( BUFR2TAC_DEBUG_LEVEL > 0 )
292 bufr2tac_set_error ( s, 0, "temp_parse_x02()", "Descriptor not parsed" );
293 break;
294 }
295 return 0;
296}
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)
#define SUBSET_MASK_HAVE_TYPE_STATION
Bit mask to mark a struct bufr_subset_sequence_data having type station information.
Definition: bufr2tac.h:86
int syn_parse_x02(struct synop_chunks *syn, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:34
int climat_parse_x02(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:146
int buoy_parse_x02(struct buoy_chunks *b, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:83
int temp_parse_x02(struct temp_chunks *t, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 02.
Definition: bufr2tac_x02.c:187
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
Definition: bufrdeco.h:140
#define BUOY_SEC3
mask bit meaning section 3 of buoy is solicited to or parsed with success
Definition: metbuoy.h:48
stores information needed to parse a sequential list of expanded descriptors for a subset
Definition: bufr2tac.h:246
struct bufr_atom_data * a
Definition: bufr2tac.h:249
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
struct buoy_sec3 s3
Definition: metbuoy.h:204
int mask
Definition: metbuoy.h:198
struct buoy_sec0 s0
Definition: metbuoy.h:201
char iw[2]
Definition: metbuoy.h:77
char k2[2]
Definition: metbuoy.h:151
char k6[2]
Definition: metbuoy.h:153
char k3[2]
Definition: metbuoy.h:152
contains all possible substrings from a synop report is parsed with success
Definition: metclimat.h:213
struct climat_sec4 s4
Definition: metclimat.h:221
char iw[2]
Definition: metclimat.h:182
char iy[2]
Definition: metclimat.h:187
contains all possible substrings from a synop report is parsed with success
Definition: metsynop.h:293
struct synop_sec1 s1
Definition: metsynop.h:298
struct synop_sec0 s0
Definition: metsynop.h:297
char iw[2]
Definition: metsynop.h:100
char ix[2]
Definition: metsynop.h:124
struct temp_sec7 s7
Definition: mettemp.h:459
char a4[2]
Definition: mettemp.h:343
struct temp_sec7 s7
Definition: mettemp.h:473
struct temp_b_sec1 s1
Definition: mettemp.h:470
struct temp_sec7 s7
Definition: mettemp.h:489
Store the whole TEMP report.
Definition: mettemp.h:511
struct temp_c c
Definition: mettemp.h:517
struct temp_d d
Definition: mettemp.h:518
struct temp_b b
Definition: mettemp.h:516
struct temp_a a
Definition: mettemp.h:515
struct temp_sec7 s7
Definition: mettemp.h:503
char rara[4]
Definition: mettemp.h:406
char sr[2]
Definition: mettemp.h:405
char sasa[4]
Definition: mettemp.h:407