NCEPLIBS-g2c 2.0.0
|
Header file with internal function prototypes NCEPLIBS-g2c library. More...
#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"
Go to the source code of this file.
Data Structures | |
struct | g2c_code_table |
A GRIB2 code table. More... | |
struct | g2c_dim_info |
Keep information about dimensions defined in section 3. More... | |
struct | g2c_entry |
An entry in a GRIB2 code table. More... | |
struct | g2c_file_info |
This is the information about each open file. More... | |
struct | g2c_param |
An entry in the table of NOAA abbreviations for GRIB parameters. More... | |
struct | g2c_section3_info |
Information about Section 3 GRID DEFINITION SECTION. More... | |
struct | g2c_section4_info |
Information about Section 4 PRODUCT DEFINITION SECTION. More... | |
struct | g2c_section5_info |
Information about Section 5 DATA REPRESENTATION SECTION. More... | |
struct | g2c_section6_info |
Information about Section 6 BIT-MAP SECTION. More... | |
struct | g2c_section_info |
Information about a section 3 through 7 in a GRIB2 message. More... | |
struct | gtemplate |
Struct for GRIB template, returned by getgridtemplate(). More... | |
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. | |
Header file with internal function prototypes NCEPLIBS-g2c library.
Definition in file grib2_int.h.
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.
struct g2c_section5_info |
Information about Section 5 DATA REPRESENTATION SECTION.
Definition at line 218 of file grib2_int.h.
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. |
#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.
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.
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 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.
Struct for GRIB template.
Definition at line 305 of file grib2_int.h.
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.
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. |
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, | ||
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.
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. |
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.
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.
|
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. |
Definition at line 297 of file aecpack.c.
References aecpack_int().
Referenced by g2_addfield().
Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation Template 5.42.
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. |
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.
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
|
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. |
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.
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.
|
cpack | The packed data field. |
lcpack | length of packed field cpack. |
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).
Date | Programmer | Comments |
---|---|---|
2002-10-29 | Gilbert | Initial |
2004-12-16 | Gilbert | Added test (from Arthur Taylor/MDL) verifying group widths/lengths |
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. |
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.
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. |
Definition at line 38 of file decenc_aec.c.
References LOG.
Referenced by aecunpack_int().
Decode a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) using JasPer Software.
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. |
Definition at line 376 of file decenc_jpeg2000.c.
References int_dec_jpeg2000().
Referenced by jpcunpack_int().
Decode PNG.
pngbuf | Pointer to PNG buffer. |
width | Pointer to width. |
height | Pointer to height. |
cout | Output buffer. |
Definition at line 100 of file decenc_png.c.
References user_read_data().
Referenced by pngunpack_int().
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.
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. |
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, | ||
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.
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. |
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.
|
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. |
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.
data | data. |
width | width. |
height | height. |
nbits | number of bits. |
pngbuf | PNG buffer. |
Definition at line 207 of file decenc_png.c.
References user_flush_data(), and user_write_data().
Referenced by pngpack_int().
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.
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. |
Definition at line 213 of file drstemplates.c.
References getdrsindex(), and getdrstemplate().
Referenced by g2_unpack5().
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.
number | The number of the Grid Definition Template that is being requested. |
template | The grid definition template array. |
Definition at line 225 of file gridtemplates.c.
References getgridindex(), and getgridtemplate().
Referenced by g2_addgrid(), g2_unpack3(), and g2c_get_grid_template_extension().
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.
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. |
Definition at line 326 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.
path | Path of the file. |
mode | Open mode flags. |
g2cid | Pointer that gets an indentifier for the file. |
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'.
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. |
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.
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. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the byte. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the int. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the long long. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the short. |
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.
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. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the unsigned byte. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the unsigned int. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the unsigned long long. |
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.
f | Pointer to the open GRIB2 FILE. |
write | Non-zero to write, zero to read. |
var | Pointer to the unsigned short. |
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, | ||
unsigned char | minute, | ||
unsigned char | second, | ||
char * | tabbrev | ||
) |
Convert date and time from GRIB2 info to string output.
[in] | 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. |
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.
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. |
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.
msg | Pointer to G2C_MESSAGE_INFO_T which contains section 0 information. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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().
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array.
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. |
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().
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked iout array.
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. |
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().
Return the dimensions and scanning mode of a grid definition.
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. |
Definition at line 27 of file getdim.c.
References g2_unpack3().
Referenced by g2_addfield().
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.
number | The number of the Data Representation Template that is being requested. |
Definition at line 167 of file drstemplates.c.
References getdrsindex(), and templatesdrs.
Referenced by extdrstemplate(), g2_addfield(), and g2_unpack5().
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.
number | The number of the Grid Definition Template that is being requested. |
Definition at line 177 of file gridtemplates.c.
References getgridindex(), and templatesgrid.
Referenced by extgridtemplate(), g2_addgrid(), and g2_unpack3().
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.
number | the number of the Product Definition Template that is being requested. |
Definition at line 277 of file pdstemplates.c.
References getpdsindex(), and templatespds.
Referenced by extpdstemplate(), g2_addfield(), and g2_unpack4().
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:
csec3 | Character array that contains the packed GRIB2 GDS. |
jj | J pentagonal resolution parameter. |
kk | K pentagonal resolution parameter. |
mm | M pentagonal resolution parameter. |
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.
x | The base value whose power is to be calculated. |
y | The power value. |
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.
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.
|
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. |
Definition at line 269 of file jpcpack.c.
References jpcpack_int().
Referenced by g2_addfield().
Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representation Template 5.40 or 5.40000.
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. |
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.
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.
|
cpack | The packed data field (character*1 array). |
lcpack | length of packed field cpack. |
Definition at line 43 of file misspack.c.
References ALOG2, int_power(), mkieee(), pack_gp(), rdieee(), sbit(), and sbits().
Referenced by cmplxpack().
Store a list of real values in 32-bit IEEE floating point format.
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. |
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:
DATA SET USE
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
|
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.
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.
|
cpack | The packed data field. |
lcpack | length of packed field cpack. |
Definition at line 254 of file pngpack.c.
References pngpack_int().
Referenced by g2_addfield().
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.
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. |
Definition at line 126 of file pngunpack.c.
References G2_JPCUNPACK_MEM, G2C_ENOMEM, and pngunpack_int().
Referenced by g2c_unpack7_int().
Read a list of real values in 32-bit IEEE floating point format.
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. |
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().
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
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. |
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().
Store arbitrary size values into a packed bit string, taking the low order bits from each value in the unpacked array.
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. |
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().
Packs a data field using the simple packing algorithm.
This function also fills in GRIB2 Data Representation Template 5.0 with the appropriate values.
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).
|
cpack | The packed data field |
lcpack | length of packed field starting at cpack. |
Definition at line 36 of file simpack.c.
References ALOG2, int_power(), LOG, mkieee(), sbit(), and sbits().
Referenced by g2_addfield(), and specpack().
Unpack a data field that was packed using a simple packing algorithm, using info from the GRIB2 Data Representation Template 5.0.
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. |
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.
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. |
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.
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. |
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().