Loading...
Searching...
No Matches
grib2_int.h
Go to the documentation of this file.
#ifndef _grib2_int_H
#define _grib2_int_H
#include <assert.h>
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#if defined(WIN32)
#include <winsock2.h> /* ntohl() function for Windows. */
#else
#include <arpa/inet.h> /* ntohl() function for Unix/Mac. */
#endif
#ifdef PTHREADS
#include <pthread.h>
#endif
#include "grib2.h"
#define ALOG2 (0.69314718)
#define G2C_JASPER_JPEG_FORMAT_NAME "jpc"
#define G2C_MIN_MAX_BYTES 16
#define G2C_MAGIC_HEADER "GRIB"
#define G2C_MAGIC_HEADER_LEN 8
#define G2C_MAX_MESSAGES 1024
#define BYTE 8
#define WORD 32
#define ONE_BYTE 1
#define TWO_BYTES 2
#define FOUR_BYTES 4
#define EIGHT_BYTES 8
#define LATITUDE "Latitude"
#define LONGITUDE "Longitude"
/* For GRIB1. */
#define G2C_INDEX1_PDS_VAL_LEN 27
#define G2C_INDEX1_GDS_VAL_LEN 41
#define G2C_INDEX1_BMS_VAL_LEN 5
#define G2C_INDEX1_BDS_VAL_LEN 10
#define G2C_INDEX1_PDS_VAL2_LEN 27
#define G2C_INDEX1_PDS_VAL3_LEN 27
#define G2C_INDEX1_GDS_VAL2_LEN 27
/* For thread-safety, use these macros. */
#ifdef PTHREADS
#define MUTEX(m) pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
#define EXTERN_MUTEX(m) extern pthread_mutex_t m;
#define MUTEX_LOCK(m) \
do \
{ \
pthread_mutex_lock(&m); \
} while (0)
#define MUTEX_UNLOCK(m) \
do \
{ \
pthread_mutex_unlock(&m); \
} while (0)
#else /* not PTHREADS */
#define MUTEX(m)
#define EXTERN_MUTEX(m)
#define MUTEX_LOCK(m)
#define MUTEX_UNLOCK(m)
#endif /* PTHREADS */
#define ntoh64(x) ((1==ntohl(1)) ? (x) : (((uint64_t)ntohl((x) & 0xFFFFFFFFUL)) << 32) | ntohl((uint32_t)((x) >> 32)))
#define hton64(x) ((1==htonl(1)) ? (x) : (((uint64_t)htonl((x) & 0xFFFFFFFFUL)) << 32) | htonl((uint32_t)((x) >> 32)))
#define G2C_FILE_READ 0
#define G2C_FILE_WRITE 1
typedef struct g2c_message_info
{
size_t msg_num;
size_t bytes_to_msg;
size_t bytes_in_msg;
unsigned char discipline;
int section1[G2C_SECTION1_ARRAY_LEN];
int num_fields;
int num_local;
size_t bytes_to_local;
size_t bytes_to_bms;
size_t bytes_to_data;
int num_sections;
int *section_number;
size_t *section_offset;
int sec1_len;
short center;
short subcenter;
unsigned char master_version;
unsigned char local_version;
unsigned char sig_ref_time;
short year;
unsigned char month;
unsigned char day;
unsigned char hour;
unsigned char minute;
unsigned char second;
unsigned char status;
unsigned char type;
struct g2c_section_info *sec;
struct g2c_file_info *file;
struct g2c_message_info *next;
} G2C_MESSAGE_INFO_T;
typedef struct g2c_section_info
{
int sec_id;
unsigned int sec_len;
size_t bytes_to_sec;
unsigned char sec_num;
G2C_MESSAGE_INFO_T *msg;
void *sec_info;
struct g2c_section_info *next;
struct g2c_section_info *prev;
long long int *template;
int template_len;
} G2C_SECTION_INFO_T;
typedef struct g2c_dim_info
{
int dimid;
size_t len;
char name[G2C_MAX_NAME + 1];
float *value;
} G2C_DIM_INFO_T;
typedef struct g2c_section3_info
{
unsigned char source_grid_def;
unsigned int num_data_points;
unsigned char num_opt;
unsigned char interp_list;
unsigned short grid_def;
int *optional;
G2C_DIM_INFO_T dim[2];
} G2C_SECTION3_INFO_T;
typedef struct g2c_section4_info
{
int field_num;
unsigned short num_coord;
unsigned short prod_def;
int *optional;
} G2C_SECTION4_INFO_T;
typedef struct g2c_section5_info
{
unsigned int num_data_points;
unsigned short data_def;
} G2C_SECTION5_INFO_T;
typedef struct g2c_section6_info
{
unsigned char indicator;
} G2C_SECTION6_INFO_T;
typedef struct g2c_file_info
{
int g2cid;
char path[G2C_MAX_NAME + 1];
FILE *f;
size_t num_messages;
G2C_MESSAGE_INFO_T *msg;
} G2C_FILE_INFO_T;
typedef struct g2c_entry
{
struct g2c_entry *next;
char desc[G2C_MAX_GRIB_DESC_LEN + 1];
char status[G2C_MAX_GRIB_STATUS_LEN + 1];
char code[G2C_MAX_GRIB_CODE_LEN + 1];
} G2C_CODE_ENTRY_T;
typedef struct g2c_code_table
{
struct g2c_code_table *next;
char title[G2C_MAX_GRIB_TITLE_LEN + 1];
G2C_CODE_ENTRY_T *entry;
} G2C_CODE_TABLE_T;
typedef struct g2c_param
{
int g1num;
int g1ver;
int g2disc;
int g2cat;
int g2num;
char abbrev[G2C_MAX_NOAA_ABBREV_LEN + 1];
} G2C_PARAM_T;
struct gtemplate
{
g2int type;
g2int num;
g2int maplen;
g2int *map;
g2int needext;
g2int extlen;
g2int *ext;
};
typedef struct gtemplate gtemplate;
/* Legacy support functions. */
double int_power(double x, g2int y);
void mkieee(float *a, g2int *rieee, g2int num);
void rdieee(g2int *rieee, float *a, g2int num);
/* Get the various templates. */
gtemplate *getdrstemplate(g2int number);
gtemplate *extdrstemplate(g2int number, g2int *list);
gtemplate *getpdstemplate(g2int number);
gtemplate *extpdstemplate(g2int number, g2int *list);
gtemplate *getgridtemplate(g2int number);
gtemplate *extgridtemplate(g2int number, g2int *list);
/* Level and date/time info. */
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);
int g2c_get_level_desc(int ipdtn, long long int *ipdtmpl, char *level_desc);
/* Packing and unpacking data. */
void simpack(float *fld, g2int ndpts, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts,
float *fld);
void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum,
g2int *idrstmpl, g2int ndpts, float *fld);
void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
g2int *idrstmpl, unsigned char *cpack, g2int *lcpack);
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ,
g2int KK, g2int MM, float *fld);
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan);
int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits,
unsigned char *pngbuf);
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height,
unsigned char *cout);
void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
float *fld);
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits,
g2int ltype, g2int ratio, g2int retry, char *outjpc,
g2int jpclen);
int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld);
void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
float *fld);
void aecpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int aecunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
float *fld);
int enc_aec(unsigned char *data, g2int ctemplen, g2int nbits, g2int flags,
g2int block_size, g2int rsi, unsigned char *aecbuf, g2int *aecbuflen);
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags,
g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen);
/* Packing and unpacking bits. */
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits);
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits);
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits,
g2int nskip, g2int n);
void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits,
g2int nskip, g2int n);
/* Deal with grib groups. */
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);
/* Check the message header and check for message termination. */
int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose, int from);
/* Basic file I/O. */
int g2c_file_io(FILE *f, int write, int g2ctype, void *var);
int g2c_file_io_byte(FILE *f, int write, char *var);
int g2c_file_io_ubyte(FILE *f, int write, unsigned char *var);
int g2c_file_io_short(FILE *f, int write, short *var);
int g2c_file_io_ushort(FILE *f, int write, unsigned short *var);
int g2c_file_io_int(FILE *f, int write, int *var);
int g2c_file_io_uint(FILE *f, int write, unsigned int *var);
int g2c_file_io_longlong(FILE *f, int write, long long *var);
int g2c_file_io_ulonglong(FILE *f, int write, unsigned long long *var);
int g2c_file_io_template(FILE *f, int rw_flag, int map, long long int *template_value);
/* Read and remember file, message, and section metadata. */
int g2c_add_file(const char *path, int mode, int *g2cid);
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);
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);
int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg);
int g2c_rw_section3_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
int g2c_rw_section4_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
int g2c_rw_section5_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
int g2c_rw_section6_metadata(FILE *f, int rw_flag, G2C_SECTION_INFO_T *sec);
/* Logging output. */
int g2c_log_section1(G2C_MESSAGE_INFO_T *msg);
/* Handle logging. */
#ifdef LOGGING
/* To log something... */
void g2_log(int severity, const char *fmt, ...);
#define LOG(e) g2_log e
#else /* LOGGING */
#define LOG(e)
#endif /* LOGGING */
#endif /* _grib2_int_H */
grib2.h
Header file for NCEPLIBS-g2c library.
G2C_MAX_GRIB_TITLE_LEN
#define G2C_MAX_GRIB_TITLE_LEN
Maximum length of code table title.
Definition grib2.h:425
G2C_MAX_GRIB_DESC_LEN
#define G2C_MAX_GRIB_DESC_LEN
Maximum length of code description.
Definition grib2.h:421
G2C_MAX_NAME
#define G2C_MAX_NAME
Maximum length of a name.
Definition grib2.h:274
G2C_MAX_GRIB_STATUS_LEN
#define G2C_MAX_GRIB_STATUS_LEN
Maximum length of code status.
Definition grib2.h:422
G2C_MAX_GRIB_CODE_LEN
#define G2C_MAX_GRIB_CODE_LEN
Maximum length of code.
Definition grib2.h:424
G2C_SECTION1_ARRAY_LEN
#define G2C_SECTION1_ARRAY_LEN
Length of section 1 array.
Definition grib2.h:415
g2int
int64_t g2int
Long integer type.
Definition grib2.h:32
G2C_MAX_NOAA_ABBREV_LEN
#define G2C_MAX_NOAA_ABBREV_LEN
Maximum length of a NOAA abbreviation of a parameter.
Definition grib2.h:429
jpcunpack
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
G2C_SECTION3_INFO_T
struct g2c_section3_info G2C_SECTION3_INFO_T
Information about Section 3 GRID DEFINITION SECTION.
G2C_CODE_TABLE_T
struct g2c_code_table G2C_CODE_TABLE_T
A GRIB2 code table.
cmplxpack
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
enc_png
int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits, unsigned char *pngbuf)
Encode PNG.
Definition decenc_png.c:259
g2c_message_info::bytes_to_local
size_t bytes_to_local
Number of bytes in the message before the (first) local section.
Definition grib2_int.h:144
g2c_file_io_ushort
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
pngpack
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
mkieee
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
g2c_file_io_byte
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
g2c_section_info::next
struct g2c_section_info * next
Pointer to next in list.
Definition grib2_int.h:178
g2c_message_info::sec
struct g2c_section_info * sec
List of section metadata.
Definition grib2_int.h:164
g2c_param::g1ver
int g1ver
GRIB1 table version.
Definition grib2_int.h:267
gbit
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
g2c_dim_info::len
size_t len
Length of dimension.
Definition grib2_int.h:188
g2c_message_info::subcenter
short subcenter
Originating subcenter.
Definition grib2_int.h:152
g2c_section_info::sec_id
int sec_id
ID of the section (0-based).
Definition grib2_int.h:172
g2c_section3_info::dim
G2C_DIM_INFO_T dim[2]
Dimension information.
Definition grib2_int.h:203
pngunpack
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
g2c_message_info::master_version
unsigned char master_version
GRIB master tables version number.
Definition grib2_int.h:153
G2C_FILE_INFO_T
struct g2c_file_info G2C_FILE_INFO_T
This is the information about each open file.
g2c_file_io_template
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
g2c_param::g1num
int g1num
GRIB1 parameter number.
Definition grib2_int.h:266
g2c_file_info::path
char path[G2C_MAX_NAME+1]
Path of the file.
Definition grib2_int.h:240
gtemplate::ext
g2int * ext
Number of octets of each entry in the extension part of the template.
Definition grib2_int.h:302
gbits
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
g2c_message_info::section_offset
size_t * section_offset
Array (length num_sections) of byte offsets from start of message to section.
Definition grib2_int.h:149
g2c_message_info::type
unsigned char type
Type of processed data in this GRIB message.
Definition grib2_int.h:163
g2c_message_info::section_number
int * section_number
Array (length num_sections) of section numbers.
Definition grib2_int.h:148
g2c_section3_info::grid_def
unsigned short grid_def
Grid definition template number (= N) (See Table 3.1).
Definition grib2_int.h:201
g2c_message_info::hour
unsigned char hour
Hour.
Definition grib2_int.h:159
dec_png
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
Decode PNG.
Definition decenc_png.c:127
aecunpack
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
g2c_file_io_ulonglong
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
g2c_message_info::num_sections
int num_sections
Number of sections in the file.
Definition grib2_int.h:147
g2c_message_info::minute
unsigned char minute
Minute.
Definition grib2_int.h:160
g2c_section3_info::num_data_points
unsigned int num_data_points
Number of data points.
Definition grib2_int.h:198
g2c_file_info::num_messages
size_t num_messages
Number of messages in the file.
Definition grib2_int.h:242
g2c_log_section1
int g2c_log_section1(G2C_MESSAGE_INFO_T *msg)
Log section 0 information.
Definition g2cutil.c:101
g2c_section4_info::num_coord
unsigned short num_coord
Number of coordinate values after template.
Definition grib2_int.h:211
G2C_DIM_INFO_T
struct g2c_dim_info G2C_DIM_INFO_T
Keep information about dimensions defined in section 3.
enc_aec
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
g2c_message_info::num_local
int num_local
Number of local sections in the message.
Definition grib2_int.h:143
g2c_message_info::sig_ref_time
unsigned char sig_ref_time
Significance of reference time.
Definition grib2_int.h:155
G2C_SECTION_INFO_T
struct g2c_section_info G2C_SECTION_INFO_T
Information about a section 3 through 7 in a GRIB2 message.
g2c_section3_info::num_opt
unsigned char num_opt
Number of octets for optional list of numbers defining number of points.
Definition grib2_int.h:199
g2c_param::g2cat
int g2cat
GRIB2 category number.
Definition grib2_int.h:269
g2c_section4_info::optional
int * optional
Optional list of numbers defining number of points.
Definition grib2_int.h:213
g2c_message_info::discipline
unsigned char discipline
Discipline from section 0.
Definition grib2_int.h:140
int_power
double int_power(double x, g2int y)
Function similar to C pow() power function.
Definition int_power.c:18
g2c_file_info::g2cid
int g2cid
ID of the file.
Definition grib2_int.h:239
G2C_PARAM_T
struct g2c_param G2C_PARAM_T
An entry in the table of NOAA abbreviations for GRIB parameters.
g2c_dim_info::name
char name[G2C_MAX_NAME+1]
Name of dimension.
Definition grib2_int.h:189
gtemplate::extlen
g2int extlen
Number of entries in the template extension.
Definition grib2_int.h:298
g2c_section3_info::interp_list
unsigned char interp_list
Interpetation of list of numbers defining number of points (See Table 3.11).
Definition grib2_int.h:200
g2c_rw_section6_metadata
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
G2C_SECTION5_INFO_T
struct g2c_section5_info G2C_SECTION5_INFO_T
Information about Section 5 DATA REPRESENTATION SECTION.
g2c_message_info::bytes_in_msg
size_t bytes_in_msg
Number of bytes in this message.
Definition grib2_int.h:139
g2c_section_info::prev
struct g2c_section_info * prev
Pointer to previous in list.
Definition grib2_int.h:179
g2c_message_info::num_fields
int num_fields
Number of fields in the message.
Definition grib2_int.h:142
G2C_SECTION4_INFO_T
struct g2c_section4_info G2C_SECTION4_INFO_T
Information about Section 4 PRODUCT DEFINITION SECTION.
g2c_file_io
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
gtemplate::map
g2int * map
Number of octets of each entry in the static part of the template.
Definition grib2_int.h:292
g2c_message_info::bytes_to_bms
size_t bytes_to_bms
Number of bytes in the message to the bitmap section.
Definition grib2_int.h:145
g2c_section_info::sec_num
unsigned char sec_num
Section number.
Definition grib2_int.h:175
gtemplate::needext
g2int needext
Indicates whether or not the template needs to be extended.
Definition grib2_int.h:295
g2c_section5_info::num_data_points
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
sbits
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
g2c_file_io_short
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
add_msg
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
g2c_section_info::sec_info
void * sec_info
Pointer to struct specific for section 3, 4, 5, 6, or 7.
Definition grib2_int.h:177
gtemplate::num
g2int num
The template number.
Definition grib2_int.h:285
g2c_dim_info::value
float * value
Array of dimension values.
Definition grib2_int.h:190
g2c_section6_info::indicator
unsigned char indicator
Bit map indicator.
Definition grib2_int.h:233
G2C_MESSAGE_INFO_T
struct g2c_message_info G2C_MESSAGE_INFO_T
This is the information about each message.
g2c_section_info::sec_len
unsigned int sec_len
Length of the section (in bytes).
Definition grib2_int.h:173
add_section
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
g2c_param::abbrev
char abbrev[G2C_MAX_NOAA_ABBREV_LEN+1]
NOAA abbreviation for this parameter.
Definition grib2_int.h:271
getdrstemplate
gtemplate * getdrstemplate(g2int number)
This subroutine returns DRS template information for a specified Data Representation Template.
Definition drstemplates.c:172
g2c_get_level_desc
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
g2c_message_info::year
short year
Year.
Definition grib2_int.h:156
getpoly
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
misspack
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
g2c_section_info::bytes_to_sec
size_t bytes_to_sec
Number of bytes from start of message to this section.
Definition grib2_int.h:174
g2c_message_info::status
unsigned char status
Production Status of Processed data in the GRIB message.
Definition grib2_int.h:162
getdim
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
pack_gp
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_file_info::msg
G2C_MESSAGE_INFO_T * msg
Information about each message in the file.
Definition grib2_int.h:243
comunpack
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
specpack
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
g2c_message_info::second
unsigned char second
Second.
Definition grib2_int.h:161
g2c_dim_info::dimid
int dimid
Dimension ID.
Definition grib2_int.h:187
g2c_rw_section5_metadata
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
g2c_message_info::day
unsigned char day
Day.
Definition grib2_int.h:158
extpdstemplate
gtemplate * extpdstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Product Definition Template,...
Definition pdstemplates.c:553
simpack
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
g2c_file_info::f
FILE * f
FILE pointer to open file.
Definition grib2_int.h:241
g2c_section3_info::source_grid_def
unsigned char source_grid_def
Source of grid definition (See Table 3.0).
Definition grib2_int.h:197
g2c_section_info::template_len
int template_len
Number of entries in template.
Definition grib2_int.h:181
jpcpack
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
g2c_message_info::local_version
unsigned char local_version
Version number of GRIB local tables used to augment Master Tables.
Definition grib2_int.h:154
compack
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
specunpack
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
g2c_message_info::bytes_to_data
size_t bytes_to_data
Number of bytes in the message to the (first) data section.
Definition grib2_int.h:146
g2c_message_info::section1
int section1[G2C_SECTION1_ARRAY_LEN]
Section 1 array.
Definition grib2_int.h:141
gtemplate::type
g2int type
The template type: 3 Grid Defintion Template.
Definition grib2_int.h:283
G2C_CODE_ENTRY_T
struct g2c_entry G2C_CODE_ENTRY_T
An entry in a GRIB2 code table.
extgridtemplate
gtemplate * extgridtemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Grid Definition Template,...
Definition gridtemplates.c:241
g2c_param::g2disc
int g2disc
GRIB2 discipline.
Definition grib2_int.h:268
dec_aec
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
g2c_check_msg
int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose, int from)
Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already termi...
Definition util.c:41
g2c_message_info::month
unsigned char month
Month.
Definition grib2_int.h:157
g2c_message_info::msg_num
size_t msg_num
Number of message in file (0-based).
Definition grib2_int.h:137
extdrstemplate
gtemplate * extdrstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Data Representation Template,...
Definition drstemplates.c:218
g2c_rw_section1_metadata
int g2c_rw_section1_metadata(FILE *f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
Read Section 1.
Definition g2cfile.c:874
g2c_file_io_ubyte
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
getgridtemplate
gtemplate * getgridtemplate(g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Secti...
Definition gridtemplates.c:193
getpdstemplate
gtemplate * getpdstemplate(g2int number)
This subroutine returns PDS template information for a specified Product Definition Template.
Definition pdstemplates.c:504
gtemplate::maplen
g2int maplen
Number of entries in the static part of the template.
Definition grib2_int.h:288
g2c_section5_info::data_def
unsigned short data_def
Data representation template number (See Table 5.0).
Definition grib2_int.h:224
dec_jpeg2000
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...
Definition decenc_jpeg2000.c:377
g2c_file_io_longlong
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
g2c_get_datetime
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
g2c_add_file
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
g2c_file_io_uint
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
g2c_message_info::bytes_to_msg
size_t bytes_to_msg
Number of bytes to skip in the file, to get to this message.
Definition grib2_int.h:138
simunpack
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
G2C_SECTION6_INFO_T
struct g2c_section6_info G2C_SECTION6_INFO_T
Information about Section 6 BIT-MAP SECTION.
g2c_message_info::sec1_len
int sec1_len
Length of section 1.
Definition grib2_int.h:150
enc_jpeg2000
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....
Definition decenc_jpeg2000.c:94
rdieee
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
g2c_param::g2num
int g2num
GRIB2 parameter number.
Definition grib2_int.h:270
g2c_rw_section3_metadata
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
g2c_rw_section4_metadata
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
g2c_message_info::next
struct g2c_message_info * next
Pointer to next in list.
Definition grib2_int.h:166
sbit
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
g2c_file_io_int
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_section_info::msg
G2C_MESSAGE_INFO_T * msg
Pointer to contianing message.
Definition grib2_int.h:176
aecpack
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
g2c_message_info::center
short center
Originating center.
Definition grib2_int.h:151
g2c_section3_info::optional
int * optional
Optional list of numbers defining number of points.
Definition grib2_int.h:202
g2c_message_info::file
struct g2c_file_info * file
Pointer to containing file.
Definition grib2_int.h:165
g2c_section4_info::prod_def
unsigned short prod_def
Product definition template number (See Table 4.0).
Definition grib2_int.h:212
g2c_code_table
A GRIB2 code table.
Definition grib2_int.h:257
g2c_dim_info
Keep information about dimensions defined in section 3.
Definition grib2_int.h:186
g2c_entry
An entry in a GRIB2 code table.
Definition grib2_int.h:248
g2c_file_info
This is the information about each open file.
Definition grib2_int.h:238
g2c_message_info
This is the information about each message.
Definition grib2_int.h:136
g2c_param
An entry in the table of NOAA abbreviations for GRIB parameters.
Definition grib2_int.h:265
g2c_section3_info
Information about Section 3 GRID DEFINITION SECTION.
Definition grib2_int.h:196
g2c_section4_info
Information about Section 4 PRODUCT DEFINITION SECTION.
Definition grib2_int.h:209
g2c_section5_info
Information about Section 5 DATA REPRESENTATION SECTION.
Definition grib2_int.h:219
g2c_section6_info
Information about Section 6 BIT-MAP SECTION.
Definition grib2_int.h:230
g2c_section_info
Information about a section 3 through 7 in a GRIB2 message.
Definition grib2_int.h:171
gtemplate
Struct for GRIB template, returned by getgridtemplate().
Definition grib2_int.h:278