Man page - jpcunpack(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_int.h
NAMESYNOPSIS
Data Structures
Macros
Typedefs
Functions
Detailed Description
Data Type Documentation
struct g2c_code_table
struct g2c_dim_info
struct g2c_entry
struct g2c_file_info
struct g2c_message_info
struct g2c_param
struct g2c_section3_info
struct g2c_section4_info
struct g2c_section5_info
struct g2c_section6_info
struct g2c_section_info
struct gtemplate
Macro Definition Documentation
#define ALOG2 (0.69314718)
#define BYTE 8
#define EIGHT_BYTES 8
#define EXTERN_MUTEX(m)
#define FOUR_BYTES 4
#define G2C_FILE_READ 0
#define G2C_FILE_WRITE 1
#define G2C_INDEX1_BDS_VAL_LEN 10
#define G2C_INDEX1_BMS_VAL_LEN 5
#define G2C_INDEX1_GDS_VAL2_LEN 27
#define G2C_INDEX1_GDS_VAL_LEN 41
#define G2C_INDEX1_PDS_VAL2_LEN 27
#define G2C_INDEX1_PDS_VAL3_LEN 27
#define G2C_INDEX1_PDS_VAL_LEN 27
#define G2C_JASPER_JPEG_FORMAT_NAME ’jpc’
#define G2C_MAGIC_HEADER ’GRIB’
#define G2C_MAGIC_HEADER_LEN 8
#define G2C_MAX_MESSAGES 1024
#define G2C_MIN_MAX_BYTES 16
#define hton64(y) (((uint64_t)htonl(y)) << WORD | htonl(y >> WORD))
#define LATITUDE ’Latitude’
#define LOG(e)
#define LONGITUDE ’Longitude’
#define MUTEX(m)
#define MUTEX_LOCK(m)
#define MUTEX_UNLOCK(m)
#define ntoh64(y) (((uint64_t)ntohl(y)) << WORD | ntohl(y >> WORD))
#define ONE_BYTE 1
#define TWO_BYTES 2
#define WORD 32
Typedef Documentation
typedef struct g2c_entry G2C_CODE_ENTRY_T
typedef struct g2c_code_table G2C_CODE_TABLE_T
typedef struct g2c_dim_info G2C_DIM_INFO_T
typedef struct g2c_file_info G2C_FILE_INFO_T
typedef struct g2c_message_info G2C_MESSAGE_INFO_T
typedef struct g2c_param G2C_PARAM_T
typedef struct g2c_section3_info G2C_SECTION3_INFO_T
typedef struct g2c_section4_info G2C_SECTION4_INFO_T
typedef struct g2c_section5_info G2C_SECTION5_INFO_T
typedef struct g2c_section6_info G2C_SECTION6_INFO_T
typedef struct g2c_section_info G2C_SECTION_INFO_T
typedef struct gtemplate gtemplate
Function Documentation
int add_msg (G2C_FILE_INFO_T * file, int msg_num, size_t bytes_to_msg,size_t bytes_in_msg, int read_file, G2C_MESSAGE_INFO_T ** msg)
int add_section (FILE * f, G2C_MESSAGE_INFO_T * msg, int sec_id, unsignedint sec_len, size_t bytes_to_sec, unsigned char sec_num)
void aecpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
g2int aecunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, float * fld)
void cmplxpack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
void compack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
int comunpack (unsigned char * cpack, g2int lensec, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float * fld)
Program History Log
int dec_aec (unsigned char * cpack, g2int len, g2int nbits, g2int flags,g2int block_size, g2int rsi, unsigned char * cfld, g2int cfldlen)
int dec_jpeg2000 (char * injpc, g2int bufsize, g2int * outfld)
int dec_png (unsigned char * pngbuf, g2int * width, g2int * height,unsigned char * cout)
int enc_aec (unsigned char * data, g2int ctemplen, g2int nbits, g2intflags, g2int block_size, g2int rsi, unsigned char * aecbuf, g2int *aecbuflen)
int enc_jpeg2000 (unsigned char * cin, g2int width, g2int height, g2intnbits, g2int ltype, g2int ratio, g2int retry, char * outjpc, g2intjpclen)
int enc_png (unsigned char * data, g2int width, g2int height, g2int nbits,unsigned char * pngbuf)
gtemplate * extdrstemplate (g2int number, g2int * list)
gtemplate * extgridtemplate (g2int number, g2int * template)
gtemplate * extpdstemplate (g2int number, g2int * list)
int g2c_add_file (const char * path, int mode, int * g2cid)
int g2c_check_msg (unsigned char * cgrib, g2int * lencurr, int verbose)
int g2c_file_io (FILE * f, int write, int g2ctype, void * var)
int g2c_file_io_byte (FILE * f, int write, char * var)
int g2c_file_io_int (FILE * f, int write, int * var)
int g2c_file_io_longlong (FILE * f, int write, long long * var)
int g2c_file_io_short (FILE * f, int write, short * var)
int g2c_file_io_template (FILE * f, int rw_flag, int map, long long int *template_value)
int g2c_file_io_ubyte (FILE * f, int write, unsigned char * var)
int g2c_file_io_uint (FILE * f, int write, unsigned int * var)
int g2c_file_io_ulonglong (FILE * f, int write, unsigned long long * var)
int g2c_file_io_ushort (FILE * f, int write, unsigned short * var)
int g2c_get_datetime (int ipdtn, long long int * ipdtmpl, short year,unsigned char month, unsigned char day, unsigned char hour, unsignedchar minute, unsigned char second, char * tabbrev)
int g2c_get_level_desc (int ipdtn, long long int * ipdtmpl, char *level_desc)
int g2c_log_section1 (G2C_MESSAGE_INFO_T * msg)
int g2c_rw_section1_metadata (FILE * f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
int g2c_rw_section3_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section4_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section5_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
int g2c_rw_section6_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
void gbit (unsigned char * in, g2int * iout, g2int iskip, g2int nbits)
void gbits (unsigned char * in, g2int * iout, g2int iskip, g2int nbits,g2int nskip, g2int n)
g2int getdim (unsigned char * csec3, g2int * width, g2int * height, g2int *iscan)
gtemplate * getdrstemplate (g2int number)
gtemplate * getgridtemplate (g2int number)
gtemplate * getpdstemplate (g2int number)
g2int getpoly (unsigned char * csec3, g2int * jj, g2int * kk, g2int * mm)
double int_power (double x, g2int y)
void jpcpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
g2int jpcunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, float * fld)
void misspack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
void mkieee (float * a, g2int * rieee, g2int num)
int pack_gp (g2int * kfildo, g2int * ic, g2int * nxy, g2int * is523, g2int* minpk, g2int * inc, g2int * missp, g2int * misss, g2int * jmin, g2int* jmax, g2int * lbit, g2int * nov, g2int * ndg, g2int * lx, g2int *ibit, g2int * jbit, g2int * kbit, g2int * novref, g2int * lbitref,g2int * ier)
void pngpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
g2int pngunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, float * fld)
void rdieee (g2int * rieee, float * a, g2int num)
void sbit (unsigned char * out, g2int * in, g2int iskip, g2int nbits)
void sbits (unsigned char * out, g2int * in, g2int iskip, g2int nbits,g2int nskip, g2int n)
void simpack (float * fld, g2int ndpts, g2int * idrstmpl, unsigned char *cpack, g2int * lcpack)
g2int simunpack (unsigned char * cpack, g2int * idrstmpl, g2int ndpts,float * fld)
void specpack (float * fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,g2int * idrstmpl, unsigned char * cpack, g2int * lcpack)
g2int specunpack (unsigned char * cpack, g2int * idrstmpl, g2int ndpts,g2int JJ, g2int KK, g2int MM, float * fld)
Author
NAME
grib2_int.h - Header file with internal function prototypes NCEPLIBS-g2c library.
SYNOPSIS
#include
<assert.h>
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <arpa/inet.h>
#include ’grib2.h’
Data Structures
struct
g2c_code_table
A GRIB2 code table.
struct
g2c_dim_info
Keep information about dimensions defined in section 3.
struct
g2c_entry
An entry in a GRIB2 code table.
struct
g2c_file_info
This is the information about each open file.
struct
g2c_message_info
This is the information about each message.
struct
g2c_param
An entry in the table of NOAA abbreviations for GRIB
parameters.
struct
g2c_section3_info
Information about
Section 3 GRID DEFINITION
SECTION
.
struct
g2c_section4_info
Information about
Section 4 PRODUCT DEFINITION
SECTION
.
struct
g2c_section5_info
Information about
Section 5 DATA REPRESENTATION
SECTION
.
struct
g2c_section6_info
Information about
Section 6 BIT-MAP SECTION
.
struct
g2c_section_info
Information about a section 3 through 7 in a GRIB2 message.
struct
gtemplate
Struct for GRIB template, returned by
getgridtemplate()
.
Macros
#define
ALOG2
(0.69314718)
ln(2.0)
#define
BYTE
8
Number of bits in a byte.
#define
EIGHT_BYTES
8
Eight bytes.
#define
EXTERN_MUTEX
(m)
Pthreads not enabled, so do nothing.
#define
FOUR_BYTES
4
Four bytes.
#define
G2C_FILE_READ
0
Read.
#define
G2C_FILE_WRITE
1
Write.
#define
G2C_INDEX1_BDS_VAL_LEN
10
Length of the binary data section (bds) in index file.
#define
G2C_INDEX1_BMS_VAL_LEN
5
Length of the bitmap section (bms) in index file.
#define
G2C_INDEX1_GDS_VAL2_LEN
27
Length of the gds in index file.
#define
G2C_INDEX1_GDS_VAL_LEN
41
Length of the grid definition section (gds) in index file.
#define
G2C_INDEX1_PDS_VAL2_LEN
27
Length of the pds 2 section in the index file.
#define
G2C_INDEX1_PDS_VAL3_LEN
27
Length of the pds 3 section in the index file.
#define
G2C_INDEX1_PDS_VAL_LEN
27
Length of the product definition section (pds) in index
file.
#define
G2C_JASPER_JPEG_FORMAT_NAME
’jpc’
Name of JPEG codec in Jasper.
#define
G2C_MAGIC_HEADER
’GRIB’
GRIB magic header string.
#define
G2C_MAGIC_HEADER_LEN
8
Full length of magic header string (includes GRIB version
byte).
#define
G2C_MAX_MESSAGES
1024
Maximum number of messages in a file.
#define
G2C_MIN_MAX_BYTES
16
Minimum acceptable value for max_bytes parameter of
g2c_get_msg()
.
#define
hton64
(y) (((uint64_t)htonl(y)) <<
WORD
| htonl(y >>
WORD
))
Byte swap 64-bit ints.
#define
LATITUDE
’Latitude’
Latitude.
#define
LOG
(e)
Ignore logging to stdout.
#define
LONGITUDE
’Longitude’
Longitude.
#define
MUTEX
(m)
Pthreads not enabled, so do nothing.
#define
MUTEX_LOCK
(m)
Pthreads not enabled, so do nothing.
#define
MUTEX_UNLOCK
(m)
Pthreads not enabled, so do nothing.
#define
ntoh64
(y) (((uint64_t)ntohl(y)) <<
WORD
| ntohl(y >>
WORD
))
Byte swap 64-bit ints.
#define
ONE_BYTE
1
One byte.
#define
TWO_BYTES
2
Two bytes.
#define
WORD
32
Number of bits in four bytes.
Typedefs
typedef struct
g2c_entry G2C_CODE_ENTRY_T
An entry in a GRIB2 code table.
typedef struct
g2c_code_table G2C_CODE_TABLE_T
A GRIB2 code table.
typedef struct
g2c_dim_info G2C_DIM_INFO_T
Keep information about dimensions defined in section 3.
typedef struct
g2c_file_info G2C_FILE_INFO_T
This is the information about each open file.
typedef struct
g2c_message_info G2C_MESSAGE_INFO_T
This is the information about each message.
typedef struct
g2c_param G2C_PARAM_T
An entry in the table of NOAA abbreviations for GRIB
parameters.
typedef struct
g2c_section3_info G2C_SECTION3_INFO_T
Information about
Section 3 GRID DEFINITION
SECTION
.
typedef struct
g2c_section4_info G2C_SECTION4_INFO_T
Information about
Section 4 PRODUCT DEFINITION
SECTION
.
typedef struct
g2c_section5_info G2C_SECTION5_INFO_T
Information about
Section 5 DATA REPRESENTATION
SECTION
.
typedef struct
g2c_section6_info G2C_SECTION6_INFO_T
Information about
Section 6 BIT-MAP SECTION
.
typedef struct
g2c_section_info G2C_SECTION_INFO_T
Information about a section 3 through 7 in a GRIB2 message.
typedef struct
gtemplate gtemplate
Struct for GRIB template.
Functions
int
add_msg
(
G2C_FILE_INFO_T
*file, int msg_num,
size_t bytes_to_msg, size_t bytes_in_msg, int read_file,
G2C_MESSAGE_INFO_T
**msg)
Add new message to linked list.
int
add_section
(FILE *f,
G2C_MESSAGE_INFO_T
*msg, int sec_id, unsigned int sec_len, size_t bytes_to_sec,
unsigned char sec_num)
Add metadata about a new section 3, 4, 5, 6, or 7.
void
aecpack
(float *fld,
g2int
width,
g2int
height,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
This function packs up a float array into a AEC code stream.
g2int aecunpack
(unsigned char *cpack,
g2int
len,
g2int
*idrstmpl,
g2int
ndpts, float *fld)
Unpack AEC compressed data into an array of floats, using
info from the GRIB2 Data Representation
Template
5.42
.
void
cmplxpack
(float *fld,
g2int
ndpts,
g2int
idrsnum,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
Pack up a data field using a complex packing algorithm.
void
compack
(float *fld,
g2int
ndpts,
g2int
idrsnum,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
Pack a data field using a complex packing algorithm.
int
comunpack
(unsigned char *cpack,
g2int
lensec,
g2int
idrsnum,
g2int
*idrstmpl,
g2int
ndpts, float *fld)
Unpack a data field that was packed using a complex packing
algorithm, using info from the GRIB2 Data Representation
Template 5.2
or
Template 5.3
.
int
dec_aec
(unsigned char *cpack,
g2int
len,
g2int
nbits,
g2int
flags,
g2int
block_size,
g2int
rsi, unsigned char *cfld,
g2int
cfldlen)
Decode an AEC code stream specified in the
CCSDS
121.0-B-3 Blue Book
.
int
dec_jpeg2000
(char *injpc,
g2int
bufsize,
g2int
*outfld)
Decode a JPEG2000 code stream specified in the JPEG2000
Part-1 standard (i.e., ISO/IEC 15444-1) using
JasPer
Software
.
int
dec_png
(unsigned char *pngbuf,
g2int
*width,
g2int
*height, unsigned char *cout)
Decode PNG.
int
enc_aec
(unsigned char *data,
g2int
ctemplen,
g2int
nbits,
g2int
flags,
g2int
block_size,
g2int
rsi, unsigned char
*aecbuf,
g2int
*aecbuflen)
Encode data into an AEC code stream specified in the
CCSDS 121.0-B-3 Blue Book
.
int
enc_jpeg2000
(unsigned char *cin,
g2int
width,
g2int
height,
g2int
nbits,
g2int
ltype,
g2int
ratio,
g2int
retry, char *outjpc,
g2int
jpclen)
Encode a grayscale image into a JPEG2000 code stream
specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC
15444-1) using
JasPer Software
.
int
enc_png
(unsigned char *data,
g2int
width,
g2int
height,
g2int
nbits, unsigned char
*pngbuf)
Encode PNG.
gtemplate
*
extdrstemplate
(
g2int
number,
g2int
*list)
This subroutine generates the remaining octet map for a
given Data Representation Template, if required.
gtemplate
*
extgridtemplate
(
g2int
number,
g2int
*list)
This subroutine generates the remaining octet map for a
given Grid Definition Template, if required.
gtemplate
*
extpdstemplate
(
g2int
number,
g2int
*list)
This subroutine generates the remaining octet map for a
given Product Definition Template, if required.
int
g2c_add_file
(const char *path, int mode, int
*g2cid)
Open a GRIB2 file and add it to the list of open files.
int
g2c_check_msg
(unsigned char *cgrib,
g2int
*lencurr, int verbose)
Check for ’GRIB’ at the beginning of a GRIB
message, and check to see if the message is already
terminated with ’7777’.
int
g2c_file_io
(FILE *f, int write, int g2ctype,
void *var)
Read or write a big-endian integer type to an open file,
with conversion between native and big-endian format.
int
g2c_file_io_byte
(FILE *f, int write, char *var)
Read or write a big-endian signed byte to an open GRIB2
file, with conversion between native and big-endian format,
and special GRIB2 handling of negative numbers.
int
g2c_file_io_int
(FILE *f, int write, int *var)
Read or write a big-endian 4-byte signed int to an open
GRIB2 file, with conversion between native and big-endian
format, and special GRIB2 handling of negative numbers.
int
g2c_file_io_longlong
(FILE *f, int write, long
long *var)
Read or write a big-endian signed long long to an open GRIB2
file, with conversion between native and big-endian format,
and special GRIB2 handling of negative numbers.
int
g2c_file_io_short
(FILE *f, int write, short
*var)
Read or write a big-endian signed short to an open GRIB2
file, with conversion between native and big-endian format,
and special GRIB2 handling of negative numbers.
int
g2c_file_io_template
(FILE *f, int rw_flag, int
map, long long int *template_value)
Read or write a big-endian 4-byte int or unsigned int from
or to an open file, with conversion between native and
big-endian format, and handling of GRIB negative numbers.
int
g2c_file_io_ubyte
(FILE *f, int write, unsigned
char *var)
Read or write a big-endian unsigned byte to an open GRIB2
file, with conversion between native and big-endian format.
int
g2c_file_io_uint
(FILE *f, int write, unsigned
int *var)
Read or write a big-endian 4-byte unsigned int to an open
GRIB2 file, with conversion between native and big-endian
format.
int
g2c_file_io_ulonglong
(FILE *f, int write,
unsigned long long *var)
Read or write a big-endian unsigned long long to an open
GRIB2 file, with conversion between native and big-endian
format.
int
g2c_file_io_ushort
(FILE *f, int write, unsigned
short *var)
Read or write a big-endian unsigned short to an open GRIB2
file, with conversion between native and big-endian format.
int
g2c_get_datetime
(int ipdtn, long long int
*ipdtmpl, short year, unsigned char month, unsigned char
day, unsigned char hour, unsigned char minute, unsigned char
second, char *tabbrev)
Convert date and time from GRIB2 info to string output.
int
g2c_get_level_desc
(int ipdtn, long long int
*ipdtmpl, char *level_desc)
Determine the string that describes the level information,
given the GRIB2 Product Definition Template information.
int
g2c_log_section1
(
G2C_MESSAGE_INFO_T
*msg)
Log section 0 information.
int
g2c_rw_section1_metadata
(FILE *f, int rw_flag,
G2C_MESSAGE_INFO_T
*msg)
Read Section 1.
int
g2c_rw_section3_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read the metadata from section 3 (Grid Definition Section)
of a GRIB2 message.
int
g2c_rw_section4_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 4 (Product
Definition Section) of a GRIB2 message.
int
g2c_rw_section5_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 5 (Data
Representation Section) of a GRIB2 message.
int
g2c_rw_section6_metadata
(FILE *f, int rw_flag,
G2C_SECTION_INFO_T
*sec)
Read or write the metadata from section 6 (Data
Representation Section) of a GRIB2 message.
void
gbit
(unsigned char *in,
g2int
*iout,
g2int
iskip,
g2int
nbits)
Get arbitrary size values from a packed bit string, right
justifying each value in the unpacked iout array.
void
gbits
(unsigned char *in,
g2int
*iout,
g2int
iskip,
g2int
nbits,
g2int
nskip,
g2int
n)
Unpack arbitrary size values from a packed bit string, right
justifying each value in the unpacked iout array.
g2int getdim
(unsigned char *csec3,
g2int
*width,
g2int
*height,
g2int
*iscan)
Return the dimensions and scanning mode of a grid
definition.
gtemplate
*
getdrstemplate
(
g2int
number)
This subroutine returns DRS template information for a
specified Data Representation Template.
gtemplate
*
getgridtemplate
(
g2int
number)
This subroutine returns grid template information for a
specified Grid Definition Template for [Section 3 - the Grid
Definition Section
(GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml).
gtemplate
*
getpdstemplate
(
g2int
number)
This subroutine returns PDS template information for a
specified Product Definition Template.
g2int getpoly
(unsigned char *csec3,
g2int
*jj,
g2int
*kk,
g2int
*mm)
This subroutine returns the J, K, and M pentagonal
resolution parameters specified in a GRIB Grid Definition
Section (GDS) used spherical harmonic coefficients using GDT
5.50 through 5.53.
double
int_power
(double x,
g2int
y)
Function similar to C pow() power function.
void
jpcpack
(float *fld,
g2int
width,
g2int
height,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
This function packs up a float array into a JPEG2000 code
stream.
g2int jpcunpack
(unsigned char *cpack,
g2int
len,
g2int
*idrstmpl,
g2int
ndpts, float *fld)
Unpack JPEG2000 compressed data into an array of floats,
using info from the GRIB2 Data Representation
Template
5.40
or 5.40000.
void
misspack
(float *fld,
g2int
ndpts,
g2int
idrsnum,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
Pack a data field using a complex packing algorithm.
void
mkieee
(float *a,
g2int
*rieee,
g2int
num)
Store a list of real values in 32-bit IEEE floating point
format.
int
pack_gp
(
g2int
*kfildo,
g2int
*ic,
g2int
*nxy,
g2int
*is523,
g2int
*minpk,
g2int
*inc,
g2int
*missp,
g2int
*misss,
g2int
*jmin,
g2int
*jmax,
g2int
*lbit,
g2int
*nov,
g2int
*ndg,
g2int
*lx,
g2int
*ibit,
g2int
*jbit,
g2int
*kbit,
g2int
*novref,
g2int
*lbitref,
g2int
*ier)
Determines groups of variable size, but at least of size
minpk, the associated max (jmax( )) and min (jmin( )), the
number of bits necessary to hold the values in each group
(lbit( )), the number of values in each group (nov( )), the
number of bits necessary to pack the jmin( ) values (ibit),
the number of bits necessary to pack the lbit( ) values
(jbit), and the number of bits necessary to pack the nov( )
values (kbit).
void
pngpack
(float *fld,
g2int
width,
g2int
height,
g2int
*idrstmpl, unsigned char
*cpack,
g2int
*lcpack)
This subroutine packs up a float data field into PNG image
format.
g2int pngunpack
(unsigned char *cpack,
g2int
len,
g2int
*idrstmpl,
g2int
ndpts, float *fld)
This subroutine unpacks a data field that was packed into a
PNG image format using info from the GRIB2 Data
Representation Template 5.41 or 5.40010.
void
rdieee
(
g2int
*rieee, float *a,
g2int
num)
Read a list of real values in 32-bit IEEE floating point
format.
void
sbit
(unsigned char *out,
g2int
*in,
g2int
iskip,
g2int
nbits)
Store arbitrary size values into a packed bit string, taking
the low order bits from each value in the unpacked array.
void
sbits
(unsigned char *out,
g2int
*in,
g2int
iskip,
g2int
nbits,
g2int
nskip,
g2int
n)
Store arbitrary size values into a packed bit string, taking
the low order bits from each value in the unpacked array.
void
simpack
(float *fld,
g2int
ndpts,
g2int
*idrstmpl, unsigned char *cpack,
g2int
*lcpack)
Packs a data field using the simple packing algorithm.
g2int simunpack
(unsigned char *cpack,
g2int
*idrstmpl,
g2int
ndpts, float *fld)
Unpack a data field that was packed using a simple packing
algorithm, using info from the GRIB2 Data Representation
Template 5.0.
void
specpack
(float *fld,
g2int
ndpts,
g2int
JJ,
g2int
KK,
g2int
MM,
g2int
*idrstmpl, unsigned char *cpack,
g2int
*lcpack)
Pack a spectral data field using the complex packing
algorithm for spherical harmonic data as defined in the
GRIB2 Data Representation
Template 5.51
.
g2int specunpack
(unsigned char *cpack,
g2int
*idrstmpl,
g2int
ndpts,
g2int
JJ,
g2int
KK,
g2int
MM, float *fld)
Unpack a spectral data field that was packed using the
complex packing algorithm for spherical harmonic data as
defined in the GRIB2 documention, using info from the GRIB2
Data Representation
Template 5.51
.
Detailed Description
Header file with internal function prototypes NCEPLIBS-g2c library.
Author
Ed Hartnett
Date
2021-11-08
Definition in file grib2_int.h .
Data Type Documentation
struct g2c_code_table
A GRIB2 code table.
Definition at line 256 of file grib2_int.h .
Data Fields:
G2C_CODE_ENTRY_T * entry
struct g2c_code_table * next
char title[ G2C_MAX_GRIB_TITLE_LEN +1]
struct g2c_dim_info
Keep information about dimensions defined in section 3.
Definition at line 185 of file grib2_int.h .
Data Fields:
int dimid Dimension ID.
size_t len Length of dimension.
char name[ G2C_MAX_NAME +1] Name of dimension.
float * value Array of dimension values.
struct g2c_entry
An entry in a GRIB2 code table.
Definition at line 247 of file grib2_int.h .
Data Fields:
char code[ G2C_MAX_GRIB_CODE_LEN +1]
char desc[ G2C_MAX_GRIB_DESC_LEN +1]
struct g2c_entry * next
char status[ G2C_MAX_GRIB_STATUS_LEN +1]
struct g2c_file_info
This is the information about each open file.
Definition at line 237 of file grib2_int.h .
Data Fields:
FILE * f FILE pointer to open file.
int g2cid ID of the file.
G2C_MESSAGE_INFO_T * msg Information about each message in the file.
size_t num_messages Number of messages in the file.
char path[ G2C_MAX_NAME +1] Path of the file.
struct g2c_message_info
This is the information about each message.
Definition at line 135 of file grib2_int.h .
Data Fields:
size_t bytes_in_msg Number of bytes in this message.
size_t bytes_to_bms Number of bytes in the message to the bitmap section.
size_t bytes_to_data Number of bytes in the message to the (first) data section.
size_t bytes_to_local Number of bytes in the message before the (first) local section.
size_t bytes_to_msg Number of bytes to skip in the file, to get to this message.
short center Originating center.
unsigned char day Day.
unsigned char discipline Discipline from section 0.
struct g2c_file_info * file Pointer to containing file.
unsigned char hour Hour.
unsigned char local_version Version number of GRIB local tables used to augment Master Tables.
unsigned char master_version GRIB master tables version number.
unsigned char minute Minute.
unsigned char month Month.
size_t msg_num Number of message in file (0-based).
struct g2c_message_info * next Pointer to next in list.
int num_fields Number of fields in the message.
int num_local Number of local sections in the message.
int num_sections Number of sections in the file.
struct g2c_section_info * sec List of section metadata.
int sec1_len Length of section 1.
unsigned char second Second.
int section1[ G2C_SECTION1_ARRAY_LEN ] Section 1 array.
int * section_number Array (length num_sections) of section numbers.
size_t * section_offset Array (length num_sections) of byte offsets from start of message to section.
unsigned char sig_ref_time Significance of reference time.
unsigned char status Production Status of Processed data in the GRIB message.
short subcenter Originating subcenter.
unsigned char type Type of processed data in this GRIB message.
short year Year.
struct g2c_param
An entry in the table of NOAA abbreviations for GRIB parameters.
Definition at line 264 of file grib2_int.h .
Data Fields:
char abbrev[ G2C_MAX_NOAA_ABBREV_LEN +1] NOAA abbreviation for this parameter.
int g1num GRIB1 parameter number.
int g1ver GRIB1 table version.
int g2cat GRIB2 category number.
int g2disc GRIB2 discipline.
int g2num GRIB2 parameter number.
struct g2c_section3_info
Information about Section 3 GRID DEFINITION SECTION .
Definition at line 195 of file grib2_int.h .
Data Fields:
G2C_DIM_INFO_T dim[2] Dimension information.
unsigned short grid_def Grid definition template number (= N) (See Table 3.1).
unsigned char interp_list Interpetation of list of numbers defining number of points (See Table 3.11).
unsigned int num_data_points Number of data points.
unsigned char num_opt Number of octets for optional list of numbers defining number of points.
int * optional Optional list of numbers defining number of points.
unsigned char source_grid_def Source of grid definition (See Table 3.0).
struct g2c_section4_info
Information about Section 4 PRODUCT DEFINITION SECTION .
Definition at line 208 of file grib2_int.h .
Data Fields:
int field_num
unsigned short num_coord Number of coordinate values after template.
int * optional Optional list of numbers defining number of points.
unsigned short prod_def Product definition template number (See Table 4.0).
struct g2c_section5_info
Information about Section 5 DATA REPRESENTATION SECTION .
Definition at line 218 of file grib2_int.h .
Data Fields:
unsigned short data_def Data representation template number (See Table 5.0).
unsigned int num_data_points Number of data points where one or more values are specified in Section 7 when a bit map is present, total number of data points when a bit map is absent.
struct g2c_section6_info
Information about Section 6 BIT-MAP SECTION .
Definition at line 229 of file grib2_int.h .
Data Fields:
unsigned char
indicator
Bit map indicator.
See
Table 6.0
.
struct g2c_section_info
Information about a section 3 through 7 in a GRIB2 message.
Definition at line 170 of file grib2_int.h .
Data Fields:
size_t bytes_to_sec Number of bytes from start of message to this section.
G2C_MESSAGE_INFO_T * msg Pointer to contianing message.
struct g2c_section_info * next Pointer to next in list.
struct g2c_section_info * prev Pointer to previous in list.
int sec_id ID of the section (0-based).
void * sec_info Pointer to struct specific for section 3, 4, 5, 6, or 7.
unsigned int sec_len Length of the section (in bytes).
unsigned char sec_num Section number.
long long int * template Grid, product, or data template.
int template_len Number of entries in template.
struct gtemplate
Struct for GRIB template, returned by getgridtemplate() .
Definition at line 277 of file grib2_int.h .
Data Fields:
g2int * ext Number of octets of each entry in the extension part of the template.
g2int extlen Number of entries in the template extension.
g2int * map Number of octets of each entry in the static part of the template.
g2int maplen Number of entries in the static part of the template.
g2int needext Indicates whether or not the template needs to be extended.
g2int num The template number.
g2int
type
The template type: 3 Grid Defintion Template.
4 Product Defintion Template. 5 Data Representation
Template.
Macro Definition Documentation
#define ALOG2 (0.69314718)
ln(2.0)
Definition at line 30 of file grib2_int.h .
#define BYTE 8
Number of bits in a byte.
Definition at line 47 of file grib2_int.h .
#define EIGHT_BYTES 8
Eight bytes.
Definition at line 53 of file grib2_int.h .
#define EXTERN_MUTEX(m)
Pthreads not enabled, so do nothing.
Definition at line 113 of file grib2_int.h .
#define FOUR_BYTES 4
Four bytes.
Definition at line 52 of file grib2_int.h .
#define G2C_FILE_READ 0
Read.
Definition at line 131 of file grib2_int.h .
#define G2C_FILE_WRITE 1
Write.
Definition at line 132 of file grib2_int.h .
#define G2C_INDEX1_BDS_VAL_LEN 10
Length of the binary data section (bds) in index file.
Definition at line 73 of file grib2_int.h .
#define G2C_INDEX1_BMS_VAL_LEN 5
Length of the bitmap section (bms) in index file.
Definition at line 70 of file grib2_int.h .
#define G2C_INDEX1_GDS_VAL2_LEN 27
Length of the gds in index file.
Definition at line 82 of file grib2_int.h .
#define G2C_INDEX1_GDS_VAL_LEN 41
Length of the grid definition section (gds) in index file.
Definition at line 67 of file grib2_int.h .
#define G2C_INDEX1_PDS_VAL2_LEN 27
Length of the pds 2 section in the index file.
Definition at line 76 of file grib2_int.h .
#define G2C_INDEX1_PDS_VAL3_LEN 27
Length of the pds 3 section in the index file.
Definition at line 79 of file grib2_int.h .
#define G2C_INDEX1_PDS_VAL_LEN 27
Length of the product definition section (pds) in index file.
Definition at line 64 of file grib2_int.h .
#define G2C_JASPER_JPEG_FORMAT_NAME ’jpc’
Name of JPEG codec in Jasper.
Definition at line 33 of file grib2_int.h .
#define G2C_MAGIC_HEADER ’GRIB’
GRIB magic header string.
Definition at line 39 of file grib2_int.h .
#define G2C_MAGIC_HEADER_LEN 8
Full length of magic header string (includes GRIB version byte).
Definition at line 42 of file grib2_int.h .
#define G2C_MAX_MESSAGES 1024
Maximum number of messages in a file.
Definition at line 45 of file grib2_int.h .
#define G2C_MIN_MAX_BYTES 16
Minimum acceptable value for max_bytes parameter of g2c_get_msg() .
Definition at line 36 of file grib2_int.h .
#define hton64(y) (((uint64_t)htonl(y)) << WORD | htonl(y >> WORD))
Byte swap 64-bit ints. This converts native-endian 8-byte ints into big-endian 8-byte ints.
Definition at line 129 of file grib2_int.h .
#define LATITUDE ’Latitude’
Latitude.
Definition at line 56 of file grib2_int.h .
#define LOG(e)
Ignore logging to stdout. Library was not built with LOGGING=ON.
Definition at line 428 of file grib2_int.h .
#define LONGITUDE ’Longitude’
Longitude.
Definition at line 59 of file grib2_int.h .
#define MUTEX(m)
Pthreads not enabled, so do nothing.
Definition at line 110 of file grib2_int.h .
#define MUTEX_LOCK(m)
Pthreads not enabled, so do nothing.
Definition at line 116 of file grib2_int.h .
#define MUTEX_UNLOCK(m)
Pthreads not enabled, so do nothing.
Definition at line 119 of file grib2_int.h .
#define ntoh64(y) (((uint64_t)ntohl(y)) << WORD | ntohl(y >> WORD))
Byte swap 64-bit ints. This converts big-endian 8-byte ints into native endian 8-byte ints.
Definition at line 125 of file grib2_int.h .
#define ONE_BYTE 1
One byte.
Definition at line 50 of file grib2_int.h .
#define TWO_BYTES 2
Two bytes.
Definition at line 51 of file grib2_int.h .
#define WORD 32
Number of bits in four bytes.
Definition at line 48 of file grib2_int.h .
Typedef Documentation
typedef struct g2c_entry G2C_CODE_ENTRY_T
An entry in a GRIB2 code table.
typedef struct g2c_code_table G2C_CODE_TABLE_T
A GRIB2 code table.
typedef struct g2c_dim_info G2C_DIM_INFO_T
Keep information about dimensions defined in section 3.
typedef struct g2c_file_info G2C_FILE_INFO_T
This is the information about each open file.
typedef struct g2c_message_info G2C_MESSAGE_INFO_T
This is the information about each message.
typedef struct g2c_param G2C_PARAM_T
An entry in the table of NOAA abbreviations for GRIB parameters.
typedef struct g2c_section3_info G2C_SECTION3_INFO_T
Information about Section 3 GRID DEFINITION SECTION .
typedef struct g2c_section4_info G2C_SECTION4_INFO_T
Information about Section 4 PRODUCT DEFINITION SECTION .
typedef struct g2c_section5_info G2C_SECTION5_INFO_T
Information about Section 5 DATA REPRESENTATION SECTION .
typedef struct g2c_section6_info G2C_SECTION6_INFO_T
Information about Section 6 BIT-MAP SECTION .
typedef struct g2c_section_info G2C_SECTION_INFO_T
Information about a section 3 through 7 in a GRIB2 message.
typedef struct gtemplate gtemplate
Struct for GRIB template.
Definition at line 305 of file grib2_int.h .
Function Documentation
int add_msg (G2C_FILE_INFO_T * file, int msg_num, size_t bytes_to_msg,size_t bytes_in_msg, int read_file, G2C_MESSAGE_INFO_T ** msg)
Add new message to linked list.
Parameters
file
Pointer to the
G2C_FILE_INFO_T for this file.
msg_num
Number of the message in file (0-based).
bytes_to_msg
Number of bytes to the start of the message
in the file.
bytes_in_msg
Length of message in bytes.
read_file
Set to true to cause metadata to be read from
a GRIB2 data file.
msg
Pointer to a pointer that will get the location of
the newly created
G2C_MESSAGE_INFO_T
object. Ignored
if NULL.
Returns
|
• |
G2C_NOERROR - No error. |
Author
Ed Hartnett
Date
Sep 12, 2022
Definition at line 1017 of file g2cfile.c .
References g2c_message_info::bytes_in_msg , g2c_message_info::bytes_to_msg , g2c_message_info::file , G2C_ENOMEM , G2C_NOERROR , LOG , g2c_file_info::msg , g2c_message_info::msg_num , g2c_message_info::next , g2c_file_info::num_messages , and read_msg_metadata() .
Referenced by g2c_open_index() , and read_metadata() .
int add_section (FILE * f, G2C_MESSAGE_INFO_T * msg, int sec_id, unsignedint sec_len, size_t bytes_to_sec, unsigned char sec_num)
Add metadata about a new section 3, 4, 5, 6, or 7.
Parameters
f
FILE pointer to open
GRIB2 file.
msg
Pointer to the G2C_MESSAGE_INFO_T struct.
sec_id
0-based section ID.
sec_len
Length of section.
bytes_to_sec
Number of bytes from start of message to
this section.
sec_num
Section number.
Returns
|
• |
G2C_NOERROR - No error. |
Author
Ed Hartnett
Date
Sep 12, 2022
Definition at line 794 of file g2cfile.c .
References g2c_section_info::bytes_to_sec , G2C_EBADSECTION , G2C_ENOMEM , G2C_FILE_READ , G2C_NOERROR , g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , g2c_rw_section5_metadata() , g2c_rw_section6_metadata() , LOG , g2c_section_info::msg , g2c_section_info::next , g2c_message_info::num_local , g2c_section_info::prev , g2c_message_info::sec , g2c_section_info::sec_id , g2c_section_info::sec_len , and g2c_section_info::sec_num .
Referenced by g2c_open_index() , and read_msg_metadata() .
void aecpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
This function packs up a float array into a AEC code stream. 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.
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.
Author
Eric Engle (adapted from jpcpack)
Definition at line 297 of file aecpack.c .
References aecpack_int() .
Referenced by g2_addfield() .
g2int aecunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, 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. |
Author
Eric Engle
Date
2023-10-16
Definition at line 161 of file aecunpack.c .
References aecunpack_int() , and LOG .
Referenced by g2c_unpack7_int() .
void cmplxpack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
Pack up a data field using a complex packing algorithm. This function supports GRIB2 complex packing templates with or without spatial differences (i.e. DRTs 5.2 and 5.3). It also fills in GRIB2 Data Representation Template 5.2 or 5.3 with the appropriate values.
Parameters
fld
Contains the data
values to pack.
ndpts
The number of data values in array fld
idrsnum
Data Representation Template number. Must equal
2 or 3.
idrstmpl
Contains the array of values for Data
Representation Template 5.2 or 5.3
|
• |
0 Reference value - ignored on input, set by compack routine. |
|||
|
• |
1 Binary Scale Factor |
|||
|
• |
2 Decimal Scale Factor |
|||
|
• |
6 Missing value management |
|||
|
• |
7 Primary missing value |
|||
|
• |
8 Secondary missing value |
|||
|
• |
16 Order of Spatial Differencing ( 1 or 2 ) |
cpack
The packed data field.
lcpack
length of packed field cpack. Will be set to -1
if missing value management field is not 1 or 2.
Author
Stephen Gilbert
Date
2004-08-27
Definition at line 37 of file cmplxpack.c .
References compack() , and misspack() .
Referenced by g2_addfield() .
void compack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
Pack a data field using a complex packing algorithm. This function supports GRIB2 complex packing templates with or without spatial differences (i.e. DRTs 5.2 and 5.3). It also fills in GRIB2 Data Representation Template 5.2 or Template 5.3 with the appropriate values.
Parameters
fld
Contains the data
values to pack.
ndpts
The number of data values in array fld.
idrsnum
Data Representation Template number. Must equal
2 or 3.
idrstmpl
Contains the array of values for Data
Representation Template 5.2 or 5.3.
|
• |
0 Reference value - ignored on input, set my compack() . |
|||
|
• |
1 Binary Scale Factor |
|||
|
• |
2 Decimal Scale Factor |
|||
|
• |
6 Missing value management |
|||
|
• |
7 Primary missing value |
|||
|
• |
8 Secondary missing value |
|||
|
• |
16 Order of Spatial Differencing (1 or 2) |
cpack
The packed data field.
lcpack
length of packed field cpack.
Author
Stephen Gilbert
Date
2002-11-07
Definition at line 42 of file compack.c .
References ALOG2 , int_power() , mkieee() , pack_gp() , sbit() , and sbits() .
Referenced by cmplxpack() .
int comunpack (unsigned char * cpack, g2int lensec, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float * fld)
Unpack a data field that was packed using a complex packing algorithm, using info from the GRIB2 Data Representation Template 5.2 or Template 5.3 . Supports GRIB2 complex packing templates with or without spatial differences (i.e. DRTs 5.2 and 5.3).
Program History Log
Date Programmer Comments 2002-10-29 Gilbert Initial 2004-12-16 Gilbert Added test (from Arthur Taylor/MDL) verifying group widths/lengths
Parameters
cpack
pointer to the
packed data field.
lensec
length of section 7 (used for error checking).
idrsnum
Data Representation Template number. Must equal
2 or 3.
idrstmpl
pointer to the array of values for Data
Representation Template 5.2 or 5.3
ndpts
The number of data values to unpack
fld
Contains the unpacked data values. Must be allocated
with at least ndpts * sizeof(float) bytes before calling
this routine.
Returns
0 for success, error code otherwise.
Author
Stephen Gilbert
Date
2002-10-29
Definition at line 41 of file comunpack.c .
References gbit() , gbits() , int_power() , LOG , and rdieee() .
Referenced by g2c_unpack7_int() .
int dec_aec (unsigned char * cpack, g2int len, g2int nbits, g2int flags,g2int block_size, g2int rsi, unsigned char * cfld, g2int cfldlen)
Decode an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book .
Parameters
cpack
Pointer to buffer
that holds the input AEC code stream.
len
Length (in bytes) of the buffer that holds the input
AEC code stream.
nbits
CCSDS bits per sample.
flags
CCSDS compression options mask.
block_size
CCSDS block size.
rsi
CCSDS reference sample interval.
cfld
Pointer to output buffer from the AEC decoder.
cfldlen
length of output buffer.
Returns
|
• |
>0 Length of data from AEC decoder |
|||
|
• |
0 Successful decode (AEC_OK) |
|||
|
• |
-1 AEC_CONF_ERROR |
|||
|
• |
-2 AEC_STREAM_ERROR |
|||
|
• |
-3 AEC_DATA_ERROR |
|||
|
• |
-4 AEC_MEM_ERROR |
|||
|
• |
-5 AEC_RSI_OFFSETS_ERROR |
Author
Eric Engle
Date
2023-10-16
Definition at line 38 of file decenc_aec.c .
References LOG .
Referenced by aecunpack_int() .
int dec_jpeg2000 (char * injpc, g2int bufsize, g2int * outfld)
Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) using 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 g2int array, already allocated, that
gets the unpacked data.
Returns
|
• |
0 Successful decode |
||
|
• |
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
Stephen Gilbert, Ed Hartnett
Definition at line 377 of file decenc_jpeg2000.c .
References int_dec_jpeg2000() .
Referenced by jpcunpack_int() .
int dec_png (unsigned char * pngbuf, g2int * width, g2int * 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
Stephen Gilbert
Definition at line 127 of file decenc_png.c .
References G2C_PNG_HEIGHT_MAX , G2C_PNG_WIDTH_MAX , and user_read_data() .
Referenced by g2c_dec_png() , and pngunpack_int() .
int enc_aec (unsigned char * data, g2int ctemplen, g2int nbits, g2intflags, g2int block_size, g2int rsi, unsigned char * aecbuf, g2int *aecbuflen)
Encode data into an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book .
Parameters
data
Pointer to buffer
that holds the input data.
ctemplen
Length (in bytes) of the buffer that holds the
input data..
nbits
CCSDS bits per sample.
flags
CCSDS compression options mask.
block_size
CCSDS block size.
rsi
CCSDS reference sample interval.
aecbuf
Pointer to buffer holding the AEC encoded stream.
aecbuflen
Length of AEC code stream.
Returns
|
• |
>0 Exact length of AEC encoded data. |
|||
|
• |
0 Successful decode (AEC_OK) |
|||
|
• |
-1 AEC_CONF_ERROR |
|||
|
• |
-2 AEC_STREAM_ERROR |
|||
|
• |
-3 AEC_DATA_ERROR |
|||
|
• |
-4 AEC_MEM_ERROR |
|||
|
• |
-5 AEC_RSI_OFFSETS_ERROR |
Author
Eric Engle
Date
2023-10-16
Definition at line 108 of file decenc_aec.c .
References LOG .
Referenced by aecpack_int() .
int enc_jpeg2000 (unsigned char * cin, g2int width, g2int height, g2intnbits, g2int ltype, g2int ratio, g2int retry, char * outjpc, g2intjpclen)
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 .
|
• |
### Program History Log Date Programmer Comments 2002-12-02 Gilbert Initial 2004-12-16 Gilbert Added retry argument allowing increased guard bits. 2022-04-15 Hartnett Converted to use jas_ instead of jpc_ functions. |
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 94 of file decenc_jpeg2000.c .
References G2_JASPER_ENCODE , G2_JASPER_INIT , G2C_JASPER_JPEG_FORMAT_NAME , LOG , and MAXOPTSSIZE .
Referenced by g2c_enc_jpeg2000() , and jpcpack_int() .
int enc_png (unsigned char * data, g2int width, g2int height, g2int 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
Stephen Gilbert
Definition at line 259 of file decenc_png.c .
References user_flush_data() , and user_write_data() .
Referenced by g2c_enc_png() , and pngpack_int() .
gtemplate * extdrstemplate (g2int number, g2int * list)
This subroutine generates the remaining octet map for a given Data Representation Template, if required. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.
Parameters
number
The number of the
Data Representation Template that is being requested.
list
The list of values for each entry in the the Data
Representation Template.
Returns
Pointer to the returned template struct. Returns NULL pointer, if template not found.
Author
Stephen Gilbert
Date
2000-05-11
Definition at line 218 of file drstemplates.c .
References getdrsindex() , and getdrstemplate() .
Referenced by g2_unpack5() .
gtemplate * extgridtemplate (g2int number, g2int * template)
This subroutine generates the remaining octet map for a given Grid Definition Template, if required. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.
This function allocates memory for the extension. The pointer ext in the gtemplate struct must be freed to prevent memory leaks.
Parameters
number
The number of the
Grid Definition Template that is being requested.
template
The grid definition template array.
Returns
Pointer to the returned template struct. Returns NULL pointer, if template not found.
Author
Stephen Gilbert
Date
2000-05-09
Definition at line 241 of file gridtemplates.c .
References getgridindex() , and getgridtemplate() .
Referenced by g2_addgrid() , g2_unpack3() , and g2c_get_grid_template_extension() .
gtemplate * extpdstemplate (g2int number, g2int * list)
This subroutine generates the remaining octet map for a given Product Definition Template, if required. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.
This function allocates memory in the ext field of the gtemplate struct. This memory must be freed by the caller.
Parameters
number
number of the
Product Definition Template 4.NN that is being requested.
list
The list of values for each entry in the the
Product Definition Template.
Returns
Pointer to the returned template struct. Returns NULL pointer if template not found.
Author
Stephen Gilbert
Date
2000-05-11
Definition at line 553 of file pdstemplates.c .
References getpdsindex() , and getpdstemplate() .
Referenced by g2_addfield() , g2_unpack4() , and g2c_get_pds_template_extension() .
int g2c_add_file (const char * path, int mode, int * g2cid)
Open a GRIB2 file and add it to the list of open files.
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 1143 of file g2cfile.c .
References find_available_g2cid() , G2C_EFILE , G2C_EINVAL , G2C_ENAMETOOLONG , g2c_file , G2C_MAX_NAME , G2C_NOERROR , G2C_WRITE , g2c_file_info::g2cid , LOG , g2c_file_info::msg , and g2c_file_info::num_messages .
Referenced by g2c_open() , and g2c_open_index() .
int g2c_check_msg (unsigned char * cgrib, g2int * lencurr, int verbose)
Check for ’GRIB’ at the beginning of a GRIB message, and check to see if the message is already terminated with ’7777’.
Parameters
cgrib
Buffer that
contains the GRIB message.
lencurr
Pointer that gets the length of the GRIB
message.
verbose
If non-zero, print any error messages to
stdout.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_ENOTGRIB GRIB header not found. |
|||
|
• |
G2C_EMSGCOMPLETE GRIB message already complete. |
Author
Ed Hartnett
Date
Nov 11, 2021
Definition at line 26 of file util.c .
References G2C_EMSGCOMPLETE , G2C_ENOTGRIB , G2C_NOERROR , and gbit() .
Referenced by g2_addfield() , g2_addgrid() , g2_addlocal() , and g2_gribend() .
int g2c_file_io (FILE * f, int write, int g2ctype, void * var)
Read or write a big-endian integer type to an open file, with conversion between native and big-endian format. GRIB2 handles negative numbers in a special way. Instead of storing two-compliments, like every other programmer and computing organization in the world, GRIB2 flips the first bit, then stores the rest of the int as an unsigned number in the remaining 31 bits. How exciting!
This function takes the excitement out of GRIB2 negative numbers.
Parameters
f
Pointer to the open
FILE.
write
Non-zero if function should write, otherwise
function will read.
g2ctype
The type to be read or written.
var
Pointer to the int to be written, or pointer to the
storage that gets the int read.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett
Date
11/7/22
Definition at line 41 of file g2cio.c .
References BITSHIFT_15 , BITSHIFT_31 , BITSHIFT_63 , BITSHIFT_7 , EIGHT_BYTES , FOUR_BYTES , G2C_BYTE , G2C_EBADTYPE , G2C_EFILE , G2C_EINVAL , G2C_INT , G2C_INT64 , G2C_NOERROR , G2C_SHORT , G2C_UBYTE , G2C_UINT , G2C_UINT64 , G2C_USHORT , hton64 , ntoh64 , ONE_BYTE , and TWO_BYTES .
Referenced by g2c_file_io_byte() , g2c_file_io_int() , g2c_file_io_longlong() , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ulonglong() , and g2c_file_io_ushort() .
int g2c_file_io_byte (FILE * f, int write, char * var)
Read or write a big-endian signed byte to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the byte.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 316 of file g2cio.c .
References G2C_BYTE , and g2c_file_io() .
Referenced by g2c_file_io_template() .
int g2c_file_io_int (FILE * f, int write, int * var)
Read or write a big-endian 4-byte signed int to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the int.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/7/22
Definition at line 230 of file g2cio.c .
References g2c_file_io() , and G2C_INT .
Referenced by g2c_file_io_template() .
int g2c_file_io_longlong (FILE * f, int write, long long * var)
Read or write a big-endian signed long long to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the long long.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 359 of file g2cio.c .
References g2c_file_io() , and G2C_INT64 .
int g2c_file_io_short (FILE * f, int write, short * var)
Read or write a big-endian signed short to an open GRIB2 file, with conversion between native and big-endian format, and special GRIB2 handling of negative numbers.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the short.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 273 of file g2cio.c .
References g2c_file_io() , and G2C_SHORT .
Referenced by g2c_file_io_template() , g2c_rw_section1_metadata() , g2c_start_index_record() , and g2c_start_index_record_lf() .
int g2c_file_io_template (FILE * f, int rw_flag, int map, long long int *template_value)
Read or write a big-endian 4-byte int or unsigned int from or to an open file, with conversion between native and big-endian format, and handling of GRIB negative numbers. This is for template values.
With template values, if the map value is negative, then the template value may be negative.
Parameters
f
Pointer to the open
FILE.
rw_flag
Non-zero if function should write, otherwise
function will read.
map
The map value for this template item.
template_value
Pointer to the template value to be
written, or pointer to the storage that gets the templage
value read.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/7/22
Definition at line 408 of file g2cio.c .
References FOUR_BYTES , G2C_EBADTEMPLATE , g2c_file_io_byte() , g2c_file_io_int() , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ushort() , G2C_NOERROR , ONE_BYTE , and TWO_BYTES .
Referenced by g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , and g2c_rw_section5_metadata() .
int g2c_file_io_ubyte (FILE * f, int write, unsigned char * var)
Read or write a big-endian unsigned byte to an open GRIB2 file, with conversion between native and big-endian format.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the unsigned byte.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 337 of file g2cio.c .
References g2c_file_io() , and G2C_UBYTE .
Referenced by g2c_file_io_template() , g2c_open_index() , g2c_rw_section1_metadata() , g2c_rw_section3_metadata() , g2c_rw_section6_metadata() , g2c_start_index1_record() , g2c_start_index_record() , g2c_start_index_record_lf() , g2c_write_index() , and read_msg_metadata() .
int g2c_file_io_uint (FILE * f, int write, unsigned int * var)
Read or write a big-endian 4-byte unsigned int to an open GRIB2 file, with conversion between native and big-endian format.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the unsigned int.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/7/22
Definition at line 251 of file g2cio.c .
References g2c_file_io() , and G2C_UINT .
Referenced by g2c_file_io_template() , g2c_open_index() , g2c_rw_section1_metadata() , g2c_rw_section3_metadata() , g2c_rw_section5_metadata() , g2c_start_index1_record() , g2c_start_index_record() , g2c_start_index_record_lf() , g2c_write_index() , and read_msg_metadata() .
int g2c_file_io_ulonglong (FILE * f, int write, unsigned long long * var)
Read or write a big-endian unsigned long long to an open GRIB2 file, with conversion between native and big-endian format.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the unsigned long long.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 380 of file g2cio.c .
References g2c_file_io() , and G2C_UINT64 .
Referenced by g2c_start_index_record() , and g2c_start_index_record_lf() .
int g2c_file_io_ushort (FILE * f, int write, unsigned short * var)
Read or write a big-endian unsigned short to an open GRIB2 file, with conversion between native and big-endian format.
Parameters
f
Pointer to the open
GRIB2 FILE.
write
Non-zero to write, zero to read.
var
Pointer to the unsigned short.
Returns
|
• |
:: G2C_NOERROR No error. |
|||
|
• |
:: G2C_EINVAL Invalid input. |
|||
|
• |
:: G2C_EFILE Error reading/writing file. |
Author
Ed Hartnett 11/13/22
Definition at line 294 of file g2cio.c .
References g2c_file_io() , and G2C_USHORT .
Referenced by g2c_file_io_template() , g2c_rw_section3_metadata() , g2c_rw_section4_metadata() , and g2c_rw_section5_metadata() .
int g2c_get_datetime (int ipdtn, long long int * ipdtmpl, short year,unsigned char month, unsigned char day, unsigned char hour, unsignedchar minute, unsigned char second, char * tabbrev)
Convert date and time from GRIB2 info to string output.
Note
This function is based on the prvtime() function in NCEPLIBS-grib_utils.
Parameters
ipdtn
Product Definition
Template Number ([Code Table 4.0]
(https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)).
ipdtmpl
Array of data values for the Product Definition
Template specified by ipdtn.
year
year
month
month
day
day
hour
hour
minute
minute
second
second
tabbrev
Character array that will get the date and time
string. Must be of length 100.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
Sep 28, 2022
Definition at line 49 of file g2cdegrib2.c .
References G2C_DATE_TIME_LEN , and G2C_NOERROR .
Referenced by g2c_degrib2() .
int g2c_get_level_desc (int ipdtn, long long int * ipdtmpl, char *level_desc)
Determine the string that describes the level information, given the GRIB2 Product Definition Template information. This subroutine finds the ’Type of first fixed surface’ (see [Code table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)) using the product definition template value and product template array. The location in the template array varies depending on the template number.
Parameters
ipdtn
Product Definition
Template Number ([Code Table 4.0]
(https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)).
ipdtmpl
Array of data values for the Product Definition
Template specified by ipdtn.
level_desc
Character array which gets the string
describing the level. Must be of length 40.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
Sep 28, 2022
Definition at line 309 of file g2cdegrib2.c .
References format_level() , and G2C_NOERROR .
Referenced by g2c_degrib2() .
int g2c_log_section1 (G2C_MESSAGE_INFO_T * msg)
Log section 0 information.
Parameters
msg Pointer to G2C_MESSAGE_INFO_T which contains section 0 information.
Returns
|
• |
G2C_NOERROR No error. |
Author
Ed Hartnett
Date
10/16/22
Definition at line 101 of file g2cutil.c .
References g2c_message_info::center , g2c_message_info::day , g2c_message_info::discipline , g2c_csv_init() , g2c_find_desc() , G2C_MAX_GRIB_DESC_LEN , G2C_NOERROR , 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::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 g2c_log_file() , and g2c_open_index() .
int g2c_rw_section1_metadata (FILE * f, int rw_flag, G2C_MESSAGE_INFO_T *msg)
Read Section 1.
Parameters
f
Pointer to open file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
msg
Pointer to G2C_MESSAGE_INFO_T which will be
populated with the values of section 0.
Returns
-G2C_NOERROR No error.
Author
Ed Hartnett
Date
10/16/22
Definition at line 874 of file g2cfile.c .
References g2c_message_info::center , g2c_message_info::day , G2C_ENOSECTION , g2c_file_io_short() , g2c_file_io_ubyte() , g2c_file_io_uint() , G2C_NOERROR , G2C_SECTION1_BYTES , 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::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 g2c_open_index() , g2c_write_index() , and read_msg_metadata() .
int g2c_rw_section3_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read the metadata from section 3 (Grid Definition Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
(0) if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 15, 2022
Definition at line 478 of file g2cfile.c .
References determine_dims() , G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_ubyte() , g2c_file_io_uint() , g2c_file_io_ushort() , g2c_get_grid_template() , G2C_MAX_GDS_TEMPLATE_MAPLEN , G2C_NOERROR , g2c_section3_info::grid_def , g2c_section3_info::interp_list , LOG , g2c_section3_info::num_data_points , g2c_section3_info::num_opt , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_section3_info::source_grid_def , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section4_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 4 (Product Definition Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read/written when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 574 of file g2cfile.c .
References G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_ushort() , g2c_get_pds_template() , G2C_MAX_PDS_TEMPLATE_MAPLEN , G2C_NOERROR , LOG , g2c_section_info::msg , g2c_section4_info::num_coord , g2c_message_info::num_fields , g2c_section4_info::prod_def , g2c_section_info::sec_info , g2c_section_info::sec_num , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section5_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 5 (Data Representation Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 663 of file g2cfile.c .
References g2c_section5_info::data_def , G2C_EINVAL , G2C_ENOMEM , g2c_file_io_template() , g2c_file_io_uint() , g2c_file_io_ushort() , g2c_get_drs_template() , G2C_MAX_PDS_TEMPLATE_MAPLEN , G2C_NOERROR , LOG , g2c_section5_info::num_data_points , g2c_section_info::sec_info , g2c_section_info::template , and g2c_section_info::template_len .
Referenced by add_section() , and g2c_write_index() .
int g2c_rw_section6_metadata (FILE * f, int rw_flag, G2C_SECTION_INFO_T *sec)
Read or write the metadata from section 6 (Data Representation Section) of a GRIB2 message. When this function is called, the file cursor is positioned just after the section number field in the section. The size of the section, and the section number, have already been read when this function is called.
Parameters
f
FILE pointer to open
GRIB2 file.
rw_flag
G2C_FILE_WRITE
if function should write,
G2C_FILE_READ
if it should read.
sec
Pointer to the G2C_SECTION_INFO_T struct.
Returns
|
• |
G2C_NOERROR No error. |
|||
|
• |
G2C_EINVAL Invalid input. |
|||
|
• |
G2C_ENOMEM Out of memory. |
|||
|
• |
G2C_ENOTEMPLATE Can’t find template. |
Author
Ed Hartnett
Date
Sep 16, 2022
Definition at line 745 of file g2cfile.c .
References G2C_EINVAL , G2C_ENOMEM , g2c_file_io_ubyte() , G2C_NOERROR , g2c_section6_info::indicator , LOG , and g2c_section_info::sec_info .
Referenced by add_section() .
void gbit (unsigned char * in, g2int * iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array.
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 20 of file gbits.c .
References gbits() .
Referenced by comunpack() , g2_addfield() , g2_addgrid() , g2_addlocal() , g2_getfld() , g2_gribend() , g2_info() , g2_unpack1() , g2_unpack2() , g2_unpack3() , g2_unpack4() , g2_unpack5() , g2_unpack6() , g2c_check_msg() , g2c_unpack7_int() , and seekgb() .
void gbits (unsigned char * in, g2int * iout, g2int iskip, g2int nbits,g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array.
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.
Author
NOAA Programmer
Definition at line 57 of file gbits.c .
Referenced by aecunpack_int() , comunpack() , g2_unpack3() , g2_unpack4() , g2_unpack6() , g2c_gbits_int() , gbit() , pngunpack_int() , simunpack() , and specunpack() .
g2int getdim (unsigned char * csec3, g2int * width, g2int * height, g2int *iscan)
Return the dimensions and scanning mode of a grid definition.
Parameters
csec3
Character array
that contains the packed GRIB2 GDS.
width
x (or i) dimension of the grid. 0 if grid is not
recognized.
height
y (or j) dimension of the grid. 0 if grid is not
recognized.
iscan
Scanning mode (see
Table 3.4
). 0 of grid
not recognized.
Returns
Always returns 0.
Author
Stephen Gilbert
Date
2002-12-11
Definition at line 27 of file getdim.c .
References g2_unpack3() .
Referenced by g2_addfield() .
gtemplate * getdrstemplate (g2int number)
This subroutine returns DRS template information for a specified Data Representation Template. The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.
Parameters
number The number of the Data Representation Template that is being requested.
Returns
Pointer to the returned template struct. Returns NULL if template not found.
Author
Stephen Gilbert
Date
2000-05-11
Definition at line 172 of file drstemplates.c .
References getdrsindex() , and templatesdrs .
Referenced by extdrstemplate() , g2_addfield() , and g2_unpack5() .
gtemplate * getgridtemplate (g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Section 3 - the Grid Definition Section (GDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml). The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.
This function allocates storage for the template. The returned pointer must be freed by the caller.
Parameters
number The number of the Grid Definition Template that is being requested.
Returns
Pointer to the returned template struct (must be freed by caller). Returns NULL pointer, if template not found.
Author
Stephen Gilbert
Date
2000-05-09
Definition at line 193 of file gridtemplates.c .
References getgridindex() , and templatesgrid .
Referenced by extgridtemplate() , g2_addgrid() , and g2_unpack3() .
gtemplate * getpdstemplate (g2int number)
This subroutine returns PDS template information for a specified Product Definition Template. The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.
This function allocates memory for the gtemplate struct, which must be freed by the caller.
Parameters
number the number of the Product Definition Template that is being requested.
Returns
Pointer to the returned template struct. Returns NULL pointer if template not found.
Author
Stephen Gilbert
Date
2000-05-11
Definition at line 504 of file pdstemplates.c .
References getpdsindex() , and templatespds .
Referenced by extpdstemplate() , g2_addfield() , and g2_unpack4() .
g2int getpoly (unsigned char * csec3, g2int * jj, g2int * kk, g2int * mm)
This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Definition Section (GDS) used spherical harmonic coefficients using GDT 5.50 through 5.53. If 51 - complex data spectral packing is used as the data representation template number (see Table 5.0 ), then the Grid Definition Template Number in section 3 should be one of:
|
• |
50: Spherical Harmonic Coefficients (See Template 3.50) |
||
|
• |
51: Rotated Spherical Harmonic Coefficients (See Template 3.51) |
||
|
• |
52: Stretched Spherical Harmonic Coefficients (See Template 3.52) |
||
|
• |
53: Rotated and Stretched Spherical Harmonic Coefficients (See Template 3.53) |
Parameters
csec3
Character array
that contains the packed GRIB2 GDS.
jj
J pentagonal resolution parameter.
kk
K pentagonal resolution parameter.
mm
M pentagonal resolution parameter.
Returns
always returns 0.
Note
Returns jj, kk, and mm set to zero, if grid template not recognized.
Author
Stephen Gilbert
Date
2002-12-11
Definition at line 40 of file getpoly.c .
References g2_unpack3() .
Referenced by g2_addfield() .
double int_power (double x, g2int y)
Function similar to C pow() power function.
Parameters
x
The base value whose
power is to be calculated.
y
The power value.
Returns
x**y
Author
Wesley Ebisuzaki
Definition at line 18 of file int_power.c .
Referenced by aecpack_int() , aecunpack_int() , compack() , comunpack() , jpcpack_int() , jpcunpack_int() , misspack() , mkieee() , pngpack_int() , pngunpack_int() , rdieee() , simpack() , simunpack() , and specunpack() .
void jpcpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
This function packs up a float array into a JPEG2000 code stream. 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.
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.
Author
Stephen Gilbert, Ed Hartnett
Definition at line 269 of file jpcpack.c .
References jpcpack_int() .
Referenced by g2_addfield() .
g2int jpcunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, 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. |
|||
|
• |
G2_JPCUNPACK_MEM Out of memory. |
Author
Stephem Gilbert
Date
2003-08-27
Definition at line 123 of file jpcunpack.c .
References G2_JPCUNPACK_MEM , jpcunpack_int() , and LOG .
Referenced by g2c_unpack7_int() .
void misspack (float * fld, g2int ndpts, g2int idrsnum, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
Pack a data field using a complex packing algorithm. This funciton supports GRIB2 complex packing templates with or without spatial differences (See Template 5.2 and Template 5.3 ).
This function fills in GRIB2 Data Representation template arrays with the appropriate values.
Parameters
fld
Contains the data
values to pack
ndpts
The number of data values in array fld
idrsnum
Data Representation Template number. Must equal
2 or 3.
idrstmpl
Contains the array of values for Data
Representation Template 5.2 or 5.3.
|
• |
0 Reference value - ignored on input, set by misspack routine. |
|||
|
• |
1 Binary Scale Factor - used on input. |
|||
|
• |
2 Decimal Scale Factor- used on input. |
|||
|
• |
6 Missing value management. |
|||
|
• |
7 Primary missing value. |
|||
|
• |
8 Secondary missing value. |
|||
|
• |
16 Order of Spatial Differencing (1 or 2). |
cpack
The packed data field (character*1 array).
lcpack
length of packed field cpack.
Author
Stephen Gilbert
Date
2000-06-21
Definition at line 43 of file misspack.c .
References ALOG2 , int_power() , mkieee() , pack_gp() , rdieee() , sbit() , and sbits() .
Referenced by cmplxpack() .
void mkieee (float * a, g2int * rieee, g2int num)
Store a list of real values in 32-bit IEEE floating point format.
Parameters
a
Input array of
floating point values.
num
Number of floating point values to convert.
rieee
Output array of data values in 32-bit IEEE format
stored in g2int integer array. rieee must be allocated with
at least 4*num bytes of memory before calling this
function.
Author
Stephen Gilbert
Date
2002-10-29
Definition at line 22 of file mkieee.c .
References int_power() .
Referenced by aecpack_int() , compack() , g2_addfield() , jpcpack_int() , misspack() , pngpack_int() , simpack() , and specpack() .
int pack_gp (g2int * kfildo, g2int * ic, g2int * nxy, g2int * is523, g2int* minpk, g2int * inc, g2int * missp, g2int * misss, g2int * jmin, g2int* jmax, g2int * lbit, g2int * nov, g2int * ndg, g2int * lx, g2int *ibit, g2int * jbit, g2int * kbit, g2int * novref, g2int * lbitref,g2int * ier)
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min (jmin( )), the number of bits necessary to hold the values in each group (lbit( )), the number of values in each group (nov( )), the number of bits necessary to pack the jmin( ) values (ibit), the number of bits necessary to pack the lbit( ) values (jbit), and the number of bits necessary to pack the nov( ) values (kbit). The routine is designed to determine the groups such that a small number of bits is necessary to pack the data without excessive computations. If all values in the group are zero, the number of bits to use in packing is defined as zero when there can be no missing values; when there can be missing values, the number of bits must be at least 1 to have the capability to recognize the missing value. However, if all values in a group are missing, the number of bits needed is 0, and the unpacker recognizes this. All variables are g2int. Even though the groups are initially of size minpk or larger, an adjustment between two groups (the lookback procedure) may make a group smaller than minpk. The control on group size is that the sum of the sizes of the two consecutive groups, each of size minpk or larger, is not decreased. When determining the number of bits necessary for packing, the largest value that can be accommodated in, say, mbits, is 2**mbits-1; this largest value (and the next smallest value) is reserved for the missing value indicator (only) when is523 ne 0. If the dimension ndg is not large enough to hold all the groups, the local value of minpk is increased by 50 percent. This is repeated until ndg will suffice. A diagnostic is printed whenever this happens, which should be very rarely. If it happens often, ndg in subroutine pack should be increased and a corresponding increase in subroutine unpack made. Considerable code is provided so that no more checking for missing values within loops is done than necessary; the added efficiency of this is relatively minor, but does no harm. For grib2, the reference value for the length of groups in nov( ) and for the number of bits necessary to pack group values are determined, and subtracted before jbit and kbit are determined.
When 1 or more groups are large compared to the others, the width of all groups must be as large as the largest. A subroutine reduce breaks up large groups into 2 or more to reduce total bits required. If reduce should abort, pack_gp will be executed again without the call to reduce.
PROGRAM HISTORY LOG:
|
• |
February 1994 Glahn tdl mos-2000 |
||
|
• |
June 1995 Glahn modified for lmiss error. |
||
|
• |
July 1996 Glahn added misss |
||
|
• |
February 1997 Glahn removed 4 redundant tests for missp.eq.0; inserted a test to better handle a string of 9999’s |
||
|
• |
February 1997 Glahn added loops to eliminate test for misss when misss = 0 |
||
|
• |
March 1997 Glahn corrected for secondary missing value |
||
|
• |
March 1997 Glahn corrected for use of local value of minpk |
||
|
• |
March 1997 Glahn corrected for secondary missing value |
||
|
• |
March 1997 Glahn changed calculating number of bits through exponents to an array (improved overall packing performance by about 35 percent!). allowed 0 bits for packing jmin( ), lbit( ), and nov( ). |
||
|
• |
May 1997 Glahn a number of changes for efficiency. mod functions eliminated and one ifthen added. jount removed. recomputation of bits not made unless necessary after moving points from one group to another. nendb adjusted to eliminate possibility of very small group at the end. about 8 percent improvement in overall packing. iskipa removed; there is always a group b that can become group a. control on size of group b (statement below 150) added. added adda, and use of ge and le instead of gt and lt in loops between 150 and 160. ibitbs added to shorten trips through loop. |
||
|
• |
March 2000 Glahn modified for grib2; changed name from packgp |
||
|
• |
january 2001 Glahn comments; ier = 706 substituted for stops; added return1; removed statement number 110; added ier and * return |
||
|
• |
November 2001 Glahn changed some diagnostic formats to allow printing larger numbers |
||
|
• |
November 2001 Glahn added misslx( ) to put maximum value into jmin( ) when all values missing to agree with grib standard. |
||
|
• |
November 2001 Glahn changed two tests on missp and misss eq 0 to tests on is523. however, missp and misss cannot in general be = 0. |
||
|
• |
November 2001 Glahn added call to reduce; defined itest before loops to reduce computation; started large group when all same value |
||
|
• |
December 2001 Glahn modified and added a few comments |
||
|
• |
January 2002 Glahn removed loop before 150 to determine a group of all same value |
||
|
• |
January 2002 Glahn changed mallow from 9999999 to 2**30+1, and made it a parameter |
||
|
• |
March 2002 Glahn added non fatal ier = 716, 717; removed nendb=nxy above 150; added iersav=0; comments |
DATA SET USE
|
• |
kfildo - unit number for output (print) file. (output) |
Parameters
kfildo
unit number for
output (print) file. (input)
ic
array to hold data for packing. the values do not
have to be positive at this point, but must be in the range
-2**30 to +2**30 (the the value of mallow). these g2int
values will be retained exactly through packing and
unpacking. (input)
nxy
number of values in ic( ). also treated as its
dimension. (input)
is523
missing value management 0=data contains no
missing values 1=data contains primary missing values 2=data
contains primary and secondary missing values (input)
minpk
the minimum size of each group, except possibly
the last one. (input)
inc
the number of values to add to an already existing
group in determining whether or not to start a new group.
ideally, this would be 1, but each time inc values are
attempted, the max and min of the next minpk values must be
found. this is ’a loop within a loop,’ and a
slightly larger value may give about as good results with
slightly less computational time. if inc is le 0, 1 is used,
and a diagnostic is output. note: it is expected that inc
will equal 1. the code uses inc primarily in the loops
starting at statement 180. if inc were 1, there would not
need to be loops as such. however, kinc (the local value of
inc) is set ge 1 when near the end of the data to forestall
a very small group at the end. (input)
missp
when missing points can be present in the data,
they will have the value missp or misss. missp is the
primary missing value and misss is the secondary missing
value . these must not be values that would occur with
subtracting the minimum (reference) value or scaling. for
example, missp = 0 would not be advisable. (input)
misss
secondary missing value indicator (see missp).
(input)
jmin
the minimum of each group (j=1,lx). (output)
jmax
the maximum of each group (j=1,lx). this is not
really needed, but since the max of each group must be
found, saving it here is cheap in case the user wants it.
(output)
lbit
the number of bits necessary to pack each group
(j=1,lx). it is assumed the minimum of each group will be
removed before packing, and the values to pack will,
therefore, all be positive. however, ic( ) does not
necessarily contain all positive values. if the overall
minimum has been removed (the usual case), then ic( ) will
contain only positive values. (output)
nov
the number of values in each group (j=1,lx).
(output)
ndg
the dimension of jmin, jmax, lbit, and nov. (input)
lx
the number of groups determined. (output)
ibit
the number of bits necessary to pack the jmin(j)
values, j=1,lx. (output)
jbit
the number of bits necessary to pack the lbit(j)
values, j=1,lx. (output)
kbit
the number of bits necessary to pack the nov(j)
values, j=1,lx. (output)
novref
reference value for nov( ). (output)
lbitref
reference value for lbit( ). (output)
ier
Error code
|
• |
0 No error. |
|||
|
• |
706 value will not pack in 30 bits--fatal |
|||
|
• |
714 error in reduce--non-fatal |
|||
|
• |
715 ngp not large enough in reduce--non-fatal |
|||
|
• |
716 minpk inceased--non-fatal |
|||
|
• |
717 inc set |
|||
|
• |
1--non-fatal |
|||
|
• |
alternate return when ier ne 0 and fatal error. |
Returns
0 - check ier for error code.
INTERNAL VARIABLES
cfeed =
contains the character representation
of a printer form feed.
ifeed = contains the g2int value of a printer
form feed.
kinc = working copy of inc. may be modified.
mina = minimum value in group a.
maxa = maximum value in group a.
nenda = the place in ic( ) where group a ends.
kstart = the place in ic( ) where group a starts.
ibita = number of bits needed to hold values in group a.
minb = minimum value in group b.
maxb = maximum value in group b.
nendb = the place in ic( ) where group b ends.
ibitb = number of bits needed to hold values in group b.
minc = minimum value in group c.
maxc = maximum value in group c.
ktotal = count of number of values in ic( ) processed.
nount = number of values added to group a.
lmiss = 0 when is523 = 0. when packing into a
specific number of bits, say mbits,
the maximum value that can be handled is
2**mbits-1. when is523 = 1, indicating
primary missing values, this maximum value
is reserved to hold the primary missing value
indicator and lmiss = 1. when is523 = 2,
the value just below the maximum i.e.,
2**mbits-2 is reserved to hold the secondary
missing value indicator and lmiss = 2.
lminpk = local value of minpk. this will be adjusted
upward whenever ndg is not large enough to hold
all the groups.
mallow = the largest allowable value for packing.
mislla = set to 1 when all values in group a are missing.
this is used to distinguish between a real
minimum when all values are not missing
and a minimum that has been set to zero when
all values are missing. 0 otherwise.
note that this does not distinguish between
primary and secondary missings when secondary
missings are present. this means that
lbit( ) will not be zero with the resulting
compression efficiency when secondary missings
are present. also note that a check has been
made earlier to determine that secondary
missings are really there.
misllb = set to 1 when all values in group b are missing.
this is used to distinguish between a real
minimum when all values are not missing
and a minimum that has been set to zero when
all values are missing. 0 otherwise.
misllc = performs the same function for group c that
mislla and misllb do for groups b and c,
respectively.
ibxx2(j) = an array that when this routine is first entered
is set to 2**j, j=0,30. ibxx2(30) = 2**30, which
is the largest value packable, because 2**31
is larger than the g2int word size.
ifirst = set by data statement to 0. changed to 1 on
first
entry when ibxx2( ) is filled.
minak = keeps track of the location in ic( ) where the
minimum value in group a is located.
maxak = does the same as minak, except for the maximum.
minbk = the same as minak for group b.
maxbk = the same as maxak for group b.
minck = the same as minak for group c.
maxck = the same as maxak for group c.
adda = keeps track whether or not an attempt to add
points to group a was made. if so, then adda
keeps from trying to put one back into b.
(g2int)
ibitbs = keeps current value if ibitb so that loop
ending at 166 doesn’t have to start at
ibitb = 0 every time.
misslx(j) = mallow except when a group is all one value (and
lbit(j) = 0) and that value is missing. in
that case, misslx(j) is missp or misss. this
gets inserted into jmin(j) later as the
missing indicator; it can’t be put in until
the end, because jmin( ) is used to calculate
the maximum number of bits (ibits) needed to
pack jmin( ).
Definition at line 255 of file pack_gp.c .
References FALSE_ , reduce() , and TRUE_ .
Referenced by compack() , and misspack() .
void pngpack (float * fld, g2int width, g2int height, g2int * idrstmpl,unsigned char * cpack, g2int * lcpack)
This subroutine packs up a float data field into PNG image format. 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.
Author
Stephen Gilbert
Date
2003-08-27
Author
Ed Hartnett
Definition at line 254 of file pngpack.c .
References pngpack_int() .
Referenced by g2_addfield() .
g2int pngunpack (unsigned char * cpack, g2int len, g2int * idrstmpl, g2intndpts, 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. |
|||
|
• |
G2_JPCUNPACK_MEM Out of memory. |
Author
Stephen Gilbert
Date
2003-08-27
Author
Ed Hartnett
Definition at line 126 of file pngunpack.c .
References G2_JPCUNPACK_MEM , G2C_ENOMEM , and pngunpack_int() .
Referenced by g2c_unpack7_int() .
void rdieee (g2int * rieee, float * a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.
Parameters
rieee
g2int array of
floating point values in 32-bit IEEE format.
num
Number of floating point values to convert.
a
float array of real values. a must be allocated with
at least 4*num bytes of memory before calling this
function.
Author
Stephen Gilbert
Date
2002-10-25
Definition at line 20 of file rdieee.c .
References int_power() .
Referenced by aecunpack_int() , comunpack() , g2_miss() , g2_unpack4() , g2c_unpack7_int() , jpcunpack_int() , misspack() , pngunpack_int() , simunpack() , and specunpack() .
void sbit (unsigned char * out, g2int * in, g2int iskip, g2int nbits)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
Parameters
out
Pointer to packed
array output. Must be allocated large enough to hold output.
in
Pointer that gets the unpacked array input.
iskip
Initial number of bits to skip.
nbits
Number of bits to pack.
Author
NOAA Programmer
Definition at line 38 of file gbits.c .
References sbits() .
Referenced by compack() , g2_addfield() , g2_addgrid() , g2_addlocal() , g2_create() , g2_gribend() , misspack() , and simpack() .
void sbits (unsigned char * out, g2int * in, g2int iskip, g2int nbits,g2int nskip, g2int n)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
Parameters
out
Pointer to packed
array output. Must be allocated large enough to hold output.
in
Pointer that gets the unpacked array input.
iskip
Initial number of bits to skip.
nbits
Number of bits to pack.
nskip
Additional number of bits to skip on each
iteration.
n
Number of iterations.
Author
NOAA Programmer
Definition at line 178 of file gbits.c .
Referenced by aecpack_int() , compack() , g2_addfield() , g2_addgrid() , jpcpack_int() , misspack() , pngpack_int() , sbit() , and simpack() .
void simpack (float * fld, g2int ndpts, g2int * idrstmpl, unsigned char *cpack, g2int * lcpack)
Packs a data field using the simple packing algorithm. This function also fills in GRIB2 Data Representation Template 5.0 with the appropriate values.
Parameters
fld
Contains the data
values to pack.
ndpts
The number of data values in array fld.
idrstmpl
Contains the array of values for [Data
Representation Template
5.0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml).
|
• |
0 Reference value - ignored on input - set by simpack routine. |
||
|
• |
1 Binary Scale Factor - unchanged from input. |
||
|
• |
2 Decimal Scale Factor - unchanged from input. |
||
|
• |
3 Number of bits used to pack data, if value is > 0 and <= 31. If this input value is 0 or outside above range then the num of bits is calculated based on given data and scale factors. |
||
|
• |
4 Original field type - currently ignored on input. Data values assumed to be reals. Set to 0 by simpack routine. |
cpack
The packed data field
lcpack
length of packed field starting at cpack.
Author
Stephen Gilbert
Date
2002-11-06
Definition at line 36 of file simpack.c .
References ALOG2 , int_power() , LOG , mkieee() , sbit() , and sbits() .
Referenced by g2_addfield() , and specpack() .
g2int simunpack (unsigned char * cpack, g2int * idrstmpl, g2int ndpts,float * fld)
Unpack a data field that was packed using a simple packing algorithm, using info from the GRIB2 Data Representation Template 5.0.
Parameters
cpack
pointer to the
packed data field.
idrstmpl
pointer to the array of values for Data
Representation Template 5.0.
ndpts
The number of data values to unpack.
fld
A pointer that gets the unpacked data values. fld
must be ‘* allocated with at least ndpts *
sizeof(float) bytes before calling this routine.
Returns
0 for success, error code otherwise.
Author
Stephen Gilbert
Date
2002-10-29
Definition at line 28 of file simunpack.c .
References G2_JPCUNPACK_MEM , G2_NO_ERROR , gbits() , int_power() , LOG , and rdieee() .
Referenced by g2c_unpack7_int() .
void specpack (float * fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,g2int * idrstmpl, unsigned char * cpack, g2int * lcpack)
Pack a spectral data field using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 Data Representation Template 5.51 .
Parameters
fld
Contains the data
values to be packed.
ndpts
The number of data values to pack.
JJ
J - pentagonal resolution parameter.
KK
K - pentagonal resolution parameter.
MM
M - pentagonal resolution parameter.
idrstmpl
Contains the array of 10 values for [Data
Representation Template
5.51](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-51.shtml).
cpack
Pointer that gets the packed data field. Must be
allocated by caller.
lcpack
length of packed field cpack.
Author
Stephen Gilbert
Date
2002-12-19
Definition at line 33 of file specpack.c .
References mkieee() , and simpack() .
Referenced by g2_addfield() .
g2int specunpack (unsigned char * cpack, g2int * idrstmpl, g2int ndpts,g2int JJ, g2int KK, g2int MM, float * fld)
Unpack a spectral data field that was packed using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 documention, using info from the GRIB2 Data Representation Template 5.51 .
Parameters
cpack
pointer to the
packed data field.
idrstmpl
pointer to the array of values for Data
Representation Template 5.51.
ndpts
The number of data values to unpack (real and
imaginary parts).
JJ
pentagonal resolution parameter.
KK
pentagonal resolution parameter.
MM
pentagonal resolution parameter.
fld
Contains the unpacked data values. fld must be
allocated with at least ndpts * sizeof(float) bytes before
calling this routine.
Returns
0 for success, -3 for wrong type.
Author
Stephen Gilbert
Date
2000-06-21
Definition at line 35 of file specunpack.c .
References G2_NO_ERROR , G2_SPECUNPACK_TYPE , gbits() , int_power() , and rdieee() .
Referenced by g2c_unpack7_int() .
Author
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.