How does one quality mask remove whole observation rows?
compress uses a one-dimensional condition to select slices along an axis and preserves their input order.
numpy.compress in practice
When rows one and three pass inspection, each retained row still has both channels. A short condition can truncate selection, so check its length against the axis.
import numpy as np
np.compress([True,False,True], [[2,3],[4,5],[6,7]], axis=0)Result [[2, 3], [6, 7]]
中文
如何让同一个质量掩码筛掉整行测量?
compress 使用一维真假条件选择指定轴上的切片,保留命中项的原始顺序。
numpy.compress 算例
三行测量的第一和第三行合格,筛选后两行仍各含两个通道。较短的条件可能截断检查范围,先核对掩码长度。
import numpy as np
np.compress([True,False,True], [[2,3],[4,5],[6,7]], axis=0)结果 [[2, 3], [6, 7]]