NCEPLIBS-g2c
1.6.4
|
Pack up Sections 4 through 7 for a given field and adds them to a GRIB2 message. More...
Go to the source code of this file.
Functions | |
void | cmplxpack (g2float *, g2int, g2int, g2int *, unsigned char *, g2int *) |
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 documention. More... | |
g2int | g2_addfield (unsigned char *cgrib, g2int ipdsnum, g2int *ipdstmpl, g2float *coordlist, g2int numcoord, g2int idrsnum, g2int *idrstmpl, g2float *fld, g2int ngrdpts, g2int ibmap, g2int *bmap) |
This routine packs up Sections 4 through 7 for a given field and adds them to a GRIB2 message. More... | |
g2int | getdim (unsigned char *, g2int *, g2int *, g2int *) |
This subroutine returns the dimensions and scanning mode of a grid definition packed in GRIB2 Grid Definition Section 3 format. More... | |
g2int | getpoly (unsigned char *, g2int *, g2int *, g2int *) |
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. More... | |
void | jpcpack (g2float *, g2int, g2int, g2int *, unsigned char *, g2int *) |
This subroutine packs up a data field into a JPEG2000 code stream. More... | |
void | pngpack (g2float *, g2int, g2int, g2int *, unsigned char *, g2int *) |
This subroutine packs up a data field into PNG image format. More... | |
void | simpack (g2float *, g2int, g2int *, unsigned char *, g2int *) |
This subroutine packs up a data field using the simple packing algorithm as defined in the GRIB2 documention. More... | |
void | specpack (g2float *, g2int, g2int, g2int, g2int, g2int *, unsigned char *, g2int *) |
This subroutine packs a spectral data field using the complex packing algorithm for spherical harmonic data as defined in the GRIB2 Data Representation Template 5.51. More... | |
Pack up Sections 4 through 7 for a given field and adds them to a GRIB2 message.
Definition in file g2_addfield.c.
void cmplxpack | ( | g2float * | fld, |
g2int | ndpts, | ||
g2int | idrsnum, | ||
g2int * | idrstmpl, | ||
unsigned char * | cpack, | ||
g2int * | lcpack | ||
) |
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 documention.
It 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. |
Definition at line 35 of file cmplxpack.c.
References compack(), and misspack().
Referenced by g2_addfield().
g2int g2_addfield | ( | unsigned char * | cgrib, |
g2int | ipdsnum, | ||
g2int * | ipdstmpl, | ||
g2float * | coordlist, | ||
g2int | numcoord, | ||
g2int | idrsnum, | ||
g2int * | idrstmpl, | ||
g2float * | fld, | ||
g2int | ngrdpts, | ||
g2int | ibmap, | ||
g2int * | bmap | ||
) |
This routine packs up Sections 4 through 7 for a given field and adds them to a GRIB2 message.
They are Product Definition Section, Data Representation Section, Bit-Map Section and Data Section, respectively.
This routine is used with routines g2_create(), g2_addlocal(), g2_addgrid(), and g2_gribend() to create a complete GRIB2 message. Function g2_create() must be called first to initialize a new GRIB2 message. Function g2_addgrid() must be called after g2_create() and before this routine to add the appropriate grid description to the GRIB2 message. A call to g2_gribend() is required to complete GRIB2 message after all fields have been added.
Date | Programmer | Comments |
---|---|---|
2002-11-05 | Gilbert | Initial |
2002-12-23 | Gilbert | Added complex spherical harmonic packing |
2003-08-27 | Gilbert | Added support for new templates using PNG and JPEG2000 algorithms/templates. |
2004-11-29 | Gilbert | JPEG2000 now can use WMO Template 5.40 PNG can use WMO Template 5.41. Added packing algorithm check. |
2005-05-10 | Gilbert | Imposed minimum size on cpack. |
2009-01-14 | Vuong | Changed structure name template to gtemplate |
cgrib | Char array that contains the GRIB2 message to which sections 4 through 7 should be added. Must be allocated large enough to store the entire GRIB2 message. |
ipdsnum | Product Definition Template Number (see Code Table 4.0). |
ipdstmpl | Contains the data values for the Product Definition Template specified by ipdsnum. |
coordlist | Array containg floating point values intended to document the vertical discretisation associated to model data on hybrid coordinate vertical levels. |
numcoord | number of values in array coordlist. |
idrsnum | Data Representation Template Number (see Code Table 5.0). |
idrstmpl | The data values for the Data Representation Template specified by idrsnum. Note that some values in this template (eg. reference values, number of bits, etc...) may be changed by the data packing algorithms. Use this to specify scaling factors and order of spatial differencing, if desired. |
fld | Array of data points to pack. |
ngrdpts | Number of data points in grid. i.e. size of fld and bmap. |
ibmap | Bitmap indicator (see Code Table 6.0)
|
bmap | Integer array containing bitmap to be added (if ibmap = 0). |
Definition at line 106 of file g2_addfield.c.
References cmplxpack(), gtemplate::ext, gtemplate::extlen, extpdstemplate(), gbit(), getdim(), getdrstemplate(), getpdstemplate(), getpoly(), jpcpack(), gtemplate::map, gtemplate::maplen, mkieee(), gtemplate::needext, pngpack(), sbit(), sbits(), simpack(), and specpack().
This subroutine returns the dimensions and scanning mode of a grid definition packed in GRIB2 Grid Definition Section 3 format.
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 29 of file getdim.c.
References g2_unpack3().
Referenced by g2_addfield().
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().
void jpcpack | ( | g2float * | fld, |
g2int | width, | ||
g2int | height, | ||
g2int * | idrstmpl, | ||
unsigned char * | cpack, | ||
g2int * | lcpack | ||
) |
This subroutine packs up a data field into a JPEG2000 code stream.
After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a JPEG2000 encoder. It also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
Date | Programmer | Comments |
---|---|---|
2003-08-17 | Gilbert | Initial. |
2004-11-92 | Gilbert | Fixed bug packing a near constant field. |
2004-07-19 | Gilbert | If jpeg2000 encoding fails, try again with different encoder options. |
2005-05-10 | Gilbert | Imposed minimum size on cpack. |
fld | 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 Table 5.40 or 5.40000.
|
cpack | The packed data field. |
lcpack | Pointer that points to a g2int which contains the length of packed field in cpack. This must be set by the calling function. |
Definition at line 53 of file jpcpack.c.
References enc_jpeg2000(), int_power(), mkieee(), and sbits().
Referenced by g2_addfield().
void pngpack | ( | g2float * | fld, |
g2int | width, | ||
g2int | height, | ||
g2int * | idrstmpl, | ||
unsigned char * | cpack, | ||
g2int * | lcpack | ||
) |
This subroutine packs up a 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 | 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 38 of file pngpack.c.
References enc_png(), int_power(), mkieee(), and sbits().
Referenced by g2_addfield().
void simpack | ( | g2float * | fld, |
g2int | ndpts, | ||
g2int * | idrstmpl, | ||
unsigned char * | cpack, | ||
g2int * | lcpack | ||
) |
This subroutine packs up a data field using the simple packing algorithm as defined in the GRIB2 documention.
It 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 34 of file simpack.c.
References int_power(), mkieee(), sbit(), and sbits().
Referenced by g2_addfield(), and specpack().
void specpack | ( | g2float * | fld, |
g2int | ndpts, | ||
g2int | JJ, | ||
g2int | KK, | ||
g2int | MM, | ||
g2int * | idrstmpl, | ||
unsigned char * | cpack, | ||
g2int * | lcpack | ||
) |
This subroutine packs 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().