I have had some progress reading in the data but am unsure how to create
lats and lons from the info I have (see above).
the error I am receiving is:

Traceback (most recent call last):
  File "d:\plotrainfall.py", line 40, in <module>
    CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
line 3072, in contourf
    np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
AttributeError: logical_or


from the below code:


onefile=r"E:/test_in/r19000117.txt"

f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
print f


map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
              llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
map.drawcoastlines()
map.drawstates()
xi=N.linspace(111.975, 156.275, 886)
yi=N.linspace(-44.525, -9.975, 691)
x,y=map(*N.meshgrid(xi,yi))
plt.title('rainfall')
CS = map.contourf(x,y, f, 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(OutputFolder, 'rainfall.png')))
plt.show()
plt.close()




On Thu, Mar 1, 2012 at 9:29 AM, questions anon <questions.a...@gmail.com>wrote:

> I have a txt file (with an associated prj file) containing gridded weather
> data.
> Firstly how can I open this file and convert it to a numpy array?
> and then how to plot in matplotlib, paticularly how to use the lat, lon
> and nrows,ncols.
> ncols=886
> nrows=691
> longitude west=111.975, east=156.275
> latitude north=-9.975, south=-44.525
> cell size=0.05
>
> My attempt below:
> --------------------------------------------------
>
> onefile=open("E:/test_in/r19000117.txt", 'r')
>
> map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
>               llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
> map.drawcoastlines()
> map.drawstates()
> xi=N.linspace(111.975, 156.275, 886)
> yi=N.linspace(-44.525, -9.975, 691)
> x,y=map(*N.meshgrid(xi,yi))
> plt.title('rainfall')
> CS = map.contourf(x,y, onefile, 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(OutputFolder, 'rainfall.png')))
> plt.show()
> plt.close()
>
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to