Given the following artificially generated data:
t_steps = 30 data = np.array([ np.arange(t_steps) * .05, np.arange(t_steps) * .1, np.arange(t_steps) * .2, np.arange(t_steps) * .3 ])
I find the time-step the each line of data has passed a threshold. If it does not pass the given threshold, I assign a time-step of
react_tms =  thresh = 3.5 for dat in data: whr = np.where(dat > thresh) if len(whr) == 0: react_tms.append(-1) else: react_tms.append(whr)
[-1, -1, 18, 12]
Is there some way to do this without the for-loop? Even before the for-loop is removed, should I be using something other than
np.where to find the threshold crossing?