numpy.ma.notmasked_contiguous

numpy.ma.notmasked_contiguous(a, axis=None)

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

Parameters :

a : array_like

The input array.

axis : int, optional

Axis along which to perform the operation. If None (default), applies to a flattened version of the array.

Returns :

endpoints : list

A list of slices (start and end indexes) of unmasked indexes in the array.

Notes

Only accepts 2-D arrays at most.

Examples

>>> a = np.arange(9).reshape((3, 3))
>>> mask = np.zeros_like(a)
>>> mask[1:, 1:] = 1
>>> ma = np.ma.array(a, mask=mask)
>>> np.array(ma[~ma.mask])
array([0, 1, 2, 3, 6])
>>> np.ma.extras.notmasked_contiguous(ma)
[slice(0, 3, None), slice(6, 6, None)]

Previous topic

numpy.ma.flatnotmasked_edges

Next topic

numpy.ma.notmasked_edges

This Page