[Numpy-discussion] how to combine (stack) two masked arrays?

Pierre GM pgmdevlist@gmail....
Thu Mar 1 16:28:21 CST 2007

The simplest is:

But for this particular kind of operation, I don't think that you need masked 
array at all: this could do the trick
>>>rescaled = clipped.copy()
>>>inside = numpy.logical_and(clipped>=123, clipped<=354)
>>>outside = numpy.logical_not(inside)
>>>newrescaled[inside] = 5*clipped[inside]
>>>newrescaled[outside] = clipped[outside]

A side note: when using numpy.core.ma, it's more efficient to deal w/ the 
_data and _mask parts separately than at once.

You may want to try an alternative implementation of maskedarray, available in 
the sandbox of the scipy SVN. I'd be very happy to have your feedback

Let me know if this helps

More information about the Numpy-discussion mailing list