46 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Try to parse compressed data without parsed tree\n", __func__ );
90 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Unspected NULL argument\n", __func__ );
130 rf = & ( r->
refs[r->
nd] );
139 for ( i = 0; i < seq->
ndesc ; i++ )
142 switch ( seq->
lseq[i].
f )
148 i <= seq->no_data_present.last )
151 if ( seq->
lseq[i].
x > 9 &&
152 seq->
lseq[i].
x != 31 )
154 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Getting data from table b with class other than 1-9,31 and no data present activated\n", __func__ );
161 rf = & ( r->
refs[r->
nd] );
180 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more space for first order statistic vars in bitmap. Check BUFR_MAX_QUALITY_DATA\n", __func__ );
196 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more space for difference statistic vars in bitmap. Check BUFR_MAX_QUALITY_DATA\n", __func__ );
207 rf = & ( r->
refs[r->
nd] );
231 rf = & ( r->
refs[r->
nd] );
241 replicator.
ixrep = i;
242 if ( seq->
lseq[i].
y != 0 )
245 replicator.
ixdel = i;
264 replicator.
ixdel = i + 1;
266 rf = & ( r->
refs[r->
nd] );
301 rf = & ( r->
refs[r->
nd] );
326 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Found bad 'f' in descriptor '%s' \n", __func__, seq->
lseq[i].
c );
333 rf = & ( r->
refs[r->
nd] );
366 if ( r == NULL || rep == NULL )
368 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Unspected NULL argument(s)\n", __func__ );
378 for ( ixloop = 0; ixloop < rep->
nloops; ixloop++ )
380 for ( ixd = 0; ixd < rep->
ndesc ; ixd ++ )
382 i = ixd + rep->
ixdel + 1;
383 switch ( l->
lseq[i].
f )
392 if ( l->
lseq[i].
x > 9 &&
395 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Getting data from table b with class other than 1-9,31 and no data present activated\n", __func__ );
401 rf = & ( r->
refs[r->
nd] );
437 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more space for quality vars in bitmap. Check BUFR_MAX_QUALITY_DATA\n", __func__ );
458 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more space for first order statistic vars in bitmap. Check BUFR_MAX_QUALITY_DATA\n", __func__ );
478 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more space for difference statistic vars in bitmap. Check BUFR_MAX_QUALITY_DATA\n", __func__ );
493 rf = & ( r->
refs[r->
nd] );
515 rf = & ( r->
refs[r->
nd] );
529 replicator.
ixrep = i;
530 if ( l->
lseq[i].
y != 0 )
533 replicator.
ixdel = i;
537 ixd += replicator.
ndesc;
542 replicator.
ixdel = i + 1;
544 rf = & ( r->
refs[r->
nd] );
560 ixd += replicator.
ndesc + 1;
566 rf = & ( r->
refs[r->
nd] );
590 rf = & ( r->
refs[r->
nd] );
612 rf = & ( r->
refs[r->
nd] );
646 rf = & ( r->
refs[r->
nd] );
684 rf = & ( r->
refs[r->
nd] );
696 rf->
ref = - ( ( int32_t ) 1 << rf->
bits );
705 if ( l->
lseq[i].
x == 5 )
722 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Found bad 'f' in descriptor\n", __func__ );
747 uint32_t ival, ival0;
754 if ( a == NULL || r == NULL )
756 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Unspected NULL argument(s)\n", __func__ );
764 strcpy ( a->
name,
"LOCAL DESCRIPTOR" );
765 strcpy ( a->
unit,
"UNKNOWN" );
772 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot get associated bits from '%s'\n", __func__, r->
desc->
c );
818 if ( strstr ( a->
unit,
"CCITT" ) != NULL )
839 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot get uchars from '%s'\n", __func__, r->
desc->
c );
857 strcpy ( a->
name,
"Associated value" );
858 strcpy ( a->
unit,
"Associated unit" );
877 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot get associated bits from '%s'\n", __func__, r->
desc->
c );
905 ivals = r->
ref + ( int32_t ) r->
ref0;
915 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Cannot get %d inc_bits from '%s'\n", __func__, r->
inc_bits, r->
desc->
c );
921 ivals = r->
ref + ( int32_t ) ( r->
ref0 + ival0 );
932 a->
val = ( double ) ( ivals ) * exp10 ( (
double ) ( - r->
escale ) );
934 if ( strstr ( a->
unit,
"CODE TABLE" ) == a->
unit || strstr ( a->
unit,
"Code table" ) == a->
unit )
936 ival = ( uint32_t ) ( a->
val + 0.5 );
943 else if ( strstr ( a->
unit,
"FLAG" ) == a->
unit || strstr ( a->
unit,
"Flag" ) == a->
unit )
945 ival = ( uint32_t ) ( a->
val + 0.5 );
974 if ( r->
refs == NULL || r->
nd == 0 )
976 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Try to get subset data without previous references\n", __func__ );
993 for ( i = 0; i < r->
nd; i++ )
1015 if ( s->
nd < ( s->
dim - 1 ) )
1021 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more bufr_atom_data available. Check BUFR_NMAXSEQ\n", __func__ );
1027 if ( s->
nd < ( s->
dim - 1 ) )
1033 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): No more bufr_atom_data available. Check BUFR_NMAXSEQ\n", __func__ );
1097 snprintf ( b->
error, sizeof ( b->
error ),
"%s(): Reached limit. Consider increas BUFR_NMAXSEQ\n", __func__ );
Include header file for bufrdeco library.
#define BUFR_NMAXSEQ
Maximum expected descriptors in a expanded sequence for a single subset.
buf_t bufrdeco_print_json_subset_data_prologue(FILE *out, struct bufrdeco *b)
#define BUFRDECO_COMPRESSED_REF_OPERATOR_DESCRIPTOR
Bitmask for struct bufrdeco_compressed_ref which marks an operator descriptor.
uint32_t buf_t
Type to set offsets and dimension of arrays or counters used in bufrdeco.
buf_t bufrdeco_print_json_separator(FILE *out)
Print the comma ',' separator in an output.
int is_a_local_descriptor(struct bufr_descriptor *d)
check if a descriptor is a local descriptor
char * bufrdeco_explained_table_val(char *expl, size_t dim, struct bufr_tableC *tc, uint32_t *index, struct bufr_descriptor *d, uint32_t ival)
int bufrdeco_add_to_bitmap(struct bufrdeco_bitmap *bm, buf_t index_to, buf_t index_by)
Push a bitmap element in a bufrdeco_bitmap.
#define DESCRIPTOR_HAVE_FLAG_TABLE_STRING
Bit mask for a flag table string in a struct bufr_atom_data.
buf_t bufrdeco_print_json_object_operator_descriptor(FILE *out, struct bufr_descriptor *d, char *aux)
print an operator desciptor as a json object
#define BUFR_MAX_QUALITY_DATA
Max amount of quality data which is maped by a struct bufrdeco_bitmap element.
uint32_t get_bits_as_char_array(char *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
buf_t bufrdeco_print_json_sequence_descriptor_final(FILE *out)
char * bufrdeco_explained_flag_val(char *expl, size_t dim, struct bufr_tableC *tc, struct bufr_descriptor *d, uint64_t ival, uint8_t nbits)
buf_t bufrdeco_print_json_object_replicator_descriptor(FILE *out, struct bufr_descriptor *d, char *aux)
print an operator desciptor as a json object
#define BUFRDECO_COMPRESSED_REF_DATA_DESCRIPTOR_BITMASK
Bitmask for struct bufrdeco_compressed_ref which marks a data descriptor.
#define BUFRDECO_OUTPUT_JSON_SUBSET_DATA
Bit mask to the member mask of struct bufrdeco to print bufr subset data in json format.
#define DESCRIPTOR_HAVE_STRING_VALUE
Bit mask for a string in a struct bufr_atom_data.
int bufrdeco_init_compressed_data_references(struct bufrdeco_compressed_data_references *rf)
Init a struct bufrdeco_compressed_data_references.
#define DESCRIPTOR_IS_LOCAL
Bit mask for a flag table string in a struct bufr_atom_data.
#define BUFRDECO_COMPRESSED_REF_SEQUENCE_INIT_BITMASK
Bitmask for struct bufrdeco_compressed_ref which marks the init of a descriptor sequence.
#define MISSING_REAL
The missing default value for real values.
buf_t bufrdeco_print_json_sequence_descriptor_header(FILE *out, struct bufr_sequence *seq)
Print the header of a sequence descriptor (f == 3)
#define MISSING_INTEGER
The missing default value for integer values.
int bufrdeco_parse_f2_compressed(struct bufrdeco_compressed_data_references *r, struct bufr_descriptor *d, struct bufrdeco *b)
parse a descritor with f = 2 in case of compressed bufr
int bufrdeco_tableB_compressed(struct bufrdeco_compressed_ref *r, struct bufrdeco *b, struct bufr_descriptor *d, int mode)
get data from table B when parsing compressed data references
uint32_t get_bits_as_uint32_t(uint32_t *target, uint8_t *has_data, uint8_t *source, buf_t *bit0_offset, buf_t bit_length)
int bufrdeco_increase_data_array(struct bufrdeco_subset_sequence_data *s)
doubles the allocated space for a struct bufrdeco_subset_sequence_data whenever is posible
buf_t bufrdeco_print_json_subset_data_epilogue(FILE *out)
#define DESCRIPTOR_IS_FLAG_TABLE
Bit mask for a flag table in a struct bufr_atom_data.
#define DESCRIPTOR_IS_CODE_TABLE
Bit mask for a code table in a struct bufr_atom_data.
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
#define BUFRDECO_COMPRESSED_REF_SEQUENCE_FINAL_BITMASK
Bitmask for struct bufrdeco_compressed_ref which marks the final of a descriptor sequence.
buf_t bufrdeco_print_json_object_atom_data(FILE *out, struct bufr_atom_data *a, char *aux)
Print an json object with a descriptor data.
#define BUFRDECO_COMPRESSED_REF_REPLICATOR_DESCRIPTOR
Bitmask for struct bufrdeco_compressed_ref which marks a replicator descriptor.
#define DESCRIPTOR_HAVE_CODE_TABLE_STRING
Bit mask for a code table string in a struct bufr_atom_data.
int bufrdeco_decode_replicated_subsequence_compressed(struct bufrdeco_compressed_data_references *r, struct bufr_replicator *rep, struct bufrdeco *b)
decodes a repicated subsequence
int bufrdeco_get_atom_data_from_compressed_data_ref(struct bufr_atom_data *a, struct bufrdeco_compressed_ref *r, buf_t subset, struct bufrdeco *b)
Get atom data from a descriptor for a given subset.
int bufrdeco_parse_compressed(struct bufrdeco_compressed_data_references *r, struct bufrdeco *b)
Preliminary parse of a compressed data bufr.
int bufrdeco_parse_compressed_recursive(struct bufrdeco_compressed_data_references *r, struct bufr_sequence *l, struct bufrdeco *b)
Parse recursively the compressed data in a bufr report to get references where to get data for every ...
int bufrdeco_increase_compressed_data_references_count(struct bufrdeco_compressed_data_references *r, struct bufrdeco *b)
Increment the count of a struct bufrdeco_compressed_data_references.
int bufr_decode_subset_data_compressed(struct bufrdeco_subset_sequence_data *s, struct bufrdeco_compressed_data_references *r, struct bufrdeco *b)
Get data for a given subset in a compressed data bufr.
Contains all the information for a single data related with a descriptor in a expanded squence.
char name[BUFR_TABLEB_NAME_LENGTH]
char ctable[BUFR_EXPLAINED_LENGTH]
struct bufr_descriptor desc
char unit[BUFR_TABLEB_UNIT_LENGTH]
char cval[BUFR_CVAL_LENGTH]
store the information when parsing related to replicators
Stores an unexpanded sequence of descriptors.
struct bufr_descriptor lseq[NMAXSEQ_DESCRIPTORS]
struct bufr_sequence_index_range no_data_present
struct bufr_sequence * sons[NMAXSEQ_DESCRIPTORS]
Store a table B readed from a file formated and named as ECMWF bufrdc package.
struct bufr_tableB_decoded_item item[BUFR_MAXLINES_TABLEB]
struct bufrdeco_bitmap * bmap[BUFR_MAX_BITMAPS]
buf_t dstat_desc[BUFR_MAX_QUALITY_DATA]
buf_t stat1_desc[BUFR_MAX_QUALITY_DATA]
buf_t stat1[BUFR_MAX_QUALITY_DATA]
buf_t quality[BUFR_MAX_QUALITY_DATA]
buf_t bitmap_to[BUFR_MAX_BITMAP_PRESENT_DATA]
Manage an array of structs bufrdeco_compressed_ref.
struct bufrdeco_compressed_ref * refs
Struct to hold the needed reference bit offsets, descriptor tree and replications in a compressed BUF...
char unit[BUFR_TABLEB_UNIT_LENGTH]
char name[BUFR_TABLEB_NAME_LENGTH]
struct bufr_descriptor * desc
struct bufr_sequence * seq
stores the state when expanding a sequence.
uint8_t changing_reference
uint8_t local_bit_reserved
struct bufrdeco_bitmap * bitmap
struct bufr_sequence seq[BUFR_MAX_EXPANDED_SEQUENCES]
Contains all the information for a subset in a expanded squence This is a version to use with bufrdec...
struct bufr_atom_data * sequence
This struct contains all needed data to parse and decode a BUFR file.
struct bufrdeco_bitmap_array bitmap
struct bufrdeco_decoding_data_state state
struct bufr_tables * tables
struct bufrdeco_expanded_tree * tree