[Tutor] pygrib issues involving wind

Ben Iannitelli cannedham284 at hotmail.com
Tue Feb 28 19:30:27 EST 2017


Hi Jason,


I know nothing about pygrib, but usually Python is case-sensitive.


Look again at the upper-case and lower-case letters in the original file:

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 look again at your code:

grbs=pygrib.open(grib)
uwind = grbs.select(name='U-component of wind')[0] #<----"component" with small "c" and #"wind" with small "w"
rh = grbs.select(name='Relative humidity')[0] #<----"humidity" with a small "h"
temp = grbs.select(name='Maximum temperature')[0] #<----"temperature" with a small "t"
prate = grbs.select(name='Precipitation rate')[0] #<---- "rate" with a small "r"

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 don't know why letter case wouldn't matter for the other fields (did you cut and paste, or type from memory?), but if you alter your code to match the capitalization exactly, you might rule case sensitivity out.

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

HTH,

-Ben I.



More information about the Tutor mailing list