[Numpy-discussion] averaging array, with fill values

Evan Mason evanmason@gmail....
Fri Feb 9 16:22:41 CST 2007

Hi, I want to get the mean over an array with 3 dimensions.  The array
has, say, dimensions 2x3x4 and I want the result to be 3x4; so the
averaging is to be done over the 1st dimension.  Also, there are some
fill values, and I want these to be excluded from the calculation.  I
know I can use the ma module to locate the fill values, but after that
I am unsure how to exclude them, and how to do the averaging.

In [150]: x = rand(2,3,4)

In [151]: x[0,2,1]=999 # fill value

In [152]: x[1,2,3]=999

In [153]: x[0,1,3]=999

In [154]: x
array([[[  3.01880915e-02,   5.77085271e-02,   7.59176038e-01,
       [  5.48643693e-01,   3.84995126e-01 ,   5.01683678e-01,
       [  5.72779004e-01,   9.99000000e+02,   4.18143934e-01,

      [[  8.90443158e-01,   3.76986788e-01,   8.81270409e-01,
       [  8.12944573e-01,   3.89858156e-01,   5.99219891e-01,
       [  2.31215256e-01,   5.93222883e-01,   2.45004093e-01,

In [155]:

Thanks in advance for any help.  -Evan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070209/5a3f4836/attachment.html 

More information about the Numpy-discussion mailing list