numpy.ma.flatnotmasked_edges

numpy.ma.flatnotmasked_edges(a)
Find the indices of the first and last not masked values in a 1D masked array. If all values are masked, returns None.