Timeseries#
- class peccary.timeseries.Timeseries(t, x=None, y=None, z=None, data=None, dt=None)[source]#
Bases:
objectThe
Timeseriesclass is a flexible class used to store data and timesteps for a simulation.The only required parameter is the timesteps parameter,
t. If nodtis inputted in the class initialization, the timestep resolutiondtwill be calculated from the inputted timesteps array.The other parameter are
x,y,z, anddata. The first three are intended to be used for systems with one, two, or three dimensions and can consist of multidimensional arrays for scenarios where the inputted arrays contain data on multiple particles (e.g.,examples.doublePendulum). The shapes of these arrays should be (particles, timesteps).The
dataparameter requires a 1D array and is intended to be the catch-all input for datasets that do not fall under the other parameters.Examples
Suppose we have a random, 1D array of white noise that we’d like to store. Since an array of random noise does not have a particular timescale, we can approximate it by using the index numbers as the “timesteps”. For example:
>>> from peccary.timeseries import Timeseries >>> import numpy as np >>> data = np.random.random(1000) >>> times = np.arange(len(data)) >>> tser = Timeseries(t=times, x=data) >>> ### OR ### >>> tser = Timeseries(t=times, x=data)
Let’s now try making a