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

Home » Public Forums » archive » Avoiding a for cicle
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: Avoiding a for cicle [message #19706 is a reply to message #19664] Wed, 12 April 2000 00:00 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"J.D. Smith" <jdsmith@astro.cornell.edu> writes:
>> This one does exactly what was requested, which I'm not sure of about
>> your solution, J.D. On the other hand, your solution may be more
>> physically meaningful since it involves smoothing.
>>
>
> Nice entry Craig. But unfortunatly it doesn't *alway* do exactly
> what was requested. It works fine for n=5, but for n>5 (7,9,...),
> the index is off. Part of the reason is in the way convol works.
> For n=5, nh=2, and convol subscripts are left of center (t+i-1 for
> i=0,1). For n=7, nh=3, and convol subscripts are (t+i-1 for
> i=0,1,2), which is centered. For n=9, nh=4, and you again have
> (t+i-2 for i=0,1,2,3), left of center again... and so on. The
> additional complication is that you are finding the center of the
> *wrapped* up-going and down-going entries... the center of the peak
> is offset from this by (nh+1)/2 (which happens to equal 1 when n=5
> or n=3). Adding this rather than 1 to the returned indices would
> make it correct. Here's an example for n=9 (^=up-goin,
> v=down-going):
> ...

Arghh. I stand corrected. This turns out to be the kind of "feature"
in CONVOL which we can turn off, by setting the keyword CENTER=0. I
actually read the documentation for the function, intended to put
CENTER=0 in, but forgot. I think now it works as advertised.

dd = d(1:*)-d
nh = (n-1)/2
wh = where(convol((dd GT 0) AND (dd(nh:*) LT 0), bytarr(nh)+1, nh, center=0) $
EQ 1, count) + 1

> Now I'll explain my solution, which does indeed produce indentical
> results ...

I must admit your entry was the cruftier. Nice explanation.

Here is the algorithm I used to make my random spiky_data.sav. You
will find a 13-peak about every 4000 data points with this.

m = 1024L
d = randomn(seed,m)
for i = 1L, m-1 do d(i) = d(i-1)+d(i)

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Q: IDL and endianness issues
Next Topic: Dissect SAVE files, and more!

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

Current Time: Sat Oct 11 13:17:34 PDT 2025

Total time taken to generate the page: 0.24426 seconds