[Numpy-discussion] Masked Array Usage Problems
Sat Apr 10 02:49:03 CDT 2010
I am trying out masked arrays for the first time and having some
problems. I have a 2-D image as dtype=numpy.int16
I create a mask of all False to not mask out any pixels.
I calculate the mean of the image original image and it comes out ~597.
I calculate the mean of the masked array and it comes out differently
around -179. It produces the same negative mean value no matter what
masks I try, e.g. (all True, all False, etc). Furthermore there are no
negative samples in the entire array.
Any ideas on what am I doing wrong?
Here is some sample code showing the behavior:
In : img.dtype, img.shape
Out: (dtype('int16'), (3200, 3456))
In : mask = numpy.zeros(img.shape, dtype=bool)
In : imgma = ma.masked_array(img, mask)
In : img.mean()
In : imgma.mean()
In : imgma.min()
In : numpy.__version__
In : numpy.ma.__version__
More information about the NumPy-Discussion