find_transitions¶
- sofia_redux.scan.chopper.chopper_numba_functions.find_transitions(x, y, threshold)[source]¶
Given (x, y) chopper positions, find the transitions and other parameters.
Given a chopper position in (x, y) coordinates, centered about (0, 0), return the index on (x, y) marking the
start
of the first transition, the index marking theend
of the last transition, the number oftransitions
, the calculatedangle
between the two chop positions, and thedistance
from the center while chopping.This algorithm assumes that there are two chopping positions present in the (x, y) data (on and off) that are relative to a central (0, 0) nominal chop position. A chop transition is marked when the absolute x or y position is greater than
tolerance
and of the opposite sign to the last detected chop transition. Once a transition has been detected in both the x and y directions, the distance will be calculated as:d = sqrt(x^2 + y^2)
for each subsequent (x, y) position. The returned angle is weighted by distance (d) from the center and is given by:
a = sum(d * arctan(s * y, s * x)) / sum(d)
where s is given by:
s = sign(y); x = 0 s = sign(x); otherwise
It is up to the user on how to best extract the chop amplitude from the data given the chop profile. For a standard box-step chop profile, a median on the distances should suffice, while more advanced analysis should be applied to other patterns.
- Parameters:
- xnumpy.ndarray (float)
The x-direction chopper position of shape (n,).
- ynumpy.ndarray (float)
The y-direction chopper position of shape (n,).
- thresholdfloat
The distance away from the center (x, y) = (0, 0) that would be considered representing a single chopper transition (chopper amplitude).
- Returns:
- start, end, transitions, angle, distanceint, int, int, float, np.ndarray