find_nearest module

Functions to find a value and/or index in a array

DMT.extraction.find_nearest.find_nearest(value, array)[source]

Find the index of the value in array nearest to value, and also the corresponding value in the array. Copied From : https://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array

Parameters:
valuefloat, np.array[1]

The value for which the index in the array is to be determined.

array[], np.array()

The array for which the index of value shall be determined.

Returns:
[value, i_value][np.float, Index]

The index and value in array that are closest to “value”.

DMT.extraction.find_nearest.find_nearest_index(value, array)[source]

Find the index of the value in array nearest to value. Copied From : https://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array

Parameters:
valuefloat, np.array[1]

The value for which the index in the array is to be determined.

array[], np.array()

The array for which the index of value shall be determined.

Returns:
i_valueIndex

The index that corresponds to the closest value to “value” in array.