def index_nearest ( value , array ) : a = ( array - value ) ** 2 return index ( a . min ( ) , a )
python nearest value in array
expects a _n . array returns the global minimum of ( value - array ) ^2
def index_nearest(value, array):
    """
    expects a _n.array
    returns the global minimum of (value-array)^2
    """

    a = (array-value)**2
    return index(a.min(), a)