nearestindex¶
- emlib.numpytools.nearestindex(a, grid, left=True, right=True)[source]¶
For each value in a return the index into grid nearest to it
To get the nearest element, do:
indexes = nearest_index(a, grid) nearest_elements = grid[indexes]
- Parameters:
a (
ndarray
) – events to match from. Does not need to be sortedgrid (
ndarray
) – events to match against. Does not need to be sortedleft – match events lower than the event from
right – match events higher than the event from
- Return type:
ndarray