NCEPLIBS-g2  3.5.0
g2png.F90 File Reference

Pack/unpack a data field into PNG image format, defined in Data Representation Template 5.40. More...

Go to the source code of this file.

Functions/Subroutines

subroutine pngpack (fld, width, height, idrstmpl, cpack, lcpack)
 Pack a data field into PNG image format, defined in [Data Representation Template 5.41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml). More...
 
subroutine pngunpack (cpack, len, idrstmpl, ndpts, fld)
 Unpack a data field with PNG, defined in [Data Representation Template 5.40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml). More...
 

Detailed Description

Pack/unpack a data field into PNG image format, defined in Data Representation Template 5.40.

Author
Stephen Gilbert
Date
2002-12-21

Definition in file g2png.F90.

Function/Subroutine Documentation

◆ pngpack()

subroutine pngpack ( real, dimension(width * height), intent(in)  fld,
integer, intent(in)  width,
integer, intent(in)  height,
integer, dimension(*), intent(inout)  idrstmpl,
character(len = 1), dimension(*), intent(out)  cpack,
integer, intent(out)  lcpack 
)

Pack a data field into PNG image format, defined in [Data Representation Template 5.41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml).

After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder. It also fills in GRIB2 Data Representation Template 5.41 or 5.40010 with the appropriate values.

Parameters
[in]fldContains the data values to pack.
[in]widthnumber of points in the x direction.
[in]heightnumber of points in the y direction.
[in,out]idrstmplContains the array of values for Data Representation Template 5.2 or 5.3.
  • idrstmpl(1) Reference value - ignored on input.
  • idrstmpl(2) Binary Scale Factor.
  • idrstmpl(3) Decimal Scale Factor.
  • idrstmpl(4) Number of bits containing each grayscale pixel value.
  • idrstmpl(5) Original field type, currently set = 0 on output Data values assumed to be reals.
  • idrstmpl(6) = 0 use lossless compression; = 1 use lossy compression.
  • idrstmpl(7) Desired compression ratio, if idrstmpl(6)=1.
[out]cpackThe packed data field (character*1 array)
[out]lcpackThe length of packed field cpack.
Author
Stephen Gilbert
Date
2002-12-21

Definition at line 33 of file g2png.F90.

References enc_png(), g2_sbytesc(), and mkieee().

Referenced by addfield().

◆ pngunpack()

subroutine pngunpack ( character(len = 1), dimension(len), intent(in)  cpack,
integer, intent(in)  len,
integer, dimension(*), intent(in)  idrstmpl,
integer, intent(in)  ndpts,
real, dimension(ndpts), intent(out)  fld 
)

Unpack a data field with PNG, defined in [Data Representation Template 5.40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml).

This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.40 or 5.40000.

Parameters
[in]cpackThe packed data field (character*1 array).
[in]lenlength of packed field cpack().
[in]idrstmplContains the array of values for Data Representation Template 5.40 or 5.40000.
[in]ndptsThe number of data values to unpack.
[out]fldContains the unpacked data values.
Author
Stephen Gilbert
Date
2000-06-21

Definition at line 167 of file g2png.F90.

References dec_png(), g2_gbytesc(), and rdieee().

Referenced by getfield(), and gf_unpack7().