pygrib
pygrib copied to clipboard
Issues with extracting data from OpenWRF
Im trying to extract data from OpenWRF grib, and for messages with u/v wind and u/v current I'm getting errors:
ECCODES ERROR : unable to create iterator ECCODES ERROR : numberOfPoints != size(values) (12600!=12608)
I'm using file 'France_12km_WRF_WAM_210224-00.grb' you can download it from here
Steps to reproduce:
import pygrib
grb = pygrib.open("openwrf_data/France_12km_WRF_WAM_210224-00.grb")
mes = grb.message(15)
print(mes)
vals = mes.codedValues
/home/andrzej/PycharmProjects/veo-grib-importer/venv/bin/python /snap/pycharm-community/226/plugins/python-ce/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 46875 --file /home/andrzej/PycharmProjects/veo-grib-importer/grib_bug.py
Connected to pydev debugger (build 203.7148.72)
15:U-component of current:m s**-1 (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 202102240000
ECCODES ERROR : numberOfPoints != size(values) (12600!=12608)
ECCODES ERROR : unable to create iterator
Traceback (most recent call last):
File "/snap/pycharm-community/226/plugins/python-ce/helpers/pydev/pydevd.py", line 1477, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/snap/pycharm-community/226/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/andrzej/PycharmProjects/veo-grib-importer/grib_bug.py", line 8, in <module>
vals1 = mes.latLonValues
File "pygrib/_pygrib.pyx", line 764, in pygrib._pygrib.gribmessage.__getattr__
File "pygrib/_pygrib.pyx", line 1168, in pygrib._pygrib.gribmessage.__getitem__
RuntimeError: b'Grid description is wrong or inconsistent'
Process finished with exit code 1
Apparently the grib file is encoded incorrectly - the ECCODES C library is reporting that the stated grid size doesn't match the number of data values.