Loading...
Searching...
No Matches
grib2.h
Go to the documentation of this file.
#ifndef _grib2_H
#define _grib2_H
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#define G2C_VERSION "2.3.0"
#define G2_PNG_ENABLED 1
#define G2_JPEG2000_ENABLED 1
#define G2_AEC_ENABLED 1
typedef int64_t g2int;
typedef uint64_t g2intu;
typedef float g2float;
struct gribfield
{
g2int version;
g2int discipline;
g2int *idsect;
g2int idsectlen;
unsigned char *local;
g2int locallen;
g2int ifldnum;
g2int griddef;
g2int ngrdpts;
g2int numoct_opt;
g2int interp_opt;
g2int num_opt;
g2int *list_opt;
g2int igdtnum;
g2int igdtlen;
g2int *igdtmpl;
g2int ipdtnum;
g2int ipdtlen;
g2int *ipdtmpl;
g2int num_coord;
float *coord_list;
g2int ndpts;
g2int idrtnum;
g2int idrtlen;
g2int *idrtmpl;
g2int unpacked;
g2int expanded;
g2int ibmap;
g2int *bmap;
float *fld;
};
typedef struct gribfield gribfield;
/* Prototypes for unpacking sections API */
g2int g2_unpack1(unsigned char *cgrib, g2int *iofst, g2int **ids, g2int *idslen);
g2int g2_unpack2(unsigned char *cgrib, g2int *iofst, g2int *lencsec2,
unsigned char **csec2);
g2int g2_unpack3(unsigned char *cgrib, g2int *iofst, g2int **igds, g2int **igdstmpl,
g2int *mapgridlen, g2int **ideflist, g2int *idefnum);
g2int g2_unpack4(unsigned char *cgrib, g2int *iofst, g2int *ipdsnum, g2int **ipdstmpl,
g2int *mappdslen, float **coordlist, g2int *numcoord);
g2int g2_unpack5(unsigned char *cgrib, g2int *iofst, g2int *ndpts, g2int *idrsnum,
g2int **idrstmpl, g2int *mapdrslen);
g2int g2_unpack6(unsigned char *cgrib, g2int *iofst, g2int ngpts, g2int *ibmap,
g2int **bmap);
g2int g2_unpack7(unsigned char *cgrib, g2int *iofst, g2int igdsnum, g2int *igdstmpl,
g2int idrsnum, g2int *idrstmpl, g2int ndpts, float **fld);
/* Prototypes for unpacking API */
void seekgb(FILE *lugb, g2int iseek, g2int mseek, g2int *lskip,
g2int *lgrib);
g2int g2_info(unsigned char *cgrib, g2int *listsec0, g2int *listsec1,
g2int *numfields, g2int *numlocal);
g2int g2_getfld(unsigned char *cgrib, g2int ifldnum, g2int unpack, g2int expand,
gribfield **gfld);
void g2_free(gribfield *gfld);
/* Prototypes for packing API */
g2int g2_create(unsigned char *cgrib, g2int *listsec0, g2int *listsec1);
g2int g2_addlocal(unsigned char *cgrib, unsigned char *csec2, g2int lcsec2);
g2int g2_addgrid(unsigned char *cgrib, g2int *igds, g2int *igdstmpl, g2int *ideflist,
g2int idefnum);
g2int g2_addfield(unsigned char *cgrib, g2int ipdsnum, g2int *ipdstmpl,
float *coordlist, g2int numcoord, g2int idrsnum, g2int *idrstmpl,
float *fld, g2int ngrdpts, g2int ibmap, g2int *bmap);
g2int g2_gribend(unsigned char *cgrib);
/* The file-based g2c API was introduced in version 2.0.0 of the library. */
/* Data types. */
#define G2C_BYTE 1
#define G2C_CHAR 2
#define G2C_SHORT 3
#define G2C_INT 4
#define G2C_FLOAT 5
#define G2C_DOUBLE 6
#define G2C_UBYTE 7
#define G2C_USHORT 8
#define G2C_UINT 9
#define G2C_INT64 10
#define G2C_UINT64 11
/* Defines for file handling. */
#define G2C_MAX_FILES 3
#define G2C_MAX_NAME 1024
#define G2C_NOWRITE 0x0000
#define G2C_WRITE 0x0001
#define G2C_CLOBBER 0x0000
#define G2C_NOCLOBBER 0x0004
#define G2C_LARGE_FILE_INDEX 0x0008
/* Useful constants. */
#define G2C_SECTION0_BYTES 16
#define G2C_SECTION1_BYTES 21
#define G2C_SECTION0_LEN 3
#define G2C_SECTION1_LEN 13
/* Constants to help with templates. */
#define G2C_MAX_GDS_TEMPLATE 38
#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28
#define G2C_MAX_PDS_TEMPLATE 102
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50
#define G2C_MAX_DRS_TEMPLATE 11
#define G2C_MAX_DRS_TEMPLATE_MAPLEN 18
/* File handling functions. */
int g2c_open(const char *path, int mode, int *g2cid);
int g2c_open_index(const char *data_file, const char *index_file, int mode, int *g2cid);
int g2c_close(int g2cid);
int g2c_write_index(int g2cid, int mode, const char *index_file);
/* GRIB1 file functions. */
int g2c_open_index1(const char *index_file);
/* Inquiry functions. */
int g2c_inq(int g2cid, int *num_msg);
int g2c_inq_msg(int g2cid, int msg_num, unsigned char *discipline, int *num_fields,
int *num_local, short *center, short *subcenter, unsigned char *master_version,
unsigned char *local_version);
int g2c_inq_msg_time(int g2cid, int msg_num, unsigned char *sig_ref_time, short *year,
unsigned char *month, unsigned char *day, unsigned char *hour,
unsigned char *minute, unsigned char *second);
int g2c_inq_prod(int g2cid, int msg_num, int prod_num, int *pds_template_len,
long long int *pds_template, int *gds_template_len, long long int *gds_template,
int *drs_template_len, long long int *drs_template);
int g2c_inq_dim(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len,
char *name, float *val);
int g2c_inq_dim_info(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len,
char *name);
/* Getting data. */
int g2c_get_prod(int g2cid, int msg_num, int prod_num, int *num_data_points,
float *data);
/* Templates. */
int g2c_get_grid_template(int grid_template_num, int *maplen, int *map, int *needext);
int g2c_get_grid_template_extension(int grid_template_num, int *g2c_template,
int *extlen, int *ext);
int g2c_get_pds_template_extension(int pds_template_num, int *g2c_template,
int *extlen, int *ext);
int g2c_get_gdt_len(int grid_template_num, int *maplen);
int g2c_get_pds_template(int pds_template_num, int *maplen, int *map, int *needext);
int g2c_get_pdt_len(int pds_template_num, int *maplen);
int g2c_get_drs_template(int drs_template_num, int *maplen, int *map, int *needext);
/* Internal functions. */
int g2c_get_msg(int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg,
size_t *bytes_in_msg, unsigned char **cbuf);
int g2c_find_msg2(int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg,
size_t *bytes_in_msg);
int g2c_csv_init();
int g2c_find_desc_str(char *title, char *code, char *desc);
int g2c_find_desc(char *title, int code, char *desc);
void g2c_free_tables();
void g2c_gbit_int(unsigned char *in, int *iout, int iskip, int nbits);
int g2c_gbits_int(unsigned char *in, int *iout, int iskip, int nbits,
int nskip, int n);
int g2c_seekmsg(int g2cid, size_t skip, size_t *offset, size_t *msglen);
/* Logging, for debugging purposes. */
int g2c_set_log_level(int new_level);
int g2c_log_file(int g2cid);
/* Error handling. */
const char *g2c_strerror(int g2cerr);
/* Compression. */
int g2c_unpack7(unsigned char *cgrib, int igdsnum, int gds_tmpl_len, long long int *gdstmpl,
int idrsnum, int drs_tmpl_len, long long int *drstmpl, int ndpts, float *fld);
int g2c_pngpackf(float *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, int *lcpack);
int g2c_pngpackd(double *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, int *lcpack);
int g2c_pngunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
float *fld);
int g2c_pngunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
double *fld);
int g2c_jpcpackf(float *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, size_t *lcpack);
int g2c_jpcpackd(double *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, size_t *lcpack);
int g2c_jpcunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
float *fld);
int g2c_jpcunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
double *fld);
int g2c_enc_jpeg2000(unsigned char *cin, int width, int height, int nbits,
int ltype, int ratio, int retry, char *outjpc,
size_t jpclen);
int g2c_dec_jpeg2000(char *injpc, size_t bufsize, int *outfld);
int g2c_enc_png(unsigned char *data, int width, int height, int nbits,
unsigned char *pngbuf);
int g2c_dec_png(unsigned char *pngbuf, int *width, int *height,
unsigned char *cout);
int g2c_enc_aec(unsigned char *data, int ctemplen, int nbits, int flags,
int block_size, int rsi, unsigned char *aecbuf, int *aecbuflen);
int g2c_dec_aec(unsigned char *cpack, int len, int nbits, int flags,
int block_size, int rsi, unsigned char *cfld, int cfldlen);
int g2c_aecpackf(float *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, size_t *lcpack);
int g2c_aecpackd(double *fld, size_t width, size_t height, int *idrstmpl,
unsigned char *cpack, size_t *lcpack);
int g2c_aecunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
float *fld);
int g2c_aecunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts,
double *fld);
/* Testing. */
int g2c_compare(int g2cid1, int g2cid2);
/* Output. */
int g2c_degrib2(int g2cid, const char *fileout);
/* Parameters. */
int g2c_param_g1tog2(int g1val, int g1ver, int *g2disc, int *g2cat, int *g2num);
int g2c_param_abbrev(int g2disc, int g2cat, int g2num, char *abbrev);
int g2c_param_g2tog1(int g2disc, int g2cat, int g2num, int *g1val, int *g1ver);
int g2c_param_all(int param_idx, int *g1ver, int *g1val, int *g2disc, int *g2cat,
int *g2num, char *abbdrev);
/* Useful constants. */
#define G2C_SECTION0_ARRAY_LEN 3
#define G2C_SECTION1_ARRAY_LEN 13
#define G2C_JPEG_DRS_TEMPLATE_LEN 7
#define G2C_PNG_DRS_TEMPLATE_LEN 5
#define G2C_AEC_DRS_TEMPLATE_LEN 8
#define G2C_MAX_GRIB_DESC_LEN 512
#define G2C_MAX_GRIB_STATUS_LEN 40
#define G2C_MAX_GRIB_LEVEL_DESC_LEN 40
#define G2C_MAX_GRIB_CODE_LEN 20
#define G2C_MAX_GRIB_TITLE_LEN 200
#define G2C_MAX_NUM_SECTIONS 1024
#define G2C_MAX_NOAA_PARAMS 2000
#define G2C_MAX_NOAA_ABBREV_LEN 11
#define G2C_MAX_NOAA_PARAM_LINE_LEN 120
#define G2C_JASPER_MAX_MEM
#define G2C_PNG_WIDTH_MAX 100000000
#define G2C_PNG_HEIGHT_MAX 100000
/* Error codes for G2 API. */
#define G2_NO_ERROR 0
#define G2_CREATE_GRIB_VERSION -1
#define G2_INFO_NO_GRIB 1
#define G2_INFO_GRIB_VERSION 2
#define G2_INFO_NO_SEC1 3
#define G2_INFO_WRONG_END 4
#define G2_INFO_BAD_END 5
#define G2_INFO_INVAL_SEC 6
#define G2_GETFLD_NO_GRIB 1
#define G2_GETFLD_GRIB_VERSION 2
#define G2_GETFLD_INVAL 3
#define G2_GETFLD_WRONG_END 4
#define G2_GETFLD_WRONG_NFLDS 6
#define G2_GETFLD_BAD_END 7
#define G2_GETFLD_INVAL_SEC 8
#define G2_GETFLD_NO_DRT 9
#define G2_GETFLD_BAD_SEC1 15
#define G2_GETFLD_BAD_SEC2 16
#define G2_GETFLD_BAD_SEC3 10
#define G2_GETFLD_BAD_SEC4 11
#define G2_GETFLD_BAD_SEC5 12
#define G2_GETFLD_BAD_SEC6 13
#define G2_GETFLD_BAD_SEC7 14
#define G2_GETFLD_NO_BITMAP 17
#define G2_GRIBEND_MSG_INIT -1
#define G2_BAD_SEC -4
#define G2_UNPACK_BAD_SEC 2
#define G2_UNPACK_NO_MEM 6
#define G2_UNPACK3_BAD_GDT 5
#define G2_UNPACK4_BAD_PDT 5
#define G2_UNPACK5_BAD_DRT 7
#define G2_UNPACK6_BAD_BITMAP 4
#define G2_UNPACK7_CORRUPT_SEC 7
#define G2_UNPACK7_WRONG_GDT 5
#define G2_UNPACK7_BAD_DRT 4
#define G2_ADD_MSG_INIT -1
#define G2_ADD_MSG_COMPLETE -2
#define G2_BAD_SEC_COUNTS -3
#define G2_ADDFIELD_BAD_PDT -5
#define G2_ADDFIELD_BAD_GDS -6
#define G2_ADDFIELD_BAD_DRT -7
#define G2_ADDFIELD_BAD_BITMAP -8
#define G2_ADDFIELD_BAD_GDT -9
#define G2_ADDFIELD_ERR -10
#define G2_ADDGRID_BAD_GDT -5
#define G2_JPCUNPACK_MEM 1
#define G2_SPECUNPACK_TYPE -3
#define G2_JASPER_INIT -2
#define G2_JASPER_ENCODE -3
#define G2_JASPER_DECODE -3
#define G2_JASPER_DECODE_COLOR -5
/* These are the new error codes. */
#define G2C_NOERROR 0
#define G2C_ERROR 1
#define G2C_ENOTGRIB (-50)
#define G2C_EMSGCOMPLETE (-51)
#define G2C_ENAMETOOLONG (-52)
#define G2C_EINVAL (-53)
#define G2C_EFILE (-54)
#define G2C_EBADID (-55)
#define G2C_ETOOMANYFILES (-56)
#define G2C_ENOMEM (-57)
#define G2C_EMSG (-58)
#define G2C_ENOMSG (-59)
#define G2C_EXML (-60)
#define G2C_ENOTFOUND (-61)
#define G2C_ENOTGRIB2 (-62)
#define G2C_ENOSECTION (-63)
#define G2C_ENOEND (-64)
#define G2C_EBADEND (-65)
#define G2C_EBADSECTION (-66)
#define G2C_EJPEG (-67)
#define G2C_EPNG (-68)
#define G2C_ENOTEMPLATE (-69)
#define G2C_EBADTEMPLATE (-70)
#define G2C_ENOPARAM (-71)
#define G2C_ENOPRODUCT (-72)
#define G2C_EBADTYPE (-73)
#define G2C_EAEC (-74)
#define G2C_ECSV (-75)
#endif /* _grib2_H */
g2_unpack5
g2int g2_unpack5(unsigned char *cgrib, g2int *iofst, g2int *ndpts, g2int *idrsnum, g2int **idrstmpl, g2int *mapdrslen)
Unpack Section 5 (Data Representation Section) of a GRIB2 message.
Definition g2_unpack5.c:40
gribfield::igdtnum
g2int igdtnum
Grid Definition Template Number (See Table 3.1).
Definition grib2.h:148
g2_free
void g2_free(gribfield *gfld)
Free memory that was allocated for struct gribfield.
Definition g2_free.c:23
gribfield::locallen
g2int locallen
Length of array local.
Definition grib2.h:110
g2_create
g2int g2_create(unsigned char *cgrib, g2int *listsec0, g2int *listsec1)
Initialize a new GRIB2 message and pack GRIB2 Section 0 (Indicator Section) and Section 1 (Identifica...
Definition g2_create.c:68
gribfield::ibmap
g2int ibmap
Bitmap indicator (see Table 6.0).
Definition grib2.h:211
g2c_inq
int g2c_inq(int g2cid, int *num_msg)
Learn about a GRIB2 file.
Definition g2cinq.c:31
g2c_open_index
int g2c_open_index(const char *data_file, const char *index_file, int mode, int *g2cid)
Open a GRIB2 file with the help of an index file.
Definition g2cindex.c:914
g2_addgrid
g2int g2_addgrid(unsigned char *cgrib, g2int *igds, g2int *igdstmpl, g2int *ideflist, g2int idefnum)
Packs a Grid Definition Section (Section 3) and adds it to a GRIB2 message.
Definition g2_addgrid.c:66
g2c_jpcunpackd
int g2c_jpcunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)
Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representati...
Definition jpcunpack.c:199
g2c_aecpackf
int g2c_aecpackf(float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)
This function packs up a float array into a AEC code stream.
Definition aecpack.c:346
gribfield::interp_opt
g2int interp_opt
Interpretation of list for optional points definition.
Definition grib2.h:133
gribfield::ngrdpts
g2int ngrdpts
Number of grid points in the defined grid.
Definition grib2.h:123
g2c_find_desc_str
int g2c_find_desc_str(char *title, char *code, char *desc)
Given a table title and a code, find a description.
Definition g2ccsv.c:84
g2c_dec_jpeg2000
int g2c_dec_jpeg2000(char *injpc, size_t bufsize, int *outfld)
Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) using...
Definition decenc_jpeg2000.c:350
g2c_open
int g2c_open(const char *path, int mode, int *g2cid)
Open an existing GRIB2 file.
Definition g2cfile.c:1201
g2c_strerror
const char * g2c_strerror(int g2cerr)
Given an error code, return an error message.
Definition g2cutil.c:29
seekgb
void seekgb(FILE *lugb, g2int iseek, g2int mseek, g2int *lskip, g2int *lgrib)
Search a file for the next GRIB Message.
Definition seekgb.c:46
g2c_jpcpackd
int g2c_jpcpackd(double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)
This function packs up a double array into a JPEG2000 code stream.
Definition jpcpack.c:386
g2c_param_g2tog1
int g2c_param_g2tog1(int g2disc, int g2cat, int g2num, int *g1val, int *g1ver)
Translate GRIB2 parameter to GRIB1 parameter.
Definition g2cparams.c:1475
gribfield::ifldnum
g2int ifldnum
Field number within GRIB message.
Definition grib2.h:113
g2c_jpcunpackf
int g2c_jpcunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)
Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representatio...
Definition jpcunpack.c:159
g2float
float g2float
Float type.
Definition grib2.h:40
g2c_param_abbrev
int g2c_param_abbrev(int g2disc, int g2cat, int g2num, char *abbrev)
Get NOAA abbreviation for a GRIB2 parameter.
Definition g2cparams.c:1430
g2c_open_index1
int g2c_open_index1(const char *index_file)
Open a GRIB1 index file and read the contents.
Definition g2cindex.c:812
g2c_pngunpackd
int g2c_pngunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
Definition pngunpack.c:188
g2_unpack7
g2int g2_unpack7(unsigned char *cgrib, g2int *iofst, g2int igdsnum, g2int *igdstmpl, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float **fld)
This subroutine unpacks Section 7 (Data Section) of a GRIB2 message.
Definition g2_unpack7.c:214
g2_unpack4
g2int g2_unpack4(unsigned char *cgrib, g2int *iofst, g2int *ipdsnum, g2int **ipdstmpl, g2int *mappdslen, float **coordlist, g2int *numcoord)
Unpack Section 4 (Product Definition Section) of a GRIB2 message.
Definition g2_unpack4.c:45
g2c_enc_aec
int g2c_enc_aec(unsigned char *data, int ctemplen, int nbits, int flags, int block_size, int rsi, unsigned char *aecbuf, int *aecbuflen)
Encode data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:215
g2c_get_pdt_len
int g2c_get_pdt_len(int pds_template_num, int *maplen)
Get initial length (number of entries) in static part of PDS template.
Definition pdstemplates.c:1848
g2c_aecunpackd
int g2c_aecunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)
Unpack AEC compressed data into an array of doubles, using info from the GRIB2 Data Representation Te...
Definition aecunpack.c:232
gribfield::griddef
g2int griddef
Source of grid definition (see Table 3.0).
Definition grib2.h:120
g2c_find_desc
int g2c_find_desc(char *title, int code, char *desc)
Given a table title and an integer code, find a description.
Definition g2ccsv.c:131
gribfield::ipdtnum
g2int ipdtnum
Product Definition Template Number (see Table 4.0).
Definition grib2.h:160
gribfield::ipdtmpl
g2int * ipdtmpl
Contains the data values for the Product Definition Template specified by ipdtnum.
Definition grib2.h:168
gribfield::discipline
g2int discipline
Message Discipline (see Table 0.0).
Definition grib2.h:52
g2_unpack2
g2int g2_unpack2(unsigned char *cgrib, g2int *iofst, g2int *lencsec2, unsigned char **csec2)
Unpack Section 2 (Local Use Section) of a GRIB2 message.
Definition g2_unpack2.c:37
g2c_enc_jpeg2000
int g2c_enc_jpeg2000(unsigned char *cin, int width, int height, int nbits, int ltype, int ratio, int retry, char *outjpc, size_t jpclen)
Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
Definition decenc_jpeg2000.c:45
g2c_csv_init
int g2c_csv_init()
Initialize tables from "CodeFlag.txt".
Definition g2ccsv.c:215
gribfield::numoct_opt
g2int numoct_opt
Number of octets needed for each additional grid points definition.
Definition grib2.h:128
g2_unpack1
g2int g2_unpack1(unsigned char *cgrib, g2int *iofst, g2int **ids, g2int *idslen)
Unpacks Section 1 - Identification Section of a GRIB2 message.
Definition g2_unpack1.c:55
g2c_get_pds_template
int g2c_get_pds_template(int pds_template_num, int *maplen, int *map, int *needext)
Get PDS template information.
Definition pdstemplates.c:1806
g2c_pngpackd
int g2c_pngpackd(double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack)
This subroutine packs up a double data field into PNG image format.
Definition pngpack.c:348
gribfield::idrtlen
g2int idrtlen
Number of elements in idrtmpl.
Definition grib2.h:186
g2c_get_grid_template_extension
int g2c_get_grid_template_extension(int grid_template_num, int *g2c_template, int *extlen, int *ext)
Get grid template extension information.
Definition gridtemplates.c:316
g2c_close
int g2c_close(int g2cid)
Close a GRIB2 file, freeing resources.
Definition g2cfile.c:1367
gribfield::unpacked
g2int unpacked
Logical value indicating whether the bitmap and data values were unpacked.
Definition grib2.h:194
g2c_jpcpackf
int g2c_jpcpackf(float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)
This function packs up a float array into a JPEG2000 code stream.
Definition jpcpack.c:320
g2c_degrib2
int g2c_degrib2(int g2cid, const char *fileout)
Write a summary file like the degrib2 utility.
Definition g2cdegrib2.c:634
g2_unpack6
g2int g2_unpack6(unsigned char *cgrib, g2int *iofst, g2int ngpts, g2int *ibmap, g2int **bmap)
Unpack Section 6 (Bit-Map Section) of a GRIB2 message.
Definition g2_unpack6.c:32
g2_gribend
g2int g2_gribend(unsigned char *cgrib)
Finalize a GRIB2 message after all grids and fields have been added.
Definition g2_gribend.c:40
g2c_pngunpackf
int g2c_pngunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t 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:156
gribfield::idsectlen
g2int idsectlen
Number of elements in idsect.
Definition grib2.h:103
gribfield::ipdtlen
g2int ipdtlen
Number of elements in ipdtmpl - i.e.
Definition grib2.h:164
g2c_inq_dim
int g2c_inq_dim(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len, char *name, float *val)
Learn about the one of the dimensions of a GRIB2 product.
Definition g2cinq.c:372
g2c_inq_msg_time
int g2c_inq_msg_time(int g2cid, int msg_num, unsigned char *sig_ref_time, short *year, unsigned char *month, unsigned char *day, unsigned char *hour, unsigned char *minute, unsigned char *second)
Learn about the date/time information in a GRIB2 message.
Definition g2cinq.c:170
g2c_inq_prod
int g2c_inq_prod(int g2cid, int msg_num, int prod_num, int *pds_template_len, long long int *pds_template, int *gds_template_len, long long int *gds_template, int *drs_template_len, long long int *drs_template)
Inquire about a product.
Definition g2cinq.c:247
g2intu
uint64_t g2intu
Unsigned long integer type.
Definition grib2.h:36
gribfield::coord_list
float * coord_list
Array containing floating point values intended to document the vertical discretisation associated to...
Definition grib2.h:176
g2c_free_tables
void g2c_free_tables()
Free table memory.
Definition g2ccsv.c:42
g2c_enc_png
int g2c_enc_png(unsigned char *data, int width, int height, int nbits, unsigned char *pngbuf)
Encode PNG.
Definition decenc_png.c:237
g2c_get_msg
int g2c_get_msg(int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t *bytes_in_msg, unsigned char **cbuf)
Search a file for the next GRIB1 or GRIB2 message, and read it, allocating space in memory to hold th...
Definition g2cfile.c:291
g2c_set_log_level
int g2c_set_log_level(int new_level)
Use this to set the global log level.
Definition util.c:165
g2c_inq_msg
int g2c_inq_msg(int g2cid, int msg_num, unsigned char *discipline, int *num_fields, int *num_local, short *center, short *subcenter, unsigned char *master_version, unsigned char *local_version)
Learn about a GRIB2 message.
Definition g2cinq.c:87
gribfield::igdtmpl
g2int * igdtmpl
Contains the data values for the Grid Definition Template specified by igdtnum.
Definition grib2.h:156
gribfield::idrtnum
g2int idrtnum
Data Representation Template Number (see Table 5.0).
Definition grib2.h:183
g2c_write_index
int g2c_write_index(int g2cid, int mode, const char *index_file)
Create an index file from a GRIB2 file, just like those created by the grb2index utility.
Definition g2cindex.c:431
g2c_inq_dim_info
int g2c_inq_dim_info(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len, char *name)
Learn about the one of the dimensions of a GRIB2 product.
Definition g2cinq.c:468
g2_addlocal
g2int g2_addlocal(unsigned char *cgrib, unsigned char *csec2, g2int lcsec2)
Adds a Local Use Section (Section 2) to a GRIB2 message.
Definition g2_addlocal.c:41
gribfield::ndpts
g2int ndpts
Number of data points unpacked and returned.
Definition grib2.h:179
g2c_get_drs_template
int g2c_get_drs_template(int drs_template_num, int *maplen, int *map, int *needext)
Get DRS template information.
Definition drstemplates.c:266
g2c_param_all
int g2c_param_all(int param_idx, int *g1ver, int *g1val, int *g2disc, int *g2cat, int *g2num, char *abbdrev)
Return all the information about a parameter.
Definition g2cparams.c:1524
gribfield::idrtmpl
g2int * idrtmpl
Contains the data values for the Data Representation Template specified by idrtnum.
Definition grib2.h:190
g2c_find_msg2
int g2c_find_msg2(int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t *bytes_in_msg)
Search a file for the next GRIB1 or GRIB2 message.
Definition g2cfile.c:164
gribfield::list_opt
g2int * list_opt
(Used if numoct_opt .ne.
Definition grib2.h:144
g2c_get_prod
int g2c_get_prod(int g2cid, int msg_num, int prod_num, int *num_data_points, float *data)
Read the data for a product.
Definition g2cprod.c:32
g2c_param_g1tog2
int g2c_param_g1tog2(int g1val, int g1ver, int *g2disc, int *g2cat, int *g2num)
Translate GRIB1 parameter to GRIB2 parameter.
Definition g2cparams.c:1390
g2c_unpack7
int g2c_unpack7(unsigned char *cgrib, int igdsnum, int gds_tmpl_len, long long int *gdstmpl, int idrsnum, int drs_tmpl_len, long long int *drstmpl, int ndpts, float *fld)
This subroutine unpacks Section 7 (Data Section) of a GRIB2 message.
Definition g2_unpack7.c:259
g2c_get_pds_template_extension
int g2c_get_pds_template_extension(int pds_template_num, int *g2c_template, int *extlen, int *ext)
Get pds template extension information.
Definition pdstemplates.c:1731
g2_getfld
g2int g2_getfld(unsigned char *cgrib, g2int ifldnum, g2int unpack, g2int expand, gribfield **gfld)
Return all the metadata, template values, bit-map (if applicable), and the unpacked data for a data f...
Definition g2_getfld.c:93
g2c_dec_aec
int g2c_dec_aec(unsigned char *cpack, int len, int nbits, int flags, int block_size, int rsi, unsigned char *cfld, int cfldlen)
Decode an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
Definition decenc_aec.c:179
g2_info
g2int g2_info(unsigned char *cgrib, g2int *listsec0, g2int *listsec1, g2int *numfields, g2int *numlocal)
Search through a GRIB2 message and return the number of gridded fields found in the message and the n...
Definition g2_info.c:70
gribfield::version
g2int version
GRIB edition number (2).
Definition grib2.h:48
g2c_aecpackd
int g2c_aecpackd(double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)
This function packs up a double array into a AEC code stream.
Definition aecpack.c:410
g2c_dec_png
int g2c_dec_png(unsigned char *pngbuf, int *width, int *height, unsigned char *cout)
Decode PNG.
Definition decenc_png.c:100
g2c_log_file
int g2c_log_file(int g2cid)
Print a summary of the contents of an open GRIB2 file.
Definition g2cutil.c:189
g2_addfield
g2int g2_addfield(unsigned char *cgrib, g2int ipdsnum, g2int *ipdstmpl, float *coordlist, g2int numcoord, g2int idrsnum, g2int *idrstmpl, float *fld, g2int ngrdpts, g2int ibmap, g2int *bmap)
Pack sections 4 through 7 and adds them to a GRIB2 message.
Definition g2_addfield.c:100
gribfield::idsect
g2int * idsect
Contains the entries in the Identification Section (Section 1).
Definition grib2.h:100
gribfield::fld
float * fld
Array of ndpts unpacked data points.
Definition grib2.h:218
gribfield::num_coord
g2int num_coord
Number of values in array coord_list.
Definition grib2.h:171
g2_unpack3
g2int g2_unpack3(unsigned char *cgrib, g2int *iofst, g2int **igds, g2int **igdstmpl, g2int *mapgridlen, g2int **ideflist, g2int *idefnum)
Unpack Section 3 (Grid Definition Section) of a GRIB2 message.
Definition g2_unpack3.c:62
g2c_gbits_int
int g2c_gbits_int(unsigned char *in, int *iout, int iskip, int nbits, int nskip, int n)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked i...
Definition gbits.c:137
gribfield::local
unsigned char * local
Pointer to character array containing contents of Local Section 2, if included.
Definition grib2.h:107
gribfield::expanded
g2int expanded
Logical value indicating whether the data field was expanded to the grid in the case where a bit-map ...
Definition grib2.h:203
gribfield::num_opt
g2int num_opt
(Used if numoct_opt .ne.
Definition grib2.h:139
g2c_pngpackf
int g2c_pngpackf(float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack)
This subroutine packs up a float data field into PNG image format.
Definition pngpack.c:294
gribfield::igdtlen
g2int igdtlen
Number of elements in igdtmpl - i.e.
Definition grib2.h:152
g2c_compare
int g2c_compare(int g2cid1, int g2cid2)
Compare the metadata of two open GRIB2 files.
Definition g2ccompare.c:28
gribfield::bmap
g2int * bmap
Integer array containing decoded bitmap, if ibmap=0 or ibap=254.
Definition grib2.h:215
g2c_aecunpackf
int g2c_aecunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)
Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation Tem...
Definition aecunpack.c:194
g2c_get_gdt_len
int g2c_get_gdt_len(int grid_template_num, int *maplen)
Get initial length (number of entries) in static part of Grid Definition Template.
Definition gridtemplates.c:433
g2int
int64_t g2int
Long integer type.
Definition grib2.h:32
g2c_get_grid_template
int g2c_get_grid_template(int grid_template_num, int *maplen, int *map, int *needext)
Get grid template information.
Definition gridtemplates.c:391
g2c_seekmsg
int g2c_seekmsg(int g2cid, size_t skip, size_t *offset, size_t *msglen)
Search a file for the next GRIB2 Message.
Definition g2cfile.c:56
g2c_gbit_int
void g2c_gbit_int(unsigned char *in, int *iout, int iskip, int nbits)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked i...
Definition gbits.c:113
gribfield
Struct for GRIB2 field.
Definition grib2.h:46