Suppose I have a variable arr
that stores multiple 3D arrays.
arr = [[[1,2,3],
[4,5,6],
[10,11,12]]]
[[[13,14,15],
[16,17,18],
[19,20,21]]]
How can I get the nearest values to the corresponding given values in variable vals
from the arr
. The nearest value for the first value in vals
should be searched only in 1st array of the arr
and similarly second one in the second array
vals = np.array([3.2, 6.8])
The expected outcome:
nearest values = [3, 13]