How to extract specific information from GRIB files?
Another idea would be to use pygrib module:
import pygrib
grbs= pygrib.open("my_file.grb")
# use grbs.select to select the grids you are interested in (shortName, typeOfLevel, level=500, marsParam, dataDate, dataTime, ...)
DATA=np.array(grbs.select(marsParam=my_param,dataDate=my_date,dataTime=my_time))
# DATA will contain 3 arrays
# DATA[0] for values
# DATA[1] for longitudes
# DATA[2] for latitudes
# from the "values" array, extract in lon and lat
DATA1=DATA[0].data(lat1=my_y1,lat2=my_y2,lon1=my_x1,lon2=my_x2))
I eventually ended up with ditching gribapi and switching to Met Office's Iris Python package which solves my problem in a very elegant way. Although it was a bit of a pain to install it (dependencies could be really tricky) at least the documentation is good and it is really easy to use it.