NCEPLIBS-g2c  1.8.0
grib2_int.h
Go to the documentation of this file.
1 
8 #ifndef _grib2_int_H
9 #define _grib2_int_H
10 
11 #include <stdio.h>
12 #include <stdint.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <ctype.h>
16 
17 #include <errno.h>
18 #if defined(WIN32)
19 #include <winsock2.h> /* ntohl() function for Windows. */
20 #else
21 #include <arpa/inet.h> /* ntohl() function for Unix/Mac. */
22 #endif
23 
24 #ifdef PTHREADS
25 #include <pthread.h>
26 #endif
27 
28 #include "grib2.h"
29 
30 #define ALOG2 (0.69314718)
33 #define G2C_JASPER_JPEG_FORMAT_NAME "jpc"
34 
36 #define G2C_MIN_MAX_BYTES 16
37 
39 #define G2C_MAGIC_HEADER "GRIB"
40 
42 #define G2C_MAGIC_HEADER_LEN 8
43 
45 #define G2C_MAX_MESSAGES 1024
46 
47 #define BYTE 8
48 #define WORD 32
50 #define ONE_BYTE 1
51 #define TWO_BYTES 2
52 #define FOUR_BYTES 4
53 #define EIGHT_BYTES 8
56 #define LATITUDE "Latitude"
57 
59 #define LONGITUDE "Longitude"
60 
61 /* For GRIB1. */
62 
64 #define G2C_INDEX1_PDS_VAL_LEN 27
65 
67 #define G2C_INDEX1_GDS_VAL_LEN 41
68 
70 #define G2C_INDEX1_BMS_VAL_LEN 5
71 
73 #define G2C_INDEX1_BDS_VAL_LEN 10
74 
76 #define G2C_INDEX1_PDS_VAL2_LEN 27
77 
79 #define G2C_INDEX1_PDS_VAL3_LEN 27
80 
82 #define G2C_INDEX1_GDS_VAL2_LEN 27
83 
84 /* For thread-safety, use these macros. */
85 #ifdef PTHREADS
86 
88 #define MUTEX(m) pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
89 
91 #define EXTERN_MUTEX(m) extern pthread_mutex_t m;
92 
94 #define MUTEX_LOCK(m) \
95  do { \
96  pthread_mutex_lock(&m); \
97  } while(0)
98 
100 #define MUTEX_UNLOCK(m) \
101  do { \
102  pthread_mutex_unlock(&m); \
103  } while(0)
104 
105 #else /* not PTHREADS */
106 
108 #define MUTEX(m)
109 
111 #define EXTERN_MUTEX(m)
112 
114 #define MUTEX_LOCK(m)
115 
117 #define MUTEX_UNLOCK(m)
118 
119 #endif /* PTHREADS */
120 
123 #define ntoh64(y) (((uint64_t)ntohl(y)) << WORD | ntohl(y >> WORD))
124 
127 #define hton64(y) (((uint64_t)htonl(y)) << WORD | htonl(y >> WORD))
128 
129 #define G2C_FILE_READ 0
130 #define G2C_FILE_WRITE 1
133 typedef struct g2c_message_info
134 {
135  size_t msg_num;
136  size_t bytes_to_msg;
137  size_t bytes_in_msg;
138  unsigned char discipline;
141  int num_local;
147  size_t *section_offset;
148  int sec1_len;
149  short center;
150  short subcenter;
151  unsigned char master_version;
152  unsigned char local_version;
153  unsigned char sig_ref_time;
154  short year;
155  unsigned char month;
156  unsigned char day;
157  unsigned char hour;
158  unsigned char minute;
159  unsigned char second;
160  unsigned char status;
161  unsigned char type;
163  struct g2c_file_info *file;
166 
168 typedef struct g2c_section_info
169 {
170  int sec_id;
171  unsigned int sec_len;
172  size_t bytes_to_sec;
173  unsigned char sec_num;
175  void *sec_info;
178  long long int *template;
181 
183 typedef struct g2c_dim_info
184 {
185  int dimid;
186  size_t len;
187  char name[G2C_MAX_NAME + 1];
188  float *value;
190 
193 typedef struct g2c_section3_info
194 {
195  unsigned char source_grid_def;
196  unsigned int num_data_points;
197  unsigned char num_opt;
198  unsigned char interp_list;
199  unsigned short grid_def;
200  int *optional;
201  G2C_DIM_INFO_T dim[2];
203 
206 typedef struct g2c_section4_info
207 {
208  int field_num;
209  unsigned short num_coord;
210  unsigned short prod_def;
211  int *optional;
213 
216 typedef struct g2c_section5_info
217 {
221  unsigned int num_data_points;
222  unsigned short data_def;
224 
227 typedef struct g2c_section6_info
228 {
231  unsigned char indicator;
233 
235 typedef struct g2c_file_info
236 {
237  int g2cid;
238  char path[G2C_MAX_NAME + 1];
239  FILE *f;
240  size_t num_messages;
243 
245 typedef struct g2c_entry
246 {
247  struct g2c_entry *next;
248  char desc[G2C_MAX_GRIB_DESC_LEN + 1];
249  char status[G2C_MAX_GRIB_STATUS_LEN + 1];
250  char code[G2C_MAX_GRIB_CODE_LEN + 1];
252 
254 typedef struct g2c_code_table
255 {
256  struct g2c_code_table *next;
257  char title[G2C_MAX_GRIB_TITLE_LEN + 1];
258  G2C_CODE_ENTRY_T *entry;
260 
262 typedef struct g2c_param
263 {
264  int g1num;
265  int g1ver;
266  int g2disc;
267  int g2cat;
268  int g2num;
269  char abbrev[G2C_MAX_NOAA_ABBREV_LEN + 1];
271 
275 struct gtemplate
276 {
282 
287 
291 
294 
297 
301 };
302 
303 typedef struct gtemplate gtemplate;
305 /* Legacy support functions. */
306 double int_power(double x, g2int y);
307 void mkieee(float *a, g2int *rieee, g2int num);
308 void rdieee(g2int *rieee, float *a, g2int num);
309 
310 /* Get the various templates. */
312 gtemplate *extdrstemplate(g2int number, g2int *list);
314 gtemplate *extpdstemplate(g2int number, g2int *list);
316 gtemplate *extgridtemplate(g2int number, g2int *list);
317 
318 /* Level and date/time info. */
319 int g2c_get_datetime(int ipdtn, long long int *ipdtmpl, short year, unsigned char month, unsigned char day,
320  unsigned char hour, unsigned char minute, unsigned char second, char *tabbrev);
321 int g2c_get_level_desc(int ipdtn, long long int *ipdtmpl, char *level_desc);
322 
323 /* Packing and unpacking data. */
324 void simpack(float *fld, g2int ndpts, g2int *idrstmpl,
325  unsigned char *cpack, g2int *lcpack);
326 g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts,
327  float *fld);
328 void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
329  unsigned char *cpack, g2int *lcpack);
330 int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum,
331  g2int *idrstmpl, g2int ndpts, float *fld);
332 void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
333  unsigned char *cpack, g2int *lcpack);
334 void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
335  unsigned char *cpack, g2int *lcpack);
336 g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);
337 void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
338  g2int *idrstmpl, unsigned char *cpack, g2int *lcpack);
339 g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ,
340  g2int KK, g2int MM, float *fld);
341 g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan);
342 
343 int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits,
344  unsigned char *pngbuf);
345 int dec_png(unsigned char *pngbuf, g2int *width, g2int *height,
346  unsigned char *cout);
347 void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
348  unsigned char *cpack, g2int *lcpack);
349 g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
350  float *fld);
351 int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits,
352  g2int ltype, g2int ratio, g2int retry, char *outjpc,
353  g2int jpclen);
354 int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld);
355 void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
356  unsigned char *cpack, g2int *lcpack);
357 g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
358  float *fld);
359 
360 void aecpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
361  unsigned char *cpack, g2int *lcpack);
362 g2int aecunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
363  float *fld);
364 int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
365  g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen);
366 int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
367  g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen);
368 
369 /* Packing and unpacking bits. */
370 void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits);
371 void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits);
372 void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits,
373  g2int nskip, g2int n);
374 void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits,
375  g2int nskip, g2int n);
376 
377 /* Deal with grib groups. */
378 int pack_gp(g2int *kfildo, g2int *ic, g2int *nxy,
379  g2int *is523, g2int *minpk, g2int *inc, g2int *missp, g2int *misss,
380  g2int *jmin, g2int *jmax, g2int *lbit, g2int *nov,
381  g2int *ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int *kbit,
382  g2int *novref, g2int *lbitref, g2int *ier);
383 
384 /* Check the message header and check for message termination. */
385 int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose);
386 
387 /* Basic file I/O. */
388 int g2c_file_io(FILE *f, int write, int g2ctype, void *var);
389 int g2c_file_io_byte(FILE *f, int write, char *var);
390 int g2c_file_io_ubyte(FILE *f, int write, unsigned char *var);
391 int g2c_file_io_short(FILE *f, int write, short *var);
392 int g2c_file_io_ushort(FILE *f, int write, unsigned short *var);
393 int g2c_file_io_int(FILE *f, int write, int *var);
394 int g2c_file_io_uint(FILE *f, int write, unsigned int *var);
395 int g2c_file_io_longlong(FILE *f, int write, long long *var);
396 int g2c_file_io_ulonglong(FILE *f, int write, unsigned long long *var);
397 int g2c_file_io_template(FILE *f, int rw_flag, int map, long long int *template_value);
398 
399 /* Read and remember file, message, and section metadata. */
400 int g2c_add_file(const char *path, int mode, int *g2cid);
401 int add_msg(G2C_FILE_INFO_T *file, int msg_num, size_t bytes_to_msg, size_t bytes_in_msg,
402  int read_file, G2C_MESSAGE_INFO_T **msg);
403 int add_section(FILE *f, G2C_MESSAGE_INFO_T *msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec,
404  unsigned char sec_num);
405 int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg);
406 int g2c_rw_section3_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
407 int g2c_rw_section4_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
408 int g2c_rw_section5_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
409 int g2c_rw_section6_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
410 
411 /* Logging output. */
413 
414 /* Handle logging. */
415 #ifdef LOGGING
416 
417 /* To log something... */
418 void g2_log(int severity, const char *fmt, ...);
419 
421 #define LOG(e) g2_log e
422 
423 #else /* LOGGING */
424 
426 #define LOG(e)
427 
428 #endif /* LOGGING */
429 
430 #endif /* _grib2_int_H */
Header file for NCEPLIBS-g2c library.
#define G2C_MAX_GRIB_TITLE_LEN
Maximum length of code table title.
Definition: grib2.h:428
#define G2C_MAX_GRIB_DESC_LEN
Maximum length of code description.
Definition: grib2.h:424
#define G2C_MAX_NAME
Maximum length of a name.
Definition: grib2.h:290
#define G2C_MAX_GRIB_STATUS_LEN
Maximum length of code status.
Definition: grib2.h:425
#define G2C_MAX_GRIB_CODE_LEN
Maximum length of code.
Definition: grib2.h:427
#define G2C_SECTION1_ARRAY_LEN
Length of section 1 array.
Definition: grib2.h:418
int64_t g2int
Long integer type.
Definition: grib2.h:33
#define G2C_MAX_NOAA_ABBREV_LEN
Maximum length of a NOAA abbreviation of a parameter.
Definition: grib2.h:432
g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representatio...
Definition: jpcunpack.c:124
int bytes_to_local
Number of bytes in the message before the (first) local section.
Definition: grib2_int.h:142
struct g2c_section3_info G2C_SECTION3_INFO_T
Information about Section 3 GRID DEFINITION SECTION.
struct g2c_code_table G2C_CODE_TABLE_T
A GRIB2 code table.
void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: cmplxpack.c:36
int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits, unsigned char *pngbuf)
Encode PNG.
Definition: enc_png.c:75
gtemplate * extgridtemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Grid Definition Template,...
int g2c_file_io_ushort(FILE *f, int write, unsigned short *var)
Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and b...
Definition: g2cio.c:294
void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a float data field into PNG image format.
Definition: pngpack.c:242
void mkieee(float *a, g2int *rieee, g2int num)
This subroutine stores a list of real values in 32-bit IEEE floating point format.
Definition: mkieee.c:22
int g2c_file_io_byte(FILE *f, int write, char *var)
Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-...
Definition: g2cio.c:316
struct g2c_section_info * next
Pointer to next in list.
Definition: grib2_int.h:176
struct g2c_section_info * sec
List of section metadata.
Definition: grib2_int.h:162
int g1ver
GRIB1 table version.
Definition: grib2_int.h:265
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Definition: gbits.c:20
struct gtemplate gtemplate
Struct for GRIB template.
Definition: grib2_int.h:303
size_t len
Length of dimension.
Definition: grib2_int.h:186
short subcenter
Originating subcenter.
Definition: grib2_int.h:150
int sec_id
ID of the section (0-based).
Definition: grib2_int.h:170
g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
Definition: pngunpack.c:117
unsigned char master_version
GRIB master tables version number.
Definition: grib2_int.h:151
struct g2c_file_info G2C_FILE_INFO_T
This is the information about each open file.
gtemplate * extdrstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Data Representation Template,...
Definition: drstemplates.c:213
int g2c_file_io_template(FILE *f, int rw_flag, int map, long long int *template_value)
Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion betwee...
Definition: g2cio.c:408
int g1num
GRIB1 parameter number.
Definition: grib2_int.h:264
g2int * ext
Number of octets of each entry in the extension part of the template.
Definition: grib2_int.h:300
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Definition: gbits.c:57
int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose)
Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already termi...
Definition: util.c:26
size_t * section_offset
Array (length num_sections) of byte offsets from start of message to section.
Definition: grib2_int.h:147
unsigned char type
Type of processed data in this GRIB message.
Definition: grib2_int.h:161
int * section_number
Array (length num_sections) of section numbers.
Definition: grib2_int.h:146
unsigned short grid_def
Grid definition template number (= N) (See Table 3.1).
Definition: grib2_int.h:199
unsigned char hour
Hour.
Definition: grib2_int.h:157
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
Decode PNG.
Definition: dec_png.c:61
g2int aecunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation Tem...
Definition: aecunpack.c:139
int g2c_file_io_ulonglong(FILE *f, int write, unsigned long long *var)
Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native a...
Definition: g2cio.c:380
int num_sections
Number of sections in the file.
Definition: grib2_int.h:145
unsigned char minute
Minute.
Definition: grib2_int.h:158
unsigned int num_data_points
Number of data points.
Definition: grib2_int.h:196
size_t num_messages
Number of messages in the file.
Definition: grib2_int.h:240
int g2c_log_section1(G2C_MESSAGE_INFO_T *msg)
Log section 0 information.
Definition: g2cutil.c:101
unsigned short num_coord
Number of coordinate values after template.
Definition: grib2_int.h:209
struct g2c_dim_info G2C_DIM_INFO_T
Keep information about dimensions defined in section 3.
int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen)
This Function encodes data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition: decenc_aec.c:111
int num_local
Number of local sections in the message.
Definition: grib2_int.h:141
unsigned char sig_ref_time
Significance of reference time.
Definition: grib2_int.h:153
int bytes_to_data
Number of bytes in the message to the (first) data section.
Definition: grib2_int.h:144
struct g2c_section_info G2C_SECTION_INFO_T
Information about a section 3 through 7 in a GRIB2 message.
unsigned char num_opt
Number of octets for optional list of numbers defining number of points.
Definition: grib2_int.h:197
gtemplate * extpdstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Product Definition Template,...
Definition: pdstemplates.c:325
int g2cat
GRIB2 category number.
Definition: grib2_int.h:267
int * optional
Optional list of numbers defining number of points.
Definition: grib2_int.h:211
unsigned char discipline
Discipline from section 0.
Definition: grib2_int.h:138
double int_power(double x, g2int y)
Function similar to C pow() power function.
Definition: int_power.c:18
int g2cid
ID of the file.
Definition: grib2_int.h:237
struct g2c_param G2C_PARAM_T
An entry in the table of NOAA abbreviations for GRIB parameters.
g2int extlen
Number of entries in the template extension.
Definition: grib2_int.h:296
unsigned char interp_list
Interpetation of list of numbers defining number of points (See Table 3.11).
Definition: grib2_int.h:198
int g2c_rw_section6_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 6 (Data Representation Section) of a GRIB2 message.
Definition: g2cfile.c:748
struct g2c_section5_info G2C_SECTION5_INFO_T
Information about Section 5 DATA REPRESENTATION SECTION.
size_t bytes_in_msg
Number of bytes in this message.
Definition: grib2_int.h:137
struct g2c_section_info * prev
Pointer to previous in list.
Definition: grib2_int.h:177
int num_fields
Number of fields in the message.
Definition: grib2_int.h:140
struct g2c_section4_info G2C_SECTION4_INFO_T
Information about Section 4 PRODUCT DEFINITION SECTION.
int g2c_file_io(FILE *f, int write, int g2ctype, void *var)
Read or write a big-endian integer type to an open file, with conversion between native and big-endia...
Definition: g2cio.c:41
g2int * map
Number of octets of each entry in the static part of the template.
Definition: grib2_int.h:290
unsigned char sec_num
Section number.
Definition: grib2_int.h:173
g2int needext
Indicates whether or not the template needs to be extended.
Definition: grib2_int.h:293
unsigned int num_data_points
Number of data points where one or more values are specified in Section 7 when a bit map is present,...
Definition: grib2_int.h:221
void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits, g2int nskip, g2int n)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:180
int g2c_file_io_short(FILE *f, int write, short *var)
Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big...
Definition: g2cio.c:273
int add_msg(G2C_FILE_INFO_T *file, int msg_num, size_t bytes_to_msg, size_t bytes_in_msg, int read_file, G2C_MESSAGE_INFO_T **msg)
Add new message to linked list.
Definition: g2cfile.c:1020
void * sec_info
Pointer to struct specific for section 3, 4, 5, 6, or 7.
Definition: grib2_int.h:175
g2int num
The template number.
Definition: grib2_int.h:283
float * value
Array of dimension values.
Definition: grib2_int.h:188
unsigned char indicator
Bit map indicator.
Definition: grib2_int.h:231
struct g2c_message_info G2C_MESSAGE_INFO_T
This is the information about each message.
unsigned int sec_len
Length of the section (in bytes).
Definition: grib2_int.h:171
int add_section(FILE *f, G2C_MESSAGE_INFO_T *msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec, unsigned char sec_num)
Add metadata about a new section 3, 4, 5, 6, or 7.
Definition: g2cfile.c:797
int g2c_get_level_desc(int ipdtn, long long int *ipdtmpl, char *level_desc)
Determine the string that describes the level information, given the GRIB2 Product Definition Templat...
Definition: g2cdegrib2.c:312
short year
Year.
Definition: grib2_int.h:154
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm)
This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Def...
Definition: getpoly.c:40
void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This function packs up a data field using a complex packing algorithm as defined in the GRIB2 documen...
Definition: misspack.c:42
size_t bytes_to_sec
Number of bytes from start of message to this section.
Definition: grib2_int.h:172
unsigned char status
Production Status of Processed data in the GRIB message.
Definition: grib2_int.h:160
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
This subroutine returns the dimensions and scanning mode of a grid definition packed in GRIB2 Grid De...
Definition: getdim.c:29
int pack_gp(g2int *kfildo, g2int *ic, g2int *nxy, g2int *is523, g2int *minpk, g2int *inc, g2int *missp, g2int *misss, g2int *jmin, g2int *jmax, g2int *lbit, g2int *nov, g2int *ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int *kbit, g2int *novref, g2int *lbitref, g2int *ier)
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min ...
Definition: pack_gp.c:255
G2C_MESSAGE_INFO_T * msg
Information about each message in the file.
Definition: grib2_int.h:241
int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed using a complex packing algorithm as defined in ...
Definition: comunpack.c:42
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs a spectral data field using the complex packing algorithm for spherical harmoni...
Definition: specpack.c:33
unsigned char second
Second.
Definition: grib2_int.h:159
int dimid
Dimension ID.
Definition: grib2_int.h:185
int g2c_rw_section5_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 5 (Data Representation Section) of a GRIB2 message.
Definition: g2cfile.c:666
unsigned char day
Day.
Definition: grib2_int.h:156
void simpack(float *fld, g2int ndpts, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using the simple packing algorithm as defined in the GRIB2 docu...
Definition: simpack.c:34
FILE * f
FILE pointer to open file.
Definition: grib2_int.h:239
unsigned char source_grid_def
Source of grid definition (See Table 3.0).
Definition: grib2_int.h:195
int template_len
Number of entries in template.
Definition: grib2_int.h:179
void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This function packs up a float array into a JPEG2000 code stream.
Definition: jpcpack.c:270
unsigned char local_version
Version number of GRIB local tables used to augment Master Tables.
Definition: grib2_int.h:152
void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: compack.c:42
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ, g2int KK, g2int MM, float *fld)
This subroutine unpacks a spectral data field that was packed using the complex packing algorithm for...
Definition: specunpack.c:35
gtemplate * getdrstemplate(g2int number)
This subroutine returns DRS template information for a specified Data Representation Template.
Definition: drstemplates.c:167
gtemplate * getpdstemplate(g2int number)
This subroutine returns PDS template information for a specified Product Definition Template.
Definition: pdstemplates.c:277
int section1[G2C_SECTION1_ARRAY_LEN]
Section 1 array.
Definition: grib2_int.h:139
g2int type
The template type: 3 Grid Defintion Template.
Definition: grib2_int.h:281
struct g2c_entry G2C_CODE_ENTRY_T
An entry in a GRIB2 code table.
int g2disc
GRIB2 discipline.
Definition: grib2_int.h:266
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
This Function decodes an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition: decenc_aec.c:43
unsigned char month
Month.
Definition: grib2_int.h:155
size_t msg_num
Number of message in file (0-based).
Definition: grib2_int.h:135
int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
Read Section 1.
Definition: g2cfile.c:877
int g2c_file_io_ubyte(FILE *f, int write, unsigned char *var)
Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and bi...
Definition: g2cio.c:337
int bytes_to_bms
Number of bytes in the message to the bitmap section.
Definition: grib2_int.h:143
g2int maplen
Number of entries in the static part of the template.
Definition: grib2_int.h:286
unsigned short data_def
Data representation template number (See Table 5.0).
Definition: grib2_int.h:222
int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld)
This Function decodes a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
Definition: dec_jpeg2000.c:201
int g2c_file_io_longlong(FILE *f, int write, long long *var)
Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and...
Definition: g2cio.c:359
int g2c_get_datetime(int ipdtn, long long int *ipdtmpl, short year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minute, unsigned char second, char *tabbrev)
Convert date and time from GRIB2 info to string output.
Definition: g2cdegrib2.c:49
int g2c_add_file(const char *path, int mode, int *g2cid)
Open a GRIB2 file and add it to the list of open files.
Definition: g2cfile.c:1146
int g2c_file_io_uint(FILE *f, int write, unsigned int *var)
Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native ...
Definition: g2cio.c:251
size_t bytes_to_msg
Number of bytes to skip in the file, to get to this message.
Definition: grib2_int.h:136
g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed using a simple packing algorithm as defined in t...
Definition: simunpack.c:26
struct g2c_section6_info G2C_SECTION6_INFO_T
Information about Section 6 BIT-MAP SECTION.
int sec1_len
Length of section 1.
Definition: grib2_int.h:148
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, g2int ltype, g2int ratio, g2int retry, char *outjpc, g2int jpclen)
This Function encodes a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 ...
Definition: enc_jpeg2000.c:100
void rdieee(g2int *rieee, float *a, g2int num)
This subroutine reads a list of real values in 32-bit IEEE floating point format.
Definition: rdieee.c:21
gtemplate * getgridtemplate(g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Secti...
int g2num
GRIB2 parameter number.
Definition: grib2_int.h:268
int g2c_rw_section3_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read the metadata from section 3 (Grid Definition Section) of a GRIB2 message.
Definition: g2cfile.c:481
int g2c_rw_section4_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 4 (Product Definition Section) of a GRIB2 message.
Definition: g2cfile.c:577
struct g2c_message_info * next
Pointer to next in list.
Definition: grib2_int.h:164
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:38
int g2c_file_io_int(FILE *f, int write, int *var)
Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native an...
Definition: g2cio.c:230
G2C_MESSAGE_INFO_T * msg
Pointer to contianing message.
Definition: grib2_int.h:174
void aecpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This function packs up a float array into a AEC code stream.
Definition: aecpack.c:297
short center
Originating center.
Definition: grib2_int.h:149
int * optional
Optional list of numbers defining number of points.
Definition: grib2_int.h:200
struct g2c_file_info * file
Pointer to containing file.
Definition: grib2_int.h:163
unsigned short prod_def
Product definition template number (See Table 4.0).
Definition: grib2_int.h:210
A GRIB2 code table.
Definition: grib2_int.h:255
Keep information about dimensions defined in section 3.
Definition: grib2_int.h:184
An entry in a GRIB2 code table.
Definition: grib2_int.h:246
This is the information about each open file.
Definition: grib2_int.h:236
This is the information about each message.
Definition: grib2_int.h:134
An entry in the table of NOAA abbreviations for GRIB parameters.
Definition: grib2_int.h:263
Information about Section 3 GRID DEFINITION SECTION.
Definition: grib2_int.h:194
Information about Section 4 PRODUCT DEFINITION SECTION.
Definition: grib2_int.h:207
Information about Section 5 DATA REPRESENTATION SECTION.
Definition: grib2_int.h:217
Information about Section 6 BIT-MAP SECTION.
Definition: grib2_int.h:228
Information about a section 3 through 7 in a GRIB2 message.
Definition: grib2_int.h:169
Struct for GRIB template, returned by getgridtemplate().
Definition: grib2_int.h:276