Suppose I have a 1D array A,
A = [0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.51, 1.52, 1.6, 2, 3, 4, 5, 6, 7, 8, 9, 10]
and I have a value a = 1.5 and I need to find the smallest index of the entry where the value would fit in the array. In this case it should be 5.
import numpy as np
A = np.array([0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.51, 1.52, 1.6, 2, 3, 4, 5, 6, 7, 8, 9, 10])
a = 1.5
print A[np.where(A >= a >= A)]
I know this would not work but can np.where find such indexes?
Aalways sorted?