On 10/03/2011 03:00 PM, Benjamin Root wrote:
> On Mon, Oct 3, 2011 at 6:51 PM, questions anon <questions.a...@gmail.com
> <mailto:questions.a...@gmail.com>> wrote:
>
>     Hi All,
>     Is there a simple way to plot a directional arrow to represent a degree?
>     I have a netcdf file containing wind direction as degrees and I
>     would like to make a plot with all little arrows representing the
>     wind direction.
>     Below is the code I am using currently to plot wind direction but am
>     not sure where/how to add directional arrows.
>     Thanks
>
>
>     from netCDF4 import Dataset
>     import numpy as N
>     import pylab as plt
>     from numpy import ma as MA
>     from mpl_toolkits.basemap import Basemap
>     import os
>
>     ncfile=Dataset('E:/WINDDIR/IDZ00026_VIC_ADFD_Wind_Dir_SFC.nc', 'r+',
>     'NETCDF4')
>     WDIR=ncfile.variables['Wind_Dir_SFC'][-50]
>     LAT=ncfile.variables['latitude'][:]
>     LON=ncfile.variables['longitude'][:]
>     TIME=ncfile.variables['time'][-50]
>     fillvalue=ncfile.variables['Wind_Dir_SFC']._FillValue
>     WDIR=MA.masked_values(WDIR, fillvalue)
>     ncfile.close()
>
>     map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
>                    llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
>     x,y=map(*N.meshgrid(LON,LAT))
>     map.drawstates()
>     map.drawcoastlines()
>     plt.title('Wind Direction')
>     CS = map.contourf(x,y,WDIR,15, cmap=plt.cm.jet)
>     l,b,w,h =0.1,0.1,0.8,0.8
>     cax = plt.axes([l+w+0.025, b, 0.025, h])
>     plt.colorbar(CS,cax=cax,drawedges=True)
>     plt.savefig((os.path.join('E:/WINDDIR/', 'WDIRSFC.png')))
>     plt.show()
>
>
> Would the barb() command do what you want?
>
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.barbs
> http://matplotlib.sourceforge.net/examples/pylab_examples/barb_demo.html
>
> They aren't arrows, but they are commonly used in meteorology to plot
> windfields.
>
> Cheers,
> Ben Root

There is also quiver, both in matplotlib and in basemap.  See the 
quiver_demo.py and barb_demo.py in the basemap examples directory.

Eric

>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to