signal = numpy.array([1, 2, 3, 4, 4, 3, 2, 1, 0, 3, 2, 1, 0, 0, 1, 1, 4, 8,
    7, 6, 5, 0])
thresholded_data = signal > threshold
threshold_edges = numpy.convolve([1, -1], thresholded_data, mode='same')
thresholded_edge_indices = numpy.where(threshold_edges == 1)[0]
print(thresholded_edge_indices)
Finding first samples greater than a threshold value efficiently in Python (and MATLAB comparison)