numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
notmasked_contiguous(a, axis=None)

Notes

Only accepts 2-D arrays at most.

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, and this is the same as flatnotmasked_contiguous .

Returns

endpoints : list

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

If the input is 2d and axis is specified, the result is a list of lists.

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

See Also

clump_masked
clump_unmasked
flatnotmasked_contiguous
flatnotmasked_edges
notmasked_edges

Examples

>>> a = np.arange(12).reshape((3, 4))
... mask = np.zeros_like(a)
... mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0
... ma = np.ma.array(a, mask=mask)
... ma masked_array( data=[[0, --, 2, 3], [--, --, --, 7], [8, --, --, 11]], mask=[[False, True, False, False], [ True, True, True, False], [False, True, True, False]], fill_value=999999)
>>> np.array(ma[~ma.mask])
array([ 0,  2,  3,  7, 8, 11])
>>> np.ma.notmasked_contiguous(ma)
[slice(0, 1, None), slice(2, 4, None), slice(7, 9, None), slice(11, 12, None)]
>>> np.ma.notmasked_contiguous(ma, axis=0)
[[slice(0, 1, None), slice(2, 3, None)], [], [slice(0, 1, None)], [slice(0, 3, None)]]
>>> np.ma.notmasked_contiguous(ma, axis=1)
[[slice(0, 1, None), slice(2, 4, None)], [slice(3, 4, None)], [slice(0, 1, None), slice(3, 4, None)]]
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.ma.extras.clump_unmasked numpy.ma.extras.notmasked_edges numpy.ma.extras.flatnotmasked_contiguous numpy.ma.extras.clump_masked numpy.ma.extras.flatnotmasked_edges

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/ma/extras.py#1684
type: <class 'function'>
Commit: