I'm trying to read grib2 file using pygrib from here. But it takes more than 4-5 hours to read the entire 120 files. So I tried making indexes to read the file faster. Whenever I try to make a index on the value key, I get this error:
msgs = grbindx.select(level = 0, typeOfLevel = "surface",parameterName = "values")
File "pygrib.pyx", line 2003, in pygrib.index.select (pygrib.c:30731)
ValueError: no matches found
Here's my code:
#grb = grbs.select(name='UV index')[0]
#uvi surface 0
grbindx = pygrib.index('uv.t12z.grbf64.grib2','typeOfLevel','level','parameterName')
msgs = grbindx.select(level = 0, typeOfLevel = "surface",parameterName = "values")
print msgs.keys
Can anyone explain what am I doing wrong ?
grib_ls
shows on file of such type:
edition centre date dataType gridType stepRange typeOfLevel level shortName packingType
2 kwbc 20160612 fc regular_ll 12 surface 0 uvi grid_jpeg
1 of 1 grib messages in uv.t12z.grbf12.grib2
Therefore, try to read like here:
grbindx = pygrib.index('uv.t12z.grbf64.grib2','typeOfLevel','level','shortName')
msgs = grbindx.select(level = 0, typeOfLevel = "surface",shortName = "uvi")
print msgs
However, I guess, you will not get speed-up because of this file has only one record.