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)
| 2173 | |
| 2174 | |
| 2175 | def clump_masked(a): |
| 2176 | """ |
| 2177 | Returns a list of slices corresponding to the masked clumps of a 1-D array. |
| 2178 | (A "clump" is defined as a contiguous region of the array). |
| 2179 | |
| 2180 | Parameters |
| 2181 | ---------- |
| 2182 | a : ndarray |
| 2183 | A one-dimensional masked array. |
| 2184 | |
| 2185 | Returns |
| 2186 | ------- |
| 2187 | slices : list of slice |
| 2188 | The list of slices, one for each continuous region of masked elements |
| 2189 | in `a`. |
| 2190 | |
| 2191 | See Also |
| 2192 | -------- |
| 2193 | flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges |
| 2194 | notmasked_contiguous, clump_unmasked |
| 2195 | |
| 2196 | Examples |
| 2197 | -------- |
| 2198 | >>> import numpy as np |
| 2199 | >>> a = np.ma.masked_array(np.arange(10)) |
| 2200 | >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked |
| 2201 | >>> np.ma.clump_masked(a) |
| 2202 | [slice(0, 3, None), slice(6, 7, None), slice(8, 10, None)] |
| 2203 | |
| 2204 | """ |
| 2205 | mask = ma.getmask(a) |
| 2206 | if mask is nomask: |
| 2207 | return [] |
| 2208 | return _ezclump(mask) |
| 2209 | |
| 2210 | |
| 2211 | ############################################################################### |
searching dependent graphs…