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

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


Hello,
The simplest is:
rescaled[rescaled.mask]=clipped_mask[rescaled.mask]

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.

<pushing_product> 
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
</pushing_product>

Let me know if this helps
P.


More information about the Numpy-discussion mailing list