Returns a list of slices corresponding to the masked clumps of a 1-D array. (A "clump" is defined as a contiguous region of the array). Parameters ---------- a : ndarray A one-dimensional masked array. Returns ------- slices : list of slice The list
(a)
| 2039 | |
| 2040 | |
| 2041 | def clump_masked(a): |
| 2042 | """ |
| 2043 | Returns a list of slices corresponding to the masked clumps of a 1-D array. |
| 2044 | (A "clump" is defined as a contiguous region of the array). |
| 2045 | |
| 2046 | Parameters |
| 2047 | ---------- |
| 2048 | a : ndarray |
| 2049 | A one-dimensional masked array. |
| 2050 | |
| 2051 | Returns |
| 2052 | ------- |
| 2053 | slices : list of slice |
| 2054 | The list of slices, one for each continuous region of masked elements |
| 2055 | in `a`. |
| 2056 | |
| 2057 | Notes |
| 2058 | ----- |
| 2059 | .. versionadded:: 1.4.0 |
| 2060 | |
| 2061 | See Also |
| 2062 | -------- |
| 2063 | flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges |
| 2064 | notmasked_contiguous, clump_unmasked |
| 2065 | |
| 2066 | Examples |
| 2067 | -------- |
| 2068 | >>> a = np.ma.masked_array(np.arange(10)) |
| 2069 | >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked |
| 2070 | >>> np.ma.clump_masked(a) |
| 2071 | [slice(0, 3, None), slice(6, 7, None), slice(8, 10, None)] |
| 2072 | |
| 2073 | """ |
| 2074 | mask = ma.getmask(a) |
| 2075 | if mask is nomask: |
| 2076 | return [] |
| 2077 | return _ezclump(mask) |
| 2078 | |
| 2079 | |
| 2080 | ############################################################################### |