Plotting 3D skymap surfaces

Hi

I have some skymap data, i.e. theta, phi and some intensity that I
would like to plot on the surface of a sphere, does matplotlib support
plotting on the surface of a sphere? I've looked through the examples
and can't seem to find anything.

Any help would be greatly appreciated.

Cheers

Adam

Adam Mercer wrote:

Hi

I have some skymap data, i.e. theta, phi and some intensity that I
would like to plot on the surface of a sphere, does matplotlib support
plotting on the surface of a sphere? I've looked through the examples
and can't seem to find anything.

Any help would be greatly appreciated.

Cheers

Adam

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).

-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-124
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory

Thats just what I'm after. Thanks a lot!

Cheers

Adam

···

On 09/10/2007, Jeff Whitaker <jswhit@...146...> 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

···

On 09/10/2007, Jeff Whitaker <jswhit@...146...> 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).

Gonna assume that values is a 1D array, right ? I'm pretty sure that you need
a 2D array for contours to work.

http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

···

On Tuesday 09 October 2007 20:08:29 Adam Mercer wrote:

On 09/10/2007, Jeff Whitaker <jswhit@...146...> 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:

Adam Mercer 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

···

On 09/10/2007, Jeff Whitaker <jswhit@...146...> wrote:

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328