def njit_time_point_thresh(wf_in, threshold, tp_max, tp_out):
    """
    Find the last timepoint before tp_max that wf_in crosses a threshold
     wf_in: input waveform
     threshold: threshold to search for
     tp_max: time of a maximum of a waveform that the search starts at
     tp_out: final time that waveform is less than threshold
    """
    for i in range(tp_max, 0, -1):
        if(wf_in[i]>threshold and wf_in[i-1]<threshold):
            tp_out = i
            return tp_out
    tp_out = 0
    return tp_out