floodlight.models.kinematics
- class floodlight.models.kinematics.AccelerationModel[source]
Computations for velocities of all players.
Upon calling the
fit()
-method, this model calculates the frame-wise acceleration for each player. The calculation can subsequently be queried by calling the corresponding method:Frame-wise acceleration –>
acceleration()
Notes
For input data in metrical units, the output equals the input unit. Differences between frames can be calculated with two different methods:
Central difference method (recommended) allows for differenciation without temporal shift:
\[y^{\prime}(t_{0}) = \frac{y_{1}-y_{-1}}{t_{1} - t_{-1}}\]The first and last frame are padded with linear extrapolation.
Backward difference method calculates the difference between each consecutive frame:
\[y^{\prime}(t_{0}) = \frac{y_{0}-y_{-1}}{t_{0} - t_{-1}}\]The first frame is padded prepending a ‘0’ at the beginning of the array along axis=1.
Examples
>>> import numpy as np >>> from floodlight import XY >>> from floodlight.models.kinematics import AccelerationModel
>>> xy = XY(np.array(((0, 0), (0, 1), (1, 1), (2, 2))), framerate=20)
>>> am = AccelerationModel() >>> am.fit(xy)
>>> am.acceleration() PlayerProperty(property=array([[-117.15728753], [ 23.60679775], [ 141.42135624], [ 118.47182945]]), name='acceleration', framerate=20)
- acceleration()[source]
Returns the frame-wise acceleration as computed by the fit method.
- Returns
acceleration – A PlayerProperty object of shape (T, N), where T is the total number of frames and N is the number of players. The columns contain the frame-wise acceleration.
- Return type
- fit(xy, difference='central', axis=None)[source]
Fits a model calculating accelerations of each player to an XY object.
- Parameters
xy (XY) – Floodlight XY Data object.
difference ({‘central’, ‘backward’}, optional) – The method of differentiation. ‘central’ will differentiate using the central difference method, ‘backward’ will differentiate using the backward difference method as described in the Notes.
axis ({None, ‘x’, ‘y’}, optional) – Optional argument that restricts distance calculation to either the x- or y-dimension of the data. If set to None (default), distances are calculated in both dimensions.
- class floodlight.models.kinematics.DistanceModel[source]
Computations for Euclidean distances of all players.
Upon calling the
fit()
-method, this model calculates the frame-wise Euclidean distance for each player. The following calculations can subsequently be queried by calling the corresponding methods:Frame-wise Distance Covered –>
distance_covered()
Cumulative Distance Covered –>
cumulative_distance_covered()
Notes
For input data in metrical units, the output equals the input unit. Differences between frames can be calculated with two different methods:
Central difference method (recommended) allows for differenciation without temporal shift:
\[y^{\prime}(t_{0}) = \frac{y_{1}-y_{-1}}{t_{1} - t_{-1}}\]The first and last frame are padded with linear extrapolation.
Backward difference method calculates the difference between each consecutive frame:
\[y^{\prime}(t_{0}) = \frac{y_{0}-y_{-1}}{t_{0} - t_{-1}}\]The first frame is padded prepending a ‘0’ at the beginning of the array along axis=1.
Examples
>>> import numpy as np >>> from floodlight import XY >>> from floodlight.models.kinematics import DistanceModel
>>> xy = XY(np.array(((0, 0), (0, 1), (1, 1), (2, 2))))
>>> dm = DistanceModel() >>> dm.fit(xy)
>>> dm.distance_covered() PlayerProperty(property=array([[1. ], [0.70710678], [1.11803399], [1.41421356]]), name='distance_covered'0) >>> dm.cumulative_distance_covered() PlayerProperty(property=array([[1. ], [0.70710678], [1.11803399], [1.41421356]]), name='distance_covered')
- cumulative_distance_covered()[source]
Returns the cumulative distance covered.
- Returns
cumulative_distance_euclidean – A PlayerProperty object of shape (T, N), where T is the total number of frames and N is the number of players. The columns contain the cumulative Euclidean distance covered calculated by numpy.nancumsum() over axis=0.
- Return type
- distance_covered()[source]
Returns the frame-wise distance covered as computed by the fit method.
- Returns
distance_euclidean – A PlayerProperty object of shape (T, N), where T is the total number of frames and N is the number of players. The columns contain the frame-wise Euclidean distance covered.
- Return type
- fit(xy, difference='central', axis=None)[source]
Fits a model calculating Euclidean distances of each player to an XY object.
- Parameters
xy (XY) – Floodlight XY Data object.
difference ({‘central’, ‘backward’}, optional) – The method of differentiation. ‘central’ will differentiate using the central difference method, ‘backward’ will differentiate using the backward difference method as described in the Notes.
axis ({None, ‘x’, ‘y’}, optional) – Optional argument that restricts distance calculation to either the x- or y-dimension of the data. If set to None (default), distances are calculated in both dimensions.
- class floodlight.models.kinematics.VelocityModel[source]
Computations for velocities of all players.
Upon calling the
fit()
-method, this model calculates the frame-wise velocity for each player. The calculation can subsequently be queried by calling the corresponding method:Frame-wise velocity –>
velocity()
Notes
For input data in metrical units, the output equals the input unit. Differences between frames can be calculated with two different methods:
Central difference method (recommended) allows for differenciation without temporal shift:
\[y^{\prime}(t_{0}) = \frac{y_{1}-y_{-1}}{t_{1} - t_{-1}}\]The first and last frame are padded with linear extrapolation.
Backward difference method calculates the difference between each consecutive frame:
\[y^{\prime}(t_{0}) = \frac{y_{0}-y_{-1}}{t_{0} - t_{-1}}\]The first frame is padded prepending a ‘0’ at the beginning of the array along axis=1.
Examples
>>> import numpy as np >>> from floodlight import XY >>> from floodlight.models.kinematics import VelocityModel
>>> xy = XY(np.array(((0, 0), (0, 1), (1, 1), (2, 2))), framerate=20)
>>> vm = VelocityModel() >>> vm.fit(xy)
>>> vm.velocity() PlayerProperty(property=array([[20. ], [14.14213562], [22.36067977], [28.28427125]]), name='velocity', framerate=20)
- fit(xy, difference='central', axis=None)[source]
Fits a model calculating velocities of each player to an XY object.
- Parameters
xy (XY) – Floodlight XY Data object.
difference ({‘central’, ‘backward’}, optional) – The method of differentiation. ‘central’ will differentiate using the central difference method, ‘backward’ will differentiate using the backward difference method as described in the Notes.
axis ({None, ‘x’, ‘y’}, optional) – Optional argument that restricts distance calculation to either the x- or y-dimension of the data. If set to None (default), distances are calculated in both dimensions.