Is there a numpy-thonic way, e.g. function, to find the nearest value in an array?
Example:
np.find_nearest( array, value )
If you don't want to use numpy this will do it:
def find_nearest(array, value): n = [abs(i-value) for i in array] idx = n.index(min(n)) return array[idx]