find_closest_index#
- PySeismoSoil.helper_generic.find_closest_index(array: ndarray, value: float) tuple[int | None, float | None] [source]#
Find the index in
array
corresponding to the value closest to the givenvalue
.- Parameters:
array (np.ndarray) – A 1D numpy array. It does not need to be sorted, because this function has an O(n) time complexity.
value (float) – The value to search for.
- Returns:
index (int | None) – The index whose value is closest to the given
value
.closest_value (float | None) – The value in
array
that is closest to the givenvalue
.
- Raises:
TypeError – When
value
is not a single number