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

Home » Public Forums » archive » Re: coherence test implementation
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
Re: coherence test implementation [message #15328] Thu, 13 May 1999 00:00
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
Mark Rehbein wrote (paraphrased):
>
> I'm doing what some people call a coherence test.
> I have implemented this the following way:
>
> for y=1, lines-1 do begin
> for x=1, pixels-1 do begin
> matrix=ch4(x-1:x+1, y-1:y+1)
> stats=moment(matrix, sdev=sdev)
> sddevimage(x,y)=sdev
> endfor
> endfor
>
> Can the code be more efficient if I use array and matrix operations?

Mark,

I took a shot at it, tried a couple ideas, including reordering the
original array into a [9,x] array (multiple elements where needed) and
doing a stdev calculation on all the rows simultaneously. In addition
to enlarging the original array by a factor of almost 9 (bad), it only
seemed to slow things down (also bad).

If you only need the standard deviation of each submatrix, you can save
a lot of time by only calculating that particular moment directly:

for y=1,lines-1 do for x=1,pixels-1 do begin
matrix=ch4[x-1:x+1,y-1:y+1]
n = n_elements(matrix)
sddevimage[x,y]=sqrt(total((matrix-(total(matrix)/n))^2)/(n- 1))
endfor

When I tested this it ran 10x faster than the case using moment, which,
whilst not what you asked for, is a significant speed increase.

Cheers,
eddie

----- ---- --- --- ---- --- -- --- --- -- -- - - - -
|\ A G Edward Haskell
|\ Center for Coastal Physical Oceanography
|\ Old Dominion University, Norfolk VA 23529
|\ Voice 757.683.4816 Fax 757.683.5550
|\ e-mail haskell*ccpo.odu.edu
----- ---- --- ---- --- --- --- --- -- -- -- - - - -
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: FORMAT codes and tabs - why not use STR_SEP?
Next Topic: Re: little and big endian -- once more

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

Current Time: Wed Oct 08 17:40:40 PDT 2025

Total time taken to generate the page: 0.00498 seconds