[SciPy-user] iteratively masking timeseries

Pierre GM pgmdevlist at gmail.com
Fri Jun 13 19:23:46 EDT 2008


On Thursday 12 June 2008 17:14:03 Tim Michelsen wrote:
> Does that mean that one can only mask an array once and cannot mask more
> values later on?

No no, the message
> IndexError: Masked arrays must be filled before they can be used as
> indices!

doesn't mean you can't mask arrays more than once, just that you can't use a 
MaskedArray as index in a TimeSeries without having to fill it first. The 
reason for this behavior is that we can't tell beforehand how you want to 
deal with your masked values: should a masked value be considered True ? 
False ?

So, when you want to do something like:
> mask[mask<0] = numpy.ma.masked

just do:

mask[(mask<0).filled(True)] = numpy.ma.masked

That way, you're masking the values of mask that are negative, and keep the 
masked values as masked.




More information about the SciPy-User mailing list