webbpsf_ext.maths.find_closest

webbpsf_ext.maths.find_closest(A, B)[source]

Find closest indices

Given two arrays, A and B, find the indices in B whose values are closest to those in A. Returns an array with size equal to A.

This is much much faster than something like, especially for large arrays:

np.argmin(np.abs(A - B[:, np.newaxis]), axis=0)