[Tutor] pygrib issues involving wind

Jason Snyder jmssnyder at ucdavis.edu
Tue Feb 28 17:42:10 EST 2017


I have a grib2 file.  You can see the components of this grib2 file below:

wgrib2 -v chart_2017022812_0057.grb2

1:0:d=2017022812:RH Relative Humidity [%]:2 m above ground:57 hour fcst:
2:227081:d=2017022812:TMAX Maximum Temperature [K]:2 m above ground:54-57
hour max fcst:
3:486870:d=2017022812:UGRD U-Component of Wind [m/s]:10 m above ground:57
hour fcst:
4:751610:d=2017022812:VGRD V-Component of Wind [m/s]:10 m above ground:57
hour fcst:
5:1009523:d=2017022812:PRATE Precipitation Rate [kg/m^2/s]:surface:54-57
hour ave fcst:


Now I am trying to use pygrib to extract the U and V wind components of
this grib2 file with the below python script:

grib = 'chart_2017022812_0057.grb2'

grbs=pygrib.open(grib)
uwind = grbs.select(name='U-component of wind')[0]
rh = grbs.select(name='Relative humidity')[0]
temp = grbs.select(name='Maximum temperature')[0]
prate = grbs.select(name='Precipitation rate')[0]

while with this script, I am able to successfully extract relative
humidity, temperature, and precipitation rate, I am having a problem
extracting the u component of wind.  I get the error:

Traceback (most recent call last):
  File "testgrib.py", line 16, in <module>
    uwind = grbs.select(name='U-Component of wind')[0]
  File "pygrib.pyx", line 609, in pygrib.open.select (pygrib.c:6175)
ValueError: no matches found


How can I resolve this issue?


More information about the Tutor mailing list