ktk.TimeSeries.from_array#
- static TimeSeries.from_array(array, /, *, data_key='data', time=[], time_info={'Unit': 's'}, data_info={}, events=[])[source]#
Create a new TimeSeries from an array.
- Parameters
array (ArrayLike) – An array or list where the first dimension corresponds to time.
data_key (str) – Optional. The name of the data (used as the key in the TimeSeries’ data attribute). Default is “data”.
time (ArrayLike) – Optional. An array that indicates the time for each sample. Its length must match the first dimension of the data array. If None (default), a matching time attribute of with a period of one second is created.
time_info (dict[str, Any]) – Optional. Will be copied to the TimeSeries’ time_info attribute.
data_info (dict[str, dict[str, Any]]) – Optional. Will be copied to the TimeSeries’ data_info attribute.
events (list[kineticstoolkit.timeseries.TimeSeriesEvent]) – Optional. Will be copied to the TimeSeries’ events attribute.
- Returns
The new TimeSeries.
- Return type
See also
ktk.TimeSeries.to_array
,ktk.TimeSeries.from_dataframe
,ktk.TimeSeries.to_dataframe
Examples
Using default time
>>> ktk.TimeSeries([0.1, 0.2, 0.3, 0.4, 0.5]) TimeSeries with attributes: time: array([0., 1., 2., 3., 4.]) data: {'data': array([0.1, 0.2, 0.3, 0.4, 0.5])} time_info: {'Unit': 's'} data_info: {} events: []
Specifiying time
>>> ktk.TimeSeries([0.1, 0.2, 0.3, 0.4, 0.5], time=[0.1, 0.2, 0.3, 0.4, 0.5]) TimeSeries with attributes: time: array([0.1, 0.2, 0.3, 0.4, 0.5]) data: {'data': array([0.1, 0.2, 0.3, 0.4, 0.5])} time_info: {'Unit': 's'} data_info: {} events: []