def window(i, abs_time, low, high):
    """
    get offsets from the current index i in abs_time that are in the relative
    time window defined by low and high.

    :param int i: current abs_time index.
    :param ndarray abs_time: absolute times.
    :param low: low end of relative window.
    :param high: high end of relative window.
    :return: (low_o, high_o) coincident times are abs_time[low_o:i+high_o]
    """

    length = len(abs_time)
    low_o = 0  # low index offset
    high_o = 0  # high index offset
    now = abs_time[i]
    low_t = now + low
    high_t = now + high

    if low_t < now:
        while (i + low_o >= 0) and abs_time[i + low_o] >= low_t: low_o -= 1;
    else:
        while (low_o + i < length) and abs_time[i + low_o] < low_t: low_o += 1;

    if high_t < now:
        while (i + high_o >= 0) and abs_time[i + high_o] > high_t:
            high_o -= 1
    else:
        while (high_o + i < length) and abs_time[i + high_o] <= high_t:
            high_o += 1
    return low_o, high_o