signals.synchronous_average
Time synchronous averaging (TSA) of a periodic waveform in noise.
Time domain averaging extracts a repetitive signal of known period T
from additive noise by ensemble-averaging successive length-T blocks,
following P. D. McFadden, “A revised model for the extraction of periodic
waveforms by time domain averaging”, Mechanical Systems and Signal
Processing 1(1) 1987, 83-95. Given a signal
with x periodic in T and e
asynchronous, the average
reinforces every component synchronous with T and suppresses the rest.
Two models, one implementation. McFadden distinguishes the existing comb-filter model from the revised model. In the frequency domain the average is the multiplication of by the comb filter (Eq. 8)
whose magnitude
is a Dirichlet
kernel: unity at every harmonic (the teeth, Eq. 9, of unit
height regardless of N) and zero at the nodes with
j not a
multiple of N. That model assumes knowledge of y over infinite time
and produces a result that is not exactly periodic. McFadden’s revised
model applies a rectangular window of width T in the time domain and
samples the transform in the frequency domain, so it needs only a finite
block of the signal and yields a result that is exactly periodic and can be
stored as a single period. The digital block average computed here, N
consecutive periods of an integer number of samples reduced to one period,
is that revised model: the returned period_waveform, repeated,
is exactly periodic.
Noise reduction. Asynchronous noise of variance
averaged over N periods has residual variance :
the residual standard deviation falls as and the
amplitude signal-to-noise ratio improves by (a power
reduction of dB, reported as
noise_reduction).
Choosing N (McFadden’s revised-model correction). Because a discrete
interfering tone at a non-harmonic order is only
attenuated, not removed, its rejection is optimised by choosing N so
that a comb node lands exactly on it, i.e. the smallest N with
an integer.
McFadden’s own example, a tone at 32.05 orders, is suppressed by more
than 100 dB with (since )
yet (evaluating Eq. 8
at that order) by only about 14 dB with the common power-of-two choice
(; the paper makes the
comparison but does
not print this figure). Thus the habit of taking a power-of-two number of
averages is not, in general, optimal.
Non-integer samples per period. When is not an integer
the period boundaries fall between samples. Each block is then aligned to
a common integer grid by the band-limited fractional delay of
phonometry.signals.fractional_delay before averaging, so
the periodic waveform is recovered within the interpolation error of that
band-limited shift. An integer needs no interpolation and
the waveform is recovered to machine precision. The averaged samples stay
on the sampling grid throughout: output sample m is the
average of the input at the times , so the returned
time axis is and the
samples cover one period exactly
when is an integer and to within half a sample otherwise.
No resampling onto an M-point angular grid is performed.
Auto-generated from the source docstrings by
scripts/generate_api_docs.py(make api-docs). Do not edit by hand.
comb_filter_response
Section titled “comb_filter_response”comb_filter_response( frequencies: float | np.floating[Any] | np.integer[Any], period_s: float, n_averages: int | np.integer[Any],) -> float
comb_filter_response( frequencies: Sequence[float] | Sequence[np.floating[Any]] | Sequence[np.integer[Any]] | NDArray[np.bool_ | np.integer[Any] | np.floating[Any]], period_s: float, n_averages: int | np.integer[Any],) -> NDArray[np.float64]
comb_filter_response( frequencies: NumericArrayLike, period_s: float, n_averages: int | np.integer[Any],) -> float | NDArray[np.float64]Magnitude of the N-period synchronous-averaging comb filter.
The closed form of McFadden Eq. 8,
,
a Dirichlet kernel with unit-height teeth at the
harmonics (Eq. 9) and nodes at for j
not a multiple of N.
Parameters
| Name | Description |
|---|---|
frequencies |
Frequencies at which to evaluate, in Hz. |
period_s |
Repetition period T, in seconds. |
n_averages |
Number of averaged periods N (at least 1). |
Returns: The filter magnitude at each frequency (unitless; bounded by 1, though floating-point cancellation immediately beside a tooth can return values above 1 by a few parts in 1e9). A float for a number, an array for a sequence or an array, a zero-dimensional one included.
Raises
| Exception | When |
|---|---|
| ValueError | If the parameters are invalid. |
| TypeError | if n_averages is a flag, a text or an array where a count goes, or frequencies holds a text or a value that is not a real number. |
SynchronousAverageResult
Section titled “SynchronousAverageResult”SynchronousAverageResult( period_waveform: Signal | NDArray[np.float64], times: NDArray[np.float64], residual: NDArray[np.float64], n_averages: int, samples_per_period: int, period_s: float, fs: float, *, noise_reduction: float, residual_rms: float, comb_frequencies: NDArray[np.float64], comb_response: NDArray[np.float64],)Time synchronous average of a periodic waveform in noise.
Attributes
| Name | Description |
|---|---|
period_waveform |
The averaged periodic waveform, one period of samples_per_period samples on the input’s sampling grid, in the type the input arrived as: a Signal when it was one (in pascals and carrying calibration_factor=1.0 when it was calibrated), a bare array otherwise. |
times |
Time axis of period_waveform, in seconds: the sampling grid , (the averaged samples stay on the grid; see the module note). The axis spans one period exactly when is an integer, and to within half a sample otherwise. |
residual |
Input minus the periodic reconstruction, over the analysed span (n_averages * samples_per_period samples, aligned to the integer period grid): what is left after the synchronous component is removed. Always a bare array: when fs * T is not an integer each period is shifted onto the grid before the blocks are joined, so the joined record is not one uniformly sampled recording and a Signal would claim that it is. |
n_averages |
Number of periods averaged, N. |
samples_per_period |
Integer samples per period M after any alignment. |
period_s |
Repetition period T, in seconds. |
fs |
Sample rate, in Hz. |
noise_reduction |
Power reduction of asynchronous noise, dB (amplitude SNR gain ). |
residual_rms |
Root-mean-square of residual. |
comb_frequencies |
Frequency axis of the comb-filter response, in Hz (from DC over a whole number of harmonics of 1/T). |
comb_response |
Magnitude of the comb filter (McFadden Eq. 8) on comb_frequencies. |
Whether the periods were aligned by a fractional delay
(interpolated) is read from fs and period_s, so
it is not a field.
SynchronousAverageResult.amplitude_snr_gain
Section titled “SynchronousAverageResult.amplitude_snr_gain”property
Amplitude signal-to-noise improvement .
SynchronousAverageResult.interpolated
Section titled “SynchronousAverageResult.interpolated”property
Whether band-limited fractional-delay alignment was applied.
True when is not an integer, to within
of a sample, so the period starts between samples and
each block is shifted onto the grid before it is averaged. Read from
fs and period_s.
SynchronousAverageResult.plot()
Section titled “SynchronousAverageResult.plot()”SynchronousAverageResult.plot( ax: None = None, *, language: Literal['en', 'es'] = 'en', **kwargs: Any,) -> tuple[Axes, Axes]
SynchronousAverageResult.plot( ax: Axes, *, language: Literal['en', 'es'] = 'en', **kwargs: Any,) -> AxesPlot the averaged waveform and the comb-filter magnitude.
With ax given, only the averaged-waveform panel is drawn on it.
Parameters
| Name | Description |
|---|---|
language |
Label language, "en" (default) or "es". |
time_synchronous_average
Section titled “time_synchronous_average”time_synchronous_average( x: Signal | NumericArrayLike, fs: float | None = None, *, period_s: float, n_averages: int | np.integer[Any] | None = None, n_harmonics: int | np.integer[Any] = 8,) -> SynchronousAverageResultExtract a periodic waveform of known period by time domain averaging.
Ensemble-averages N successive periods of the record (McFadden
Eq. 5) to reinforce the component synchronous with period_s and
suppress asynchronous noise, whose residual standard deviation falls as
. When fs * period is an integer the periods are
sliced
directly and a noiseless periodic signal is recovered exactly; otherwise
each period is aligned to a common integer grid by the band-limited
fractional delay of fractional_delay
and recovered within that interpolation error.
Parameters
| Name | Description |
|---|---|
x |
Signal, 1-D, containing the periodic component plus noise. Accepts a phonometry.io.Signal, whose calibration is applied to the samples, so the period waveform, the residual and its RMS come out in Pa, and the period waveform comes back as a Signal. The noise reduction in dB is a ratio and does not move. |
fs |
Sample rate, in Hz. Required for a bare array; a Signal brings its own, and an explicit value that disagrees with it raises instead of silently winning. |
period_s |
Known repetition period T, in seconds (e.g. one revolution of a rotating machine). |
n_averages |
Number of whole periods to average (default: as many as the record holds). Choosing N so that is an integer places a comb node on an interfering tone at order q and maximises its rejection (McFadden’s revised-model result). |
n_harmonics |
Number of harmonics of 1/T spanned by the returned comb-filter response (default 8). |
Returns: A SynchronousAverageResult.
Raises
| Exception | When |
|---|---|
| ValueError | If the inputs or parameters are invalid. |
| TypeError | if n_averages or n_harmonics is a flag, a text or an array where a count goes. |