def get_closest_index(i1, i2, T, t0):
    """ Returns the index i such that abs(T[i]-t0) is minimum for i1,i2 """
    if abs(T[i1] - t0) <= abs(T[i2] - t0):
        return i1
    else:
        return i2
