find_idx_nearest_val

halotools.utils.find_idx_nearest_val(array, value)[source]

Method returns the index where the input array is closest to the input value.

Parameters:
arrayarray_like
valuefloat or int
Returns:
idx_nearestint

Notes

Use of this function is deprecated. The numpy.argmin function provides equivalent behavior.

Examples

>>> x = np.linspace(0, 1000, num=int(1e5))
>>> val = 45.5
>>> idx_nearest_val = find_idx_nearest_val(x, val)
>>> nearest_val = x[idx_nearest_val]