[Numpy-discussion] Setting element to masked in a masked array previously containing no masked values
Pierre GM
pgmdevlist at gmail.com
Mon Jun 25 09:37:15 EDT 2007
On Monday 25 June 2007 05:12:01 Jesper Larsen wrote:
> Hi numpy users,
>
> I have a masked array. I am looping over the elements of this array and
> sometimes want to set a value to missing. Normally this can be done by:
>
> myarray.mask[i] = True
Mmh. Experience shows that directly accessing the mask can lead to bad
surprises. To mask a series of values in an array, the easiest (and
recommended method) is
myarray[i] = masked
where 'i' can be whatever object used for indexing (an integer, a sequence, a
slice...).
> Does anyone by the way have any pointers to documentation of the masked
> array features of numpy? I know that it is treated in the numarray manual
> but it seems like there are some important syntax differences that make
> this manual of little use in that regard.
I can't really point you to any documentation. The differences of syntax
should be minimal. We could however start a wiki page.
A side issue is the kind of implementation of masked arrays you want. There
are currently two, one directly accessible through numpy.core.ma, another
available in the sandbox of the scipy svn site, as maskedarray. This latter
considers MaskedArray as a subclass of ndarray, which makes it easier to
define subclasses. Moreover, it gives access to soft/hard masks, masked
records, more stats functions, and thanks to Eric Firing, can be used
directly with matplotlib... I'd be quite happy if you could give it a try and
send me your feedback.
More information about the NumPy-Discussion
mailing list