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

Home » Public Forums » archive » Re: Conditional averaging
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: Conditional averaging [message #32723] Wed, 06 November 2002 15:33 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
thompson@orpheus.nascom.nasa.gov (William Thompson) writes:

> klassen@rowan.edu (David Klassen) writes:
>
>> I have a set of arrays which I wish to average in a pixel-by-pixel fashion;
>> that is, I want to create an average array. The problem is that there are
>> points I wish to exclude from the averaging procedure (all of them have
>> been given a particular value, say, -100).
>
>> I think I can get them to add so that the 'bad pixel' flags don't contribute
>> to the sum, however, I can't simply divide by the number of arrays, as each
>> point in the array has had a different number of good pixels put into its
>> sum. Is there an easy way to keep track of the number points which went
>> into to the sum?
>
> A = RANDOMN(SEED, 100, 100, 10) ;Simulated data
> A(20:30,20:30) = -100
> AVG = TOTAL(A,3) / TOTAL(A NE -100,3)

Hmm, you probably don't want to leave those -100s in there do you?

How about this?

nval = total(a NE -100,3) ;; Figure out number of valid pixels
wh = where(a EQ -100, ct) ;; Now zero-out the invalid pixels
if ct GT 0 then a(wh) = 0
avg = total(a,3)/npix

Of course, there is would be further checking needed when there are no
valid pixels for a given position. If you can set your invalid values
to NaN, then you can avoid some of those steps and use TOTAL(...,/NAN).

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
Previous Topic: Conditional averaging
Next Topic: 3D Plot

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

Current Time: Sat Oct 11 06:45:55 PDT 2025

Total time taken to generate the page: 0.71947 seconds