获取数据和掩码值为0



我有一个遮罩数组。我可以通过数组返回数据。数据,但不通过掩码过滤数据。

我怎么能得到数据,但在有掩码的地方得到零。


这是我到目前为止得到的:

 ary.data * (~ary.mask).astype(byte)

use numpy.ma.filled():

import numpy as np
m = np.ma.masked_greater(np.random.rand(10), 0.5)
print np.ma.filled(m, 0)

最新更新