matplotlib/basemap question

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:

http://aurapar2u.ecs.nasa.gov/airscal2/Aqua_AIRS_Level1/AIRIBRAD.005/2008/001/AIRS.2008.01.01.067.L1B.AIRS_Rad.v5.0.0.0.G08003111751.hdf.jpg

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: compress

Do 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

Hi Jeff,
Do you have in your bags a similar approch but using kriging? For the moment
we use R via Rpy to make the computation, but if you know a more pythonic way
to do so, I'll appreciate :slight_smile:
Cordialy

···

Le mardi 10 juin 2008, Jeff Whitaker a écrit :

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:
>
> http://aurapar2u.ecs.nasa.gov/airscal2/Aqua_AIRS_Level1/AIRIBRAD.005/2008
>/001/AIRS.2008.01.01.067.L1B.AIRS_Rad.v5.0.0.0.G08003111751.hdf.jpg
>
>
>
> 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/base
>map.py", line 2442, in contourf
> xl = xx.compress(condition).tolist()
> AttributeError: compress
>
>
> Do 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

--
Lionel Roubeyrie - lroubeyrie@...1068...
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr