ma.
notmasked_edges
沿轴查找第一个和最后一个未屏蔽值的索引。
如果所有值都被屏蔽,则返回“无”。否则,返回两个元组的列表,分别对应于第一个和最后一个未屏蔽值的索引。
输入数组。
执行操作的轴。如果没有(默认),则应用于数组的扁平版本。
如果数组中有任何屏蔽数据,则为开始索引和结束索引的数组。如果数组中没有屏蔽数据, edges 是第一个和最后一个索引的列表。
参见
flatnotmasked_contiguous
flatnotmasked_edges
notmasked_contiguous
clump_masked
clump_unmasked
实例
>>> a = np.arange(9).reshape((3, 3)) >>> m = np.zeros_like(a) >>> m[1:, 1:] = 1
>>> am = np.ma.array(a, mask=m) >>> np.array(am[~am.mask]) array([0, 1, 2, 3, 6])
>>> np.ma.notmasked_edges(am) array([0, 6])