efficient way to get first index of first masked/non-masked value in a masked array

Dec. 1, 2006
2:07 p.m.
all I can come up with is dumb brute force methods by iterating through all the values. Anyone got any tricks I can use? Thanks, - Matt Knox

December 2006
2:13 p.m.
Matt Knox wrote:
all I can come up with is dumb brute force methods by iterating through all the values. Anyone got any tricks I can use?
import numpy as np def first_masked(m): idx = np.where(m.mask)[0] if len(idx) != 0: return idx[0] else: raise ValueError("no masked data") first_unmasked() is left as an exercise for the reader. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
6656
Age (days ago)
6656
Last active (days ago)
1 comments
2 participants
participants (2)
-
Matt Knox
-
Robert Kern