def window(ind, abs_time, low, high):
    """
    Find coincident events in the given window.

    Get offsets from the current index ind in abs_time that are in the
    relative time window defined by low and high.

    Parameters
    ----------
    ind : int
        Current index for abs_time.

    abs_time : ndarray
        Absolute times.

    low : float
        Starting point of the relative window.

    high : float
        Ending point of the relative window.

    Returns
    -------
    (low_index, high_index) : tuple
        coincident times are abs_time[low_index:ind+high_index]
    """
    length = len(abs_time)
    now = abs_time[ind]
    low_index = 0  # low index offset
    high_index = 0  # high index offset

    low_t = now + low
    high_t = now + high

    if low_t < now:
        # before and: guarantees the index will be always >= 0
        # after and:
        while (ind + low_index >= 0) and abs_time[ind + low_index] >= low_t:
            low_index -= 1

    else:
        # 1term: guarantees the index will never exceed array length
        # 2term: check if the absolute_time[index + low_index] is
        # smaller than low_t
        # if it is, low_index is increased by one
        # if it is not, finish while loop and low_index is returned
        # this low index will be the last index for abs_time where
        # it is still smaller than low_t
        while (low_index + ind < length) and abs_time[ind + low_index] < low_t:
            low_index += 1

    if high_t < now:
        while (ind + high_index >= 0) and abs_time[ind + high_index] > high_t:
            high_index -= 1

    else:
        # 1term: guarantees the index will never exceed array length
        # 2term: check if the absolute_time[index + high_index]
        # is smaller than high_t
        # if it is, high_index is increased by one
        # if it is not, finish while loop and high_index is returned
        # this high index will be the last index for abs_time where
        # it is still smaller than _t
        while ((high_index + ind < length) and
               abs_time[ind + high_index] <= high_t):
            high_index += 1
    # offset indexes marking abs_times in the window
    return low_index, high_index