compute_angular_velocity#
- movement.kinematics.compute_angular_velocity(data, window=None, in_degrees=False)[source]#
Compute the angular velocity of a 2D orientation.
The orientation is given as 2D vectors, e.g. the output of
compute_forward_vector().- Parameters:
data (
DataArray) – The input orientation vectors, containingtimeandspaceas dimensions.spacemust have exactly the coordinates["x", "y"]. The vectors need not be of unit length.window (
int|None) – IfNone(default), the angular velocity is computed with central differences (one-sided at the first and last observations). Otherwise, the size of the centred rolling window, representing the fixed number of observations to which a least-squares line is fitted; the angular velocity is its slope. Must be an odd integer greater than 1, and requires a uniformly sampledtimecoordinate.in_degrees (
bool) – IfFalse(default), the output is in radians per unit of time. IfTrue, it is in degrees per unit of time.
- Returns:
The angular velocity, with the dimensions of the input, without
space. The unit of time is that of thetimecoordinate (seconds or frames).- Return type:
See also
compute_angular_time_derivativeThe underlying function used.
compute_angular_accelerationThe second time-derivative of orientation.
Examples
>>> from movement.kinematics import ( ... compute_angular_velocity, ... compute_forward_vector, ... ) >>> head_vector = compute_forward_vector( ... ds.position, "left_ear", "right_ear" ... )
Central-difference angular head velocity:
>>> ahv = compute_angular_velocity(head_vector)
Least-squares estimate over the 7 observations centred on each time point, in degrees per unit of time:
>>> ahv = compute_angular_velocity(head_vector, window=7, in_degrees=True)
Shift the above estimate by half a window to get a trailing estimate, using only the 7 observations up to and including each time point, in radians per unit of time:
>>> ahv_trailing = compute_angular_velocity(head_vector, window=7).shift( ... time=7 // 2 ... )