pygrib
pygrib copied to clipboard
Incorrect unpacking of grib1 message with homogeneous values
I have a grib that only contains the value 100.0 which appears not to unpack correctly, the values unpack to 1000.0 not 100.
Sample file containing only the value 100.0 for each cell in grid: http://yacht.net.nz/~ckd/cldd23h15.grb
Same grid with multiple values that is handled correctly: http://yacht.net.nz/~ckd/cldd23h17.grb
Other tools (eg. CDO) handle the file with homogeneous values correctly.
>>> gs = pygrib.open('cldd23h15.grb')
>>> g = gs[1]
>>> g
1:Total Cloud Cover:% (instant):regular_ll:entireAtmosphere:level 0:fcst time 3 :from 201603231200
>>> g.values
array([[ 1000., 1000., 1000., ..., 1000., 1000., 1000.],
[ 1000., 1000., 1000., ..., 1000., 1000., 1000.],
[ 1000., 1000., 1000., ..., 1000., 1000., 1000.],
...,
[ 1000., 1000., 1000., ..., 1000., 1000., 1000.],
[ 1000., 1000., 1000., ..., 1000., 1000., 1000.],
[ 1000., 1000., 1000., ..., 1000., 1000., 1000.]])
>>> gs = pygrib.open('cldd23h17.grb')
>>> g = gs[1]
>>> g
1:Total Cloud Cover:% (instant):regular_ll:entireAtmosphere:level 0:fcst time 5 :from 201603231200
>>> g.values
array([[ 100. , 100. , 100. , ..., 100. , 100. , 100. ],
[ 100. , 100. , 100. , ..., 100. , 100. , 100. ],
[ 100. , 100. , 100. , ..., 100. , 100. , 100. ],
...,
[ 100. , 99.9, 99.9, ..., 100. , 100. , 100. ],
[ 99.9, 99.9, 99.9, ..., 100. , 100. , 100. ],
[ 99.9, 99.9, 99.8, ..., 100. , 100. , 100. ]])
Using pygrib 2.0.0 and python 2.7 on ubuntu 14.04.
Any Ideas?
pygrib uses the ECWMF grib_api library for grib packing/unpacking (except if the packing is 'grid_complex', in which case it uses the NCEP g2c library). It's either a bug in the way the grid is encoded and/or a bug in the grib_api library.