Class phasespace

Import strymmap as:

from strym import phasespace

for reading and analysing GPS csv files gathered with comma.ai Black or Grey Panda.

class strym.phasespace(dfx, dfy, resample_type='first', **kwargs)

phasespace provides an interface for phase-space analysis, plots phase space diagram and performs other analysis

df

Data for phase-space. There are three columns to the dataframe: “Time”, “X”, “Y”.

Type

pandas.DataFrame

centroidxy

Two-element tuple (C_x,C_y) that is centroid of the cluster given by df.

Type

tuple

distance

Numpy array to save distance of all points from the cluster’s centroid.

Type

numpy.array

acd

Average Centroid Distance of a cluster.

Type

float

Parameters
dfx : pandas.DataFrame

First timeseries dataframe for x-axis on phase-space diagram. First column should be “Time” and second column should be “Message”

dfy : pandas.DataFrame

Second timeseries dataframe for x-axis on phase-space diagram. First column should be “Time” and second column should be “Message”

resample_type : str, double

Specify how to resampling should be done in case dfx and dfy don’t have same sampling rate.

str: resample_type can either be “first” or “second, if specified as string. If rate=”first”, then dfy will be resampled by inheriting time points from dfx. If rate=”first”, then dfx will be resampled by inheriting time points from dfy.

double: Alternatively, user can specify desired sampling rate with which dfx and dfy will be resampled.

If dfx and dfy do not have same end and start time, then they will be truncated to match start and end time.

kwargs : variable list of argument in the dictionary format

static AWCSS(X, Y)

Calculates the average distance of phase-space cluster specified by X and Y Vectors from its centroid

Parameters
X : pandas.core.series.Series

X-coordinate on phase-space

Y : pandas.core.series.Series

Y-coordinate on phase-space

Returns

float – Average within the cluster distance from centroid

static centroid(X, Y)

Calculates the centroid of a phase-space cluster specified by X and Y Vectors

Parameters
X : pandas.core.series.Series

X-coordinate on phase-space

Y : pandas.core.series.Series

Y-coordinate on phase-space

Returns

float, float – Centroid of the phase space cluster specified by X and Y Vectors

centroidplot(title='Density of cluster distance from its centroid', xlabel='Centroid Distance', ylabel='Counts', **kwargs)

cetroidplot visualizes the distribution of distance of each point in the cluster from its centroid.

Parameters
title : str, default=”Density of cluster distance from its centroid”

Specifes title of the centroidplot

cluster()

cluster calculates centroid of the cluster, and distance of all points from the centroid and stores as a distance vector.

phaseplot(title='Phase-space plot', xlabel='Timeseries 1', ylabel='Timeseries 2', plot_each=False, **kwargs)

phasepolot creates phase-space diagram with temporal informatiom embedded as colormap.

Parameters
title : str, default=”Phase-space plot”

Specifes title of the phase-space diagram

Returns

ax – Axes object of the plot drawn