[英]get the data and the masked values as 0?
I have a masked array. 我有一个蒙版数组。 I can get back the data via array.data, but this does not filter the data trough the mask.
我可以通过array.data取回数据,但这不会通过掩码过滤数据。
How can I can get the data, but in the place where there is mask to get zero. 我如何获取数据,但是在有遮罩获取零的位置。
Here is what I got so far : 这是到目前为止我得到的:
ary.data * (~ary.mask).astype(byte)
use numpy.ma.filled()
: 使用
numpy.ma.filled()
:
import numpy as np
m = np.ma.masked_greater(np.random.rand(10), 0.5)
print np.ma.filled(m, 0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.