[Tutor] pygrib issues involving wind
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 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? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] grb.select for multiple times
I have a grib2 file with wind data at multiple taus as shown below: 3:485167:d=2017030112:UGRD:10 m above ground:3 hour fcst: 8:1652471:d=2017030112:UGRD:10 m above ground:6 hour fcst: 13:2704909:d=2017030112:UGRD:10 m above ground:9 hour fcst: 18:3865964:d=2017030112:UGRD:10 m above ground:12 hour fcst: 23:5030535:d=2017030112:UGRD:10 m above ground:15 hour fcst: 28:6089549:d=2017030112:UGRD:10 m above ground:18 hour fcst: 33:7148742:d=2017030112:UGRD:10 m above ground:21 hour fcst: 38:8216961:d=2017030112:UGRD:10 m above ground:24 hour fcst: 43:9390488:d=2017030112:UGRD:10 m above ground:27 hour fcst: Now what I would like to do is plot these wind values at the different taus in a time series. I have tried to work with the following code: grbs=pygrib.open(grib) uwind = grbs.select(name='10 metre U wind component') uwnddata=uwind.values however I am not able to from this code get a list of the uwind values over the period of time from 3 to 27 hours at 3 hour intervals. How can I tweak the code to get this desired result? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] grb.select for multiple times
In the below email I want to plot the time series of the uwind values at a specific latitude and longitude. On Wed, Mar 1, 2017 at 6:23 PM, Jason Snyder wrote: > I have a grib2 file with wind data at multiple taus as shown below: > > 3:485167:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:3 hour > fcst: > 8:1652471:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:6 hour > fcst: > 13:2704909:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:9 hour > fcst: > 18:3865964:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:12 hour > fcst: > 23:5030535:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:15 hour > fcst: > 28:6089549:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:18 hour > fcst: > 33:7148742:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:21 hour > fcst: > 38:8216961:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:24 hour > fcst: > 43:9390488:d=2017030112 <(201)%20703-0112>:UGRD:10 m above ground:27 hour > fcst: > > > Now what I would like to do is plot these wind values at the different > taus in a time series. I have tried to work with the following code: > > grbs=pygrib.open(grib) > uwind = grbs.select(name='10 metre U wind component') > uwnddata=uwind.values > > however I am not able to from this code get a list of the uwind values > over the period of time from 3 to 27 hours at 3 hour intervals. How can I > tweak the code to get this desired result? > > > -- Jason Snyder PhD ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] pdf generation problem
I have the following program where I am trying to generate a pdf: 1 import matplotlib 2 matplotlib.use('AGG') 3 import matplotlib.pyplot as plt 4 import matplotlib.image as image 5 import matplotlib.gridspec as gridspec 6 from matplotlib.backends.backend_pdf import PdfPages 7 import numpy as np 8 9 np.random.seed(0) 10 11 x, y = np.random.randn(2, 100) 12 13 with PdfPages('wx_plot.pdf') as pdf: 14 fig, (ax1,ax2) = plt.subplots(nrows=2, figsize=(8,11)) 15 gs = gridspec.GridSpec(2, 1, 16 height_ratios=[1.5,3] 17 ) 18 ax1 = plt.subplot(gs[0]) 19 ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2) 20 ax1.grid(True) 21 ax1.axhline(0, color='black', lw=2) 22 23 ax2 = plt.subplot(gs[1]) 24 ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2) 25 ax2.grid(True) 26 ax2.axhline(0, color='black', lw=2) 27 pdf.savefig('fig') 28 pdf.close() When I run it I get the following error: Traceback (most recent call last): File "testinger.py", line 13, in with PdfPages('wx_plot.pdf') as pdf: AttributeError: __exit__ What is going on here and how do I resolve this issue? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Problems with matplotlib
I installed the python module matplotlib on a computer and when I try to run a program with the commands: import matplotlib.pyplot as plt I get the following errors: Traceback (most recent call last): File "new.py", line 1, in import matplotlib File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line 151, in from matplotlib.rcsetup import (defaultParams, File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line 20, in from matplotlib.colors import is_color_like File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line 54, in import matplotlib.cbook as cbook File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 32, in import new File "/home/www/html/auroratest/new.py", line 8, in plt.scatter(x,y) NameError: name 'plt' is not defined when I try to use something like import matplotlib.image as image I get the following errors: Traceback (most recent call last): File "new.py", line 1, in import matplotlib.image as image File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line 151, in from matplotlib.rcsetup import (defaultParams, File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line 20, in from matplotlib.colors import is_color_like File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line 54, in import matplotlib.cbook as cbook File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 32, in import new File "/home/www/html/auroratest/new.py", line 1, in import matplotlib.image as image File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 13, in from matplotlib import rcParams ImportError: cannot import name rcParams What is causing these errors and what specific things do I need to do to resolve this. I need this explained clearly in a step by step way. Thanks, Jason -- Jason Snyder PhD ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor