NCEPLIBS-g2c 2.0.0
Loading...
Searching...
No Matches
grib2_int.h
Go to the documentation of this file.
1
8#ifndef _grib2_int_H
9#define _grib2_int_H
10
11#include <assert.h>
12#include <ctype.h>
13#include <stdint.h>
14#include <stdio.h>
15#include <stdlib.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 { \
97 pthread_mutex_lock(&m); \
98 } while (0)
99
101#define MUTEX_UNLOCK(m) \
102 do \
103 { \
104 pthread_mutex_unlock(&m); \
105 } while (0)
106
107#else /* not PTHREADS */
108
110#define MUTEX(m)
111
113#define EXTERN_MUTEX(m)
114
116#define MUTEX_LOCK(m)
117
119#define MUTEX_UNLOCK(m)
120
121#endif /* PTHREADS */
122
125#define ntoh64(y) (((uint64_t)ntohl(y)) << WORD | ntohl(y >> WORD))
126
129#define hton64(y) (((uint64_t)htonl(y)) << WORD | htonl(y >> WORD))
130
131#define G2C_FILE_READ 0
132#define G2C_FILE_WRITE 1
135typedef struct g2c_message_info
136{
137 size_t msg_num;
140 unsigned char discipline;
151 short center;
152 short subcenter;
153 unsigned char master_version;
154 unsigned char local_version;
155 unsigned char sig_ref_time;
156 short year;
157 unsigned char month;
158 unsigned char day;
159 unsigned char hour;
160 unsigned char minute;
161 unsigned char second;
162 unsigned char status;
163 unsigned char type;
168
170typedef struct g2c_section_info
171{
172 int sec_id;
173 unsigned int sec_len;
175 unsigned char sec_num;
177 void *sec_info;
180 long long int *template;
183
185typedef struct g2c_dim_info
186{
187 int dimid;
188 size_t len;
189 char name[G2C_MAX_NAME + 1];
190 float *value;
192
195typedef struct g2c_section3_info
196{
197 unsigned char source_grid_def;
198 unsigned int num_data_points;
199 unsigned char num_opt;
200 unsigned char interp_list;
201 unsigned short grid_def;
202 int *optional;
205
208typedef struct g2c_section4_info
209{
210 int field_num;
211 unsigned short num_coord;
212 unsigned short prod_def;
213 int *optional;
215
218typedef struct g2c_section5_info
219{
223 unsigned int num_data_points;
224 unsigned short data_def;
226
229typedef struct g2c_section6_info
230{
233 unsigned char indicator;
235
245
247typedef struct g2c_entry
248{
249 struct g2c_entry *next;
250 char desc[G2C_MAX_GRIB_DESC_LEN + 1];
251 char status[G2C_MAX_GRIB_STATUS_LEN + 1];
252 char code[G2C_MAX_GRIB_CODE_LEN + 1];
254
256typedef struct g2c_code_table
257{
258 struct g2c_code_table *next;
259 char title[G2C_MAX_GRIB_TITLE_LEN + 1];
260 G2C_CODE_ENTRY_T *entry;
262
264typedef struct g2c_param
265{
266 int g1num;
267 int g1ver;
268 int g2disc;
269 int g2cat;
270 int g2num;
271 char abbrev[G2C_MAX_NOAA_ABBREV_LEN + 1];
273
304
305typedef struct gtemplate gtemplate;
307/* Legacy support functions. */
308double int_power(double x, g2int y);
309void mkieee(float *a, g2int *rieee, g2int num);
310void rdieee(g2int *rieee, float *a, g2int num);
311
312/* Get the various templates. */
314gtemplate *extdrstemplate(g2int number, g2int *list);
316gtemplate *extpdstemplate(g2int number, g2int *list);
318gtemplate *extgridtemplate(g2int number, g2int *list);
319
320/* Level and date/time info. */
321int g2c_get_datetime(int ipdtn, long long int *ipdtmpl, short year, unsigned char month, unsigned char day,
322 unsigned char hour, unsigned char minute, unsigned char second, char *tabbrev);
323int g2c_get_level_desc(int ipdtn, long long int *ipdtmpl, char *level_desc);
324
325/* Packing and unpacking data. */
326void simpack(float *fld, g2int ndpts, g2int *idrstmpl,
327 unsigned char *cpack, g2int *lcpack);
328g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts,
329 float *fld);
330void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
331 unsigned char *cpack, g2int *lcpack);
332int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum,
333 g2int *idrstmpl, g2int ndpts, float *fld);
334void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
335 unsigned char *cpack, g2int *lcpack);
336void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
337 unsigned char *cpack, g2int *lcpack);
338g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);
339void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
340 g2int *idrstmpl, unsigned char *cpack, g2int *lcpack);
341g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ,
342 g2int KK, g2int MM, float *fld);
343g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan);
344
345int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits,
346 unsigned char *pngbuf);
347int dec_png(unsigned char *pngbuf, g2int *width, g2int *height,
348 unsigned char *cout);
349void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
350 unsigned char *cpack, g2int *lcpack);
351g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
352 float *fld);
353int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits,
354 g2int ltype, g2int ratio, g2int retry, char *outjpc,
355 g2int jpclen);
356int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld);
357void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
358 unsigned char *cpack, g2int *lcpack);
359g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
360 float *fld);
361
362void aecpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
363 unsigned char *cpack, g2int *lcpack);
364g2int aecunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
365 float *fld);
366int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
367 g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen);
368int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
369 g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen);
370
371/* Packing and unpacking bits. */
372void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits);
373void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits);
374void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits,
375 g2int nskip, g2int n);
376void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits,
377 g2int nskip, g2int n);
378
379/* Deal with grib groups. */
380int pack_gp(g2int *kfildo, g2int *ic, g2int *nxy,
381 g2int *is523, g2int *minpk, g2int *inc, g2int *missp, g2int *misss,
382 g2int *jmin, g2int *jmax, g2int *lbit, g2int *nov,
383 g2int *ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int *kbit,
384 g2int *novref, g2int *lbitref, g2int *ier);
385
386/* Check the message header and check for message termination. */
387int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose);
388
389/* Basic file I/O. */
390int g2c_file_io(FILE *f, int write, int g2ctype, void *var);
391int g2c_file_io_byte(FILE *f, int write, char *var);
392int g2c_file_io_ubyte(FILE *f, int write, unsigned char *var);
393int g2c_file_io_short(FILE *f, int write, short *var);
394int g2c_file_io_ushort(FILE *f, int write, unsigned short *var);
395int g2c_file_io_int(FILE *f, int write, int *var);
396int g2c_file_io_uint(FILE *f, int write, unsigned int *var);
397int g2c_file_io_longlong(FILE *f, int write, long long *var);
398int g2c_file_io_ulonglong(FILE *f, int write, unsigned long long *var);
399int g2c_file_io_template(FILE *f, int rw_flag, int map, long long int *template_value);
400
401/* Read and remember file, message, and section metadata. */
402int g2c_add_file(const char *path, int mode, int *g2cid);
403int add_msg(G2C_FILE_INFO_T *file, int msg_num, size_t bytes_to_msg, size_t bytes_in_msg,
404 int read_file, G2C_MESSAGE_INFO_T **msg);
405int add_section(FILE *f, G2C_MESSAGE_INFO_T *msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec,
406 unsigned char sec_num);
407int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg);
408int g2c_rw_section3_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
409int g2c_rw_section4_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
410int g2c_rw_section5_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
411int g2c_rw_section6_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
412
413/* Logging output. */
415
416/* Handle logging. */
417#ifdef LOGGING
418
419/* To log something... */
420void g2_log(int severity, const char *fmt, ...);
421
423#define LOG(e) g2_log e
424
425#else /* LOGGING */
426
428#define LOG(e)
429
430#endif /* LOGGING */
431
432#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:413
#define G2C_MAX_GRIB_DESC_LEN
Maximum length of code description.
Definition grib2.h:409
#define G2C_MAX_NAME
Maximum length of a name.
Definition grib2.h:274
#define G2C_MAX_GRIB_STATUS_LEN
Maximum length of code status.
Definition grib2.h:410
#define G2C_MAX_GRIB_CODE_LEN
Maximum length of code.
Definition grib2.h:412
#define G2C_SECTION1_ARRAY_LEN
Length of section 1 array.
Definition grib2.h:403
int64_t g2int
Long integer type.
Definition grib2.h:32
#define G2C_MAX_NOAA_ABBREV_LEN
Maximum length of a NOAA abbreviation of a parameter.
Definition grib2.h:417
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:123
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)
Pack up a data field using a complex packing algorithm.
Definition cmplxpack.c:37
int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits, unsigned char *pngbuf)
Encode PNG.
Definition decenc_png.c:207
size_t bytes_to_local
Number of bytes in the message before the (first) local section.
Definition grib2_int.h:144
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:254
void mkieee(float *a, g2int *rieee, g2int num)
Store 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:178
struct g2c_section_info * sec
List of section metadata.
Definition grib2_int.h:164
int g1ver
GRIB1 table version.
Definition grib2_int.h:267
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout ...
Definition gbits.c:20
size_t len
Length of dimension.
Definition grib2_int.h:188
short subcenter
Originating subcenter.
Definition grib2_int.h:152
int sec_id
ID of the section (0-based).
Definition grib2_int.h:172
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:126
unsigned char master_version
GRIB master tables version number.
Definition grib2_int.h:153
struct g2c_file_info G2C_FILE_INFO_T
This is the information about each open file.
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:266
g2int * ext
Number of octets of each entry in the extension part of the template.
Definition grib2_int.h:302
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
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:149
unsigned char type
Type of processed data in this GRIB message.
Definition grib2_int.h:163
int * section_number
Array (length num_sections) of section numbers.
Definition grib2_int.h:148
unsigned short grid_def
Grid definition template number (= N) (See Table 3.1).
Definition grib2_int.h:201
unsigned char hour
Hour.
Definition grib2_int.h:159
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
Decode PNG.
Definition decenc_png.c:100
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:161
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:147
unsigned char minute
Minute.
Definition grib2_int.h:160
unsigned int num_data_points
Number of data points.
Definition grib2_int.h:198
size_t num_messages
Number of messages in the file.
Definition grib2_int.h:242
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:211
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)
Encode data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:108
int num_local
Number of local sections in the message.
Definition grib2_int.h:143
unsigned char sig_ref_time
Significance of reference time.
Definition grib2_int.h:155
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:199
int g2cat
GRIB2 category number.
Definition grib2_int.h:269
int * optional
Optional list of numbers defining number of points.
Definition grib2_int.h:213
unsigned char discipline
Discipline from section 0.
Definition grib2_int.h:140
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:239
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:298
unsigned char interp_list
Interpetation of list of numbers defining number of points (See Table 3.11).
Definition grib2_int.h:200
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:745
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:139
struct g2c_section_info * prev
Pointer to previous in list.
Definition grib2_int.h:179
int num_fields
Number of fields in the message.
Definition grib2_int.h:142
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:292
size_t bytes_to_bms
Number of bytes in the message to the bitmap section.
Definition grib2_int.h:145
unsigned char sec_num
Section number.
Definition grib2_int.h:175
g2int needext
Indicates whether or not the template needs to be extended.
Definition grib2_int.h:295
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:223
void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits, g2int nskip, g2int n)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in th...
Definition gbits.c:178
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:1017
void * sec_info
Pointer to struct specific for section 3, 4, 5, 6, or 7.
Definition grib2_int.h:177
g2int num
The template number.
Definition grib2_int.h:285
float * value
Array of dimension values.
Definition grib2_int.h:190
unsigned char indicator
Bit map indicator.
Definition grib2_int.h:233
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:173
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:794
gtemplate * getdrstemplate(g2int number)
This subroutine returns DRS template information for a specified Data Representation Template.
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:309
short year
Year.
Definition grib2_int.h:156
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)
Pack a data field using a complex packing algorithm.
Definition misspack.c:43
size_t bytes_to_sec
Number of bytes from start of message to this section.
Definition grib2_int.h:174
unsigned char status
Production Status of Processed data in the GRIB message.
Definition grib2_int.h:162
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
Return the dimensions and scanning mode of a grid definition.
Definition getdim.c:27
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:243
int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack a data field that was packed using a complex packing algorithm, using info from the GRIB2 Data...
Definition comunpack.c:41
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
Pack a spectral data field using the complex packing algorithm for spherical harmonic data as defined...
Definition specpack.c:33
unsigned char second
Second.
Definition grib2_int.h:161
int dimid
Dimension ID.
Definition grib2_int.h:187
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:663
unsigned char day
Day.
Definition grib2_int.h:158
gtemplate * extpdstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Product Definition Template,...
void simpack(float *fld, g2int ndpts, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
Packs a data field using the simple packing algorithm.
Definition simpack.c:36
FILE * f
FILE pointer to open file.
Definition grib2_int.h:241
unsigned char source_grid_def
Source of grid definition (See Table 3.0).
Definition grib2_int.h:197
int template_len
Number of entries in template.
Definition grib2_int.h:181
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:269
unsigned char local_version
Version number of GRIB local tables used to augment Master Tables.
Definition grib2_int.h:154
void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
Pack a data field using a complex packing algorithm.
Definition compack.c:42
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ, g2int KK, g2int MM, float *fld)
Unpack a spectral data field that was packed using the complex packing algorithm for spherical harmon...
Definition specunpack.c:35
size_t bytes_to_data
Number of bytes in the message to the (first) data section.
Definition grib2_int.h:146
int section1[G2C_SECTION1_ARRAY_LEN]
Section 1 array.
Definition grib2_int.h:141
g2int type
The template type: 3 Grid Defintion Template.
Definition grib2_int.h:283
struct g2c_entry G2C_CODE_ENTRY_T
An entry in a GRIB2 code table.
gtemplate * extgridtemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Grid Definition Template,...
int g2disc
GRIB2 discipline.
Definition grib2_int.h:268
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
Decode an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:38
unsigned char month
Month.
Definition grib2_int.h:157
size_t msg_num
Number of message in file (0-based).
Definition grib2_int.h:137
gtemplate * extdrstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Data Representation Template,...
int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
Read Section 1.
Definition g2cfile.c:874
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
gtemplate * getgridtemplate(g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Secti...
gtemplate * getpdstemplate(g2int number)
This subroutine returns PDS template information for a specified Product Definition Template.
g2int maplen
Number of entries in the static part of the template.
Definition grib2_int.h:288
unsigned short data_def
Data representation template number (See Table 5.0).
Definition grib2_int.h:224
int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld)
Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) using...
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:1143
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:138
g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack a data field that was packed using a simple packing algorithm, using info from the GRIB2 Data ...
Definition simunpack.c:28
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:150
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, g2int ltype, g2int ratio, g2int retry, char *outjpc, g2int jpclen)
Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
void rdieee(g2int *rieee, float *a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.
Definition rdieee.c:20
int g2num
GRIB2 parameter number.
Definition grib2_int.h:270
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:478
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:574
struct g2c_message_info * next
Pointer to next in list.
Definition grib2_int.h:166
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in th...
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:176
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:151
int * optional
Optional list of numbers defining number of points.
Definition grib2_int.h:202
struct g2c_file_info * file
Pointer to containing file.
Definition grib2_int.h:165
unsigned short prod_def
Product definition template number (See Table 4.0).
Definition grib2_int.h:212
A GRIB2 code table.
Definition grib2_int.h:257
Keep information about dimensions defined in section 3.
Definition grib2_int.h:186
An entry in a GRIB2 code table.
Definition grib2_int.h:248
This is the information about each open file.
Definition grib2_int.h:238
This is the information about each message.
Definition grib2_int.h:136
An entry in the table of NOAA abbreviations for GRIB parameters.
Definition grib2_int.h:265
Information about Section 3 GRID DEFINITION SECTION.
Definition grib2_int.h:196
Information about Section 4 PRODUCT DEFINITION SECTION.
Definition grib2_int.h:209
Information about Section 5 DATA REPRESENTATION SECTION.
Definition grib2_int.h:219
Information about Section 6 BIT-MAP SECTION.
Definition grib2_int.h:230
Information about a section 3 through 7 in a GRIB2 message.
Definition grib2_int.h:171
Struct for GRIB template, returned by getgridtemplate().
Definition grib2_int.h:278