A robot vibration report may compare a filtered accelerometer channel with a motion command to see when a response begins. A timing offset estimated from one low-frequency test can be a poor fit for a higher-frequency test on the same channel. Measure the filter's group delay over the frequencies relevant to the report before shifting the trace by a single amount.

Group delay describes the timing of a narrow band of signal energy through a linear filter. SciPy computes it from the negative slope of the filter's unwrapped phase. The result is in samples even when the frequency input is in hertz. A constant delay over the useful band supports applying one time shift. A delay that changes substantially across that band can alter the shape of a broadband event.

Compare two filters at the same frequencies

The example uses an 800 Hz sample rate, a symmetric three-tap FIR filter, and a first-order IIR low-pass filter. Pass the same frequency array and sample rate to group_delay and freqz so the delay readings can be matched to the gain at each point.

import numpy as np

from scipy import signal

fs = 800.0

hz = np.array([0.0, 50.0, 200.0])

fir_b, fir_a = [0.25, 0.5, 0.25], [1.0]

iir_b, iir_a = [0.25], [1.0, -0.75]

_, fir_delay = signal.group_delay((fir_b, fir_a), w=hz, fs=fs)

_, iir_delay = signal.group_delay((iir_b, iir_a), w=hz, fs=fs)

_, response = signal.freqz(iir_b, iir_a, worN=hz, fs=fs)

assert np.allclose(fir_delay, 1.0)

assert np.allclose(iir_delay[[0, 2]], [3.0, -0.36])

assert np.allclose(np.abs(response[[0, 2]]), [1.0, 0.2])

At 0, 50, and 200 Hz, the FIR reports one sample of delay, equivalent to 1.25 milliseconds. The IIR reports approximately 3.00, 0.74, and -0.36 samples respectively. At 50 Hz its delay is about 0.92 milliseconds, while its gain is about 0.59. At 200 Hz the gain has dropped to 0.20, so the delay reading there describes a strongly attenuated component. The negative value is a local property of the phase curve and does not indicate that the causal filter observed future samples.

Write down the band used for alignment

Record the sample rate, filter coefficients, and signal band used to estimate the timing correction. Evaluate a frequency grid across the band and compare the spread in delay with the timing tolerance for the test. Keep gain beside the delay report. At a frequency where the response has a unit-circle zero or pole, SciPy can warn and return zero for undefined group delay. Treat that point as undefined when reviewing the report.

For a time-domain cross-check, replay a narrow-band test burst at a representative frequency and compare the envelopes using aligned raw and filtered records. A filter response calculation describes the filter itself. Delays caused by acquisition, buffering, and transport need separate measurements if the report compares different devices.

Sources

SciPy group_delay reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.group_delay.html

SciPy freqz reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html