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 #19713 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:

>> Alright code slingers... new challenge... find location of all peaks in a region
>> of n points (n odd), monotonically decreasing away from the peak. I.e. find
>> peaks of width n.
>>
>
> Since noone will take my challenge I'm forced to claim the prize for myself:
>
> wh=where(d gt ((m=median(d,3))) and smooth((d eq m)*(n-2),n-2) eq n-3)

Slow down there whipper-snapper! Gotta let these things stew for a
while. Though multiline, this is my best effort:

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

For the goobledy-gook impaired (aka DF :-),
dd is the first difference of the data
nh is the half-width of the peak
(dd GT 0) AND (dd(nh:*) LT 0) locates up-going followed by down-going points
convol(...) locates runs of length nh

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.

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 14:34:02 PDT 2025

Total time taken to generate the page: 2.95916 seconds