[Numpy-discussion] difference between ma.masked and ma.masked_array?

Scott Sinclair scott.sinclair.za@gmail....
Mon Nov 17 23:39:43 CST 2008


2008/11/17 Timmie <timmichelsen@gmx-topmail.de>:
> what is the difference between ma.masked and ma.masked_array?

I don't know the answer to that question, but both appear to be some
kind of alias for the MaskedArray class and not part of the API.

> I am using this expression along with the scikit.timeseries:
>
> series[(series.years>2000)&(series.years<2010)]=np.ma.masked
>
> => but now, my series does not get masked.
>
> Rather the selected values (left part of the '=') get set to 0.0.
>
> But if I use
>
> arr_masked = \
> ma.masked_array(series, series[(series.years>2000)&(series.years<2010)])
>
> the masked is applied sucessfully.

I think you should get the effect you want using masked_where

>>> import numpy.ma as ma
>>> masked_series = ma.masked_where((series.years>2000) & (series.years<2010), series)

There's some in progress documentation in the Numpy doc app at
http://docs.scipy.org/numpy/docs/numpy.ma.core.masked_where/ that
hasn't yet made it's way to the reference manual
http://docs.scipy.org/doc/numpy/reference/

Cheers,
Scott


More information about the Numpy-discussion mailing list