numpy.ma.notmasked_contiguous

numpy.ma.notmasked_contiguous(a, axis=None)[source]

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.

See also

flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges, clump_masked, clump_unmasked

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, 4, None), slice(6, 7, None)]

Previous topic

numpy.ma.flatnotmasked_edges

Next topic

numpy.ma.notmasked_edges

This Page