FLOCK.PACS
index
c:\users\james\gitrepos\gps-ruck\flock\pacs.py

Path Adapted Coordinate System transformation functions

 
Modules
       
math
numpy
pandas
matplotlib.pyplot
random
seaborn

 
Functions
       
PACS_transform(datasets, UTM=True)
Transforming group location data into a path-adapted coordinate system
 
Using the spline-smoothed trajectory path of the group, 
we get the distance of the individual to the group's spline path (left or right) as the X coordinate
we then find the distance along the spline path from the location of the groups center to the individual's location as the new Y coordinate
 
Developed by Dr. Eric Miller and James McIntyre for CABCS at Tufts University
 
Args:
    datasets (list): list of dataset dfs to re-orient
    UTM (bool, optional): True if UTM data, False if raw GPS. Defaults to True.
 
Returns:
    oriented_datasets (list): list of PACS oriented datasets in dfs
dp2s(t, sx, sy, x0, y0)
Define the distance from point to spline
 
Args:
    t (float): timepoint (normalized to 1 for spline)
    sx (scipy.UnivariateSpline object): spline of x
    sy (scipy.UnivariateSpline object): spline of y
    x0 (float): x coordinate
    y0 (float): y coordinate
 
Returns:
    d (float): distance from point
    g (float): gradient at point on spline
force_converge(t0, args4d)
Force the minimization function used to converge on the nearest spline point
iterate 100x before incrreasing (doubling) the tolerance
 
Args:
    t0 (int): initial guess
    args4d (list): packaged parameters for the distance calculation [x spline, y spline, x coord, y coord]
 
Returns:
    rac (scipy.optimize._optimize.OptimizeResult object) : result of converged minimization problem
plot_sample_PACS_figure(smooth_movements, ruck_slices_oriented, random=True, time_length=200)
Plot a sample image for the PACS transformation
 
Args:
    smooth_movements (list of DataFrames): list of smoothed movement period dataframes (not oriented)
    ruck_slices_oriented (list of DataFrames): list of PACS oriented movement period dataframes
    random (bool, optional): If True, choose a random movement period and random timepoint, otherwise use specified example timepoint. Defaults to True.
    time_length (int, optional): length of time for the PACS to plot as a 2D histogram. Defaults to 200.
 
Returns:
    None: None
rotate(x, y, radians)
rotates a point around the origin counterclockwise
 
Args:
    x (float): original coordinate 
    y (float): original coordinate 
    radians (_type_): radians to be rotated
 
Returns:
    tuple (float, float): rotated X and Y coordinates