numpy.ma.flatnotmasked_contiguous

numpy.ma.flatnotmasked_contiguous(a)

Find contiguous unmasked data in a masked array along the given axis.

Parameters:

a : narray

The input array.

Returns:

slice_list : list

A sorted sequence of slices (start index, end index).

Notes

Only accepts 2-D arrays at most.

Examples

>>> a = np.arange(10)
>>> mask = (a < 3) | (a > 8) | (a == 5)
>>> ma = np.ma.array(a, mask=mask)
>>> np.array(ma[~ma.mask])
array([3, 4, 6, 7, 8])
>>> np.ma.extras.flatnotmasked_contiguous(ma)
[slice(3, 4, None), slice(6, 8, None)]
>>> ma = np.ma.array(a, mask=np.ones_like(a))
>>> print np.ma.extras.flatnotmasked_edges(ma)
None

Previous topic

numpy.ma.masked_array.mask

Next topic

numpy.ma.flatnotmasked_edges

This Page