Using Python 2.7, I have an array of values that goes from ~0.000 to ~360.000 multiple times. I am trying to return all array indices with values closest to 147.010 (even duplicate values), so I can use each of these indices later on. For example, a smaller sample from one array is:
array([ 146.749, 147.249, 147.749, 146.749, 147.249, 147.749, 146.749, 147.263, 147.749, 146.472, 147.469, 148.471])
I am looking for an array, or list, of indices closest to 147.01, in this case would be:
1, 4, 7, 10
I have tried this:
min(range(len(array)), key=lambda i: abs(array[i]-some_value))
but this only returns one index, when multiple indices are needed. I looked but have not found a similar question or answer. Thank you for any help.