Jason Li wrote:
Hi Jeff,
Thanks for your help in the past. Just wondering if I can ask another question. This is with regard to plotting irregularly spaced geophysical data.
I have been happy plotting gridded data away using matplotlib/basemap. Now I want to try irregularly spaced satellite data (swath data), using the confourf function. Basically to replace our IDL program to make plots like this:
I have not had much luck yet. In the following example, lat and lon are 2D arrays.
map = Basemap(projection='cyl', lon_0=0, ax=ax, llcrnrlon=minLon, llcrnrlat=minLat, urcrnrlon=maxLon, urcrnrlat=maxLat)
x, y = map(lon, lat)
cs = map.contourf(x, y, obs, levels, cmap=myPrettyCmap)The error message:
File "/usr/local//lib/python2.5/site-packages/matplotlib/toolkits/basemap/basemap.py", line 2442, in contourf
xl = xx.compress(condition).tolist()
AttributeError: compressDo you have a good example as how to do this kind of thing?
thanks
Jason: contourf expects gridded data. I think you need to use one of the approaches outlined in the cookbook entry
http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
to grid your data, then plot it.
If you'd like to send me a sample of the data, I can show you what I mean.
-Jeff
···
--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg