bufr2synop 0.24.0
bufr2tac_climat.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2018 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_climat.c
22 \brief file with the code to parse a sequence as a FM-71 XII CLIMAT and FM-72 XII CLIMAT SHIP
23 */
24#include "bufr2tac.h"
25
26
27
28/*!
29 \fn int parse_subset_as_climat(struct metreport *m, char *type, struct bufr_subset_sequence_data *sq, char *err)
30 \brief parses a subset sequence as an Land fixed CLIMAT FM-71 report
31 \param m pointer to a struct \ref metreport where set some results
32 \param type strint with MiMiMjMj to choose the type of temp, temp ship, temp drop or temp mobil)
33 \param sq pointer to a struct \ref bufr_subset_sequence_data with the parsed sequence on input
34 \param err string with detected errors, if any
35
36 It return 0 if all is OK. Otherwise returns 1 and it also fills the \a err string
37*/
38int parse_subset_as_climat ( struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err )
39{
40 size_t is;
41 char aux[32];
42 struct climat_chunks *c;
43
44 c = &m->climat;
45
46 // clean data
48
49 // reject if still not coded type
50 if ( strcmp ( s->type_report,"CLIMAT" ) )
51 {
52 sprintf ( err,"bufr2tac: parse_subset_as_climat(): '%s' reports still not decoded in this software", s->type_report );
53 return 1;
54 }
55
56 strcpy ( m->type, s->type_report );
57
58 /**** First pass, sequential analysis *****/
59 for ( is = 0; is < sq->nd; is++ )
60 {
61 s->i = is;
62 s->ival = ( int ) sq->sequence[is].val;
63 s->val = sq->sequence[is].val;
64 s->a = &sq->sequence[is];
65 if ( is > 0 )
66 {
67 s->a1 = &sq->sequence[is - 1];
68 }
69
70 switch ( sq->sequence[is].desc.x )
71 {
72 case 1: //localization descriptors
73 climat_parse_x01 ( c, s );
74 break;
75
76 case 2: //Type of station descriptors
77 climat_parse_x02 ( c, s );
78 break;
79
80 case 4: //Date and time descriptors
81 climat_parse_x04 ( c, s );
82 break;
83
84 case 5: // Horizontal position. Latitude
85 climat_parse_x05 ( c, s );
86 break;
87
88 case 6: // Horizontal position. Longitude
89 climat_parse_x06 ( c, s );
90 break;
91
92 case 7: // Vertical position
93 climat_parse_x07 ( c, s );
94 break;
95
96 case 8: // significance qualifier
97 climat_parse_x08 ( c, s );
98 break;
99
100 case 10: // Air pressure
101 climat_parse_x10 ( c, s );
102 break;
103
104 case 11: // Wind
105 climat_parse_x11 ( c, s );
106 break;
107
108 case 12: // Temperature
109 climat_parse_x12 ( c, s );
110 break;
111
112 case 13: // Humidity and precipitation data
113 climat_parse_x13 ( c, s );
114 break;
115
116 case 14: // Radiation
117 climat_parse_x14 ( c, s );
118 break;
119
120 default:
121 break;
122 }
123
124 }
125
126 // Fill some metreport fields
127 if ( strlen ( c->s0.II ) )
128 {
129 strcpy ( m->g.index, c->s0.II );
130 strcat ( m->g.index, c->s0.iii );
131 }
132
134 {
135 m->g.lat = s->lat;
136 }
138 {
139 m->g.lon = s->lon;
140 }
142 {
143 m->g.alt = s->alt;
144 }
145 if ( s->mask & SUBSET_MASK_HAVE_NAME )
146 {
147 strcpy ( m->g.name, s->name );
148 }
150 {
151 strcpy ( m->g.country, s->country );
152 }
153
154 sprintf ( aux,"%s%s%s%s%s", c->e.YYYY, c->e.MM, c->e.DD, c->e.HH, c->e.mm );
155 YYYYMMDDHHmm_to_met_datetime ( &m->t, aux );
156
157 // copy WIGOS ID
158 memcpy(&m->g.wid, &m->climat.wid, sizeof (struct wigos_id) );
159
160 if ( check_date_from_future ( m ) )
161 {
162 return 1; // Bad date/time . Is a report from future!
163 }
164
165
166 return 0;
167}
Include header file for binary bufr2tac.
int check_date_from_future(struct metreport *m)
Check a estructure metreport not from future.
#define SUBSET_MASK_HAVE_COUNTRY
Bit mask to mark a struct bufr_subset_sequence_data having country name.
Definition: bufr2tac.h:134
#define SUBSET_MASK_HAVE_NAME
Bit mask to mark a struct bufr_subset_sequence_data having station name.
Definition: bufr2tac.h:128
#define bufr_subset_sequence_data
To use bufrdeco library with legacy old code using ECMWF library which is not used currently.
Definition: bufr2tac.h:220
int climat_parse_x12(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 12.
Definition: bufr2tac_x12.c:526
#define SUBSET_MASK_HAVE_ALTITUDE
Bit mask to mark a struct bufr_subset_sequence_data having altitude.
Definition: bufr2tac.h:122
int climat_parse_x10(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 10.
Definition: bufr2tac_x10.c:214
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 climat_parse_x05(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 05.
Definition: bufr2tac_x05.c:170
int climat_parse_x06(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 06.
Definition: bufr2tac_x06.c:165
int climat_parse_x13(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 13.
Definition: bufr2tac_x13.c:909
int YYYYMMDDHHmm_to_met_datetime(struct met_datetime *t, const char *source)
Parse the string YYYYMMDDHHmm[ss] and set a struct met_datetime.
void bufr2tac_clean_climat_chunks(struct climat_chunks *c)
cleans a climat_chunks struct
int climat_parse_x11(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 11.
Definition: bufr2tac_x11.c:454
#define SUBSET_MASK_HAVE_LONGITUDE
Bit mask to mark a struct bufr_subset_sequence_data having longitude.
Definition: bufr2tac.h:116
int climat_parse_x08(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 08.
Definition: bufr2tac_x08.c:164
int climat_parse_x01(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 01.
Definition: bufr2tac_x01.c:324
#define SUBSET_MASK_HAVE_LATITUDE
Bit mask to mark a struct bufr_subset_sequence_data having latitude.
Definition: bufr2tac.h:110
int climat_parse_x04(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 04.
Definition: bufr2tac_x04.c:405
int climat_parse_x07(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Definition: bufr2tac_x07.c:208
int climat_parse_x14(struct climat_chunks *c, struct bufr2tac_subset_state *s)
Parse a expanded descriptor with X = 14.
Definition: bufr2tac_x14.c:497
int parse_subset_as_climat(struct metreport *m, struct bufr2tac_subset_state *s, struct bufr_subset_sequence_data *sq, char *err)
stores information needed to parse a sequential list of expanded descriptors for a subset
Definition: bufr2tac.h:246
struct bufr_atom_data * a1
Definition: bufr2tac.h:250
struct bufr_atom_data * a
Definition: bufr2tac.h:249
char type_report[16]
Definition: bufr2tac.h:247
contains all possible substrings from a synop report is parsed with success
Definition: metclimat.h:213
struct report_date_ext e
Definition: metclimat.h:215
struct climat_sec0 s0
Definition: metclimat.h:217
struct wigos_id wid
Definition: metclimat.h:216
char iii[4]
Definition: metclimat.h:73
char II[4]
Definition: metclimat.h:72
double lat
Definition: bufr2tac.h:299
double lon
Definition: bufr2tac.h:300
double alt
Definition: bufr2tac.h:301
struct wigos_id wid
Definition: bufr2tac.h:295
char index[16]
Definition: bufr2tac.h:296
char name[80]
Definition: bufr2tac.h:297
char country[80]
Definition: bufr2tac.h:298
all the information for a meteorological report in WMO text format from a BUFR file
Definition: bufr2tac.h:309
char type[8]
Definition: bufr2tac.h:320
struct climat_chunks climat
Definition: bufr2tac.h:319
struct met_datetime t
Definition: bufr2tac.h:314
struct met_geo g
Definition: bufr2tac.h:315
char mm[4]
Definition: metcommon.h:37
char HH[4]
Definition: metcommon.h:36
char DD[4]
Definition: metcommon.h:35
char MM[4]
Definition: metcommon.h:34
char YYYY[6]
Definition: metcommon.h:33
WIGOS station identifier.
Definition: metcommon.h:46