[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: Avoiding a for cicle*From*: Craig Markwardt <craigmnet(at)cow.physics.wisc.edu>*Date*: 12 Apr 2000 13:49:46 -0500*Newsgroups*: comp.lang.idl-pvwave*Organization*: U. Wisc. Madison Physics -- Compact Objects*References*: <B51278FB.4C3D%zamb@physics.ucla.edu> <38EE2E2F.D5849FB3@astro.cornell.edu> <38F3210B.F2A82B04@mpipsykl.mpg.de> <onu2h8k7mx.fsf@cow.physics.wisc.edu> <38F34796.DD3D1BEF@astro.cornell.edu> <38F3B146.FCD65D71@astro.cornell.edu> <onr9cbjq6p.fsf@cow.physics.wisc.edu> <38F4B971.BEAF9D72@astro.cornell.edu>*Reply-To*: craigmnet(at)cow.physics.wisc.edu*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:19231

"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 --------------------------------------------------------------------------

**Follow-Ups**:**Re: Avoiding a for cicle***From:*David Fanning

**References**:**Avoiding a for cicle***From:*Ricardo Fonseca

**Re: Avoiding a for cicle***From:*J.D. Smith

**Re: Avoiding a for cicle***From:*Benno Puetz

**Re: Avoiding a for cicle***From:*Craig Markwardt

**Re: Avoiding a for cicle***From:*J.D. Smith

**Re: Avoiding a for cicle***From:*J.D. Smith

**Re: Avoiding a for cicle***From:*Craig Markwardt

**Re: Avoiding a for cicle***From:*J.D. Smith

- Prev by Date:
**Re: Avoiding a for cicle** - Next by Date:
**Re: Avoiding a for cicle** - Prev by thread:
**Re: Avoiding a for cicle** - Next by thread:
**Re: Avoiding a for cicle** - Index(es):