Man page - idrtlen(3)
Packages contains this manual
- g2c_get_drs_template(3)
- sbits(3)
- cmplxpack(3)
- g2_unpack4.c(3)
- g2_info.c(3)
- reduce(3)
- g2c_get_msg(3)
- specpack(3)
- g2intu(3)
- int_power.c(3)
- bytes_to_bms(3)
- g2c_file_io_byte(3)
- dimid(3)
- idrtnum(3)
- g2ccsv.c(3)
- g2c_pngpackd(3)
- g2c_file_io(3)
- decenc_png.c(3)
- g2_miss.c(3)
- file(3)
- g2c_open_index1(3)
- g2_unpack2(3)
- g2int(3)
- pngunpack(3)
- specpack.c(3)
- g2cutil.c(3)
- g2c_rw_section6_metadata(3)
- g2_addgrid(3)
- g2c_next_g2cid(3)
- sec_len(3)
- g2c_inq_dim(3)
- jpcunpack.c(3)
- png_stream(3)
- maplen(3)
- minute(3)
- subcenter(3)
- g2c_inq(3)
- g2_unpack5.c(3)
- g2c_file_io_template(3)
- dec_aec(3)
- griddef(3)
- num_opt(3)
- g2num(3)
- decenc_openjpeg.c(3)
- g2c_file_io_ubyte(3)
- map(3)
- bytes_to_msg(3)
- g1num(3)
- jpcunpack_int(3)
- g2c_aecunpackd(3)
- num_local(3)
- pngpack_int(3)
- read_hdr_rec2(3)
- g2_addfield(3)
- aecpack.c(3)
- section_number(3)
- status(3)
- bytes_to_sec(3)
- g2_addfield.c(3)
- drstemplates.c(3)
- year(3)
- g2c_degrib2(3)
- g2_create.c(3)
- misspack(3)
- version(3)
- enc_aec(3)
- g2c_dec_jpeg2000(3)
- g2c_enc_jpeg2000(3)
- extgridtemplate(3)
- next(3)
- section_offset(3)
- g2c_open(3)
- read_msg_metadata(3)
- num_data_points(3)
- unpacked(3)
- jpcpack(3)
- igdtnum(3)
- g2_gribend(3)
- bytes_in_msg(3)
- g2c_file_io_ulonglong(3)
- discipline(3)
- dim(3)
- g2c_rw_section1_metadata(3)
- g2_create(3)
- free_metadata(3)
- g2c_open_index(3)
- g2c_find_table(3)
- g2_unpack7.c(3)
- g2c_csv_init(3)
- templatesgrid(3)
- g2c_log_section(3)
- g2c_csv_strsep(3)
- main(3)
- g2c_param_all(3)
- data_def(3)
- g2c_log_section1(3)
- aecunpack_int(3)
- g2_getfld(3)
- reduce.c(3)
- pack_gp(3)
- g2c_gbit_int(3)
- extpdstemplate(3)
- g2cio.c(3)
- g2c_inq_prod(3)
- sec1_len(3)
- g2c_file(3)
- g2c_start_index_record_lf(3)
- int_dec_jpeg2000(3)
- g2c_seekmsg(3)
- g2_addlocal(3)
- g2c_set_log_level(3)
- g2cat(3)
- gbits.c(3)
- g2c_get_pds_template(3)
- numoct_opt(3)
- g2c_aecpackd(3)
- simunpack.c(3)
- igdtlen(3)
- grib2.h(3)
- g2c_table(3)
- g2c_jpcunpackf(3)
- num(3)
- expanded(3)
- getgridtemplate(3)
- g2c_file_io_longlong(3)
- gbit(3)
- g2c_rw_section5_metadata(3)
- sig_ref_time(3)
- g2c_find_desc(3)
- g2c_write_index(3)
- month(3)
- g2_unpack1.c(3)
- idrtlen(3)
- g2c_free_tables(3)
- g2_getfld.c(3)
- decenc_aec.c(3)
- g2c_start_index1_record(3)
- fld(3)
- g2cinq.c(3)
- g2c_pngunpackd(3)
- g2c_file_io_uint(3)
- num_fields(3)
- g2cdegrib2.c(3)
- format_level(3)
- gtemplate(3)
- decenc_jpeg2000.c(3)
- g2c_add_file(3)
- f(3)
- source_grid_def(3)
- g2c_compare(3)
- g2_unpack6(3)
- msg(3)
- g2_unpack1(3)
- compack(3)
- g2c_start_index_record(3)
- g2c_file_io_short(3)
- g2c_inq_dim_info(3)
- bmap(3)
- len(3)
- g2c_get_datetime(3)
- g2_unpack4(3)
- master_version(3)
- ndpts(3)
- abbrev(3)
- igdtmpl(3)
- prod_def(3)
- comunpack(3)
- center(3)
- pdstemplates.c(3)
- hton64(3)
- field_num(3)
- simpack.c(3)
- g2_gribend.c(3)
- ipdtnum(3)
- g2c_jpcunpackd(3)
- type(3)
- title(3)
- rdieee(3)
- getdrstemplate(3)
- bytes_to_data(3)
- code(3)
- add_section(3)
- g2c_rw_section3_metadata(3)
- g2c_unpack7_int(3)
- extdrstemplate(3)
- dec_png(3)
- getpoly.c(3)
- specunpack(3)
- entry(3)
- num_messages(3)
- g2c_log_file(3)
- g2c_file_io_int(3)
- mkieee(3)
- cmplxpack.c(3)
- dec_jpeg2000(3)
- g2_addgrid.c(3)
- num_sections(3)
- getpoly(3)
- g2c_dec_png(3)
- g1ver(3)
- ibmap(3)
- sec(3)
- user_flush_data(3)
- g2c_jpcpackd(3)
- jpcpack_int(3)
- template_len(3)
- g2float(3)
- g2c_rw_section4_metadata(3)
- local_version(3)
- indicator(3)
- compack.c(3)
- g2c_get_pds_template_extension(3)
- seekgb(3)
- g2c_get_level_desc(3)
- g2c_enc_png(3)
- gbits(3)
- pngunpack.c(3)
- msg_num(3)
- bytes_to_local(3)
- pngpack.c(3)
- user_read_data(3)
- g2cprod.c(3)
- local(3)
- specunpack.c(3)
- jpcpack.c(3)
- day(3)
- g2c_close(3)
- add_msg(3)
- aecpack(3)
- ngrdpts(3)
- g2cparams.c(3)
- g2_unpack3(3)
- list_opt(3)
- template(3)
- pngpack(3)
- g2c_inq_msg(3)
- g2cid(3)
- mkieee.c(3)
- g2c_aecunpackf(3)
- g2cfile.c(3)
- value(3)
- g2_free.c(3)
- ipdtlen(3)
- g2_free(3)
- g2_info(3)
- g2_addlocal.c(3)
- idsectlen(3)
- g2c_get_prod(3)
- g2c_gbits_int(3)
- simunpack(3)
- int_power(3)
- enc_png(3)
- section1(3)
- idsect(3)
- g2c_strerror(3)
- g2c_pngunpackf(3)
- ntoh64(3)
- templatespds(3)
- g2disc(3)
- coord_list(3)
- idrtmpl(3)
- grib2_int.h(3)
- user_write_data(3)
- rdieee.c(3)
- aecunpack(3)
- g2c_file_io_ushort(3)
- g2_unpack2.c(3)
- hour(3)
- gridtemplates.c(3)
- find_available_g2cid(3)
- interp_list(3)
- getdim(3)
- g2c_param_g2tog1(3)
- getgridindex(3)
- g2c_jpcpackf(3)
- g2_unpack6.c(3)
- comunpack.c(3)
- g2c_find_msg2(3)
- getpdstemplate(3)
- g2c_get_prod_sections(3)
- g2c_degrib2.c(3)
- g2_unpack7(3)
- extlen(3)
- aecunpack.c(3)
- param(3)
- seekgb.c(3)
- g2c_find_desc_str(3)
- misspack.c(3)
- optional(3)
- g2_unpack3.c(3)
- doc(3)
- g2ccompare.c(3)
- g2c_get_grid_template(3)
- g2c_param_g1tog2(3)
- g2c_unpack7(3)
- templatesdrs(3)
- g2c_get_grid_template_extension(3)
- path(3)
- grid_def(3)
- needext(3)
- prev(3)
- sec_info(3)
- ext(3)
- g2c_inq_msg_time(3)
- g2c_aecpackf(3)
- pngunpack_int(3)
- g2c_compare.c(3)
- g2c_param_abbrev(3)
- name(3)
- g2c_find_entry(3)
- sbit(3)
- read_hdr_rec1(3)
- gribfield(3)
- sec_num(3)
- g2cindex.c(3)
- locallen(3)
- sec_id(3)
- pack_gp.c(3)
- g2_miss(3)
- getdim.c(3)
- jpcunpack(3)
- g2_unpack5(3)
- g2c_pngpackf(3)
- read_metadata(3)
- g2c_check_msg(3)
- util.c(3)
- num_coord(3)
- desc(3)
- getpdsindex(3)
- interp_opt(3)
- getdrsindex(3)
- g2c_print_tables(3)
- enc_jpeg2000(3)
- ipdtmpl(3)
- aecpack_int(3)
- g2c_index.c(3)
- simpack(3)
- determine_dims(3)
- ifldnum(3)
apt-get install libg2c-dev
Manual
grib2.h
NAMESYNOPSIS
Data Structures
Macros
Typedefs
Functions
Detailed Description
Program History Log
Data Type Documentation
struct gribfield
Macro Definition Documentation
#define G2_ADD_MSG_COMPLETE -2
#define G2_ADD_MSG_INIT -1
#define G2_ADDFIELD_BAD_BITMAP -8
#define G2_ADDFIELD_BAD_DRT -7
#define G2_ADDFIELD_BAD_GDS -6
#define G2_ADDFIELD_BAD_GDT -9
#define G2_ADDFIELD_BAD_PDT -5
#define G2_ADDFIELD_ERR -10
#define G2_ADDGRID_BAD_GDT -5
#define G2_AEC_ENABLED 1
#define G2_BAD_SEC -4
#define G2_BAD_SEC_COUNTS -3
#define G2_CREATE_GRIB_VERSION -1
#define G2_GETFLD_BAD_END 7
#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_GRIB_VERSION 2
#define G2_GETFLD_INVAL 3
#define G2_GETFLD_INVAL_SEC 8
#define G2_GETFLD_NO_BITMAP 17
#define G2_GETFLD_NO_DRT 9
#define G2_GETFLD_NO_GRIB 1
#define G2_GETFLD_WRONG_END 4
#define G2_GETFLD_WRONG_NFLDS 6
#define G2_GRIBEND_MSG_INIT -1
#define G2_INFO_BAD_END 5
#define G2_INFO_GRIB_VERSION 2
#define G2_INFO_INVAL_SEC 6
#define G2_INFO_NO_GRIB 1
#define G2_INFO_NO_SEC1 3
#define G2_INFO_WRONG_END 4
#define G2_JASPER_DECODE -3
#define G2_JASPER_DECODE_COLOR -5
#define G2_JASPER_ENCODE -3
#define G2_JASPER_INIT -2
#define G2_JPCUNPACK_MEM 1
#define G2_JPEG2000_ENABLED 1
#define G2_NO_ERROR 0
#define G2_PNG_ENABLED 1
#define G2_SPECUNPACK_TYPE -3
#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_BAD_DRT 4
#define G2_UNPACK7_CORRUPT_SEC 7
#define G2_UNPACK7_WRONG_GDT 5
#define G2_UNPACK_BAD_SEC 2
#define G2_UNPACK_NO_MEM 6
#define G2C_AEC_DRS_TEMPLATE_LEN 8
#define G2C_BYTE 1
#define G2C_CHAR 2
#define G2C_CLOBBER 0x0000
#define G2C_DOUBLE 6
#define G2C_EAEC (-74)
#define G2C_EBADEND (-65)
#define G2C_EBADID (-55)
#define G2C_EBADSECTION (-66)
#define G2C_EBADTEMPLATE (-70)
#define G2C_EBADTYPE (-73)
#define G2C_ECSV (-75)
#define G2C_EFILE (-54)
#define G2C_EINVAL (-53)
#define G2C_EJPEG (-67)
#define G2C_EMSG (-58)
#define G2C_EMSGCOMPLETE (-51)
#define G2C_ENAMETOOLONG (-52)
#define G2C_ENOEND (-64)
#define G2C_ENOMEM (-57)
#define G2C_ENOMSG (-59)
#define G2C_ENOPARAM (-71)
#define G2C_ENOPRODUCT (-72)
#define G2C_ENOSECTION (-63)
#define G2C_ENOTEMPLATE (-69)
#define G2C_ENOTFOUND (-61)
#define G2C_ENOTGRIB (-50)
#define G2C_ENOTGRIB2 (-62)
#define G2C_EPNG (-68)
#define G2C_ERROR 1
#define G2C_ETOOMANYFILES (-56)
#define G2C_EXML (-60)
#define G2C_FLOAT 5
#define G2C_INT 4
#define G2C_INT64 10
#define G2C_JASPER_MAX_MEM
#define G2C_JPEG_DRS_TEMPLATE_LEN 7
#define G2C_LARGE_FILE_INDEX 0x0008
#define G2C_MAX_DRS_TEMPLATE 11
#define G2C_MAX_DRS_TEMPLATE_MAPLEN 18
#define G2C_MAX_FILES 3
#define G2C_MAX_GDS_TEMPLATE 38
#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28
#define G2C_MAX_GRIB_CODE_LEN 20
#define G2C_MAX_GRIB_DESC_LEN 512
#define G2C_MAX_GRIB_LEVEL_DESC_LEN 40
#define G2C_MAX_GRIB_STATUS_LEN 40
#define G2C_MAX_GRIB_TITLE_LEN 200
#define G2C_MAX_NAME 1024
#define G2C_MAX_NOAA_ABBREV_LEN 8
#define G2C_MAX_NOAA_PARAM_LINE_LEN 120
#define G2C_MAX_NOAA_PARAMS 2000
#define G2C_MAX_NUM_SECTIONS 1024
#define G2C_MAX_PDS_TEMPLATE 102
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50
#define G2C_NOCLOBBER 0x0004
#define G2C_NOERROR 0
#define G2C_NOWRITE 0x0000
#define G2C_PNG_DRS_TEMPLATE_LEN 5
#define G2C_PNG_HEIGHT_MAX 100000
#define G2C_PNG_WIDTH_MAX 100000000
#define G2C_SECTION0_ARRAY_LEN 3
#define G2C_SECTION0_BYTES 16
#define G2C_SECTION0_LEN 3
#define G2C_SECTION1_ARRAY_LEN 13
#define G2C_SECTION1_BYTES 21
#define G2C_SECTION1_LEN 13
#define G2C_SHORT 3
#define G2C_UBYTE 7
#define G2C_UINT 9
#define G2C_UINT64 11
#define G2C_USHORT 8
#define G2C_VERSION ’2.1.0’
#define G2C_WRITE 0x0001
Typedef Documentation
typedef float g2float
typedef int64_t g2int
typedef uint64_t g2intu
typedef struct gribfield gribfield
Function Documentation
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)
Program History Log
g2int g2_addgrid (unsigned char * cgrib, g2int * igds, g2int * igdstmpl,g2int * ideflist, g2int idefnum)
g2int g2_addlocal (unsigned char * cgrib, unsigned char * csec2, g2intlcsec2)
g2int g2_create (unsigned char * cgrib, g2int * listsec0, g2int * listsec1)
void g2_free (gribfield * gfld)
g2int g2_getfld (unsigned char * cgrib, g2int ifldnum, g2int unpack, g2intexpand, gribfield ** gfld)
Program History Log
Example:
g2int g2_gribend (unsigned char * cgrib)
g2int g2_info (unsigned char * cgrib, g2int * listsec0, g2int * listsec1,g2int * numfields, g2int * numlocal)
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)
Program History Log
g2int g2_unpack3 (unsigned char * cgrib, g2int * iofst, g2int ** igds,g2int ** igdstmpl, g2int * mapgridlen, g2int ** ideflist, g2int *idefnum)
Program History Log
g2int g2_unpack4 (unsigned char * cgrib, g2int * iofst, g2int * ipdsnum,g2int ** ipdstmpl, g2int * mappdslen, float ** coordlist, g2int *numcoord)
Program History Log
g2int g2_unpack5 (unsigned char * cgrib, g2int * iofst, g2int * ndpts,g2int * idrsnum, g2int ** idrstmpl, g2int * mapdrslen)
Program History Log
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)
int g2c_aecpackd (double * fld, size_t width, size_t height, int *idrstmpl, unsigned char * cpack, size_t * lcpack)
int g2c_aecpackf (float * fld, size_t width, size_t height, int * idrstmpl,unsigned char * cpack, size_t * lcpack)
int g2c_aecunpackd (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, double * fld)
int g2c_aecunpackf (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, float * fld)
int g2c_close (int g2cid)
int g2c_compare (int g2cid1, int g2cid2)
int g2c_csv_init ()
int g2c_dec_jpeg2000 (char * injpc, size_t bufsize, int * outfld)
int g2c_dec_png (unsigned char * pngbuf, int * width, int * height,unsigned char * cout)
int g2c_degrib2 (int g2cid, const char * fileout)
int g2c_enc_jpeg2000 (unsigned char * cin, int width, int height, intnbits, int ltype, int ratio, int retry, char * outjpc, size_t jpclen)
int g2c_enc_png (unsigned char * data, int width, int height, int nbits,unsigned char * pngbuf)
int g2c_find_desc (char * title, int code, char * desc)
int g2c_find_desc_str (char * title, char * code, char * desc)
int g2c_find_msg2 (int g2cid, size_t skip_bytes, size_t max_bytes, size_t *bytes_to_msg, size_t * bytes_in_msg)
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_get_drs_template (int drs_template_num, int * maplen, int * map,int * needext)
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 * template,int * extlen, int * ext)
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_get_pds_template (int pds_template_num, int * maplen, int * map,int * needext)
int g2c_get_pds_template_extension (int pds_template_num, int * template,int * extlen, int * ext)
int g2c_get_prod (int g2cid, int msg_num, int prod_num, int *num_data_points, float * data)
int g2c_inq (int g2cid, int * num_msg)
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)
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_jpcpackd (double * fld, size_t width, size_t height, int *idrstmpl, unsigned char * cpack, size_t * lcpack)
int g2c_jpcpackf (float * fld, size_t width, size_t height, int * idrstmpl,unsigned char * cpack, size_t * lcpack)
int g2c_jpcunpackd (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, double * fld)
int g2c_jpcunpackf (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, float * fld)
int g2c_log_file (int g2cid)
int g2c_open (const char * path, int mode, int * g2cid)
int g2c_open_index (const char * data_file, const char * index_file, intmode, int * g2cid)
int g2c_open_index1 (const char * index_file)
int g2c_param_abbrev (int g2disc, int g2cat, int g2num, char * abbrev)
int g2c_param_all (int param_idx, int * g1num, int * g1ver, int * g2disc,int * g2cat, int * g2num, char * abbrev)
int g2c_param_g1tog2 (int g1num, int g1ver, int * g2disc, int * g2cat, int* g2num)
int g2c_param_g2tog1 (int g2disc, int g2cat, int g2num, int * g1num, int *g1ver)
int g2c_pngpackd (double * fld, size_t width, size_t height, int *idrstmpl, unsigned char * cpack, int * lcpack)
int g2c_pngpackf (float * fld, size_t width, size_t height, int * idrstmpl,unsigned char * cpack, int * lcpack)
int g2c_pngunpackd (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, double * fld)
int g2c_pngunpackf (unsigned char * cpack, size_t len, int * idrstmpl,size_t ndpts, float * fld)
int g2c_seekmsg (int g2cid, size_t skip, size_t * offset, size_t * msglen)
int g2c_set_log_level (int new_level)
const char * g2c_strerror (int g2cerr)
int g2c_unpack7 (unsigned char * cgrib, int igdsnum, int gds_tmpl_len, longlong int * gdstmpl, int idrsnum, int drs_tmpl_len, long long int *drstmpl, int ndpts, float * fld)
int g2c_write_index (int g2cid, int mode, const char * index_file)
void seekgb (FILE * lugb, g2int iseek, g2int mseek, g2int * lskip, g2int *lgrib)
Program History Log
Author
NAME
grib2.h - Header file for NCEPLIBS-g2c library.
SYNOPSIS
#include
<stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
Data Structures
struct
gribfield
Struct for GRIB2 field.
Macros
#define
G2_ADD_MSG_COMPLETE
-2
GRIB message already complete.
#define
G2_ADD_MSG_INIT
-1
GRIB message was not initialized - call
g2_create()
first.
#define
G2_ADDFIELD_BAD_BITMAP
-8
In
g2_addfield()
no bitmap in the GRIB message.
#define
G2_ADDFIELD_BAD_DRT
-7
In
g2_addfield()
unsupported Data Representationi
Template.
#define
G2_ADDFIELD_BAD_GDS
-6
In
g2_addfield()
section 3 (GDS) not previously
defined in message.
#define
G2_ADDFIELD_BAD_GDT
-9
In
g2_addfield()
GDT of one of 5.50 through 5.53
required when using DRT 5.51.
#define
G2_ADDFIELD_BAD_PDT
-5
In
g2_addfield()
could not find requested Product
Definition Template.
#define
G2_ADDFIELD_ERR
-10
In
g2_addfield()
error packing data field.
#define
G2_ADDGRID_BAD_GDT
-5
In
g2_addgrid()
Could not find requested Grid
Definition Template.
#define
G2_AEC_ENABLED
1
Decoding/encoding AEC/CCSDS is enabled.
#define
G2_BAD_SEC
-4
Previous Section was unexpected.
#define
G2_BAD_SEC_COUNTS
-3
Sum of Section byte counts doesn’t add to total byte
count.
#define
G2_CREATE_GRIB_VERSION
-1
Wrong GRIB version for
g2_create()
, must be 2.
#define
G2_GETFLD_BAD_END
7
g2_getfld()
didn’t find ’7777’ at end
of message.
#define
G2_GETFLD_BAD_SEC1
15
Error in
g2_getfld()
unpacking section 1.
#define
G2_GETFLD_BAD_SEC2
16
Error in
g2_getfld()
unpacking section 2.
#define
G2_GETFLD_BAD_SEC3
10
Error in
g2_getfld()
unpacking section 3.
#define
G2_GETFLD_BAD_SEC4
11
Error in
g2_getfld()
unpacking section 4.
#define
G2_GETFLD_BAD_SEC5
12
Error in
g2_getfld()
unpacking section 5.
#define
G2_GETFLD_BAD_SEC6
13
Error in
g2_getfld()
unpacking section 6.
#define
G2_GETFLD_BAD_SEC7
14
Error in
g2_getfld()
unpacking section 7.
#define
G2_GETFLD_GRIB_VERSION
2
Wrong GRIB version for
g2_getfld()
, must be 2.
#define
G2_GETFLD_INVAL
3
g2_getfld()
data field request number was not positive.
#define
G2_GETFLD_INVAL_SEC
8
g2_getfld()
encountered unrecognized section.
#define
G2_GETFLD_NO_BITMAP
17
In
g2_getfld()
previous bitmap specified, yet none
exists.
#define
G2_GETFLD_NO_DRT
9
In
g2_getfld()
, Data Representation Template not
implemented.
#define
G2_GETFLD_NO_GRIB
1
g2_getfld()
can’t find beginning characters
’GRIB’.
#define
G2_GETFLD_WRONG_END
4
g2_info()
found ’7777’ not where expected.
#define
G2_GETFLD_WRONG_NFLDS
6
In
g2_getfld()
message did not contain the requested
number of data fields.
#define
G2_GRIBEND_MSG_INIT
-1
In
g2_gribend()
GRIB message was not initialized -
call
g2_create()
first.
#define
G2_INFO_BAD_END
5
g2_info()
didn’t find ’7777’ at end of
message.
#define
G2_INFO_GRIB_VERSION
2
Wrong GRIB version for
g2_info()
, must be 2.
#define
G2_INFO_INVAL_SEC
6
g2_info()
found invalid section number.
#define
G2_INFO_NO_GRIB
1
g2_info()
can’t find beginning characters
’GRIB’.
#define
G2_INFO_NO_SEC1
3
g2_info()
can’t find section 1.
#define
G2_INFO_WRONG_END
4
g2_info()
found ’7777’ not where expected.
#define
G2_JASPER_DECODE
-3
In
dec_jpeg2000()
error decoding image with jasper.
#define
G2_JASPER_DECODE_COLOR
-5
In
dec_jpeg2000()
decoded image had multiple color
components.
#define
G2_JASPER_ENCODE
-3
In
enc_jpeg2000()
error encoding image with jasper.
#define
G2_JASPER_INIT
-2
In
enc_jpeg2000()
/dec_jpeg2000() error initializing
jasper library.
#define
G2_JPCUNPACK_MEM
1
In
jpcunpack()
or other unpack function: out of
memory.
#define
G2_JPEG2000_ENABLED
1
Decoding/encoding JPEG2000 is enabled.
#define
G2_NO_ERROR
0
Function succeeded.
#define
G2_PNG_ENABLED
1
Decoding/encoding PNG is enabled.
#define
G2_SPECUNPACK_TYPE
-3
In
specunpack()
Can’t handle 64 or 128 bit
floats.
#define
G2_UNPACK3_BAD_GDT
5
In
g2_unpack3()
, undefined Grid Definition Template.
#define
G2_UNPACK4_BAD_PDT
5
In
g2_unpack4()
, undefined Product Definition
Template.
#define
G2_UNPACK5_BAD_DRT
7
In
g2_unpack5()
, undefined Data Representation
Template.
#define
G2_UNPACK6_BAD_BITMAP
4
In
g2_unpack6()
, unrecognized pre-defined bit-map.
#define
G2_UNPACK7_BAD_DRT
4
In
g2_unpack7()
, unrecognized Data Representation
Template.
#define
G2_UNPACK7_CORRUPT_SEC
7
In
g2_unpack7()
, corrupt section 7.
#define
G2_UNPACK7_WRONG_GDT
5
In
g2_unpack7()
, need one of GDT 3.50 through 3.53 to
decode DRT 5.51.
#define
G2_UNPACK_BAD_SEC
2
Bad section number in unpacking function.
#define
G2_UNPACK_NO_MEM
6
Error allocating memory in unpack function.
#define
G2C_AEC_DRS_TEMPLATE_LEN
8
Length of the idrstmpl array for AEC packing.
#define
G2C_BYTE
1
signed 1 byte integer
#define
G2C_CHAR
2
ISO/ASCII character.
#define
G2C_CLOBBER
0x0000
Destroy existing file.
#define
G2C_DOUBLE
6
double precision floating point number
#define
G2C_EAEC
(-74)
Error encoding/decoding AEC data.
#define
G2C_EBADEND
(-65)
End of message in wrong place.
#define
G2C_EBADID
(-55)
Bad ID.
#define
G2C_EBADSECTION
(-66)
Invalid section number.
#define
G2C_EBADTEMPLATE
(-70)
Template problem.
#define
G2C_EBADTYPE
(-73)
Type not found.
#define
G2C_ECSV
(-75)
CSV error.
#define
G2C_EFILE
(-54)
File I/O error.
#define
G2C_EINVAL
(-53)
Invalid input.
#define
G2C_EJPEG
(-67)
Error encoding/decoding JPEG data.
#define
G2C_EMSG
(-58)
Error decoding GRIB message.
#define
G2C_EMSGCOMPLETE
(-51)
GRIB message already complete.
#define
G2C_ENAMETOOLONG
(-52)
Name too long.
#define
G2C_ENOEND
(-64)
Cannot find end of GRIB message.
#define
G2C_ENOMEM
(-57)
Out of memory.
#define
G2C_ENOMSG
(-59)
No GRIB message found.
#define
G2C_ENOPARAM
(-71)
Parameter not found.
#define
G2C_ENOPRODUCT
(-72)
Product not found.
#define
G2C_ENOSECTION
(-63)
Cannot find section.
#define
G2C_ENOTEMPLATE
(-69)
Template not found.
#define
G2C_ENOTFOUND
(-61)
Table or entry not found.
#define
G2C_ENOTGRIB
(-50)
GRIB header not found.
#define
G2C_ENOTGRIB2
(-62)
Not GRIB 2.
#define
G2C_EPNG
(-68)
Error encoding/decoding PNG data.
#define
G2C_ERROR
1
General error code, returned for some test errors.
#define
G2C_ETOOMANYFILES
(-56)
Trying to open too many files.
#define
G2C_EXML
(-60)
XML error.
#define
G2C_FLOAT
5
single precision floating point number
#define
G2C_INT
4
signed 4 byte integer
#define
G2C_INT64
10
signed 8-byte int
#define
G2C_JASPER_MAX_MEM
Maximum size for the Jasper memory buffer.
#define
G2C_JPEG_DRS_TEMPLATE_LEN
7
Length of the idrstmpl array for JPEG packing.
#define
G2C_LARGE_FILE_INDEX
0x0008
Create a large file index.
#define
G2C_MAX_DRS_TEMPLATE
11
Maximum number of DRS templates.
#define
G2C_MAX_DRS_TEMPLATE_MAPLEN
18
Maximum DRS template map length.
#define
G2C_MAX_FILES
3
Maximum number of open files.
#define
G2C_MAX_GDS_TEMPLATE
38
Maximum number of grid templates.
#define
G2C_MAX_GDS_TEMPLATE_MAPLEN
28
Maximum grid template map length.
#define
G2C_MAX_GRIB_CODE_LEN
20
Maximum length of code.
#define
G2C_MAX_GRIB_DESC_LEN
512
Maximum length of code description.
#define
G2C_MAX_GRIB_LEVEL_DESC_LEN
40
Maximum length of level description.
#define
G2C_MAX_GRIB_STATUS_LEN
40
Maximum length of code status.
#define
G2C_MAX_GRIB_TITLE_LEN
200
Maximum length of code table title.
#define
G2C_MAX_NAME
1024
Maximum length of a name.
#define
G2C_MAX_NOAA_ABBREV_LEN
8
Maximum length of a NOAA abbreviation of a parameter.
#define
G2C_MAX_NOAA_PARAM_LINE_LEN
120
Maximum length of a line in the NOAA abbreviation CSV file.
#define
G2C_MAX_NOAA_PARAMS
2000
Maximum number of known parameters with NOAA abbreviations.
#define
G2C_MAX_NUM_SECTIONS
1024
Maximum number of sections that can be handled in one
message.
#define
G2C_MAX_PDS_TEMPLATE
102
Maximum number of PDS templates.
#define
G2C_MAX_PDS_TEMPLATE_MAPLEN
50
Maximum template map length.
#define
G2C_NOCLOBBER
0x0004
Don’t destroy existing file.
#define
G2C_NOERROR
0
No error.
#define
G2C_NOWRITE
0x0000
Set read-only access for
g2c_open()
.
#define
G2C_PNG_DRS_TEMPLATE_LEN
5
Length of the idrstmpl array for PNG packing.
#define
G2C_PNG_HEIGHT_MAX
100000
Maximum height of PNG grid.
#define
G2C_PNG_WIDTH_MAX
100000000
Maximum width of PNG grid.
#define
G2C_SECTION0_ARRAY_LEN
3
Length of section 0 array.
#define
G2C_SECTION0_BYTES
16
Number of bytes in section 0.
#define
G2C_SECTION0_LEN
3
Length of section 0 array.
#define
G2C_SECTION1_ARRAY_LEN
13
Length of section 1 array.
#define
G2C_SECTION1_BYTES
21
Number of bytes in section 1 (not including reserved,
optional data at the end of the section).
#define
G2C_SECTION1_LEN
13
Length of section 1 array.
#define
G2C_SHORT
3
signed 2 byte integer
#define
G2C_UBYTE
7
unsigned 1 byte int
#define
G2C_UINT
9
unsigned 4-byte int
#define
G2C_UINT64
11
unsigned 8-byte int
#define
G2C_USHORT
8
unsigned 2-byte int
#define
G2C_VERSION
’2.1.0’
Current version of NCEPLIBS-g2c library.
#define
G2C_WRITE
0x0001
Set read-write access for
g2c_open()
.
Typedefs
typedef float
g2float
Float type.
typedef int64_t
g2int
Long integer type.
typedef uint64_t
g2intu
Unsigned long integer type.
typedef struct
gribfield gribfield
Struct for GRIB field.
Functions
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.
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.
g2int g2_addlocal
(unsigned char *cgrib, unsigned char
*csec2,
g2int
lcsec2)
Adds a
Local Use Section (Section 2)
to a GRIB2
message.
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 (Identification
Section)
.
void
g2_free
(
gribfield
*gfld)
Free memory that was allocated for struct
gribfield
.
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 field.
g2int g2_gribend
(unsigned char *cgrib)
Finalize a GRIB2 message after all grids and fields have
been added.
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 number (and
maximum size) of Local Use Sections.
g2int g2_unpack1
(unsigned char *cgrib,
g2int
*iofst,
g2int
**ids,
g2int
*idslen)
Unpacks
Section 1 - Identification Section
of a
GRIB2 message.
g2int g2_unpack2
(unsigned char *cgrib,
g2int
*iofst,
g2int
*lencsec2, unsigned char **csec2)
Unpack
Section 2 (Local Use Section)
of a GRIB2
message.
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.
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.
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.
g2int g2_unpack6
(unsigned char *cgrib,
g2int
*iofst,
g2int
ngpts,
g2int
*ibmap,
g2int
**bmap)
Unpack Section 6 (Bit-Map Section) of a GRIB2 message.
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.
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.
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.
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
Template
5.42
.
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
Template
5.42
.
int
g2c_close
(int g2cid)
Close a GRIB2 file, freeing resources.
int
g2c_compare
(int g2cid1, int g2cid2)
Compare the metadata of two open GRIB2 files.
int
g2c_csv_init
()
Initialize tables from ’CodeFlag.txt’.
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
JasPer
Software
.
int
g2c_dec_png
(unsigned char *pngbuf, int *width,
int *height, unsigned char *cout)
Decode PNG.
int
g2c_degrib2
(int g2cid, const char *fileout)
Write a summary file like the degrib2 utility.
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.e., ISO/IEC
15444-1) using
JasPer Software
.
int
g2c_enc_png
(unsigned char *data, int width, int
height, int nbits, unsigned char *pngbuf)
Encode PNG.
int
g2c_find_desc
(char *title, int code, char *desc)
Given a table title and an integer code, find a description.
int
g2c_find_desc_str
(char *title, char *code, char
*desc)
Given a table title and a code, find a description.
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.
void
g2c_free_tables
()
Free table memory.
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 iout array.
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 iout array.
int
g2c_get_drs_template
(int drs_template_num, int
*maplen, int *map, int *needext)
Get DRS template information.
int
g2c_get_grid_template
(int grid_template_num, int
*maplen, int *map, int *needext)
Get grid template information.
int
g2c_get_grid_template_extension
(int
grid_template_num, int *g2c_template, int *extlen, int *ext)
Get grid template extension information.
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 the message.
int
g2c_get_pds_template
(int pds_template_num, int
*maplen, int *map, int *needext)
Get PDS template information.
int
g2c_get_pds_template_extension
(int
pds_template_num, int *g2c_template, int *extlen, int *ext)
Get pds template extension information.
int
g2c_get_prod
(int g2cid, int msg_num, int
prod_num, int *num_data_points, float *data)
Read the data for a product.
int
g2c_inq
(int g2cid, int *num_msg)
Learn about a GRIB2 file.
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.
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.
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.
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.
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.
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.
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.
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 Representation
Template
5.40
or 5.40000.
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 Representation
Template
5.40
or 5.40000.
int
g2c_log_file
(int g2cid)
Print a summary of the contents of an open GRIB2 file.
int
g2c_open
(const char *path, int mode, int *g2cid)
Open an existing GRIB2 file.
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.
int
g2c_open_index1
(const char *index_file)
Open a GRIB1 index file and read the contents.
int
g2c_param_abbrev
(int g2disc, int g2cat, int
g2num, char *abbrev)
Get NOAA abbreviation for a GRIB2 parameter.
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.
int
g2c_param_g1tog2
(int g1val, int g1ver, int
*g2disc, int *g2cat, int *g2num)
Translate GRIB1 parameter to GRIB2 parameter.
int
g2c_param_g2tog1
(int g2disc, int g2cat, int
g2num, int *g1val, int *g1ver)
Translate GRIB2 parameter to GRIB1 parameter.
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.
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.
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 GRIB2 Data
Representation Template 5.41 or 5.40010.
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 GRIB2 Data
Representation Template 5.41 or 5.40010.
int
g2c_seekmsg
(int g2cid, size_t skip, size_t
*offset, size_t *msglen)
Search a file for the next GRIB2 Message.
int
g2c_set_log_level
(int new_level)
Use this to set the global log level.
const char *
g2c_strerror
(int g2cerr)
Given an error code, return an error message.
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.
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.
void
seekgb
(FILE *lugb,
g2int
iseek,
g2int
mseek,
g2int
*lskip,
g2int
*lgrib)
Search a file for the next GRIB Message.
Detailed Description
Header file for NCEPLIBS-g2c library.
Program History Log
Date Programmer Comments 2002-10-25 Gilbert Initial 2009-01-14 Vuong Changed struct template to gtemplate 2021-11-9 Ed Hartnett Moved many prototypes to new internal header grib2_int.h . 2022-04-15 Ed Hartnett Added error codes related to JPEG. 2022-08-15 Ed Hartnett Added compression functions for double. 2023-09-10 Eric Engle Added AEC compression.
Author
Stephen Gilbert
Date
2002-10-25
Author
Ed Hartnett
Definition in file grib2.h .
Data Type Documentation
struct gribfield
Struct for GRIB2 field.
Definition at line 45 of file grib2.h .
Data Fields:
g2int
*
bmap
Integer array containing decoded bitmap, if ibmap=0 or
ibap=254.
Otherwise NULL.
float * coord_list Array containing floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels (part of Section 4).
g2int discipline Message Discipline (see Table 0.0 ).
g2int
expanded
Logical value indicating whether the data
field was expanded to the grid in the case where a bit-map
is present.
If true, the data points in fld match the grid points and
zeros were inserted at grid points where data was bit-mapped
out. If false, the data values in ld were not expanded to
the grid and are just a consecutive array of data points
corresponding to each value of ’1’ in bmap.
float * fld Array of ndpts unpacked data points.
g2int griddef Source of grid definition (see Table 3.0 ).
|
• |
0 Specified in Table 3.1 . |
•
|
1 Predetermined grid Defined by originating centre. |
g2int ibmap Bitmap indicator (see Table 6.0 ).
|
• |
0 bitmap applies and is included in Section 6. |
|||
|
• |
1-253 = Predefined bitmap applies |
|||
|
• |
254 = Previously defined bitmap applies to this field |
|||
|
• |
255 = Bit map does not apply to this product. |
g2int idrtlen Number of elements in idrtmpl.
g2int * idrtmpl Contains the data values for the Data Representation Template specified by idrtnum.
g2int idrtnum Data Representation Template Number (see Table 5.0 ).
g2int * idsect Contains the entries in the Identification Section (Section 1) .
|
• |
idsect[0] Identification of originating Centre (see Table 0 ). 7 is the identification for the US National Weather Service. |
||
|
• |
idsect[1] Identification of originating Sub-centre. (See Table C ). |
||
|
• |
idsect[2] GRIB Master Tables Version Number (see Table 1.0 ). |
•
|
0 Experimental |
||||
|
• |
1 Initial operational version number |
|||
|
• |
idsect[3] GRIB Local Tables Version Number (see Table 1.1 ).
|
• |
0 Local tables not used |
|||
|
• |
1-254 Number of local tables version used |
|||
|
• |
idsect[4] Significance of Reference Time (See Table 1.2 ).
|
• |
0 Analysis |
|||
|
• |
1 Start of forecast |
|||
|
• |
2 Verifying time of forecast |
|||
|
• |
3 Observation time |
|||
|
• |
idsect[5] Year (4 digits)
|
• |
idsect[6] Month |
|||
|
• |
idsect[7) Day |
|||
|
• |
idsect[8] Hour |
|||
|
• |
idsect[9] Minute |
|||
|
• |
idsect[10] Second |
|||
|
• |
idsect[11] Production status of processed data (see Table 1.3 ). |
•
|
0 Operational products |
||||
|
• |
1 Operational test products |
|||
|
• |
2 Research products |
|||
|
• |
3 Re-analysis products |
|||
|
• |
idsect[12] Type of processed data (see Table 1.4 ).
|
• |
0 Analysis products |
|||
|
• |
1 Forecast products |
|||
|
• |
2 Analysis and forecast products |
|||
|
• |
3 Control forecast products |
|||
|
• |
4 Perturbed forecast products |
|||
|
• |
5 Control and perturbed forecast products |
|||
|
• |
6 Processed satellite observations |
|||
|
• |
7 Processed radar observations |
g2int idsectlen Number of elements in idsect.
g2int ifldnum Field number within GRIB message.
g2int
igdtlen
Number of elements in igdtmpl - i.e.
number of entries in Grid Defintion Template.
g2int * igdtmpl Contains the data values for the Grid Definition Template specified by igdtnum.
g2int igdtnum Grid Definition Template Number (See Table 3.1 ).
g2int
interp_opt
Interpretation of list for optional points
definition.
(See
Table 3.11
).
g2int
ipdtlen
Number of elements in ipdtmpl - i.e.
number of entries in Product Defintion Template.
g2int * ipdtmpl Contains the data values for the Product Definition Template specified by ipdtnum.
g2int ipdtnum Product Definition Template Number (see Table 4.0 ).
g2int
*
list_opt
(Used if numoct_opt .ne.
0) This array contains the number of grid points contained
in each row (or column) (part of Section 3). NULL if
numoct_opt = 0.
unsigned char * local Pointer to character array containing contents of Local Section 2, if included.
g2int locallen Length of array local.
g2int ndpts Number of data points unpacked and returned.
g2int ngrdpts Number of grid points in the defined grid.
g2int num_coord Number of values in array coord_list.
g2int
num_opt
(Used if numoct_opt .ne.
0) The number of entries in array ideflist - i.e. number of
rows (or columns) for which optional grid points are
defined. This value is set to zero, if numoct_opt=0.
g2int
numoct_opt
Number of octets needed for each
additional grid points definition.
Used to define number of points in each row (or column) for
non-regular grids. = 0, if using regular grid.
g2int
unpacked
Logical value indicating whether the bitmap
and data values were unpacked.
If false, bmap and fld pointers are NULL.
g2int version GRIB edition number (2).
Macro Definition Documentation
#define G2_ADD_MSG_COMPLETE -2
GRIB message already complete. Cannot add new section.
Definition at line 467 of file grib2.h .
#define G2_ADD_MSG_INIT -1
GRIB message was not initialized - call g2_create() first.
Definition at line 466 of file grib2.h .
#define G2_ADDFIELD_BAD_BITMAP -8
In g2_addfield() no bitmap in the GRIB message.
Definition at line 472 of file grib2.h .
#define G2_ADDFIELD_BAD_DRT -7
In g2_addfield() unsupported Data Representationi Template.
Definition at line 471 of file grib2.h .
#define G2_ADDFIELD_BAD_GDS -6
In g2_addfield() section 3 (GDS) not previously defined in message.
Definition at line 470 of file grib2.h .
#define G2_ADDFIELD_BAD_GDT -9
In g2_addfield() GDT of one of 5.50 through 5.53 required when using DRT 5.51.
Definition at line 473 of file grib2.h .
#define G2_ADDFIELD_BAD_PDT -5
In g2_addfield() could not find requested Product Definition Template.
Definition at line 469 of file grib2.h .
#define G2_ADDFIELD_ERR -10
In g2_addfield() error packing data field.
Definition at line 474 of file grib2.h .
#define G2_ADDGRID_BAD_GDT -5
In g2_addgrid() Could not find requested Grid Definition Template.
Definition at line 475 of file grib2.h .
#define G2_AEC_ENABLED 1
Decoding/encoding AEC/CCSDS is enabled.
Definition at line 29 of file grib2.h .
#define G2_BAD_SEC -4
Previous Section was unexpected.
Definition at line 456 of file grib2.h .
#define G2_BAD_SEC_COUNTS -3
Sum of Section byte counts doesn’t add to total byte count.
Definition at line 468 of file grib2.h .
#define G2_CREATE_GRIB_VERSION -1
Wrong GRIB version for g2_create() , must be 2.
Definition at line 432 of file grib2.h .
#define G2_GETFLD_BAD_END 7
g2_getfld() didn’t find ’7777’ at end of message.
Definition at line 444 of file grib2.h .
#define G2_GETFLD_BAD_SEC1 15
Error in g2_getfld() unpacking section 1.
Definition at line 447 of file grib2.h .
#define G2_GETFLD_BAD_SEC2 16
Error in g2_getfld() unpacking section 2.
Definition at line 448 of file grib2.h .
#define G2_GETFLD_BAD_SEC3 10
Error in g2_getfld() unpacking section 3.
Definition at line 449 of file grib2.h .
#define G2_GETFLD_BAD_SEC4 11
Error in g2_getfld() unpacking section 4.
Definition at line 450 of file grib2.h .
#define G2_GETFLD_BAD_SEC5 12
Error in g2_getfld() unpacking section 5.
Definition at line 451 of file grib2.h .
#define G2_GETFLD_BAD_SEC6 13
Error in g2_getfld() unpacking section 6.
Definition at line 452 of file grib2.h .
#define G2_GETFLD_BAD_SEC7 14
Error in g2_getfld() unpacking section 7.
Definition at line 453 of file grib2.h .
#define G2_GETFLD_GRIB_VERSION 2
Wrong GRIB version for g2_getfld() , must be 2.
Definition at line 440 of file grib2.h .
#define G2_GETFLD_INVAL 3
g2_getfld() data field request number was not positive.
Definition at line 441 of file grib2.h .
#define G2_GETFLD_INVAL_SEC 8
g2_getfld() encountered unrecognized section.
Definition at line 445 of file grib2.h .
#define G2_GETFLD_NO_BITMAP 17
In g2_getfld() previous bitmap specified, yet none exists.
Definition at line 454 of file grib2.h .
#define G2_GETFLD_NO_DRT 9
In g2_getfld() , Data Representation Template not implemented.
Definition at line 446 of file grib2.h .
#define G2_GETFLD_NO_GRIB 1
g2_getfld() can’t find beginning characters ’GRIB’.
Definition at line 439 of file grib2.h .
#define G2_GETFLD_WRONG_END 4
g2_info() found ’7777’ not where expected.
Definition at line 442 of file grib2.h .
#define G2_GETFLD_WRONG_NFLDS 6
In g2_getfld() message did not contain the requested number of data fields.
Definition at line 443 of file grib2.h .
#define G2_GRIBEND_MSG_INIT -1
In g2_gribend() GRIB message was not initialized - call g2_create() first.
Definition at line 455 of file grib2.h .
#define G2_INFO_BAD_END 5
g2_info() didn’t find ’7777’ at end of message.
Definition at line 437 of file grib2.h .
#define G2_INFO_GRIB_VERSION 2
Wrong GRIB version for g2_info() , must be 2.
Definition at line 434 of file grib2.h .
#define G2_INFO_INVAL_SEC 6
g2_info() found invalid section number.
Definition at line 438 of file grib2.h .
#define G2_INFO_NO_GRIB 1
g2_info() can’t find beginning characters ’GRIB’.
Definition at line 433 of file grib2.h .
#define G2_INFO_NO_SEC1 3
g2_info() can’t find section 1.
Definition at line 435 of file grib2.h .
#define G2_INFO_WRONG_END 4
g2_info() found ’7777’ not where expected.
Definition at line 436 of file grib2.h .
#define G2_JASPER_DECODE -3
In dec_jpeg2000() error decoding image with jasper.
Definition at line 480 of file grib2.h .
#define G2_JASPER_DECODE_COLOR -5
In dec_jpeg2000() decoded image had multiple color components.
Definition at line 481 of file grib2.h .
#define G2_JASPER_ENCODE -3
In enc_jpeg2000() error encoding image with jasper.
Definition at line 479 of file grib2.h .
#define G2_JASPER_INIT -2
In enc_jpeg2000() /dec_jpeg2000() error initializing jasper library.
Definition at line 478 of file grib2.h .
#define G2_JPCUNPACK_MEM 1
In jpcunpack() or other unpack function: out of memory.
Definition at line 476 of file grib2.h .
#define G2_JPEG2000_ENABLED 1
Decoding/encoding JPEG2000 is enabled.
Definition at line 28 of file grib2.h .
#define G2_NO_ERROR 0
Function succeeded.
Definition at line 431 of file grib2.h .
#define G2_PNG_ENABLED 1
Decoding/encoding PNG is enabled.
Definition at line 27 of file grib2.h .
#define G2_SPECUNPACK_TYPE -3
In specunpack() Can’t handle 64 or 128 bit floats.
Definition at line 477 of file grib2.h .
#define G2_UNPACK3_BAD_GDT 5
In g2_unpack3() , undefined Grid Definition Template.
Definition at line 459 of file grib2.h .
#define G2_UNPACK4_BAD_PDT 5
In g2_unpack4() , undefined Product Definition Template.
Definition at line 460 of file grib2.h .
#define G2_UNPACK5_BAD_DRT 7
In g2_unpack5() , undefined Data Representation Template.
Definition at line 461 of file grib2.h .
#define G2_UNPACK6_BAD_BITMAP 4
In g2_unpack6() , unrecognized pre-defined bit-map.
Definition at line 462 of file grib2.h .
#define G2_UNPACK7_BAD_DRT 4
In g2_unpack7() , unrecognized Data Representation Template.
Definition at line 465 of file grib2.h .
#define G2_UNPACK7_CORRUPT_SEC 7
In g2_unpack7() , corrupt section 7.
Definition at line 463 of file grib2.h .
#define G2_UNPACK7_WRONG_GDT 5
In g2_unpack7() , need one of GDT 3.50 through 3.53 to decode DRT 5.51.
Definition at line 464 of file grib2.h .
#define G2_UNPACK_BAD_SEC 2
Bad section number in unpacking function.
Definition at line 457 of file grib2.h .
#define G2_UNPACK_NO_MEM 6
Error allocating memory in unpack function.
Definition at line 458 of file grib2.h .
#define G2C_AEC_DRS_TEMPLATE_LEN 8
Length of the idrstmpl array for AEC packing.
Definition at line 413 of file grib2.h .
#define G2C_BYTE 1
signed 1 byte integer
Definition at line 260 of file grib2.h .
#define G2C_CHAR 2
ISO/ASCII character.
Definition at line 261 of file grib2.h .
#define G2C_CLOBBER 0x0000
Destroy existing file. Mode flag for g2c_create().
Definition at line 277 of file grib2.h .
#define G2C_DOUBLE 6
double precision floating point number
Definition at line 265 of file grib2.h .
#define G2C_EAEC (-74)
Error encoding/decoding AEC data.
Definition at line 510 of file grib2.h .
#define G2C_EBADEND (-65)
End of message in wrong place.
Definition at line 501 of file grib2.h .
#define G2C_EBADID (-55)
Bad ID.
Definition at line 491 of file grib2.h .
#define G2C_EBADSECTION (-66)
Invalid section number.
Definition at line 502 of file grib2.h .
#define G2C_EBADTEMPLATE (-70)
Template problem.
Definition at line 506 of file grib2.h .
#define G2C_EBADTYPE (-73)
Type not found.
Definition at line 509 of file grib2.h .
#define G2C_ECSV (-75)
CSV error.
Definition at line 511 of file grib2.h .
#define G2C_EFILE (-54)
File I/O error.
Definition at line 490 of file grib2.h .
#define G2C_EINVAL (-53)
Invalid input.
Definition at line 489 of file grib2.h .
#define G2C_EJPEG (-67)
Error encoding/decoding JPEG data.
Definition at line 503 of file grib2.h .
#define G2C_EMSG (-58)
Error decoding GRIB message.
Definition at line 494 of file grib2.h .
#define G2C_EMSGCOMPLETE (-51)
GRIB message already complete.
Definition at line 487 of file grib2.h .
#define G2C_ENAMETOOLONG (-52)
Name too long.
Definition at line 488 of file grib2.h .
#define G2C_ENOEND (-64)
Cannot find end of GRIB message.
Definition at line 500 of file grib2.h .
#define G2C_ENOMEM (-57)
Out of memory.
Definition at line 493 of file grib2.h .
#define G2C_ENOMSG (-59)
No GRIB message found.
Definition at line 495 of file grib2.h .
#define G2C_ENOPARAM (-71)
Parameter not found.
Definition at line 507 of file grib2.h .
#define G2C_ENOPRODUCT (-72)
Product not found.
Definition at line 508 of file grib2.h .
#define G2C_ENOSECTION (-63)
Cannot find section.
Definition at line 499 of file grib2.h .
#define G2C_ENOTEMPLATE (-69)
Template not found.
Definition at line 505 of file grib2.h .
#define G2C_ENOTFOUND (-61)
Table or entry not found.
Definition at line 497 of file grib2.h .
#define G2C_ENOTGRIB (-50)
GRIB header not found.
Definition at line 486 of file grib2.h .
#define G2C_ENOTGRIB2 (-62)
Not GRIB 2.
Definition at line 498 of file grib2.h .
#define G2C_EPNG (-68)
Error encoding/decoding PNG data.
Definition at line 504 of file grib2.h .
#define G2C_ERROR 1
General error code, returned for some test errors.
Definition at line 485 of file grib2.h .
#define G2C_ETOOMANYFILES (-56)
Trying to open too many files.
Definition at line 492 of file grib2.h .
#define G2C_EXML (-60)
XML error.
Definition at line 496 of file grib2.h .
#define G2C_FLOAT 5
single precision floating point number
Definition at line 264 of file grib2.h .
#define G2C_INT 4
signed 4 byte integer
Definition at line 263 of file grib2.h .
#define G2C_INT64 10
signed 8-byte int
Definition at line 269 of file grib2.h .
#define G2C_JASPER_MAX_MEM
Maximum size for the Jasper memory buffer.
Definition at line 426 of file grib2.h .
#define G2C_JPEG_DRS_TEMPLATE_LEN 7
Length of the idrstmpl array for JPEG packing.
Definition at line 411 of file grib2.h .
#define G2C_LARGE_FILE_INDEX 0x0008
Create a large file index. Mode flag for g2c_write_index() .
Definition at line 279 of file grib2.h .
#define G2C_MAX_DRS_TEMPLATE 11
Maximum number of DRS templates.
Definition at line 296 of file grib2.h .
#define G2C_MAX_DRS_TEMPLATE_MAPLEN 18
Maximum DRS template map length.
Definition at line 297 of file grib2.h .
#define G2C_MAX_FILES 3
Maximum number of open files.
Definition at line 273 of file grib2.h .
#define G2C_MAX_GDS_TEMPLATE 38
Maximum number of grid templates.
Definition at line 292 of file grib2.h .
#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28
Maximum grid template map length.
Definition at line 293 of file grib2.h .
#define G2C_MAX_GRIB_CODE_LEN 20
Maximum length of code.
Definition at line 418 of file grib2.h .
#define G2C_MAX_GRIB_DESC_LEN 512
Maximum length of code description.
Definition at line 415 of file grib2.h .
#define G2C_MAX_GRIB_LEVEL_DESC_LEN 40
Maximum length of level description.
Definition at line 417 of file grib2.h .
#define G2C_MAX_GRIB_STATUS_LEN 40
Maximum length of code status.
Definition at line 416 of file grib2.h .
#define G2C_MAX_GRIB_TITLE_LEN 200
Maximum length of code table title.
Definition at line 419 of file grib2.h .
#define G2C_MAX_NAME 1024
Maximum length of a name.
Definition at line 274 of file grib2.h .
#define G2C_MAX_NOAA_ABBREV_LEN 8
Maximum length of a NOAA abbreviation of a parameter.
Definition at line 423 of file grib2.h .
#define G2C_MAX_NOAA_PARAM_LINE_LEN 120
Maximum length of a line in the NOAA abbreviation CSV file.
Definition at line 424 of file grib2.h .
#define G2C_MAX_NOAA_PARAMS 2000
Maximum number of known parameters with NOAA abbreviations.
Definition at line 422 of file grib2.h .
#define G2C_MAX_NUM_SECTIONS 1024
Maximum number of sections that can be handled in one message.
Definition at line 420 of file grib2.h .
#define G2C_MAX_PDS_TEMPLATE 102
Maximum number of PDS templates.
Definition at line 294 of file grib2.h .
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50
Maximum template map length.
Definition at line 295 of file grib2.h .
#define G2C_NOCLOBBER 0x0004
Don’t destroy existing file. Mode flag for g2c_create().
Definition at line 278 of file grib2.h .
#define G2C_NOERROR 0
No error.
Definition at line 484 of file grib2.h .
#define G2C_NOWRITE 0x0000
Set read-only access for g2c_open() .
Definition at line 275 of file grib2.h .
#define G2C_PNG_DRS_TEMPLATE_LEN 5
Length of the idrstmpl array for PNG packing.
Definition at line 412 of file grib2.h .
#define G2C_PNG_HEIGHT_MAX 100000
Maximum height of PNG grid.
Definition at line 429 of file grib2.h .
#define G2C_PNG_WIDTH_MAX 100000000
Maximum width of PNG grid.
Definition at line 428 of file grib2.h .
#define G2C_SECTION0_ARRAY_LEN 3
Length of section 0 array.
Definition at line 408 of file grib2.h .
#define G2C_SECTION0_BYTES 16
Number of bytes in section 0.
Definition at line 282 of file grib2.h .
#define G2C_SECTION0_LEN 3
Length of section 0 array.
Definition at line 288 of file grib2.h .
#define G2C_SECTION1_ARRAY_LEN 13
Length of section 1 array.
Definition at line 409 of file grib2.h .
#define G2C_SECTION1_BYTES 21
Number of bytes in section 1 (not including reserved, optional data at the end of the section).
Definition at line 286 of file grib2.h .
#define G2C_SECTION1_LEN 13
Length of section 1 array.
Definition at line 289 of file grib2.h .
#define G2C_SHORT 3
signed 2 byte integer
Definition at line 262 of file grib2.h .
#define G2C_UBYTE 7
unsigned 1 byte int
Definition at line 266 of file grib2.h .
#define G2C_UINT 9
unsigned 4-byte int
Definition at line 268 of file grib2.h .
#define G2C_UINT64 11
unsigned 8-byte int
Definition at line 270 of file grib2.h .
#define G2C_USHORT 8
unsigned 2-byte int
Definition at line 267 of file grib2.h .
#define G2C_VERSION ’2.1.0’
Current version of NCEPLIBS-g2c library.
Definition at line 25 of file grib2.h .
#define G2C_WRITE 0x0001
Set read-write access for g2c_open() .
Definition at line 276 of file grib2.h .
Typedef Documentation
typedef float g2float
Float type. This typedef is provided for backward compatibility and is not used by the library any more. Use float in new code.
Definition at line 40 of file grib2.h .
typedef int64_t g2int
Long integer type.
Definition at line 32 of file grib2.h .
typedef uint64_t g2intu
Unsigned long integer type. This typedef is provided for backward compatibility and is not used by the library any more.
Definition at line 36 of file grib2.h .
typedef struct gribfield gribfield
Struct for GRIB field.
Definition at line 221 of file grib2.h .
Function Documentation
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. They are:
|
4. |
Product Definition Section |
|||
|
5. |
Data Representation Section |
|||
|
6. |
Bit-Map Section |
|||
|
7. |
Data Section |
This routine is used with routines g2_create() , g2_addlocal() , g2_addgrid() , and g2_gribend() to create a complete GRIB2 message. Function g2_create() must be called first to initialize a new GRIB2 message. Function g2_addgrid() must be called after g2_create() and before this routine to add the appropriate grid description to the GRIB2 message. A call to g2_gribend() is required to complete GRIB2 message after all fields have been added.
Program History Log
Date Programmer Comments 2002-11-05 Gilbert Initial 2002-12-23 Gilbert Added complex spherical harmonic packing 2003-08-27 Gilbert Added support for new templates using PNG and JPEG2000 algorithms/templates. 2004-11-29 Gilbert JPEG2000 now can use WMO Template 5.40 PNG can use WMO Template 5.41. Added packing algorithm check. 2005-05-10 Gilbert Imposed minimum size on cpack. 2009-01-14 Vuong Changed structure name template to gtemplate 2023-09-08 Engle Added support for new template, 5.42, using CCSDS compression (libaec).
Parameters
cgrib
Char array that
contains the GRIB2 message to which sections 4 through 7
should be added. Must be allocated large enough to store the
entire GRIB2 message.
ipdsnum
Product Definition Template Number (see
Code
Table 4.0
).
ipdstmpl
Contains the data values for the Product
Definition Template specified by ipdsnum.
coordlist
Array containg floating point values intended
to document the vertical discretisation associated to model
data on hybrid coordinate vertical levels.
numcoord
number of values in array coordlist.
idrsnum
Data Representation Template Number (see
Code Table 5.0
).
idrstmpl
The data values for the Data Representation
Template specified by idrsnum. Note that some values in this
template (eg. reference values, number of bits, etc...) may
be changed by the data packing algorithms. Use this to
specify scaling factors and order of spatial differencing,
if desired.
fld
Array of data points to pack.
ngrdpts
Number of data points in grid. i.e. size of fld
and bmap.
ibmap
Bitmap indicator (see
Code Table 6.0
)
|
• |
0 = bitmap applies and is included in Section 6. |
|||
|
• |
1-253 = Predefined bitmap applies. |
|||
|
• |
254 = Previously defined bitmap applies to this field. |
|||
|
• |
255 = Bit map does not apply to this product. |
bmap Integer array containing bitmap to be added (if ibmap = 0).
Returns
|
• |
> 0 Current size of updated GRIB2 message |
||
|
• |
G2_ADD_MSG_INIT GRIB message was not initialized. Need to call routine g2_create() first. |
||
|
• |
G2_ADD_MSG_COMPLETE GRIB message already complete. Cannot add new section. |
||
|
• |
G2_BAD_SEC_COUNTS Sum of Section byte counts doesn’t add to total byte count. |
||
|
• |
G2_BAD_SEC Previous Section was not 3 or 7. |
||
|
• |
G2_ADDFIELD_BAD_PDT Could not find requested Product Definition Template. |
||
|
• |
G2_ADDFIELD_BAD_GDS Section 3 (GDS) not previously defined in message. |
||
|
• |
G2_ADDFIELD_BAD_DRT Tried to use unsupported Data Representationi Template. |
||
|
• |
G2_ADDFIELD_BAD_BITMAP Specified use of a previously defined bitmap, but one does not exist in the GRIB message. |
||
|
• |
G2_ADDFIELD_BAD_GDT GDT of one of 5.50 through 5.53 required to pack field using DRT 5.51. |
||
|
• |
G2_ADDFIELD_ERR Error packing data field. |
Note
Note that the Sections 4 through 7 can only follow Section 3 or Section 7 in a GRIB2 message.
Author
Stephen Gilbert
Date
2002-11-05
Definition at line 100 of file g2_addfield.c .
References aecpack() , cmplxpack() , gtemplate::ext , gtemplate::extlen , extpdstemplate() , G2_ADD_MSG_COMPLETE , G2_ADD_MSG_INIT , G2_ADDFIELD_BAD_BITMAP , G2_ADDFIELD_BAD_DRT , G2_ADDFIELD_BAD_GDS , G2_ADDFIELD_BAD_GDT , G2_ADDFIELD_BAD_PDT , G2_ADDFIELD_ERR , G2_BAD_SEC , G2_BAD_SEC_COUNTS , g2c_check_msg() , G2C_EMSGCOMPLETE , G2C_ENOTGRIB , gbit() , getdim() , getdrstemplate() , getpdstemplate() , getpoly() , jpcpack() , gtemplate::map , gtemplate::maplen , mkieee() , gtemplate::needext , pngpack() , sbit() , sbits() , simpack() , and specpack() .
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. This function is used with routines g2_create() , g2_addlocal() , g2_addfield() , and g2_gribend() to create a complete GRIB2 message. g2_create() must be called first to initialize a new GRIB2 message.
Parameters
cgrib
Char array that
contains the GRIB2 message to which section should be added.
Must be allocated large enough to store the entire GRIB2
message.
igds
Contains information needed for GRIB Grid
Definition Section 3. Must be dimensioned >= 5.
|
• |
igds[0] Source of grid definition (see Code Table 3.0 ). |
||
|
• |
igds[1] Number of grid points in the defined grid. |
||
|
• |
igds[2] Number of octets needed for each additional grid points definition. Used to define number of points in each row (or column) for non-regular grids. = 0, if using regular grid. |
||
|
• |
igds[3] Interpretation of list for optional points definition. (See Code Table 3.11 ). |
||
|
• |
igds[4] Grid Definition Template Number (See Code Table 3.1 ). |
igdstmpl
Contains the data values for the specified Grid Definition
Template (igds[4]). Each element of this integer array
contains an entry (in the order specified) of Grid Defintion
Template.
ideflist
(Used if igds[2] != 0) This array contains the
number of grid points contained in each row (or column).
idefnum
(Used if igds[2] != 0) The number of entries in
array ideflist. i.e. number of rows (or columns) for which
optional grid points are defined.
Returns
|
• |
> 0 Current size of updated GRIB2 message |
||
|
• |
G2_ADD_MSG_INIT GRIB message was not initialized. Need to call routine gribcreate first. |
||
|
• |
G2_ADD_MSG_COMPLETE GRIB message already complete. Cannot add new section. |
||
|
• |
G2_BAD_SEC_COUNTS Sum of Section byte counts doesn’t add to total byte count |
||
|
• |
G2_BAD_SEC Previous Section was not 1, 2 or 7. |
||
|
• |
G2_ADDGRID_BAD_GDT Could not find requested Grid Definition Template. |
Note
The Grid Def Section (Section 3) can only follow Section 1, 2 or Section 7 in a GRIB2 message.
Author
Stephen Gilbeert
Date
2002-11-01
Definition at line 66 of file g2_addgrid.c .
References gtemplate::ext , extgridtemplate() , gtemplate::extlen , G2_ADD_MSG_COMPLETE , G2_ADD_MSG_INIT , G2_ADDGRID_BAD_GDT , G2_BAD_SEC , G2_BAD_SEC_COUNTS , g2c_check_msg() , G2C_EMSGCOMPLETE , G2C_ENOTGRIB , gbit() , getgridtemplate() , gtemplate::map , gtemplate::maplen , gtemplate::needext , sbit() , and sbits() .
g2int g2_addlocal (unsigned char * cgrib, unsigned char * csec2, g2intlcsec2)
Adds a Local Use Section (Section 2) to a GRIB2 message. This function is used with routines g2_create() , g2_addgrid() , g2_addfield() , and g2_gribend() to create a complete GRIB2 message.
Parameters
cgrib
Char array that
contains the GRIB2 message to which section 2 should be
added. Must be allocated large enough to store the entire
GRIB2 message.
csec2
Character array containing information to be added
in Section 2.
lcsec2
Number of bytes of character array csec2 to be
added to Section 2.
Returns
> 0 = Current size of updated GRIB2 message.
|
• |
G2_ADD_MSG_INIT GRIB message was not initialized. Need to call routine gribcreate first. |
||
|
• |
G2_ADD_MSG_COMPLETE GRIB message already complete. Cannot add new section. |
||
|
• |
G2_BAD_SEC_COUNTS Sum of Section byte counts doesn’t add to total byte count. |
||
|
• |
G2_BAD_SEC Previous Section was not 1 or 7. |
Note
The Local Use Section (Section 2) can only follow Section 1 or Section 7 in a GRIB2 message.
Author
Stephen Gilbeert
Date
2002-11-01
Definition at line 41 of file g2_addlocal.c .
References G2_ADD_MSG_COMPLETE , G2_ADD_MSG_INIT , G2_BAD_SEC , G2_BAD_SEC_COUNTS , g2c_check_msg() , G2C_EMSGCOMPLETE , G2C_ENOTGRIB , gbit() , and sbit() .
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 (Identification Section) . This routine is used with routines g2_addlocal() , g2_addgrid() , g2_addfield() , and g2_gribend() to create a complete GRIB2 message. g2_create() must be called first to initialize a new GRIB2 message. A call to g2_gribend() is required to complete GRIB2 message after all fields have been added.
Parameters
cgrib
Character array to
contain the GRIB2 message. Must be allocated large enough to
store the entire GRIB2 message.
listsec0
Contains information needed for GRIB Indicator
Section 0. Must be dimensioned >= 2.
|
• |
listsec0[0] Discipline-GRIB Master Table Number ([Code Table 0.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml)). |
||
|
• |
listsec0[1] GRIB Edition Number (currently 2). |
listsec1 Contains information needed for GRIB Identification Section 1. Must be dimensioned >= 13.
|
• |
listsec1[0] Id of orginating centre ([Table 0] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)). |
||
|
• |
listsec1[1] Id of orginating sub-centre ([Table C] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)). |
||
|
• |
listsec1[2] GRIB Master Tables Version Number ([Table 1.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)). |
||
|
• |
listsec1[3] GRIB Local Tables Version Number ([Table 1.1] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)). |
||
|
• |
listsec1[4] Significance of Reference Time ([Table 1.2] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)) |
||
|
• |
listsec1[5] Reference Time - Year (4 digits) |
||
|
• |
listsec1[6] Reference Time - Month |
||
|
• |
listsec1[7] Reference Time - Day |
||
|
• |
listsec1[8] Reference Time - Hour |
||
|
• |
listsec1[9] Reference Time - Minute |
||
|
• |
listsec1[10] Reference Time - Second |
||
|
• |
listsec1[11] Production status of data ([Table 1.3] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)). |
||
|
• |
listsec1[12] Type of processed data ([Table 1.4] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)). |
Returns
|
• |
> 0 Current size of new GRIB2 message |
||
|
• |
G2_CREATE_GRIB_VERSION Tried to use for version other than GRIB Edition 2 |
This routine is intended for use with routines g2_addlocal() , g2_addgrid() , g2_addfield() , and g2_gribend() to create a complete GRIB2 message.
Author
Stephen Gilbeert
Date
2002-10-31
Definition at line 68 of file g2_create.c .
References G2_CREATE_GRIB_VERSION , LENSEC0 , MAPSEC1LEN , and sbit() .
void g2_free (gribfield * gfld)
Free memory that was allocated for struct gribfield .
Parameters
gfld pointer to gribfield structure (defined in include file grib2.h ) returned from routine g2_getfld() .
Note
This routine must be called to free up memory used by the decode routine, g2_getfld() , when user no longer needs to reference this data.
Author
Stephen Gilbeert
Date
2002-10-28
Definition at line 23 of file g2_free.c .
References gribfield::bmap , gribfield::coord_list , gribfield::fld , gribfield::idrtmpl , gribfield::idsect , gribfield::igdtmpl , gribfield::ipdtmpl , gribfield::list_opt , and gribfield::local .
Referenced by g2_getfld() .
g2int g2_getfld (unsigned char * cgrib, g2int ifldnum, g2int unpack, g2intexpand, gribfield ** gfld)
Return all the metadata, template values, bit-map (if applicable), and the unpacked data for a data field. All of the information returned is stored in a gribfield structure, which is defined in file grib2.h . Users of this routine will need to include grib2.h in their source code that calls this routine.
Since there can be multiple data fields packed into a GRIB2 message, the calling routine indicates which field is being requested with the ifldnum argument.
Program History Log
Date Programmer Comments 2002-10-28 Gilbert Initial 2013-08-08 Vuong Free up memory in array igds - free(igds)
Parameters
cgrib
Character pointer
to the GRIB2 message.
ifldnum
Specifies which field in the GRIB2 message to
return. The first field is number 1, Fortran style.
unpack
Boolean value indicating whether to unpack
bitmap/data field.
|
• |
1 unpack bitmap (if present) and data values. |
|||
|
• |
0 do not unpack bitmap and data values. |
expand Boolean value indicating whether the data points should be expanded to the correspond grid, if a bit-map is present. This argument is ignored if unpack == 0 OR if the returned field does not contain a bit-map.
|
• |
1 if possible, expand data field to grid, inserting zero values at gridpoints that are bitmapped out. (SEE REMARKS2) |
||
|
• |
0 do not expand data field, leaving it an array of consecutive data points for each ’1’ in the bitmap. |
gfld pointer to structure gribfield containing all decoded data for the data field.
Returns
|
• |
G2_NO_ERROR no error |
||
|
• |
G2_GETFLD_NO_GRIB Beginning characters ’GRIB’ not found. |
||
|
• |
G2_GETFLD_GRIB_VERSION GRIB message is not Edition 2. |
||
|
• |
G2_GETFLD_INVAL The data field request number was not positive. |
||
|
• |
G2_GETFLD_WRONG_END End string ’7777’ found, but not where expected. |
||
|
• |
G2_GETFLD_WRONG_NFLDS GRIB message did not contain the requested number of data fields. |
||
|
• |
G2_GETFLD_BAD_END End string ’7777’ not found at end of message. |
||
|
• |
G2_GETFLD_INVAL_SEC Unrecognized Section encountered. |
||
|
• |
G2_GETFLD_NO_DRT Data Representation Template 5.NN not yet implemented. |
||
|
• |
G2_GETFLD_BAD_SEC1 Error unpacking Section 1. |
||
|
• |
G2_GETFLD_BAD_SEC2 Error unpacking Section 2. |
||
|
• |
G2_GETFLD_BAD_SEC3 Error unpacking Section 3. |
||
|
• |
G2_GETFLD_BAD_SEC4 Error unpacking Section 4. |
||
|
• |
G2_GETFLD_BAD_SEC5 Error unpacking Section 5. |
||
|
• |
G2_GETFLD_BAD_SEC6 Error unpacking Section 6. |
||
|
• |
G2_GETFLD_BAD_SEC7 Error unpacking Section 7. |
||
|
• |
G2_GETFLD_NO_BITMAP Previous bitmap specified, yet none exists. |
Note
Struct gribfield is allocated by this routine and it also contains pointers to many arrays of data that were allocated during decoding. Users are encouraged to free up this memory, when it is no longer needed, by an explicit call to routine g2_free() .
Example:
#include
"grib2.h"
gribfield *gfld;
ret=g2_getfld(cgrib,1,1,1,&gfld);
...
g2_free(gfld);
Routine g2_info() can be used to first determine how many data fields exist in a given GRIB message.
Note
It may not always be possible to expand a bit-mapped data field. If a pre-defined bit-map is used and not included in the GRIB2 message itself, this routine would not have the necessary information to expand the data. In this case, gfld->expanded would would be set to 0 (false), regardless of the value of input argument expand.
Author
Stephen Gilbert
Date
2002-10-28
Definition at line 93 of file g2_getfld.c .
References gribfield::bmap , gribfield::coord_list , gribfield::discipline , gribfield::expanded , gribfield::fld , g2_free() , G2_GETFLD_BAD_END , G2_GETFLD_BAD_SEC1 , G2_GETFLD_BAD_SEC2 , G2_GETFLD_BAD_SEC3 , G2_GETFLD_BAD_SEC4 , G2_GETFLD_BAD_SEC5 , G2_GETFLD_BAD_SEC6 , G2_GETFLD_BAD_SEC7 , G2_GETFLD_GRIB_VERSION , G2_GETFLD_INVAL , G2_GETFLD_INVAL_SEC , G2_GETFLD_NO_BITMAP , G2_GETFLD_NO_GRIB , G2_GETFLD_WRONG_END , G2_GETFLD_WRONG_NFLDS , G2_NO_ERROR , g2_unpack1() , g2_unpack2() , g2_unpack3() , g2_unpack4() , g2_unpack5() , g2_unpack6() , g2_unpack7() , gbit() , gribfield::griddef , gribfield::ibmap , gribfield::idrtlen , gribfield::idrtmpl , gribfield::idrtnum , gribfield::idsect , gribfield::idsectlen , gribfield::ifldnum , gribfield::igdtlen , gribfield::igdtmpl , gribfield::igdtnum , gribfield::interp_opt , gribfield::ipdtlen , gribfield::ipdtmpl , gribfield::ipdtnum , gribfield::list_opt , gribfield::local , gribfield::locallen , gribfield::ndpts , gribfield::ngrdpts , gribfield::num_coord , gribfield::num_opt , gribfield::numoct_opt , gribfield::unpacked , and gribfield::version .
g2int g2_gribend (unsigned char * cgrib)
Finalize a GRIB2 message after all grids and fields have been added. This function adds the End Section (’7777’) to the end of the GRIB message and calculates the length and stores it in the appropriate place in Section 0. This routine is used with routines g2_create() , g2_addlocal() , g2_addgrid() , and g2_addfield() to create a complete GRIB2 message.
Parameters
cgrib Char array containing all the data sections added be previous calls to g2_create() , g2_addlocal() , g2_addgrid() , and g2_addfield() . After function is called, contains the finalized GRIB2 message.
Returns
|
• |
> 0 Length of the final GRIB2 message in bytes. |
||
|
• |
G2_GRIBEND_MSG_INIT GRIB message was not initialized - call g2_create() first. |
||
|
• |
G2_BAD_SEC_COUNTS Sum of Section byte counts doesn’t add to total byte count. |
||
|
• |
G2_BAD_SEC Previous Section was not 7. |
Note
This routine is intended for use with routines g2_create() , g2_addlocal() , g2_addgrid() , and g2_addfield() to create a complete GRIB2 message.
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 40 of file g2_gribend.c .
References G2_ADD_MSG_COMPLETE , G2_ADD_MSG_INIT , G2_BAD_SEC , G2_BAD_SEC_COUNTS , g2c_check_msg() , G2C_EMSGCOMPLETE , G2C_ENOTGRIB , gbit() , and sbit() .
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 number (and maximum size) of Local Use Sections. Other checks are performed to see if the message is a valid GRIB2 message.
Parameters
cgrib
Pointer to a
buffer containing the GRIB2 message.
listsec0
Pointer to an array that gets the information
decoded from GRIB Indicator Section 0. Must be allocated
with >= 3 elements (see
G2C_SECTION0_LEN
).
|
• |
listsec0(0) Discipline-GRIB Master Table Number ([Code Table 0.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml)). |
||
|
• |
listsec0[1] GRIB Edition Number (currently 2). |
||
|
• |
listsec0[2] Length of GRIB message. |
listsec1 Pointer to an array that gets the information read from GRIB Identification Section 1. Must be allocated with >= 13 elements (see G2C_SECTION1_LEN ).
|
• |
listsec1[0] Id of orginating centre ([Table 0] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)). |
||
|
• |
listsec1[1] Id of orginating sub-centre ([Table C] (https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)). |
||
|
• |
listsec1[2] GRIB Master Tables Version Number ([Table 1.0] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)). |
||
|
• |
listsec1[3] GRIB Local Tables Version Number ([Table 1.1] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)). |
||
|
• |
listsec1[4] Significance of Reference Time ([Table 1.2] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)) |
||
|
• |
listsec1[5] Reference Time - Year (4 digits) |
||
|
• |
listsec1[6] Reference Time - Month |
||
|
• |
listsec1[7] Reference Time - Day |
||
|
• |
listsec1[8] Reference Time - Hour |
||
|
• |
listsec1[9] Reference Time - Minute |
||
|
• |
listsec1[10] Reference Time - Second |
||
|
• |
listsec1[11] Production status of data ([Table 1.3] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)). |
||
|
• |
listsec1[12] Type of processed data ([Table 1.4] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)). |
numfields
A pointer that gets the number of gridded fields found in
the GRIB message. That is, the number of occurences of
Sections 4 - 7.
numlocal
A pointer that gets the number of Local Use
Sections (section 2) found in the GRIB message.
Returns
0 for success, otherwise:
|
• |
G2_INFO_NO_GRIB Beginning characters ’GRIB’ not found. |
||
|
• |
G2_INFO_GRIB_VERSION GRIB message is not Edition 2. |
||
|
• |
G2_INFO_NO_SEC1 Could not find Section 1, where expected. |
||
|
• |
G2_INFO_WRONG_END End string ’7777’ found, but not where expected. |
||
|
• |
G2_INFO_BAD_END End string ’7777’ not found at end of message. |
||
|
• |
G2_INFO_INVAL_SEC Invalid section number found. |
Author
Stephen Gilbeert
Date
2002-10-28
Definition at line 70 of file g2_info.c .
References G2_INFO_BAD_END , G2_INFO_GRIB_VERSION , G2_INFO_INVAL_SEC , G2_INFO_NO_GRIB , G2_INFO_NO_SEC1 , G2_INFO_WRONG_END , gbit() , and LOG .
g2int g2_unpack1 (unsigned char * cgrib, g2int * iofst, g2int ** ids, g2int* idslen)
Unpacks Section 1 - Identification Section of a GRIB2 message.
Parameters
cgrib
char array
containing Section 1 of the GRIB2 message.
iofst
Bit offset for the beginning of Section 1 in
cgrib.
ids
Pointer that gets an array which contians the
information read from Section 1, the Identification section.
This array is allocated by this function, and must be freed
by caller (using
g2_free()
).
|
• |
ids[0] Identification of originating Centre (see Table 0 ). |
|||
|
• |
ids[1] Identification of originating Sub-centre (see Table C ). |
|||
|
• |
ids[2] GRIB Master Tables Version Number (see Table 1.0 ). |
|||
|
• |
ids[3] GRIB Local Tables Version Number (see Table 1.1 ). |
|||
|
• |
ids[4] Significance of Reference Time (see Table 1.2 ). |
|||
|
• |
ids[5] Year (4 digits) |
|||
|
• |
ids[6] Month |
|||
|
• |
ids[7] Day |
|||
|
• |
ids[8] Hour |
|||
|
• |
ids[9] Minute |
|||
|
• |
ids[10] Second |
|||
|
• |
ids[11] Production status of processed data (see Table 1.3 ). |
|||
|
• |
ids[12] Type of processed data (see Table 1.4 ). |
idslen Number of elements in ids.
Returns
|
• |
G2_NO_ERROR No error. |
|||
|
• |
G2_UNPACK_BAD_SEC Array passed is not section 1. |
|||
|
• |
G2_UNPACK_NO_MEM memory allocation error. |
Author
Stephen Gilbert
Date
2002-10-29
Definition at line 55 of file g2_unpack1.c .
References G2_NO_ERROR , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , and gbit() .
Referenced by g2_getfld() .
g2int g2_unpack2 (unsigned char * cgrib, g2int * iofst, g2int * lencsec2,unsigned char ** csec2)
Unpack Section 2 (Local Use Section) of a GRIB2 message.
Program History Log
Date Programmer Comments 2002-10-31 Gilbert Initial 2008-12-23 Wesley Initialize lencsec2 Length of Local Use data 2010-08-05 Vuong If section 2 has zero length, ierr=0
Parameters
cgrib
char array
containing Section 2 of the GRIB2 message.
iofst
Pointer that contains the bit offset for the
beginning of Section 2 in cgrib. The modified version will
be returned.
lencsec2
Length (in octets) of Local Use data.
csec2
Pointer to a pointer that will get an allocated
array containing local use data. This memory must be freed
by the caller.
Returns
|
• |
G2_NO_ERROR No error. |
|||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
|||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 37 of file g2_unpack2.c .
References G2_NO_ERROR , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , and gbit() .
Referenced by g2_getfld() .
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.
Program History Log
Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate
Parameters
cgrib
Char array
ontaining Section 3 of the GRIB2 message.
iofst
Pointer to g2int which contains the bit offset for
the beginning of Section 3 in cgrib.
igds
Pointer to a pointer which will get a pointer to
memory allocated for the GDS array, of length 5. The array
will contain information read from the appropriate GRIB Grid
Definition Section 3 for the field being returned.
|
• |
igds[0] Source of grid definition (see Table 3.0 ). |
||
|
• |
igds[1] Number of grid points in the defined grid. |
||
|
• |
igds[2] Number of octets needed for each additional grid points definition. Used to define number of points in each row (or column) for non-regular grids. = 0, if using regular grid. |
||
|
• |
igds[3] Interpretation of list for optional points definition. (See Table 3.11 ) |
||
|
• |
igds[4] Grid Definition Template Number (see Table 3.1 ). |
igdstmpl
Pointer a pointer to g2int, which will get a pointer to an
allocated array that contians containing the data values
from the Grid Definition Template specified by igds[4].
mapgridlen
A pointer tat gets the number of elements in
igdstmpl. i.e. number of entries in Grid Defintion Template
specified by igds[4].
ideflist
(Used if igds[2] .ne. 0) Pointer to integer
array containing the number of grid points contained in each
row (or column).
idefnum
(Used if igds[2] != 0.) A pointer that gets the
number of entries in array ideflist - i.e. number of rows
(or columns) for which optional grid points are defined.
Returns
|
• |
G2_NO_ERROR No error. |
||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
||
|
• |
G2_UNPACK3_BAD_GDT message contains an undefined Grid Definition Template. |
||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 62 of file g2_unpack3.c .
References gtemplate::ext , extgridtemplate() , gtemplate::extlen , G2_NO_ERROR , G2_UNPACK3_BAD_GDT , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , gbit() , gbits() , getgridtemplate() , gtemplate::map , gtemplate::maplen , and gtemplate::needext .
Referenced by g2_getfld() , getdim() , and getpoly() .
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.
Program History Log
Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate
Parameters
cgrib
Array containing
Section 4 of the GRIB2 message.
iofst
Bit offset of the beginning of Section 4 in cgrib.
Returned with updated bit offset.
ipdsnum
Product Definition Template Number (see
Table 4.0
).
ipdstmpl
Pointer that gets an integer array containing
the data values for the Product Definition Template
specified by ipdsnum.
mappdslen
Number of elements in ipdstmpl - i.e. number
of entries in Product Defintion Template specified by
ipdsnum.
coordlist
Pointer that gets an array containing floating
point values intended to document the vertical
discretisation associated to model data on hybrid coordinate
vertical levels.
numcoord
number of values in array coordlist.
Returns
|
• |
G2_NO_ERROR No error. |
||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
||
|
• |
G2_UNPACK4_BAD_PDT message contains an undefined Product Definition Template. |
||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 45 of file g2_unpack4.c .
References gtemplate::ext , gtemplate::extlen , extpdstemplate() , G2_NO_ERROR , G2_UNPACK4_BAD_PDT , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , gbit() , gbits() , getpdstemplate() , gtemplate::map , gtemplate::maplen , gtemplate::needext , and rdieee() .
Referenced by g2_getfld() .
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.
Program History Log
Date Programmer Comments 2002-10-31 Gilbert Initial 2009-01-14 Vuong Changed structure name template to gtemplate
Parameters
cgrib
char array
containing Section 5 of the GRIB2 message.
iofst
Bit offset for the beginning of Section 5 in
cgrib. Returned with bit offset at the end of Section 5.
ndpts
Number of data points unpacked and returned.
idrsnum
Data Representation Template Number (see Code
Table 5.0).
idrstmpl
Pointer to an integer array containing the data
values for the specified Data Representation Template
(N=idrsnum). Each element of this integer array contains an
entry (in the order specified) of Data Representation
Template 5.N.
mapdrslen-
Number of elements in idrstmpl. i.e. number
of entries in Data Representation Template 5.N
(N=idrsnum).
Returns
|
• |
G2_NO_ERROR No error. |
||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
||
|
• |
G2_UNPACK5_BAD_DRT ’GRIB’ message contains an undefined Data Representation Template. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 40 of file g2_unpack5.c .
References gtemplate::ext , extdrstemplate() , gtemplate::extlen , G2_NO_ERROR , G2_UNPACK5_BAD_DRT , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , gbit() , getdrstemplate() , gtemplate::map , gtemplate::maplen , and gtemplate::needext .
Referenced by g2_getfld() .
g2int g2_unpack6 (unsigned char * cgrib, g2int * iofst, g2int ngpts, g2int* ibmap, g2int ** bmap)
Unpack Section 6 (Bit-Map Section) of a GRIB2 message.
Parameters
cgrib
char array
containing Section 6 of the GRIB2 message.
iofst
Bit offset of the beginning of Section 6 in cgrib.
ngpts
Number of grid points specified in the bit-map
ibmap
Bitmap indicator (see Code Table 6.0)
|
• |
0 bitmap applies and is included in Section 6. |
|||
|
• |
1-253 Predefined bitmap applies |
|||
|
• |
254 Previously defined bitmap applies to this field |
|||
|
• |
255 Bit map does not apply to this product. |
bmap Pointer to an integer array containing decoded bitmap. (if ibmap=0)
Returns
|
• |
G2_NO_ERROR No error. |
|||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
|||
|
• |
G2_UNPACK6_BAD_BITMAP Unrecognized pre-defined bit-map. |
|||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 32 of file g2_unpack6.c .
References G2_NO_ERROR , G2_UNPACK_BAD_SEC , G2_UNPACK_NO_MEM , gbit() , and gbits() .
Referenced by g2_getfld() .
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. This function is maintained for backward compatibility. Users may wish to use the newer g2c_unpack7() function instead.
Parameters
cgrib
char array
containing Section 7 of the GRIB2 message
iofst
Pointer to a bit offset of the beginning of
Section 7 in cgrib. This is updated by this function to
reflect the data read in this function. After this function
is successfully called, the value pointed to by iofst will
be the number of bits to the end of section 7 in cbuf.
igdsnum
Grid Definition Template Number (see Code Table
3.0). (Only used for DRS Template 5.51.)
igdstmpl
Pointer to an integer array containing the data
values for the specified Grid Definition Template
(N=igdsnum). Each element of this integer array contains an
entry (in the order specified) of Grid Definition Template
3.N. (Only used for DRS Template 5.51).
idrsnum
Data Representation Template Number (see Code
Table 5.0).
idrstmpl
Pointer to an integer array containing the data
values for the specified Data Representation Template
(N=idrsnum). Each element of this integer array contains an
entry (in the order specified) of Data Representation
Template 5.N
ndpts
Number of data points to be unpacked and returned.
fld
Pointer to a float pointer which gets a pointer to
an array allocated by this function to hold the unpacked
data. This memory must be freed by the caller.
Returns
|
• |
G2_NO_ERROR No error. |
||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
||
|
• |
G2_UNPACK7_BAD_DRT Unrecognized Data Representation Template. |
||
|
• |
G2_UNPACK7_WRONG_GDT need one of GDT 3.50 through 3.53 to decode DRT 5.51 |
||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
||
|
• |
G2_UNPACK7_CORRUPT_SEC Corrupt section 7. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 214 of file g2_unpack7.c .
References g2c_unpack7_int() .
Referenced by g2_getfld() .
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. After the data are scaled, and the reference value is subtracted out, the data are passed to the AEC encoder.
This function also fills in GRIB2 Data Representation Template 5.42 with the appropriate values.
This function is the V2 API version of aecpack() for floats.
Parameters
fld
Pointer to the float
data values to pack.
width
The number of points in the x direction.
height
The number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation Template
Table 5.42
.
|
• |
0 Reference value - ignored on input, set by aecpack routine. |
||
|
• |
1 Binary Scale Factor - used on input, unchanged by aecpack routine. |
||
|
• |
2 Decimal Scale Factor - used on input, unchanged by aecpack routine. |
||
|
• |
3 number of bits for each data value - ignored on input |
||
|
• |
4 Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output. |
||
|
• |
5 CCSDS compression options mask. |
||
|
• |
6 Block size. |
||
|
• |
7 Reference sample interval. May be modified in this function. |
cpack
A
pointer that will get the packed data field. Must be
allocated before this function is called. Pass the allocated
size in the lcpack parameter.
lcpack
Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size
available in cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EAEC Error encoding/decoding AEC data. |
Author
Eric Engle (adapted from jpcpack)
Definition at line 410 of file aecpack.c .
References aecpack_int() , and G2C_AEC_DRS_TEMPLATE_LEN .
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. After the data are scaled, and the reference value is subtracted out, the data are passed to the AEC encoder.
This function also fills in GRIB2 Data Representation Template 5.42 with the appropriate values.
This function is the V2 API version of aecpack() for floats.
Parameters
fld
Pointer to the float
data values to pack.
width
The number of points in the x direction.
height
The number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation Template
Table 5.42
.
|
• |
0 Reference value - ignored on input, set by aecpack routine. |
||
|
• |
1 Binary Scale Factor - used on input, unchanged by aecpack routine. |
||
|
• |
2 Decimal Scale Factor - used on input, unchanged by aecpack routine. |
||
|
• |
3 number of bits for each data value - ignored on input |
||
|
• |
4 Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output. |
||
|
• |
5 CCSDS compression options mask. |
||
|
• |
6 Block size. |
||
|
• |
7 Reference sample interval. May be modified in this function. |
cpack
A
pointer that will get the packed data field. Must be
allocated before this function is called. Pass the allocated
size in the lcpack parameter.
lcpack
Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size
available in cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EAEC Error encoding/decoding AEC data. |
Author
Eric Engle (adapted from jpcpack)
Definition at line 346 of file aecpack.c .
References aecpack_int() , and G2C_AEC_DRS_TEMPLATE_LEN .
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 Template 5.42 . This function is the V2 API version of aecunpack() for doubles.
Parameters
cpack
The packed data.
len
The length of the packed data.
idrstmpl
Pointer to array of values for Data
Representation
Template 5.42
.
ndpts
The number of data values to unpack.
fld
A pointer that gets the unpacked data values as an
array of double.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Eric Engle
Date
2023-10-16
Definition at line 232 of file aecunpack.c .
References aecunpack_int() , G2C_AEC_DRS_TEMPLATE_LEN , and LOG .
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 Template 5.42 .
Parameters
cpack
The packed data.
len
The length of the packed data.
idrstmpl
Pointer to array of values for Data
Representation
Template 5.42
.
ndpts
The number of data values to unpack.
fld
A pointer that gets the unpacked data values as an
array of float.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Eric Engle
Date
2022-10-16
Definition at line 194 of file aecunpack.c .
References aecunpack_int() , G2C_AEC_DRS_TEMPLATE_LEN , and LOG .
int g2c_close (int g2cid)
Close a GRIB2 file, freeing resources.
Parameters
g2cid Indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
|||
|
• |
G2C_EBADID - Bad file ID. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1367 of file g2cfile.c .
References g2c_file_info::f , free_metadata() , G2C_EBADID , G2C_EFILE , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_file_info::g2cid , LOG , MUTEX_LOCK , MUTEX_UNLOCK , g2c_file_info::num_messages , and g2c_file_info::path .
Referenced by main() .
int g2c_compare (int g2cid1, int g2cid2)
Compare the metadata of two open GRIB2 files.
Parameters
g2cid1
Indentifier for
one file.
g2cid2
Indentifier for the other file.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid parameters. |
|||
|
• |
G2C_EFILE File I/O error. |
Author
Ed Hartnett
Date
Dec 28, 2022
Definition at line 28 of file g2ccompare.c .
References g2c_message_info::center , g2c_section5_info::data_def , g2c_message_info::day , g2c_message_info::discipline , G2C_EBADID , G2C_ENOSECTION , G2C_ERROR , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_section3_info::grid_def , g2c_message_info::hour , g2c_section3_info::interp_list , g2c_message_info::local_version , LOG , g2c_message_info::master_version , g2c_message_info::minute , g2c_message_info::month , g2c_file_info::msg , g2c_message_info::next , g2c_section_info::next , g2c_section4_info::num_coord , g2c_section3_info::num_data_points , g2c_section5_info::num_data_points , g2c_message_info::num_fields , g2c_message_info::num_local , g2c_file_info::num_messages , g2c_section3_info::num_opt , g2c_section_info::prev , g2c_section4_info::prod_def , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_message_info::second , g2c_message_info::sig_ref_time , g2c_section3_info::source_grid_def , g2c_message_info::status , g2c_message_info::subcenter , g2c_section_info::template , g2c_section_info::template_len , g2c_message_info::type , and g2c_message_info::year .
Referenced by main() .
int g2c_csv_init ()
Initialize tables from ’CodeFlag.txt’.
Returns
|
• |
G2C_NOERROR No error. |
Author
Alyson Stahl
Date
8/2/24
Definition at line 215 of file g2ccsv.c .
References doc , g2c_csv_strsep() , G2C_ECSV , G2C_ENAMETOOLONG , G2C_ENOMEM , g2c_find_table() , G2C_MAX_GRIB_CODE_LEN , G2C_MAX_GRIB_DESC_LEN , G2C_MAX_GRIB_LEVEL_DESC_LEN , G2C_MAX_GRIB_STATUS_LEN , G2C_MAX_GRIB_TITLE_LEN , G2C_NOERROR , and g2c_table .
Referenced by g2c_log_file() , and g2c_log_section1() .
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 JasPer Software .
Parameters
injpc
Pointer to buffer
that holds the input JPEG2000 code stream.
bufsize
Length (in bytes) of the buffer that holds the
input JPEG2000 code stream.
outfld
Pointer to int array, already allocated, that
gets the unpacked data.
Returns
|
• |
G2C_NOERROR No error. |
||
|
• |
G2_JASPER_DECODE Error decode jpeg2000 code stream. |
||
|
• |
G2_JASPER_DECODE_COLOR decoded image had multiple color components. Only grayscale is expected. |
||
|
• |
G2_JASPER_INIT Error inializing Jasper library. |
Author
Ed Hartnett
Date
9/7/22
Definition at line 350 of file decenc_jpeg2000.c .
References int_dec_jpeg2000() .
int g2c_dec_png (unsigned char * pngbuf, int * width, int * height,unsigned char * cout)
Decode PNG.
Parameters
pngbuf
Pointer to PNG
buffer.
width
Pointer to width.
height
Pointer to height.
cout
Output buffer.
Returns
0 for success, error code otherwise.
Author
Alyson Stahl
Definition at line 100 of file decenc_png.c .
References dec_png() .
int g2c_degrib2 (int g2cid, const char * fileout)
Write a summary file like the degrib2 utility.
Parameters
g2cid
Indentifier for
the file, returned by
g2c_open()
or g2c_create().
fileout
Path of output file. Any existing file of this
name will be overwritten.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid parameters. |
|||
|
• |
G2C_EFILE File I/O error. |
Author
Ed Hartnett
Date
Sep 17, 2022
Definition at line 634 of file g2cdegrib2.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_msg , g2c_message_info::center , g2c_section5_info::data_def , g2c_message_info::day , g2c_message_info::discipline , G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_ENOSECTION , G2C_ERROR , g2c_file , g2c_get_datetime() , g2c_get_level_desc() , g2c_get_prod() , G2C_MAX_FILES , G2C_MAX_NOAA_ABBREV_LEN , G2C_MAX_TYPE_OF_FIXED_SURFACE_LEN , G2C_NOERROR , g2c_param_abbrev() , g2c_section3_info::grid_def , g2c_message_info::hour , g2c_section6_info::indicator , g2c_section3_info::interp_list , g2c_message_info::local_version , LOG , g2c_message_info::master_version , g2c_message_info::minute , g2c_message_info::month , g2c_section_info::msg , g2c_message_info::msg_num , g2c_message_info::next , g2c_section_info::next , g2c_section4_info::num_coord , g2c_section3_info::num_data_points , g2c_section5_info::num_data_points , g2c_message_info::num_fields , g2c_message_info::num_local , g2c_section3_info::num_opt , g2c_section3_info::optional , g2c_section_info::prev , g2c_section4_info::prod_def , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_len , g2c_section_info::sec_num , g2c_message_info::second , g2c_message_info::sig_ref_time , g2c_section3_info::source_grid_def , g2c_message_info::status , g2c_message_info::subcenter , g2c_section_info::template , g2c_section_info::template_len , g2c_message_info::type , and g2c_message_info::year .
Referenced by main() .
int g2c_enc_jpeg2000 (unsigned char * cin, int width, int height, intnbits, 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.e., ISO/IEC 15444-1) using JasPer Software .
Parameters
cin
Packed matrix of
Grayscale image values to encode.
width
width of image.
height
height of image.
nbits
depth (in bits) of image. i.e number of bits used
to hold each data value.
ltype
indicator of lossless or lossy compression.
|
• |
1, for lossy compression |
|||
|
• |
!= 1, for lossless compression |
ratio
target compression ratio. (ratio:1) Used only when ltype ==
1.
retry
If 1 try increasing number of guard bits.
outjpc
Output encoded JPEG2000 code stream.
jpclen
Number of bytes allocated for the output JPEG2000
code stream in outjpc.
Returns
|
• |
> 0 = Length in bytes of encoded JPEG2000 code stream |
|||
|
• |
G2_JASPER_INIT Error initializing jasper library. |
|||
|
• |
G2_JASPER_ENCODE Error encode jpeg2000 code stream. |
Note
Requires JasPer Software version 1.500.4 or 1.700.2 or later.
Author
Stephen Gilbert
Date
2002-12-02
Author
Ed Hartnett
Definition at line 45 of file decenc_jpeg2000.c .
References enc_jpeg2000() .
int g2c_enc_png (unsigned char * data, int width, int height, int nbits,unsigned char * pngbuf)
Encode PNG.
Parameters
data
data.
width
width.
height
height.
nbits
number of bits.
pngbuf
PNG buffer.
Returns
PNG length, or negative number for error.
Author
Alyson Stahl
Definition at line 237 of file decenc_png.c .
References enc_png() .
int g2c_find_desc (char * title, int code, char * desc)
Given a table title and an integer code, find a description.
Parameters
title
Title of table.
code
Code to search for as an int.
desc
Pointer that gets a copy of the description. Must
be allocated to
G2C_MAX_GRIB_DESC_LEN
+ 1.
Author
Ed Hartnett
Date
8/28/22
Returns
0 for success, error code otherwise.
Definition at line 131 of file g2ccsv.c .
References g2c_find_desc_str() , and G2C_MAX_GRIB_CODE_LEN .
Referenced by g2c_log_section1() .
int g2c_find_desc_str (char * title, char * code, char * desc)
Given a table title and a code, find a description.
Parameters
title
Title of table.
code
Code to search for.
desc
Pointer that gets a copy of the description. Must
be allocated to
G2C_MAX_GRIB_DESC_LEN
+ 1.
Author
Ed Hartnett
Date
8/28/22
Returns
0 for success, error code otherwise.
Definition at line 84 of file g2ccsv.c .
References G2C_EINVAL , G2C_ENOTFOUND , G2C_MAX_GRIB_CODE_LEN , G2C_MAX_GRIB_TITLE_LEN , G2C_NOERROR , and g2c_table .
Referenced by g2c_find_desc() .
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. A grib message is identified by its indicator section, i.e. an 8-byte sequence with ’GRIB’ in bytes 1-4 and a ’1’ or ’2’ in byte 8. If found, the length of the message is decoded from bytes 5-7. The search is done over a given section of the file. The search is terminated if an eof or i/o error is encountered.
Parameters
g2cid
ID of the opened
grib file, returned by
g2c_open()
.
skip_bytes
Number of bytes to skip before search.
max_bytes
Maximum number of bytes to search.
bytes_to_msg
Pointer that gets the number of bytes to
skip before message.
bytes_in_msg
Pointer that gets the number of bytes in
message (or 0 if no message found)
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
|||
|
• |
G2C_EFILE File error. |
|||
|
• |
G2C_EINVAL Invalid input. |
Author
Ed Hartnett
Date
2022-08-19
Definition at line 164 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_EMSG , G2C_ENOMEM , G2C_ERROR , g2c_file , G2C_MAGIC_HEADER_LEN , G2C_NOERROR , LOG , MIN , and READ_BUF_SIZE .
void g2c_free_tables ()
Free table memory.
Author
Ed Hartnett
Date
8/28/22
Definition at line 42 of file g2ccsv.c .
References g2c_table .
Referenced by g2c_log_file() .
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 iout array. This is similar to gbit() , but with int types instead of g2int.
Parameters
in
pointer to character
array input.
iout
pointer that gets the unpacked array output.
iskip
initial number of bits to skip.
nbits
number of bits to take.
Author
NOAA Programmer
Definition at line 113 of file gbits.c .
References 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 iout array. This is similar to gbits() , but with int types instead of g2int.
Parameters
in
Pointer to character
array input.
iout
Pointer that gets the unpacked array output.
iskip
Initial number of bits to skip.
nbits
Number of bits to take.
nskip
Additional number of bits to skip on each
iteration.
n
Number of iterations.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
8/31/22
Definition at line 137 of file gbits.c .
References G2C_EINVAL , G2C_ENOMEM , G2C_NOERROR , and gbits() .
Referenced by g2c_gbit_int() .
int g2c_get_drs_template (int drs_template_num, int * maplen, int * map,int * needext)
Get DRS template information. The DRS template consists of a template map, and its length. There are no supported DRS templates with extensions.
Parameters
drs_template_num
The DRS
template number.
maplen
Pointer that gets the length of the map. Ignored
if NULL.
map
Pointer that gets the map as an array of int. Memory
must be allocated by caller. Ignored if NULL.
needext
Pointer that a non-zero value if an extension to
this template is needed. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOTEMPLATE Template not found. |
Author
Ed Hartnett
Date
10/18/22
Definition at line 266 of file drstemplates.c .
References G2C_ENOTEMPLATE , G2C_MAX_DRS_TEMPLATE , G2C_NOERROR , and templatesdrs .
Referenced by g2c_rw_section5_metadata() .
int g2c_get_grid_template (int grid_template_num, int * maplen, int * map,int * needext)
Get grid template information. The grid template consists of a template map, its length, and, for some templates, an extra extension map, and its length. If an extension is needed, use g2c_get_grid_template_extension() to get it.
Parameters
grid_template_num
The
grid template number.
maplen
Pointer that gets the length of the map. Ignored
if NULL.
map
Pointer that gets the map as an array of int. Memory
must be allocated by caller. Ignored if NULL.
needext
Pointer that a non-zero value if an extension to
this template is needed. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOTEMPLATE Template not found. |
Author
Ed Hartnett
Date
10/16/22
Definition at line 391 of file gridtemplates.c .
References G2C_ENOTEMPLATE , G2C_MAX_GDS_TEMPLATE , G2C_NOERROR , and templatesgrid .
Referenced by g2c_rw_section3_metadata() .
int g2c_get_grid_template_extension (int grid_template_num, int * template,int * extlen, int * ext)
Get grid template extension information.
Parameters
grid_template_num
The
grid template number.
template
Pointer to array that contains the template
values.
extlen
Pointer that gets the length of the extension.
Ignored if NULL.
ext
Pointer that gets template extension array, if there
is one. Memory must be allocated by the caller. Ignored if
NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOTEMPLATE Template not found. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
10/16/22
Definition at line 316 of file gridtemplates.c .
References gtemplate::ext , extgridtemplate() , gtemplate::extlen , G2C_EINVAL , G2C_ENOMEM , G2C_ENOTEMPLATE , G2C_MAX_GDS_TEMPLATE , G2C_NOERROR , and templatesgrid .
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 the message. A grib message is identified by its indicator section, i.e. an 8-byte sequence with ’GRIB’ in bytes 1-4 and a ’1’ or ’2’ in byte 8. If found, the length of the message is decoded from bytes 5-7. The search is done over a given section of the file. The search is terminated if an EOF or I/O error is encountered.
Parameters
g2cid
ID of the opened
grib file, returned by
g2c_open()
.
skip_bytes
The number of bytes to skip before search.
max_bytes
The maximum number of bytes to search. Must be
at least 16.
bytes_to_msg
A pointer that gets the number of bytes to
skip before message.
bytes_in_msg
A pointer that gets the number of bytes in
message (or 0 if no message found)
cbuf
A pointer that gets allocation of memory, into
which the message is copied. This memory must be freed by
the caller.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
|||
|
• |
G2C_EFILE File error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOMSG No GRIB message found. |
Author
Ed Hartnett
Date
2022-08-20
Definition at line 291 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_ENOMEM , G2C_ENOMSG , G2C_ERROR , g2c_file , G2C_MIN_MAX_BYTES , G2C_NOERROR , LOG , and seekgb() .
int g2c_get_pds_template (int pds_template_num, int * maplen, int * map,int * needext)
Get PDS template information. The PDS template consists of a template map, its length, and, for some templates, an extra extension map, and its length. If an extension is needed, use g2c_get_pds_template_extension() to get it.
Parameters
pds_template_num
The PDS
template number.
maplen
Pointer that gets the length of the map. Ignored
if NULL.
map
Pointer that gets the map as an array of int. Memory
must be allocated by caller. Ignored if NULL.
needext
Pointer that a non-zero value if an extension to
this template is needed. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOTEMPLATE Template not found. |
Author
Ed Hartnett
Date
10/18/22
Definition at line 1806 of file pdstemplates.c .
References G2C_ENOTEMPLATE , G2C_MAX_PDS_TEMPLATE , G2C_NOERROR , and templatespds .
Referenced by g2c_rw_section4_metadata() .
int g2c_get_pds_template_extension (int pds_template_num, int * template,int * extlen, int * ext)
Get pds template extension information.
Parameters
pds_template_num
The pds
template number.
template
Pointer to array that contains the template
values.
extlen
Pointer that gets the length of the extension.
Ignored if NULL.
ext
Pointer that gets template extension array, if there
is one. Memory must be allocated by the caller. Ignored if
NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOTEMPLATE Template not found. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
10/16/22
Definition at line 1731 of file pdstemplates.c .
References gtemplate::ext , gtemplate::extlen , extpdstemplate() , G2C_EINVAL , G2C_ENOMEM , G2C_ENOTEMPLATE , G2C_MAX_PDS_TEMPLATE , G2C_NOERROR , and templatespds .
int g2c_get_prod (int g2cid, int msg_num, int prod_num, int *num_data_points, float * data)
Read the data for a product.
Parameters
g2cid
File ID.
msg_num
Message number in file (first message in file is
message 0).
prod_num
Product number in message (first product in
message is product 0).
num_data_points
Pointer that gets the number of data
points in the product. Ignored if NULL.
data
Pointer that gets the data. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
Sep 28, 2022
Definition at line 32 of file g2cprod.c .
References g2c_message_info::bytes_to_msg , g2c_section_info::bytes_to_sec , g2c_section5_info::data_def , g2c_file_info::f , G2C_EBADID , G2C_EFILE , G2C_EINVAL , G2C_ENOMEM , G2C_ENOMSG , G2C_ENOPRODUCT , G2C_ENOSECTION , G2C_ERROR , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_unpack7() , g2c_section3_info::grid_def , g2c_section_info::msg , g2c_message_info::msg_num , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_section_info::next , g2c_section5_info::num_data_points , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_len , g2c_section_info::sec_num , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by g2c_degrib2() .
int g2c_inq (int g2cid, int * num_msg)
Learn about a GRIB2 file.
Parameters
g2cid
ID of the opened
file, as from
g2c_open()
.
num_msg
Pointer that gets the number of messages in the
file. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
Author
Ed Hartnett
Date
10/21/22
Definition at line 31 of file g2cinq.c .
References G2C_EBADID , g2c_file , G2C_MAX_FILES , G2C_NOERROR , MUTEX_LOCK , MUTEX_UNLOCK , and g2c_file_info::num_messages .
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. This function will return the size, name, and values along the dimension.
Parameters
g2cid
ID of the opened
file, as from
g2c_open()
.
msg_num
Number of the message in the file, starting with
the first message as 0.
prod_num
Product number.
dim_num
Dimension number, with the first dimension as 0.
len
Pointer that gets the length of this dimension.
Ignored if NULL.
name
Pointer that gets the name of this dimension. Must
have memory of size G2C_MAX_NAME. Ignored if NULL.
val
Pointer that gets array of dimension values, of
length len. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
|||
|
• |
G2C_ENOMSG Message not found. |
|||
|
• |
G2C_ENOPRODUCT Product not found. |
|||
|
• |
G2C_ENOSECTION GDS not found. |
Author
Ed Hartnett
Date
10/21/22
Definition at line 372 of file g2cinq.c .
References G2C_EBADID , G2C_EINVAL , G2C_ENOMSG , G2C_ENOPRODUCT , G2C_ENOSECTION , g2c_file , G2C_MAX_FILES , G2C_MAX_NAME , G2C_NOERROR , g2c_dim_info::len , g2c_message_info::msg_num , MUTEX_LOCK , MUTEX_UNLOCK , g2c_dim_info::name , g2c_message_info::next , g2c_section_info::next , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_num , and g2c_dim_info::value .
Referenced by 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. This function will return the size and name of the dimension.
Parameters
g2cid
ID of the opened
file, as from
g2c_open()
.
msg_num
Number of the message in the file, starting with
the first message as 0.
prod_num
Product number.
dim_num
Dimension number, with the first dimension as 0.
len
Pointer that gets the length of this dimension.
Ignored if NULL.
name
Pointer that gets the name of this dimension. Must
have memory of size G2C_MAX_NAME. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
|||
|
• |
G2C_ENOMSG Message not found. |
|||
|
• |
G2C_ENOPRODUCT Product not found. |
|||
|
• |
G2C_ENOSECTION GDS not found. |
Author
Ed Hartnett
Date
10/21/22
Definition at line 468 of file g2cinq.c .
References g2c_inq_dim() .
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.
Parameters
g2cid
ID of the opened
file, as from
g2c_open()
.
msg_num
Number of the message in the file, starting with
the first message as 0.
discipline
Pointer that gets the discipline from the
message. Ignored if NULL.
num_fields
Pointer that gets the number of fields in the
message. Ignored if NULL.
num_local
Pointer that gets the number of local sections
in the message. Ignored if NULL.
center
Pointer that gets the code for the producing
center from the message. Ignored if NULL.
subcenter
Pointer that gets the code for the producing
subcenter from the message. Ignored if NULL.
master_version
Pointer that gets the master version from
the message. Ignored if NULL.
local_version
Pointer that gets the local version from
the message. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
|||
|
• |
G2C_ENOMSG Message not found. |
Author
Ed Hartnett
Date
10/21/22
Definition at line 87 of file g2cinq.c .
References g2c_message_info::center , g2c_message_info::discipline , G2C_EBADID , G2C_EINVAL , G2C_ENOMSG , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_message_info::local_version , g2c_message_info::master_version , g2c_message_info::msg_num , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_message_info::num_fields , g2c_message_info::num_local , and g2c_message_info::subcenter .
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.
Parameters
g2cid
ID of the opened
file, as from
g2c_open()
.
msg_num
Number of the message in the file, starting with
the first message as 0.
sig_ref_time
Pointer that gets Significane of reference
time value from the message. Ignored if NULL.
year
Pointer that gets the year from the message.
Ignored if NULL.
month
Pointer that gets the month from the message.
Ignored if NULL.
day
Pointer that gets the day from the message. Ignored
if NULL.
hour
Pointer that gets the hour from the message.
Ignored if NULL.
minute
Pointer that gets the minute from the message.
Ignored if NULL.
second
Pointer that gets the seconds from the message.
Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
|||
|
• |
G2C_ENOMSG Message not found. |
Author
Ed Hartnett
Date
10/22/22
Definition at line 170 of file g2cinq.c .
References g2c_message_info::day , G2C_EBADID , G2C_EINVAL , G2C_ENOMSG , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_message_info::hour , g2c_message_info::minute , g2c_message_info::month , g2c_message_info::msg_num , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_message_info::second , g2c_message_info::sig_ref_time , and g2c_message_info::year .
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.
Parameters
g2cid
File ID.
msg_num
Message number.
prod_num
Product number.
pds_template_len
PDS template length. Ignored if NULL.
pds_template
Pointer that gets the PDS template. Ignored
if NULL.
gds_template_len
GDS template length. Ignored if NULL.
gds_template
Pointer that gets the GDS template. Ignored
if NULL.
drs_template_len
The DRS template length. Ignored if
NULL.
drs_template
Pointer that gets the DRS template. Ignored
if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID File ID not found. |
|||
|
• |
G2C_ENOMSG Message not found. |
|||
|
• |
G2C_ENOPRODUCT Product not found. |
|||
|
• |
G2C_ENOSECTION Section not found. |
Author
Ed Hartnett
Date
10/21/22
Definition at line 247 of file g2cinq.c .
References G2C_EBADID , G2C_EINVAL , G2C_ENOMSG , G2C_ENOPRODUCT , G2C_ENOSECTION , g2c_file , G2C_MAX_FILES , G2C_NOERROR , g2c_message_info::msg_num , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_section_info::next , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_section_info::template , and g2c_section_info::template_len .
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. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder.
This function also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
This function is the V2 API version of jpcpack() for doubles.
Parameters
fld
Pointer to the
double data values to pack.
width
The number of points in the x direction.
height
The number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation Template
Table 5.40
or 5.40000.
|
• |
0 Reference value - ignored on input, set by jpcpack routine. |
||
|
• |
1 Binary Scale Factor - used on input, unchanged by jpcpack routine. |
||
|
• |
2 Decimal Scale Factor - used on input, unchanged by jpcpack routine. |
||
|
• |
3 number of bits for each data value - ignored on input |
||
|
• |
4 Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output. |
||
|
• |
5 if 0 use lossless compression, if 1 use lossy compression. |
||
|
• |
6 Desired compression ratio, if idrstmpl[5]=1. Set to 255, if idrstmpl[5]=0. May be modified in this function. |
cpack
A
pointer that will get the packed data field. Must be
allocated before this function is called. Pass the allocated
size in the lcpack parameter.
lcpack
Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size
available in cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EJPEG Error encoding/decoding JPEG data. |
Author
Ed Hartnett
Definition at line 386 of file jpcpack.c .
References G2C_JPEG_DRS_TEMPLATE_LEN , and jpcpack_int() .
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. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder.
This function also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
This function is the V2 API version of jpcpack() for floats.
Parameters
fld
Pointer to the float
data values to pack.
width
The number of points in the x direction.
height
The number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation Template
Table 5.40
or 5.40000.
|
• |
0 Reference value - ignored on input, set by jpcpack routine. |
||
|
• |
1 Binary Scale Factor - used on input, unchanged by jpcpack routine. |
||
|
• |
2 Decimal Scale Factor - used on input, unchanged by jpcpack routine. |
||
|
• |
3 number of bits for each data value - ignored on input |
||
|
• |
4 Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output. |
||
|
• |
5 if 0 use lossless compression, if 1 use lossy compression. |
||
|
• |
6 Desired compression ratio, if idrstmpl[5]=1. Set to 255, if idrstmpl[5]=0. May be modified in this function. |
cpack
A
pointer that will get the packed data field. Must be
allocated before this function is called. Pass the allocated
size in the lcpack parameter.
lcpack
Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size
available in cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EJPEG Error encoding/decoding JPEG data. |
Author
Ed Hartnett
Definition at line 320 of file jpcpack.c .
References G2C_JPEG_DRS_TEMPLATE_LEN , and jpcpack_int() .
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 Representation Template 5.40 or 5.40000. This function is the V2 API version of jpcunpack() for doubles.
Parameters
cpack
The packed data.
len
The length of the packed data.
idrstmpl
Pointer to array of values for Data
Representation
Template 5.40
or 5.40000.
ndpts
The number of data values to unpack.
fld
A pointer that gets the unpacked data values as an
array of double.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
2022-08-12
Definition at line 199 of file jpcunpack.c .
References G2C_JPEG_DRS_TEMPLATE_LEN , jpcunpack_int() , and LOG .
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 Representation Template 5.40 or 5.40000.
Parameters
cpack
The packed data.
len
The length of the packed data.
idrstmpl
Pointer to array of values for Data
Representation
Template 5.40
or 5.40000.
ndpts
The number of data values to unpack.
fld
A pointer that gets the unpacked data values as an
array of float.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
2022-09-08
Definition at line 159 of file jpcunpack.c .
References G2C_JPEG_DRS_TEMPLATE_LEN , jpcunpack_int() , and LOG .
int g2c_log_file (int g2cid)
Print a summary of the contents of an open GRIB2 file. If the NCEPLIBS-g2c library is built without the LOGGING option, this function will do nothing.
Parameters
g2cid The file ID, returned by g2c_open() or g2c_create().
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID g2cid not found. |
Author
Ed Hartnett 8/22/22
Definition at line 189 of file g2cutil.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_msg , g2c_message_info::center , g2c_message_info::day , g2c_csv_init() , G2C_EBADID , g2c_file , g2c_free_tables() , g2c_log_section() , g2c_log_section1() , G2C_NOERROR , g2c_table , g2c_message_info::hour , g2c_message_info::local_version , LOG , g2c_message_info::master_version , g2c_message_info::minute , g2c_message_info::month , g2c_message_info::msg_num , g2c_message_info::next , g2c_section_info::next , g2c_message_info::num_fields , g2c_message_info::num_local , g2c_message_info::sec , g2c_message_info::sec1_len , g2c_message_info::second , g2c_message_info::sig_ref_time , g2c_message_info::status , g2c_message_info::subcenter , g2c_message_info::type , and g2c_message_info::year .
Referenced by read_metadata() .
int g2c_open (const char * path, int mode, int * g2cid)
Open an existing GRIB2 file. This function opens the GRIB2 file and reads its metadata.
GRIB2 messages in the file are assigned a message ID, starting with 0 for the first message in the file.
Each product within a message is assigned a product ID, starting with 0 for the first product in the message.
Files opened with this function should be closed with a call g2c_close() to release resources.
Parameters
path
Path of the file.
mode
Open mode flags.
g2cid
Pointer that gets an indentifier for the file.
Returns
|
• |
G2C_NOERROR - No error. |
||
|
• |
G2C_EINVAL - Invalid input. |
||
|
• |
G2C_ETOOMANYFILES - Trying to open too many files at the same time. |
Author
Ed Hartnett
Date
Aug 16, 2022
Definition at line 1201 of file g2cfile.c .
References g2c_add_file() , LOG , MUTEX_LOCK , MUTEX_UNLOCK , and read_metadata() .
Referenced by main() .
int g2c_open_index (const char * data_file, const char * index_file, intmode, int * g2cid)
Open a GRIB2 file with the help of an index file. The index file, generated by the grb2index utility, of the g2c_write_index() function, contains the byte offsets for the sections of each message in the GRIB2 file. When a GRIB2 file is opened with an index file, the library does not have to scan the file to locate all metadata.
Parameters
data_file
The name of
the data file to which the index applies.
index_file
The name that will be given to the index
file. An existing file will be overwritten.
mode
Open mode flags.
g2cid
Pointer that gets the g2cid for this file. Ignored
if NULL.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 914 of file g2cindex.c .
References add_msg() , add_section() , g2c_message_info::bytes_to_bms , g2c_message_info::bytes_to_data , g2c_message_info::bytes_to_local , g2c_message_info::bytes_to_msg , g2c_message_info::discipline , g2c_add_file() , G2C_EBADSECTION , G2C_EFILE , G2C_EINVAL , G2C_ENAMETOOLONG , g2c_file , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_FILE_READ , G2C_INDEX_BASENAME_LEN , G2C_INDEX_DATE_STR_LEN , G2C_INDEX_HEADER_LEN , G2C_INDEX_STR1_LEN , G2C_INDEX_TIME_STR_LEN , g2c_log_section1() , G2C_MAX_NAME , G2C_NOERROR , g2c_rw_section1_metadata() , g2c_start_index_record() , g2c_start_index_record_lf() , LOG , g2c_message_info::master_version , MUTEX_LOCK , and MUTEX_UNLOCK .
Referenced by main() .
int g2c_open_index1 (const char * index_file)
Open a GRIB1 index file and read the contents. This function opens the GRIB2 index file and reads its metadata, and opens the accompanying GRIB2 file.
GRIB2 messages in the file are assigned a message ID, starting with 0 for the first message in the file.
Each product within a message is assigned a product ID, starting with 0 for the first product in the message.
Files opened with this function should be closed with a call g2c_close() to release resources.
Parameters
index_file The name that will be given to the index file. An existing file will be overwritten.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 812 of file g2cindex.c .
References G2C_EFILE , G2C_EINVAL , G2C_FILE_READ , G2C_INDEX1_BDS_VAL_LEN , G2C_INDEX1_BMS_VAL_LEN , G2C_INDEX1_GDS_VAL_LEN , G2C_INDEX1_PDS_VAL_LEN , G2C_INDEX_BASENAME_LEN , G2C_INDEX_DATE_STR_LEN , G2C_INDEX_HEADER_LEN , G2C_INDEX_TIME_STR_LEN , G2C_NOERROR , g2c_start_index1_record() , LOG , MUTEX_LOCK , MUTEX_UNLOCK , read_hdr_rec1() , and read_hdr_rec2() .
int g2c_param_abbrev (int g2disc, int g2cat, int g2num, char * abbrev)
Get NOAA abbreviation for a GRIB2 parameter.
Parameters
g2disc
The GRIB2
discipline number.
g2cat
The GRIB2 category number.
g2num
The GRIB2 parameter number.
abbrev
Pointer that gets the abbreviation. Ignored if
NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EFILE Error reading CSV file. |
|||
|
• |
G2C_ENOPARAM Parameter not found. |
Author
Ed Hartnett
Date
9/19/22
Definition at line 1091 of file g2cparams.c .
References G2C_MAX_NOAA_ABBREV_LEN , G2C_MAX_NOAA_PARAMS , G2C_NOERROR , LOG , and param .
Referenced by g2c_degrib2() , and g2c_log_section() .
int g2c_param_all (int param_idx, int * g1num, int * g1ver, int * g2disc,int * g2cat, int * g2num, char * abbrev)
Return all the information about a parameter.
Parameters
param_idx
Parameter
index between 0 and
G2C_MAX_NOAA_PARAMS
.
g1num
Pointer that gets the GRIB1 parameter. Ignored if
NULL.
g1ver
Pointer that gets the GRIB1 parameter table
version number. Ignored if NULL.
g2disc
Pointer that gets the GRIB2 discipline number.
Ignored if NULL.
g2cat
Pointer that gets the GRIB2 category number.
Ignored if NULL.
g2num
Pointer that gets the GRIB2 parameter number.
Ignored if NULL.
abbrev
Pointer that gets the abbreviation.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_EFILE Error reading CSV file. |
|||
|
• |
G2C_ENOPARAM Parameter not found. |
Author
Ed Hartnett
Date
9/19/22
Definition at line 1185 of file g2cparams.c .
References g2c_param::g1num , g2c_param::g1ver , G2C_EINVAL , G2C_MAX_NOAA_ABBREV_LEN , G2C_MAX_NOAA_PARAMS , G2C_NOERROR , g2c_param::g2cat , g2c_param::g2disc , g2c_param::g2num , and param .
int g2c_param_g1tog2 (int g1num, int g1ver, int * g2disc, int * g2cat, int* g2num)
Translate GRIB1 parameter to GRIB2 parameter.
Parameters
g1num
The GRIB1
parameter.
g1ver
The GRIB1 parameter table version number.
g2disc
Pointer that gets the GRIB2 discipline number.
Ignored if NULL.
g2cat
Pointer that gets the GRIB2 category number.
Ignored if NULL.
g2num
Pointer that gets the GRIB2 parameter number.
Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EFILE Error reading CSV file. |
|||
|
• |
G2C_ENOPARAM Parameter not found. |
Author
Ed Hartnett
Date
9/19/22
Definition at line 1051 of file g2cparams.c .
References G2C_ENOPARAM , G2C_MAX_NOAA_PARAMS , G2C_NOERROR , g2c_param::g2cat , g2c_param::g2disc , g2c_param::g2num , and param .
int g2c_param_g2tog1 (int g2disc, int g2cat, int g2num, int * g1num, int *g1ver)
Translate GRIB2 parameter to GRIB1 parameter.
Parameters
g2disc
The GRIB2
discipline number.
g2cat
The GRIB2 category number.
g2num
The GRIB2 parameter number.
g1num
Pointer that gets the GRIB1 parameter. Ignored if
NULL.
g1ver
Pointer that gets the GRIB1 parameter table
version number. Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EFILE Error reading CSV file. |
|||
|
• |
G2C_ENOPARAM Parameter not found. |
Author
Ed Hartnett
Date
9/19/22
Definition at line 1136 of file g2cparams.c .
References g2c_param::g1num , g2c_param::g1ver , G2C_ENOPARAM , G2C_MAX_NOAA_PARAMS , G2C_NOERROR , LOG , and param .
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. After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder. It also fills in GRIB2 Data Representation Template 5.41 or 5.40010 with the appropriate values.
Parameters
fld
Pointer to array of
double that contains the data values to pack.
width
Number of points in the x direction.
height
Number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation
Template 5.41
or 5.40010.
|
• |
0 Reference value - ignored on input, set by pngpack routine. |
||
|
• |
1 Binary Scale Factor - used on input. |
||
|
• |
2 Decimal Scale Factor - used on input. |
||
|
• |
3 number of bits for each grayscale pixel value - ignored on input. |
||
|
• |
4 Original field type - currently ignored on input, set = 0 on output. Data values assumed to be reals. |
cpack
The packed data field.
lcpack
length of packed field cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EPNG Error encoding/decoding PNG data. |
Author
Ed Hartnett
Date
Aug 8, 2022
Definition at line 348 of file pngpack.c .
References G2C_PNG_DRS_TEMPLATE_LEN , and pngpack_int() .
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. After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder. It also fills in GRIB2 Data Representation Template 5.41 or 5.40010 with the appropriate values.
Parameters
fld
Pointer to array of
float that contains the data values to pack.
width
Number of points in the x direction.
height
Number of points in the y direction.
idrstmpl
Contains the array of values for Data
Representation
Template 5.41
or 5.40010.
|
• |
0 Reference value - ignored on input, set by pngpack routine. |
||
|
• |
1 Binary Scale Factor - used on input. |
||
|
• |
2 Decimal Scale Factor - used on input. |
||
|
• |
3 number of bits for each grayscale pixel value - ignored on input. |
||
|
• |
4 Original field type - currently ignored on input, set = 0 on output. Data values assumed to be reals. |
cpack
The packed data field.
lcpack
length of packed field cpack.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EPNG Error encoding/decoding PNG data. |
Author
Ed Hartnett
Definition at line 294 of file pngpack.c .
References G2C_PNG_DRS_TEMPLATE_LEN , and pngpack_int() .
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 GRIB2 Data Representation Template 5.41 or 5.40010.
Parameters
cpack
The packed data
field (character*1 array).
len
length of packed field cpack().
idrstmpl
Pointer to array of values for Data
Representation
Template 5.41
or 5.40010.
ndpts
The number of data values to unpack.
fld
Contains the unpacked data values.
Returns
|
• |
G2C_NOERROR No Error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
Aug 8, 2022
Definition at line 188 of file pngunpack.c .
References G2C_PNG_DRS_TEMPLATE_LEN , and pngunpack_int() .
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 GRIB2 Data Representation Template 5.41 or 5.40010.
Parameters
cpack
The packed data
field (character*1 array).
len
length of packed field cpack().
idrstmpl
Pointer to array of values for Data
Representation
Template 5.41
or 5.40010.
ndpts
The number of data values to unpack.
fld
Contains the unpacked data values.
Returns
|
• |
G2C_NOERROR No Error. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
Sep 8, 2022
Definition at line 156 of file pngunpack.c .
References G2C_PNG_DRS_TEMPLATE_LEN , and pngunpack_int() .
int g2c_seekmsg (int g2cid, size_t skip, size_t * offset, size_t * msglen)
Search a file for the next GRIB2 Message. The search is terminated when a GRIB2 message is found, or the end of the file is reached.
Parameters
g2cid
ID of an open
GRIB2 file, returned from
g2c_open()
/g2c_create().
skip
The number of bytes in the file to skip before
starting the search.
offset
Pointer that gets the number of bytes to skip
from the beggining of the file to where the GRIB message
starts. Ignored if NULL.
msglen
Pointer that gets the number of bytes in message
(set to 0, if no message found). Ignored if NULL.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EBADID Bad g2cid. |
|||
|
• |
G2C_ENOMEM Out of memory. |
Author
Ed Hartnett
Date
2022-09-11
Definition at line 56 of file g2cfile.c .
References G2C_EBADID , G2C_EFILE , G2C_ENOMEM , g2c_file , G2C_MAGIC_HEADER , G2C_NOERROR , G2C_SEEKMSG_BUFSIZE , hton64 , and LOG .
Referenced by read_metadata() .
int g2c_set_log_level (int new_level)
Use this to set the global log level. Settings:
|
• |
-1 turn off all logging. |
|||
|
• |
0 show only errors. |
|||
|
• |
1 output useful as verbose to utilities. |
|||
|
• |
2 or 3 shows some/all calls to top-level functions. |
|||
|
• |
4+ ever greater levels of detail. |
If logging is not enabled when building NCEPLIBS-g2c, this function will do nothing.
Parameters
new_level The new logging level.
Returns
G2C_NOERROR No error.
Author
Ed Hartnett
Definition at line 129 of file util.c .
References G2C_NOERROR , and LOG .
Referenced by main() .
const char * g2c_strerror (int g2cerr)
Given an error code, return an error message.
Parameters
g2cerr An error number returned by one of the g2c_* functions.
Returns
The error message.
Author
Ed Hartnett
Definition at line 29 of file g2cutil.c .
References G2C_EBADEND , G2C_EBADID , G2C_EBADSECTION , G2C_EBADTEMPLATE , G2C_EBADTYPE , G2C_EFILE , G2C_EINVAL , G2C_EJPEG , G2C_EMSG , G2C_EMSGCOMPLETE , G2C_ENAMETOOLONG , G2C_ENOEND , G2C_ENOMEM , G2C_ENOMSG , G2C_ENOPARAM , G2C_ENOPRODUCT , G2C_ENOSECTION , G2C_ENOTEMPLATE , G2C_ENOTFOUND , G2C_ENOTGRIB , G2C_ENOTGRIB2 , G2C_EPNG , G2C_ETOOMANYFILES , G2C_EXML , and G2C_NOERROR .
int g2c_unpack7 (unsigned char * cgrib, int igdsnum, int gds_tmpl_len, longlong 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. This function is the newer version of g2_unpack7() .
Parameters
cgrib
char array
containing Section 7 of the GRIB2 message
igdsnum
Grid Definition Template Number (see Code Table
3.0). (Only used for DRS Template 5.51.) May be zero for
other templates.
gds_tmpl_len
Number of elements in the GDS template.
gdstmpl
Pointer to an integer array containing the data
values for the specified Grid Definition Template
(N=igdsnum). Each element of this integer array contains an
entry (in the order specified) of Grid Definition Template
3.N. (Only used for DRS Template 5.51). May be NULL.
idrsnum
Data Representation Template Number (see Code
Table 5.0).
drs_tmpl_len
Number of elements in the DRS template.
drstmpl
Pointer to an integer array containing the data
values for the specified Data Representation Template
(N=idrsnum). Each element of this integer array contains an
entry (in the order specified) of Data Representation
Template 5.N
ndpts
Number of data points to be unpacked and returned.
fld
Pointer which the data. Memory must be allocated in
advance by caller.
Returns
|
• |
G2_NO_ERROR No error. |
||
|
• |
G2_UNPACK_BAD_SEC Array passed had incorrect section number. |
||
|
• |
G2_UNPACK7_BAD_DRT Unrecognized Data Representation Template. |
||
|
• |
G2_UNPACK7_WRONG_GDT need one of GDT 3.50 through 3.53 to decode DRT 5.51 |
||
|
• |
G2_UNPACK_NO_MEM Memory allocation error. |
||
|
• |
G2_UNPACK7_CORRUPT_SEC Corrupt section 7. |
Author
Stephen Gilbert
Date
2002-10-31
Definition at line 259 of file g2_unpack7.c .
References G2C_EINVAL , G2C_ENOMEM , g2c_unpack7_int() , and LOG .
Referenced by g2c_get_prod() .
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. The index file starts with two header records:
|
1. |
81-byte header with ’gb2ix1’ in columns 42-47. |
||
|
2. |
81-byte header with number of bytes to skip before index records, total length in bytes of the index records, number of index records, and grib file basename written in format (’ix1form:’,3i10,2x,a40). |
Each following index record corresponds to a grib message and has the internal format:
|
• |
byte 001 - 004 length of index record |
||
|
• |
byte 005 - 008 bytes to skip in data file before grib message |
||
|
• |
byte 009 - 012 bytes to skip in message before lus (local use) (0, if none). |
||
|
• |
byte 013 - 016 bytes to skip in message before gds |
||
|
• |
byte 017 - 020 bytes to skip in message before pds |
||
|
• |
byte 021 - 024 bytes to skip in message before drs |
||
|
• |
byte 025 - 028 bytes to skip in message before bms |
||
|
• |
byte 029 - 032 bytes to skip in message before data section |
||
|
• |
byte 033 - 040 bytes total in the message |
||
|
• |
byte 041 - 041 grib version number (currently 2) |
||
|
• |
byte 042 - 042 message discipline |
||
|
• |
byte 043 - 044 field number within grib2 message (1-based) |
||
|
• |
byte 045 - ii identification section (ids) |
||
|
• |
byte ii+1- jj grid definition section (gds) |
||
|
• |
byte jj+1- kk product definition section (pds) |
||
|
• |
byte kk+1- ll the data representation section (drs) |
||
|
• |
byte ll+1-ll+6 first 6 bytes of the bit map section (bms) |
Parameters
g2cid
File it for an
open GRIB2 file, as returned by
g2c_open()
.
mode
Mode flags. Set
G2C_NOCLOBBER
to avoid
overwriting and existing file.
index_file
The name that will be given to the index
file. An existing file will be overwritten.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/12/22
Definition at line 431 of file g2cindex.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_local , g2c_message_info::bytes_to_msg , g2c_section_info::bytes_to_sec , g2c_message_info::discipline , g2c_file_info::f , g2c_message_info::file , G2C_EBADID , G2C_EFILE , G2C_EINVAL , g2c_file , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_FILE_WRITE , g2c_get_prod_sections() , G2C_INDEX_BASENAME_LEN , G2C_INDEX_BITMAP_BYTES , G2C_INDEX_FIXED_LEN , G2C_INDEX_FIXED_LEN_2 , G2C_INDEX_HEADER_LEN , G2C_LARGE_FILE_INDEX , G2C_MAX_FILES , G2C_NOCLOBBER , G2C_NOERROR , g2c_rw_section1_metadata() , g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , g2c_rw_section5_metadata() , g2c_start_index_record() , g2c_start_index_record_lf() , LOG , g2c_message_info::master_version , MUTEX_LOCK , MUTEX_UNLOCK , g2c_message_info::next , g2c_message_info::num_fields , ONE_BYTE , g2c_message_info::sec1_len , and g2c_section_info::sec_len .
Referenced by main() .
void seekgb (FILE * lugb, g2int iseek, g2int mseek, g2int * lskip, g2int *lgrib)
Search a file for the next GRIB Message. The search is done starting at byte offset iseek of the file referenced by lugb for mseek bytes at a time. If found, the starting position and length of the message are returned in lskip and lgrib, respectively. The search is terminated when an EOF or I/O error is encountered.
Program History Log
Date Programmer Comments 2002-10-28 GILBERT Modified from Iredell’s skgb subroutine 2009-01-16 VUONG Changed lskip to 4 instead of sizof(g2int)
Parameters
lugb
FILE pointer for
the file to search. File must be opened before this routine
is called.
iseek
The number of bytes in the file to skip before
search.
mseek
The maximum number of bytes to search at a time
(must be at least 16, but larger numbers like 4092 will
result in better perfomance).
lskip
Pointer that gets the number of bytes to skip from
the beggining of the file to where the GRIB message starts.
lgrib
Pointer that gets the number of bytes in message
(set to 0, if no message found).
Author
Stephen Gilbert
Date
2002-10-28
Definition at line 46 of file seekgb.c .
References BYTE , gbit() , and LOG .
Referenced by g2c_get_msg() .
Author
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.