def _close_to(values, v_ref):
    """
        returns the index of the value which is close to the v_ref.
    """
    ind = 0
    good=values[ind]
    for i, vv in enumerate(values):
        if abs(vv - v_ref) < good:
            good = vv
            ind = i

    return ind