Return list of slices corresponding to the unmasked 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)
| 2137 | |
| 2138 | |
| 2139 | def clump_unmasked(a): |
| 2140 | """ |
| 2141 | Return list of slices corresponding to the unmasked clumps of a 1-D array. |
| 2142 | (A "clump" is defined as a contiguous region of the array). |
| 2143 | |
| 2144 | Parameters |
| 2145 | ---------- |
| 2146 | a : ndarray |
| 2147 | A one-dimensional masked array. |
| 2148 | |
| 2149 | Returns |
| 2150 | ------- |
| 2151 | slices : list of slice |
| 2152 | The list of slices, one for each continuous region of unmasked |
| 2153 | elements in `a`. |
| 2154 | |
| 2155 | See Also |
| 2156 | -------- |
| 2157 | flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges |
| 2158 | notmasked_contiguous, clump_masked |
| 2159 | |
| 2160 | Examples |
| 2161 | -------- |
| 2162 | >>> import numpy as np |
| 2163 | >>> a = np.ma.masked_array(np.arange(10)) |
| 2164 | >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked |
| 2165 | >>> np.ma.clump_unmasked(a) |
| 2166 | [slice(3, 6, None), slice(7, 8, None)] |
| 2167 | |
| 2168 | """ |
| 2169 | mask = getattr(a, '_mask', nomask) |
| 2170 | if mask is nomask: |
| 2171 | return [slice(0, a.size)] |
| 2172 | return _ezclump(~mask) |
| 2173 | |
| 2174 | |
| 2175 | def clump_masked(a): |
searching dependent graphs…