comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Spherical Contour Plotting
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Spherical Contour Plotting [message #28725] Wed, 09 January 2002 13:48 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth Bowman (k-bowman@null.com) writes:

> If the finished "thing" (I avoid the word object) is to be 2-D, try the
> SATELLITE projection in MAP_SET.
>
> If you want a 3-D "thing", you could do a CYLINDRICAL EQUIDISTANT plot
> with MAP_SET. CONTOUR will return the coordinates of the isopleths
> (PATH_INFO, PATH_XY). Then transform the longitude-latitude coordinates
> into 3-D space and use direct or object graphics to display the resulting
> lines.

Somehow I knew the answer to this was going to be easy. :^)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Spherical Contour Plotting [message #28726 is a reply to message #28725] Wed, 09 January 2002 13:26 Go to previous messageGo to next message
k-bowman is currently offline  k-bowman
Messages: 12
Registered: December 2001
Junior Member
In article <3C3C6E5D.E082A351@students.wisc.edu>, Adam Bayliss
<rabayliss@students.wisc.edu> wrote:

> Hi,
> I'd like take a 2d array (containing a surface component of a vector)
> and make a contour plot on a sphere. So basically I'd like to take the
> results of the "contour" procedure, and project this graph onto a
> sphere. Any ideas would be appreciated.

If the finished "thing" (I avoid the word object) is to be 2-D, try the
SATELLITE projection in MAP_SET.

If you want a 3-D "thing", you could do a CYLINDRICAL EQUIDISTANT plot
with MAP_SET. CONTOUR will return the coordinates of the isopleths
(PATH_INFO, PATH_XY). Then transform the longitude-latitude coordinates
into 3-D space and use direct or object graphics to display the resulting
lines.

Ken
Re: Spherical Contour Plotting [message #28809 is a reply to message #28725] Thu, 10 January 2002 08:59 Go to previous message
k-bowman is currently offline  k-bowman
Messages: 12
Registered: December 2001
Junior Member
In article <MPG.16a6689c231416089897c5@news.frii.com>, david@dfanning.com wrote:

> Kenneth Bowman (k-bowman@null.com) writes:
>
>> If the finished "thing" (I avoid the word object) is to be 2-D, try the
>> SATELLITE projection in MAP_SET.
>>
>> If you want a 3-D "thing", you could do a CYLINDRICAL EQUIDISTANT plot
>> with MAP_SET. CONTOUR will return the coordinates of the isopleths
>> (PATH_INFO, PATH_XY). Then transform the longitude-latitude coordinates
>> into 3-D space and use direct or object graphics to display the resulting
>> lines.
>
> Somehow I knew the answer to this was going to be easy. :^)

Oh, its not nearly as hard as object graphics. Here is a direct graphics
example.
Note that the work of extracting the contour lines and converting to
Cartesian coordinates is only a few lines of IDL code.

I leave it to you object wizards to turn the 3-D lines into objects and stick
a sphere object inside. ;-)

Ken


PRO SPHERICAL_PLOT

COMPILE_OPT IDL2

cr = ''

nx =
65
;Grid resolution in longitude
ny =
33
;Grid resolution in latitude

x =
(360.0/(nx-1))*FINDGEN(nx)
;Longitude grid
y = -90 +
(180.0/(ny-1))*FINDGEN(ny)
;Latitude grid
xx = x # REPLICATE(1.0,
ny) ;2-D longitude grid
yy = REPLICATE(1.0, nx) #
y ;2-D latitude grid
z = SIN(!DTOR*xx) *
COS(!DTOR*yy) ;Test function to
contour

;Standard contour plot on satellite map projection
MAP_SET, /SATELLITE, /CONT, /ISOTROPIC
CONTOUR, z, x, y, LEVELS = -0.95 + 0.1*FINDGEN(20),
/OVERPLOT ;Contour z
PRINT, 'Enter <cr> to continue.'
READ, cr

;Get contour info
CONTOUR, z, x, y, PATH_INFO = path_info, PATH_XY = path_xy,
$ ;Contour z, save contour info
/PATH_DATA_COORDS, CLOSED = 0, LEVELS =-0.95 + 0.1*FINDGEN(20)

;2-D plot using contour info
PLOT, [0, 0], [1, 1], /NODATA, $
XTITLE = 'Longitude', $
XSTYLE = 1, $
XRANGE = [0.0, 360.0], $
XTICKS = 4, $
YTITLE = 'Latitude', $
YSTYLE = 1, $
YRANGE = [-90., 90.0], $
YTICKS = 6

FOR k = 0, N_ELEMENTS(path_info)-1 DO BEGIN
i0 =
path_info[k].offset
;First element of the k'th contour
i1 = i0 + path_info[k].n -
1 ;Last element of the k'th
contour
; PRINT, k, path_info[k].type, i0, i1
xc =
REFORM(path_xy[0,i0:i1])
;Extract x-coords of k'th contour
yc =
REFORM(path_xy[1,i0:i1])
;Extract y-coords of k'th contour
IF (path_info[k].type EQ 1) THEN
BEGIN ;Close contours, if needed
xc = [xc, path_xy[0,i0]]
yc = [yc, path_xy[1,i0]]
ENDIF

PLOTS, xc,
yc ;Plot
contours
ENDFOR
PRINT, 'Enter <cr> to continue.'
READ, cr


;3-D plot using contour info
PLOT_3DBOX, [0,0], [0,0], [0,0], /NODATA, $
XTITLE = 'X', $
XSTYLE = 1, $
XRANGE = [-1.0, 1.0], $
XTICKS = 4, $
YTITLE = 'Y', $
YSTYLE = 1, $
YRANGE = [-1., 1.0], $
YTICKS = 4, $
ZTITLE = 'Z', $
ZSTYLE = 1, $
ZRANGE = [-1.0, 1.0], $
ZTICKS = 4

r = 0.9
FOR k = 0, N_ELEMENTS(path_info)-1 DO BEGIN
i0 =
path_info[k].offset
;First element of the k'th contour
i1 = i0 + path_info[k].n -
1 ;Last element of the k'th
contour
; PRINT, k, path_info[k].type, i0, i1
xc =
REFORM(path_xy[0,i0:i1])
;Extract x-coords of k'th contour
yc =
REFORM(path_xy[1,i0:i1])
;Extract y-coords of k'th contour
IF (path_info[k].type EQ 1) THEN
BEGIN ;Close contours, if needed
xc = [xc, path_xy[0,i0]]
yc = [yc, path_xy[1,i0]]
ENDIF

x3 = r * COS(!DTOR*yc) *
COS(!DTOR*xc) ;Convert to Cartesian
coordinates
y3 = r * COS(!DTOR*yc) * SIN(!DTOR*xc)
z3 = r * SIN(!DTOR*yc)
PLOTS, x3, y3, z3, /T3D
ENDFOR

END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Null terminated strings
Next Topic: Spherical Contour Plotting

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:44:56 PDT 2025

Total time taken to generate the page: 0.00586 seconds