On Aug 25, 4:57 pm, becky_s <rda.se...@gmail.com> wrote: > All, > > I’m having a problem with the matplotlib.pyplot.contourf function. I > have a 1-D array of latitudes (mesolat), a 1-D array of longitudes > (mesolon), and a 1-D array of rainfall values (rain) at those > corresponding lat, lon points. After importing the necessary > libraries, and reading in these 1-D arrays, I do the following > commands: > > p = Basemap(projection='lcc',llcrnrlon=-108.173,llcrnrlat=26.809999, > urcrnrlon=-81.944664,urcrnrlat=45.730892, > lon_0=-97.00, lat_0=37.00, resolution='i') > > px,py = p(mesolon, mesolat) > > prplvls = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] > > crain = p.contourf(px,py,rain,prplvls) > > At this point the contourf function returns an error saying “Input z > must be a 2D array.” However, based on the documentation (http:// > matplotlib.sourceforge.net/api/ > pyplot_api.html#matplotlib.pyplot.contourf) I thought that as long as > px, py, and rain are the same dimensions, everything should be fine. > Apparently that is not the case? If 1D arrays are not allowed in > contourf, then how can I change my data into a 2D array? > > Thanks in advance for the help.
I neglected to mention that these are masked arrays, due to some missing data. I tried using numpy.griddata: mesolati = np.linspace(33.8,37.0,150) mesoloni = np.linspace(-94.5,-102.9,150) raini = griddata(mesolon,mesolat,rain,mesoloni,mesolati) but the raini array returned was entirely masked (no values). Thanks again, Becky -- http://mail.python.org/mailman/listinfo/python-list