You can use np.searchsorted
with side='right
to find the index of the last item in time
that is smaller than your new timings, and then use it to fetch values from the ev
array:
>>> np.take(ev, np.searchsorted(time, t1, side='right')-1)
array([ 0, 0, 14, 14, 23, 53, 3])
If you first convert ev
to a numpy array, fancy indecing may be more readable:
>>> ev = np.array(ev)
>>> idx = np.searchsorted(time, t1, side='right')-1
>>> ev[idx]
array([ 0, 0, 14, 14, 23, 53, 3])