snap_array¶
- emlib.misc.snap_array(X, tick, offset=0.0, out=None, nearest=True)[source]¶
Snap the values of X to the nearest slot in a grid
Assuming a grid t defined by
t(n) = offset + tick*n
, snap the values of X to the nearest value of tNB: tick > 0
- Parameters:
X (
ndarray
) – an arraytick (
float
) – the step value of the gridoffset (
float
) – the offset of the gridout (
Optional
[ndarray
]) – if given, snapped values are placed in this arraynearest – if True, the nearest slot is selected. Otherwise the next lower (floor)
- Return type:
ndarray
- Returns:
an array containing the snapped values. This array will be out if it was given