The timesignal
module¶
-
class
pylife.stress.timesignal.
TimeSignalGenerator
(sample_rate, sine_set, gauss_set, log_gauss_set)[source]¶ Generates mixed time signals
The generated time signal is a mixture of random sets of
- sinus signals
- gauss signals (not yet)
- log gauss signals (not yet)
For each set the user supplys a dict describing the set:
sinus_set = { 'number': number of signals 'amplitude_median': 'amplitude_std_dev': 'frequency_median': 'frequency_std_dev': 'offset_median': 'offset_std_dev': }
The amplitudes (\(A\)), fequencies (\(\omega\)) and offsets (\(c\)) are then norm distributed. Each sinus signal looks like
\(s = A \sin(\omega t + \phi) + c\)where \(phi\) is a random value between 0 and \(2\pi\).
So the whole sinus \(S\) set is given by the following expression:
\(S = \sum^n_i A_i \sin(\omega_i t + \phi_i) + c_i\).-
query
(sample_num)[source]¶ Gets a sample chunk of the time signal
Parameters: sample_num (int) – number of the samples requested Returns: samples – the requested samples Return type: 1D numpy.ndarray You can query multiple times, the newly delivered samples will smoothly attach to the previously queried ones.
-
class
pylife.stress.timesignal.
TimeSignalPrep
(df)[source]¶ -
-
resample_acc
(sample_rate_new=1)[source]¶ Resampling the time series
Parameters: - self (DataFrame) –
- time_col (str) – column name of the time column
- sample_rate_new (float) – sample rate of the resampled time series
Returns: Return type: DataFrame
-
running_stats_filt
(col, window_length=2048, buffer_overlap=0.1, limit=0.05, method='rms')[source]¶ Calculates the running statistics of one DataFrame column and drops the rejected data points from the whole DataFrame.
Attention: Reset_index is used
Parameters: - self (DataFrame) –
- col (str) – column name of the signal for the runnings stats calculation
- window_length (int) – window length of the single time snippet, default is 2048
- buffer_overlap (float) – overlap parameter, 0.1 is equal to 10 % overlap of every buffer, default is 0.1
- limit (float) – limit value of skipping values, 0.05 for example skips all values which buffer method parameter is lower than 5% of the total max value, default is 0.05
- method (str) – method: ‘rms’, ‘min’, ‘max’, ‘abs’, default is ‘rms’
Returns: Return type: DataFrame
-