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

Home » Public Forums » archive » Anyway to avoid this last for loop
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
Anyway to avoid this last for loop [message #64601] Thu, 08 January 2009 01:59
hldevil is currently offline  hldevil
Messages: 6
Registered: September 2008
Junior Member
Hi Everybody,

after having worked my way through dfannings and jdsmiths histogram
tips I still haven't found a way to avoid one last (and time
consuming) FOR-loop. Maybe someone has an idea.

I have to lists (Millions of entries): one containing detector hit-
times, one containing anticoincidence hit-times. Only those detector
hits which do not have a AC event at the same time are supposed to be
kept.

I used a histogram approach:

;AClength is how many frames are thrown out after one AC Hit ->
multiple entries can fall into one bin

detHist=histogram(data,REVERSE_INDICES=ri, /L64, binSize=AClength)
acHist=histogram(ACdeletes, /L64, binSize=AClength)


;renormalize to one
dI=where(detHist GT 1, cntD)
aI=where(acHist GT 1, cntA)
IF cntD NE 0 THEN detHist[dI]=1
IF cntA NE 0 THEN acHist[aI]=1

;subtract the two histograms. All detector frames which have
corresponding AC frame should now have value 0, if AC frame exists but
not detector frame then value is -1. If only detector frame exists
(the ones we want) value stays 1!!!
diffHist=detHist-acHist

;keep the ones with one
keep=where(diffHist EQ 1, cnt)

;And now my problem. I need the indices of the keep-frames but there
can be more than one in a bin so I'm stuck with this loop:

FOR k=0L, cnt-1 DO BEGIN
keepIndices=[keepIndices,ri[ri[keep[k]]:ri[keep[k]+1]-1]]
ENDFOR

Is there any way I can avoid this, especially because it scales with
the number of hits which are kept.

Best Regards,

Steffen
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Web interface development
Next Topic: Re: Some errors about 7.0.3 update

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

Current Time: Wed Oct 08 17:58:39 PDT 2025

Total time taken to generate the page: 0.00427 seconds