NCEPLIBS-g2c
1.6.4
|
Return all the metadata, template values, Bit-map (if applicable), and the unpacked data for a given data field. More...
Go to the source code of this file.
Functions | |
g2int | g2_getfld (unsigned char *cgrib, g2int ifldnum, g2int unpack, g2int expand, gribfield **gfld) |
This subroutine returns all the metadata, template values, bit-map (if applicable), and the unpacked data for a given data field. More... | |
g2int | g2_unpack1 (unsigned char *, g2int *, g2int **, g2int *) |
This subroutine unpacks Section 1 - Identification Section as defined in GRIB Edition 2. More... | |
g2int | g2_unpack2 (unsigned char *, g2int *, g2int *, unsigned char **) |
This subroutine unpacks Section 2 (Local Use Section) as defined in GRIB Edition 2. More... | |
g2int | g2_unpack3 (unsigned char *, g2int *, g2int **, g2int **, g2int *, g2int **, g2int *) |
This routine unpacks Section 3 (Grid Definition Section) as defined in GRIB Edition 2. More... | |
g2int | g2_unpack4 (unsigned char *, g2int *, g2int *, g2int **, g2int *, g2float **, g2int *) |
This subroutine unpacks Section 4 (Product Definition Section) as defined in GRIB Edition 2. More... | |
g2int | g2_unpack5 (unsigned char *, g2int *, g2int *, g2int *, g2int **, g2int *) |
This subroutine unpacks Section 5 (Data Representation Section) as defined in GRIB Edition 2. More... | |
g2int | g2_unpack6 (unsigned char *, g2int *, g2int, g2int *, g2int **) |
This subroutine unpacks Section 6 (Bit-Map Section) as defined in GRIB Edition 2. More... | |
g2int | g2_unpack7 (unsigned char *, g2int *, g2int, g2int *, g2int, g2int *, g2int, g2float **) |
This subroutine unpacks Section 7 (Data Section) as defined in GRIB Edition 2. More... | |
Return all the metadata, template values, Bit-map (if applicable), and the unpacked data for a given data field.
Definition in file g2_getfld.c.
g2int g2_getfld | ( | unsigned char * | cgrib, |
g2int | ifldnum, | ||
g2int | unpack, | ||
g2int | expand, | ||
gribfield ** | gfld | ||
) |
This subroutine returns all the metadata, template values, bit-map (if applicable), and the unpacked data for a given data field.
All of the information returned is stored in a gribfield structure, which is defined in file grib2.h. Users of this routine will need to include grib2.h in their source code that calls this routine.
Since there can be multiple data fields packed into a GRIB2 message, the calling routine indicates which field is being requested with the ifldnum argument.
Date | Programmer | Comments |
---|---|---|
2002-10-28 | Gilbert | Initial |
2013-08-08 | Vuong | Free up memory in array igds - free(igds) |
cgrib | Character pointer to the GRIB2 message. |
ifldnum | Specifies which field in the GRIB2 message to return. The first field is number 1, Fortran style. |
unpack | Boolean value indicating whether to unpack bitmap/data field.
|
expand | Boolean value indicating whether the data points should be expanded to the correspond grid, if a bit-map is present. This argument is ignored if unpack == 0 OR if the returned field does not contain a bit-map.
|
gfld | pointer to structure gribfield containing all decoded data for the data field. |
Routine g2_info() can be used to first determine how many data fields exist in a given GRIB message.
Definition at line 102 of file g2_getfld.c.
References gribfield::bmap, gribfield::coord_list, gribfield::discipline, gribfield::expanded, gribfield::fld, g2_unpack1(), g2_unpack2(), g2_unpack3(), g2_unpack4(), g2_unpack5(), g2_unpack6(), g2_unpack7(), gbit(), gribfield::griddef, gribfield::ibmap, gribfield::idrtlen, gribfield::idrtmpl, gribfield::idrtnum, gribfield::idsect, gribfield::idsectlen, gribfield::ifldnum, gribfield::igdtlen, gribfield::igdtmpl, gribfield::igdtnum, gribfield::interp_opt, gribfield::ipdtlen, gribfield::ipdtmpl, gribfield::ipdtnum, gribfield::list_opt, gribfield::local, gribfield::locallen, gribfield::ndpts, gribfield::ngrdpts, gribfield::num_coord, gribfield::num_opt, gribfield::numoct_opt, gribfield::unpacked, and gribfield::version.
This subroutine unpacks Section 1 - Identification Section as defined in GRIB Edition 2.
cgrib | char array containing Section 1 of the GRIB2 message. |
iofst | Bit offset for the beginning of Section 1 in cgrib. |
ids | Pointer that gets an array which contians the information read from Section 1, the Identification section. This array is allocated by this function, and must be freed by caller (using g2_free()).
|
idslen | Number of elements in ids. |
Definition at line 55 of file g2_unpack1.c.
References gbit().
Referenced by g2_getfld().
This subroutine unpacks Section 2 (Local Use Section) as defined in GRIB Edition 2.
Date | Programmer | Comments |
---|---|---|
2002-10-31 | Gilbert | Initial |
2008-12-23 | Wesley | Initialize lencsec2 Length of Local Use data |
2010-08-05 | Vuong | If section 2 has zero length, ierr=0 |
cgrib | char array containing Section 2 of the GRIB2 message. |
iofst | Bit offset for the beginning of Section 2 in cgrib. The modified version will be returned. |
lencsec2 | Length (in octets) of Local Use data. |
csec2 | Pointer to a char array containing local use data. |
Definition at line 37 of file g2_unpack2.c.
References gbit().
Referenced by g2_getfld().
g2int g2_unpack3 | ( | unsigned char * | cgrib, |
g2int * | iofst, | ||
g2int ** | igds, | ||
g2int ** | igdstmpl, | ||
g2int * | mapgridlen, | ||
g2int ** | ideflist, | ||
g2int * | idefnum | ||
) |
This routine unpacks Section 3 (Grid Definition Section) as defined in GRIB Edition 2.
Date | Programmer | Comments |
---|---|---|
2002-10-31 | Gilbert | Initial |
2009-01-14 | Vuong | Changed structure name template to gtemplate |
cgrib | Char array ontaining Section 3 of the GRIB2 message. |
iofst | Bit offset for the beginning of Section 3 in cgrib. |
igds | Contains information read from the appropriate GRIB Grid Definition Section 3 for the field being returned.
|
igdstmpl | Pointer to integer array containing the data values for the Grid Definition Template specified by igds[4]. |
mapgridlen | Number of elements in igdstmpl. i.e. number of entries in Grid Defintion Template specified by igds[4]. |
ideflist | (Used if igds[2] .ne. 0) Pointer to integer array containing the number of grid points contained in each row (or column). |
idefnum | (Used if igds[2] .ne. 0) The number of entries in array ideflist - i.e. number of rows (or columns) for which optional grid points are defined. |
Definition at line 57 of file g2_unpack3.c.
References gtemplate::ext, extgridtemplate(), gtemplate::extlen, gbit(), gbits(), getgridtemplate(), gtemplate::map, gtemplate::maplen, and gtemplate::needext.
Referenced by g2_getfld(), getdim(), and getpoly().
g2int g2_unpack4 | ( | unsigned char * | cgrib, |
g2int * | iofst, | ||
g2int * | ipdsnum, | ||
g2int ** | ipdstmpl, | ||
g2int * | mappdslen, | ||
g2float ** | coordlist, | ||
g2int * | numcoord | ||
) |
This subroutine unpacks Section 4 (Product Definition Section) as defined in GRIB Edition 2.
Date | Programmer | Comments |
---|---|---|
2002-10-31 | Gilbert | Initial |
2009-01-14 | Vuong | Changed structure name template to gtemplate |
cgrib | Array containing Section 4 of the GRIB2 message. |
iofst | Bit offset of the beginning of Section 4 in cgrib. Returned with updated bit offset. |
ipdsnum | Product Definition Template Number (see Table 4.0). |
ipdstmpl | Pointer that gets an integer array containing the data values for the Product Definition Template specified by ipdsnum. |
mappdslen | Number of elements in ipdstmpl - i.e. number of entries in Product Defintion Template specified by ipdsnum. |
coordlist | Pointer that gets an array containing floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels. |
numcoord | number of values in array coordlist. |
Definition at line 45 of file g2_unpack4.c.
References gtemplate::ext, gtemplate::extlen, extpdstemplate(), gbit(), gbits(), getpdstemplate(), gtemplate::map, gtemplate::maplen, gtemplate::needext, and rdieee().
Referenced by g2_getfld().
g2int g2_unpack5 | ( | unsigned char * | cgrib, |
g2int * | iofst, | ||
g2int * | ndpts, | ||
g2int * | idrsnum, | ||
g2int ** | idrstmpl, | ||
g2int * | mapdrslen | ||
) |
This subroutine unpacks Section 5 (Data Representation Section) as defined in GRIB Edition 2.
Date | Programmer | Comments |
---|---|---|
2002-10-31 | Gilbert | Initial |
2009-01-14 | Vuong | Changed structure name template to gtemplate |
cgrib | char array containing Section 5 of the GRIB2 message. |
iofst | Bit offset for the beginning of Section 5 in cgrib. Returned with bit offset at the end of Section 5. |
ndpts | Number of data points unpacked and returned. |
idrsnum | Data Representation Template Number (see Code Table 5.0). |
idrstmpl | Pointer to an integer array containing the data values for the specified Data Representation Template (N=idrsnum). Each element of this integer array contains an entry (in the order specified) of Data Representation Template 5.N. |
mapdrslen- | Number of elements in idrstmpl. i.e. number of entries in Data Representation Template 5.N (N=idrsnum). |
Definition at line 42 of file g2_unpack5.c.
References gtemplate::ext, extdrstemplate(), gtemplate::extlen, gbit(), getdrstemplate(), gtemplate::map, gtemplate::maplen, and gtemplate::needext.
Referenced by g2_getfld().
g2int g2_unpack6 | ( | unsigned char * | cgrib, |
g2int * | iofst, | ||
g2int | ngpts, | ||
g2int * | ibmap, | ||
g2int ** | bmap | ||
) |
This subroutine unpacks Section 6 (Bit-Map Section) as defined in GRIB Edition 2.
cgrib | char array containing Section 6 of the GRIB2 message. |
iofst | Bit offset of the beginning of Section 6 in cgrib. |
ngpts | Number of grid points specified in the bit-map |
ibmap | Bitmap indicator (see Code Table 6.0)
|
bmap | Pointer to an integer array containing decoded bitmap. (if ibmap=0) |
Definition at line 33 of file g2_unpack6.c.
References gbit(), and gbits().
Referenced by g2_getfld().
g2int g2_unpack7 | ( | unsigned char * | cgrib, |
g2int * | iofst, | ||
g2int | igdsnum, | ||
g2int * | igdstmpl, | ||
g2int | idrsnum, | ||
g2int * | idrstmpl, | ||
g2int | ndpts, | ||
g2float ** | fld | ||
) |
This subroutine unpacks Section 7 (Data Section) as defined in GRIB Edition 2.
Date | Programmer | Comments |
---|---|---|
2002-10-31 | Gilbert | Initial |
2002-12-20 | Gilbert | Added GDT info to arguments and added 5.51 processing. |
2003-08-29 | Gilbert | New templates using PNG and JPEG2000 algorithms/templates. |
2004-11-29 | Gilbert | JPEG2000 now allowed to use WMO Template 5.40 PNG allowed to use 5.41 |
2004-12-16 | Taylor | Added check on comunpack return code. |
2008-12-23 | Wesley | Initialize Number of data points unpacked |
cgrib | char array containing Section 7 of the GRIB2 message |
iofst | Bit offset of the beginning of Section 7 in cgrib. |
igdsnum | Grid Definition Template Number (see Code Table 3.0) (Only used for DRS Template 5.51) |
igdstmpl | Pointer to an integer array containing the data values for the specified Grid Definition Template (N=igdsnum). Each element of this integer array contains an entry (in the order specified) of Grid Definition Template 3.N. (Only used for DRS Template 5.51). |
idrsnum | Data Representation Template Number (see Code Table 5.0) |
idrstmpl | Pointer to an integer array containing the data values for the specified Data Representation Template (N=idrsnum). Each element of this integer array contains an entry (in the order specified) of Data Representation Template 5.N |
ndpts | Number of data points unpacked and returned. |
fld | Pointer to a float array containing the unpacked data field. |
Definition at line 65 of file g2_unpack7.c.
References comunpack(), gbit(), jpcunpack(), pngunpack(), rdieee(), simunpack(), and specunpack().
Referenced by g2_getfld().