You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / ma / extras / flatnotmasked_edges

function

numpy.ma.extras:flatnotmasked_edges

source: /numpy/ma/extras.py :1869

Signature

def   flatnotmasked_edges ( a )

Summary

Find the indices of the first and last unmasked values.

Extended Summary

Expects a 1-D MaskedArray, returns None if all values are masked.

Parameters

a : array_like

Input 1-D MaskedArray

Returns

edges : ndarray or None

The indices of first and last non-masked value in the array. Returns None if all values are masked.

Notes

Only accepts 1-D arrays.

Examples

import numpy as np
a = np.ma.arange(10)
np.ma.flatnotmasked_edges(a)
mask = (a < 3) | (a > 8) | (a == 5)
a[mask] = np.ma.masked
np.array(a[~a.mask])
np.ma.flatnotmasked_edges(a)
a[:] = np.ma.masked
print(np.ma.flatnotmasked_edges(a))

See also

clump_masked
clump_unmasked
flatnotmasked_contiguous
notmasked_contiguous
notmasked_edges

Aliases

  • numpy.ma.flatnotmasked_edges