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

Home » Public Forums » archive » Re: FOR statement
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FOR statement [message #24722] Fri, 13 April 2001 13:17 Go to previous message
Eli Beckerman is currently offline  Eli Beckerman
Messages: 3
Registered: April 2001
Junior Member
> Eli,
>
> No matter how look at it, your example shows you *are* using a loop to
> create an evenly spaced mesh vector. I guess I was trying to say that
> using a loop is not the best way to do this in IDL. One of the wisest
> pieces of advice I ever received about IDL programming was
>
> "Try to think like an IDL programmer, not a Fortran or C programmer".
>
> In this spirit, I submit that the following method is preferable:
>
> nx = 1000 ; number of values required
> dx = 0.25 ; step size
> x1 = 0.0 ; start value
> radius = lindgen(nx) * dx + x1
>
> You might try changing the number of values to 10,000,000 and seeing
> which method is faster.
>
> Cheers,
> Liam.

Well, here's my FOR loop with some background info... The radius
vector was what was hanging me up -- it was not what the FOR loop was FOR!

I can't reason out any way of doing this without the loop, but I
imagine it can be done...

dist = sqrt((x-xc)^2 + (y-yc)^2) ;xc & yc are the center positions
bin = 0.25 ;of a distribution of points
psf = histogram(dist,binsize=bin) ;psf is the radial profile
norm = total(psf)
maxR = max(dist)

ee=fltarr((maxR/bin)+1)
rval=fltarr(maxR/bin)+1)

FOR i=0.0, maxR/bin DO BEGIN
radius = i * bin
insidecounts = n_elements(where(dist le radius))
rval(i) = radius
ee(i) = insidecounts/norm ;to establish the number of counts
;within a given radius
ENDFOR
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: MAKE_ARRAY question
Next Topic: IDLgrWindow, Map_Patch, and contours

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

Current Time: Thu Oct 09 23:25:34 PDT 2025

Total time taken to generate the page: 1.35679 seconds