Adam Mercer wrote:
> On 09/10/2007, Jeff Whitaker <js...@fa...> wrote:
>
>
>> Adam: If you can convert your coordinates into latitudes and
>> longitudes, then you can plot the data with the basemap tookit on your
>> choice of map projection (see
>> http://www.scipy.org/Cookbook/Matplotlib/Maps for an example).
>>
>
> Following that example I'm running into a few problems, this is the code I have:
>
> map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l',area_thresh=1000.)
> map.drawmeridians(pylab.arange(0,360,30))
> map.drawparallels(pylab.arange(-90,90,30))
> map.contour(lat, lon, values)
>
> where lat is an array of the latitude, lon the corresponding latitude
> and values the value of the quantity I want to plot, this results in
> the error:
>
> Traceback (most recent call last):
> File "./plot_skymap.py", line 54, in ?
> map.contour(lat, lon, values)
> File "/opt/local/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py",
> line 2484, in contour
> xx = x[x.shape[0]/2,:]
> IndexError: too many indices
>
> Can anyone give me any pointers, on what the problem is here?
>
> Cheers
>
> Adam
>
Adam: If lat and lon are 2D arrays containing the lats and lons of the
grid in degrees, you first need to convert to map projection coordinates
using the map instance:
x,y = map(lons, lats)
(if lons and lats are 1D, you can use pylab.meshgrid to make them 2D first)
Then you pass contour the x, y values
map.contour(x,y,values)
For filled contours use contourf.
Are you sure you want an orthographic projection? I thought sky maps
used a stereographic projection
(http://www.progonos.com/furuti/MapProj/Normal/ProjAppl/projAppl.html).
-Jeff
--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
|