TemporalData¶
- class TemporalData(temporal_data, variables, times, true_times)[source]¶
Class representing any sort of temporal data for a specified list of variables
Since teneto’s TemporalNetwork class requires all times to start at zero, we again have the concept of ‘true’ times as well as times offset to start at zero.
- Parameters
temporal_data (ndarray) – 2D array whose columns are the variables we’re interested in and whose rows are the temporal data for these variables
variables (list of str) – List (not a numpy array) of variable names
times (ndarray) – 1D array based on true_times but with values shifted to start at zero
true_times ndarray – 1D array of time points
- downsample(skip)[source]¶
Return a downsampled copy of the TemporalData object, by skipping ever ‘skip’ elements
- classmethod from_df(df, times, true_times, i_tend=None)[source]¶
Create a TemporalData from a DataFrame with variables as columns and timepoints as rows
- classmethod from_dict(dict_, times, true_times, i_tend=None)[source]¶
Create a TemporalData from a dict with variables as keys and time series as values
- plot_relative_optima(variable, optima_type, ax=None, use_true_times=True, plot_var=True)[source]¶
Plot relative optima for a prticular variable
- Parameters
variable (str) – The name of the variable whose optima we want to plot
optima_type ({‘minima’, ‘maxima’})
ax (matplotlib.Axes, optional) – Axes on which to plot
use_true_times (bool, optional) – Whether to use the ‘actual’ times or offset the times so that they start at zero
- Returns
- Return type
None
- plot_series(variables=None, ax=None, norm=False, add_labels=True, labels_xvals=None, use_true_times=True)[source]¶
Plot particular variables’ values over time
- Parameters
variables (list of str) – Names of the variable whose values we want to plot
ax (matplotlib.Axes, optional) – Axes on which to plot
norm (bool, optional) – Whether or not to normalise the time series by dividing through by the max (default False)
add_labels (bool, optional) – Whether to label the variables when plotting (default True)
labels_xvals (list of float, optional) – The positions along the x-axis at which to place the variables’ labels (if using). If set to None (default), labels will be placed at regular intervals along x-axis.
use_true_times (bool, optional) – Whether to use the ‘actual’ times or offset the times so that they start at zero (default True)
- Returns
- Return type
None
- relative_optima(variable, optima_type)[source]¶
Get relative optima for a particular variable
- Parameters
variable (str) – Name of the variable whose optima we want
optima_type ({‘minima’, ‘maxima’}) – Type of optima to look for
- Returns
optima (list_like) – Value of the variable at its optima
optima_times (list_like) – Times at which these optima occur
- save_to_csv(filepath, index=False)[source]¶
Save temporal data to .csv file, with variables as rows and time points as columns