iracema.core.timeseries¶
This module contains the implementation of the class TimeSeries.
- 
class iracema.core.timeseries.TimeSeries(fs, data=None, start_time=None, unit=None, caption=None)[source]¶
- Bases: - object- Class for storing and manipulating time series objects, which model synchronous discrete time series. - Hint - This class is also available at the main package level as - iracema.TimeSeries.- Variables
- data (numpy array) – Data array sampled at - fsHz.
- time (numpy array) – Numpy data array containing the time of each sample, relative to the original time reference. 
- fs (Decimal) – Sampling frequency for the data. 
- nyquist (Decimal) – Nyquist frequency for the data. 
- ts (Decimal) – Sampling period for the data. 
- start_time (Decimal) – The time the time series start (in seconds) relative to the original time reference. 
- duration (Decimal) – Duration of the time series (in seconds). 
- end_time (Decimal) – The time the time series end (in seconds) relative to the original time reference. 
- unit (str) – String containing the name of the unit for the data (for plotting). 
- nsamples (int) – Number of samples per time series in the data array. 
- nfeatures – Number of features for each sample in the data array. 
- unit – Unit for the data (for plotting). 
- caption – Text caption. 
- label – Label for the time series. 
 
- Parameters
- fs (Decimal) – Sampling frequency for the data. 
- data (numpy array, optional) – Data array sampled at - fsHz. If this argument is not provided, the method _write_data() must be called after the initialization to set the data array.
- start_time (float, optional) – The time in seconds the time series start, relative to the original time reference. 
- unit (str, optional) – Unit name for plotting the data of the time series. 
- caption (str, optional) – Text caption for the time series. 
 
 - 
label= ''¶
 - 
unit= ''¶
 - 
caption= ''¶
 - 
property nsamples¶
 - 
property nfeatures¶
 - 
property duration¶
 - 
property nyquist¶
 - 
property end_time¶
 - 
property ts¶
 - 
property time¶
 - 
sliding_window(window_size, hop_size, function=None, window_name=None)[source]¶
- Use a sliding window to aggregate the data from the time series by applying - functionto each analysis window. The content of each window will be passed as the first argument to the function. Return the aggregated data in an array.- Parameters
- window_size (int) – Size of the window. 
- hop_size (int) – Number of samples to be skipped between two successive windowing operations. 
- function (function) – Function to be applied to each window. If no function is specified, each window will contain an unaltered excerpt of the time series. 
- window_name (str) – Name of the window function to be used. Options are: {“boxcar”, “triang”, “blackman”, “hamming”, “hann”, “bartlett”, “flattop”, “parzen”, “bohman”, “blackmanharris”, “nuttall”, “barthann”, “no_window”, None}. 
 
 
 - 
pad(pre, post, value=0.0)[source]¶
- Pad the edges of the time series. - Parameters
- pre (int) – Pre-padding length. 
- post (int) – Post-padding length. 
- value (float or str) – Value for the padding operation. If a float number is provided, this value will be used in the padding. If instead the string ‘repeat’ is provided, the values at the edges will be repeated in the padding operation. 
 
 
 - 
pad_like(timeseries, value=0.0)[source]¶
- Pad the end of the current time series to match the length of the given time series. 
 - 
resample_and_pad_like(timeseries, value=0.0)[source]¶
- Resample and pad the end of the current time series to match the given time series. 
 - 
merge(timeseries, unit=None, caption=None, start_time=None)[source]¶
- Merge two time series. Both time series must have the same length and sampling frequency. The attributes - unit,- captionand- start_timeof the resulting time series can be optionally set using the method’s optional arguments. Otherwise these attributes will be equal to the values in the instance on which the method was called (- self).
 - 
filter(critical_frequency, filter_type='low_pass', filter_order=4)[source]¶
- Filters the time series using a butterworth digital filter. This is a wrapper over - scipy.signal.butter.- Parameters
- critical_frequency (float) – The critical frequency of frequencies. 
- filter_type ([‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandstop’]) – The type of filter. 
- filter_order – The order of the filter. 
 
 
 - 
time_to_sample_index(time)[source]¶
- Convert time (in seconds) to the correspoding sample index in the time series.