aidapy.aidaxr.statistics module¶
AIDA module responsible for the statistical utilities of the timeseries
- class aidapy.aidaxr.statistics.AidaAccessorStatistics(xarray_obj)[source]¶
Bases:
object
Xarray accessor responsible for the statistical utilities
- autocorr(lagbeg=0, stride=1, dt=1, timeu='s', normalize=True)[source]¶
Calculates the autocorrelation of the xarray per column.
- Parameters
lagbeg (int) – Default = 0. Initial lag.
stride (int) – Default = 1. Stride of the window to autocorrelate.
dt (int) – Default = 1. Sampling frequeny of the signal.
timeu (str) – Default = ‘s’. Time unit of the signal.
normalize (bool) – Default = True. Normalizes the autocorrelation
- Returns
values – An xarray containing the values of the autocorrelation, where the index is the lag and the units are the same as the input vector
- Return type
- mean(**kwargs)[source]¶
Calculates the mean of on xarray DataArray
- Parameters
coord (int) – The keyword is the coordinate of the xarray on which the mean will be calculated. The value given is the size of the sliding window.
center (bool) – If true the resulting value will be placed in the middle index of the window, otherwise it will be placed in the last index of the window.
- Returns
values – An xarray containing the values of the mean in the requested coordinate.
- Return type
- psd(timeu='s', **kwargs)[source]¶
Calculates the power spectral density using the signal.welch routine from scipy
- Parameters
timeu (str) – Sampling unit of the signal. Default is ‘s’
**kwargs – arguments used by the signal.welch method of scipy
- Returns
values – An xarray containing the values of the PSD, were the index is the frequency and the units are in Hz
- Return type
- psdwt(*args)[source]¶
Returns the wavelet transform of a timeseries
- Parameters
*args – Arguments used in scipy.signal.cwt
- Returns
values – An xarray containing the wavelet transform of the original timeseries. The signal has to be one dimensional. The name of the first dimension is used as first dimension in the resulting xarray.
- Return type
- sfunc(scale=[1], order=2)[source]¶
Returns the structure function of a timeseries
\[y= \frac{1}{N-s}\sum_{i=1}^{N-s}(x_i - x_{i+s})^o\]where \(s\) is the scale, and \(o\) is the order.
- Parameters
scale (list or numpy.array) – A list or an array containing the scales to calculate.
order (int) – Order of the exponential of the structure function.
- Returns
values – An xarray containing the structure functions, one per product in the original timeseries. The index coordinate contains the scale value, and the attribute ‘order’ keeps a record on the order used for its calculation.
- Return type
- std(**kwargs)[source]¶
Calculates the standar deviation of on xarray DataArray
- Parameters
coord (int) – The keyword is the coordinate of the xarray on which the std will be calculated. The value given is the size of the sliding window.
center (bool) – If true the resulting value will be placed in the middle index of the window, otherwise it will be placed in the last index of the window.
- Returns
values – An xarray containing the values of the std in the requested coordinate.
- Return type