{ } Raw JSON

bundles / scipy 1.17.1 / scipy / signal / _spectral_py / check_COLA

function

scipy.signal._spectral_py:check_COLA

source: /scipy/signal/_spectral_py.py :1158

Signature

def   check_COLA ( window nperseg noverlap tol = 1e-10 )

Summary

Check whether the Constant OverLap Add (COLA) constraint is met (legacy function).

Parameters

window : str or tuple or array_like

Desired window to use. If window is a string or tuple, it is passed to get_window to generate the window values, which are DFT-even by default. See get_window for a list of windows and required parameters. If window is array_like it will be used directly as the window and its length must be nperseg.

nperseg : int

Length of each segment.

noverlap : int

Number of points to overlap between segments.

tol : float, optional

The allowed variance of a bin's weighted sum from the median bin sum.

Returns

verdict : bool

True if chosen combination satisfies COLA within tol, False otherwise

Notes

In order to invert a short-time Fourier transfrom (STFT) with the so-called "overlap-add method", the signal windowing must obey the constraint of "Constant OverLap Add" (COLA). This ensures that every point in the input data is equally weighted, thereby avoiding aliasing and allowing full reconstruction. Note that the algorithms implemented in ShortTimeFFT.istft and in istft (legacy) only require that the weaker "nonzero overlap-add" condition (as in check_NOLA) is met.

Some examples of windows that satisfy COLA:

  • Rectangular window at overlap of 0, 1/2, 2/3, 3/4, ...

  • Bartlett window at overlap of 1/2, 3/4, 5/6, ...

  • Hann window at 1/2, 2/3, 3/4, ...

  • Any Blackman family window at 2/3 overlap

  • Any window with noverlap = nperseg-1

A very comprehensive list of other windows may be found in [2], wherein the COLA condition is satisfied when the "Amplitude Flatness" is unity.

Array API Standard Support

check_COLA is not in-scope for support of Python Array API Standard compatible backends other than NumPy.

See dev-arrayapi for more information.

Examples

from scipy import signal
Confirm COLA condition for rectangular window of 75% (3/4) overlap:
signal.check_COLA(signal.windows.boxcar(100), 100, 75)
COLA is not true for 25% (1/4) overlap, though:
signal.check_COLA(signal.windows.boxcar(100), 100, 25)
"Symmetrical" Hann window (for filter design) is not COLA:
signal.check_COLA(signal.windows.hann(120, sym=True), 120, 60)
"Periodic" or "DFT-even" Hann window (for FFT analysis) is COLA for overlap of 1/2, 2/3, 3/4, etc.:
signal.check_COLA(signal.windows.hann(120, sym=False), 120, 60)
signal.check_COLA(signal.windows.hann(120, sym=False), 120, 80)
signal.check_COLA(signal.windows.hann(120, sym=False), 120, 90)

See also

ShortTimeFFT

Provide short-time Fourier transform and its inverse

check_NOLA

Check whether the Nonzero Overlap Add (NOLA) constraint is met

closest_STFT_dual_window

Allows determining the closest window meeting the COLA constraint for a given window

istft

Inverse Short-time Fourier transform (legacy)

stft

Short-time Fourier transform (legacy)

Aliases

  • scipy.signal.check_COLA