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

Home » Public Forums » archive » Re: help with data points of contour.
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: help with data points of contour. [message #16904] Wed, 25 August 1999 00:00
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<HTML>
Peter Brooker wrote:
<BLOCKQUOTE TYPE=CITE>Consider the following simple program.

<P>nn=101
<BR>x=findgen(nn)-(nn-1.)/2.
<BR>y=x
<BR>z=fltarr(nn,nn)
<BR>for i=0,(nn-1) do begin
<BR>for j=0,(nn-1) do begin
<BR>&nbsp;&nbsp; z(i,j)=sqrt(x(i)^2+y(j)^2)
<BR>&nbsp;&nbsp; endfor
<BR>&nbsp;&nbsp; endfor
<BR>contour,z,x,y,levels=[10,20,30,40]
<BR>end</BLOCKQUOTE>
a question.why do you use loop?
<BR>&nbsp;I use the technique:

<P>pro test

<P>&nbsp;&nbsp;&nbsp; nn=101

<P>&nbsp;&nbsp;&nbsp; x = findgen(nn)-(nn-1.)/2.
<BR>&nbsp;&nbsp;&nbsp; y = x
<BR>&nbsp;&nbsp;&nbsp; x = x#replicate(1,nn)
<BR>&nbsp;&nbsp;&nbsp; y = replicate(1,nn)#y

<P>&nbsp;&nbsp;&nbsp; z = sqrt(x^2+y^2)
<BR>&nbsp;
<BR>end

<P>don't you think it is more readeble and maybe, I didn't test it, quicker?
<BR>&nbsp;
<BLOCKQUOTE TYPE=CITE>I now want to determine the x,y data points that
form the z=20 contour.</BLOCKQUOTE>
I think that if you are interested only in discrete value of your coordinate,it
is sufficient to do:

<P>index&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = where(z eq 20)
<BR>x_index&nbsp; =&nbsp; index mod nn
<BR>y_index&nbsp; =&nbsp; index / nn
<BR>print, x_index, y_index

<P>bye.
<PRE>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</PRE>
&nbsp;</HTML>
Re: help with data points of contour. [message #16915 is a reply to message #16904] Tue, 24 August 1999 00:00 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Peter Brooker wrote:
<blockquote TYPE=CITE>Consider the following simple program.
<p>nn=101
<br>x=findgen(nn)-(nn-1.)/2.
<br>y=x
<br>z=fltarr(nn,nn)
<br>for i=0,(nn-1) do begin
<br>for j=0,(nn-1) do begin
<br>&nbsp;&nbsp; z(i,j)=sqrt(x(i)^2+y(j)^2)
<br>&nbsp;&nbsp; endfor
<br>&nbsp;&nbsp; endfor
<br>contour,z,x,y,levels=[10,20,30,40]
<br>end
<p>I now want to determine the x,y data points that form the z=20 contour.
<br>How do I do this. The manual is rather cryptic on this.
<p>thanks-Peter Brooker</blockquote>
The contour positions can be written to a variable using the PATH_INFO
and PATH_XY.
<br>&nbsp;
<p>Something like this...
<p>pro test
<br>&nbsp;
<p>nn=101
<br>x=findgen(nn)-(nn-1.)/2.
<br>y=x
<br>z=fltarr(nn,nn)
<p>for i=0,(nn-1) do begin
<br>for j=0,(nn-1) do begin
<br>&nbsp;&nbsp; z(i,j)=sqrt(x(i)^2+y(j)^2)
<br>&nbsp;&nbsp; endfor
<br>&nbsp;&nbsp; endfor
<br>&nbsp;
<p>contour,z,x,y,levels=[10,20,30,40],Path_XY = Path_XY,Path_Info = Path_Info
<p>; the Path_info contains such as number of verticies and how far down
the list in Path_XY they start
<br>; level 20 is index #1 in this case
<p>help, Path_Info[1], /struct
<p>&nbsp;;it should apears like this
<br>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;&nbsp; ; start at index Offset
<br>N = Path_Info[1].N&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;
; there are N verticies
<p>&nbsp;; to get the XY pairings of the verticies
<p>XY20 = Path_XY[*,Offset:Offset+N-1]
<p>help, XY20
<p>;IDL> help,XY20
<br> ;XY20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FLOAT&nbsp;&nbsp;&nbsp;&nbsp; = Array[2, 308]
<br>&nbsp;
<p>stop
<br>end
<br>&nbsp;
<pre>--&nbsp;
Ben Tupper

Bigelow Laboratory for Ocean Science
tupper@seadas.bigelow.org

Pemaquid River Company
pemaquidriver@tidewater.net</pre>
&nbsp;</html>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: VIP
Next Topic: Rebin fails for UInt image on PowerMac

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

Current Time: Wed Oct 08 15:36:55 PDT 2025

Total time taken to generate the page: 0.00584 seconds