tsa
Averaging of a time-synchronous signal.
| Library |
|
Syntax
Function call
-
ta,t,p,rpm = tsa(x,fs,tp)— returns the time-synchronous average value of the signalx, sampled with frequencyfs, by the pulses specified in the input argumenttp, as well as the vector of sampling periodst, corresponding tota, vector of phase valuespand a constant rotation speedrpm, measured in rpm, corresponding tota.
-
ta,t,p,rpm = tsa(___,Name=Value)— sets additional parameters for any of the previous syntax options using arguments like «name-value». For example, you can specify the number of tachometer pulses per revolution of the shaft, or choose to average the signal in the time or frequency domain.
-
tsa(___;out=:plot)— plots a time-synchronous averaged signal and time domain signals corresponding to each signal segment on the current graph.
Arguments
Input arguments
# x — input signal
+
vector
Details
The input signal is set as a vector.
| Типы данных |
|
#
fs —
sampling
rate
scalar
Details
The sampling rate, set as a positive scalar.
| Типы данных |
|
# tp — pulse time
+
scalar | vector
Details
Pulse time, set as a scalar or vector:
-
scalar— a constant time interval during which rotations occur; -
vector— non-negative, strictly increasing moments of time that determine the constant phase of rotation.
Use the function tachorpm to extract the sampling periods of the tachometer pulses from the tachometer signal.
| Типы данных |
|
Input arguments «name-value»
Specify optional argument pairs as Name=Value, where Name — the name of the argument, and Value — the appropriate value. Type arguments «name-value» they should be placed after the other arguments, but the order of the pairs does not matter. You can specify multiple pairs «name-value».
Example: ta = tsa(x, Method = "pchip", ResampleFactor = 10) indicates that the signal should be upsampled in 10 once and averaged in the time domain using piecewise cubic Hermite interpolation.
# Method — averaging algorithm
+
"linear" (by default) | "spline" | "pchip" | "fft"
Details
An interpolation scheme defined by one of the following values:
-
"linear"— performing linear interpolation and averaging in the time domain; -
"spline"— performing cubic spline interpolation and time domain averaging; -
"pchip"— performing piecewise cubic Hermite interpolation and time domain averaging; -
"fft"— performing averaging in the frequency domain.
# PulsesPerRotation — the number of time points per revolution of the shaft
+
1 (by default) | scalar
Details
The number of time points per revolution of the shaft, set as a positive scalar.
| Типы данных |
|
# ResampleFactor — the coefficient by which the sampling rate increases
+
1 (by default) | scalar
Details
The coefficient by which the sampling rate increases, set as a positive integer.
| Типы данных |
|
# out — type of output data
+
:data (by default) | :plot
Details
Type of output data:
-
:data— the function returns data; -
:plot— the function returns a graph.
Examples
Synchronous time averaging of a sine wave
Details
Let’s calculate the time-synchronous averaging of a noisy sine wave.
We will generate a signal consisting of a sine wave immersed in white Gaussian noise. The signal is sampled at a frequency 500 Hz during 20 seconds. Specify the frequency of the sine wave 10 Hz and noise dispersion 0.01. Let’s plot one period of the signal.
fs = 500
t = 0:1/fs:20-1/fs
f0 = 10
y = sin.(2π * f0 * t) + randn(length(t)) / 10
plot(t, y, xlims=(0, 1/f0))
Let’s calculate the time-synchronous averaging of the signal. As a synchronizing signal, we use a set of pulses with the same period as the sinusoid. In the function tsa setting for the argument out meaning :plot to display the result.
import EngeeDSP.Functions: tsa
tPulse = 0:1/f0:maximum(t)
tsa(y, fs, tPulse, out = :plot)
Algorithms
With the specified input signal, sampling frequency, and set of tachometer pulses, the function tsa performs the following steps:
-
Determines the start and end time of the cycle based on the tachometer pulses and the value specified for the argument
PulsesPerRotation. -
Resamples the input signal based on the value specified for the argument
ResampleFactor. -
Averages the oversampled signal based on the value specified for the argument
Method.-
If for an argument
Methodthe value is set"fft", function:-
Splits the signal into segments corresponding to different cycles.
-
Calculates the discrete Fourier transform of each segment.
-
Truncates longer transformations so that all transformations have the same length.
-
Averages the spectra.
-
Calculates the inverse discrete Fourier transform of the average value to convert it to the time domain.
-
-
If for an argument
Methodone of the time domain methods is defined, the function:-
Using this method, it interpolates the signal onto a grid of evenly distributed samples corresponding to different cycles.
-
Combines the signal segments obtained by oversampling based on the value specified for the argument
NumRotations. -
Calculates the average value of all segments.
-
-