2 arrays, average, missing data [message #45418] |
Thu, 08 September 2005 07:18 |
kimberlite
Messages: 3 Registered: January 2005
|
Junior Member |
|
|
HI All,
IDL newbie here, I would appreciate any help. (Have been pouring over
Gumley and Fanning books for a day now, can't get this simple
calculation done.)
I have 2 arrays. Each array has float values and missing
data(value=0). I want to create a third array that has the average of
the two arrays if there are two good values. Otherwise, I want the
third array to take the value of the array that has data.
If my arrays are A and B, and the new array C, I know I can use:
C = (A+B)/2
to get the third array with averaged values. The only problem, is
that missing data values are averaged in with good values also. (ie:
275 averaged w/ 0 -- when I want to just take the 275 value).
Have tried If statements, -- but I realize these are all for scalar
values, not array.
My basic idea is:
If A = 0, C = B
If B = 0, C = A
If A and B EQ 0, C = 0
If A and B NE 0, C = (A+B)/2
Any help appreciated!
Thanks.
|
|
|