Skip to content

Instantly share code, notes, and snippets.

@endolith
Last active October 7, 2021 23:23
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endolith/c5b39ab78f1910e99cadaced9b839fc1 to your computer and use it in GitHub Desktop.
Save endolith/c5b39ab78f1910e99cadaced9b839fc1 to your computer and use it in GitHub Desktop.
Window function constant overlap-add conditions (COLA)

Fractions of overlap that result in COLA condition for all SciPy windows:

  • barthann: 1/2, 3/4, 5/6, 7/8, 9/10, 11/12, 13/14, ...
  • bartlett: 1/2, 3/4, 5/6, 7/8, 9/10, 11/12, 13/14, ...
  • blackman: 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • blackmanharris: 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • bohman:
  • boxcar: 0, 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • chebwin:
  • cosine:
  • exponential:
  • flattop: 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • gaussian:
  • general_gaussian:
  • hamming: 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • hann: 1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • kaiser:
  • nuttall: 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, ...
  • parzen: 3/4, 7/8, 11/12, 15/16, 19/20, 23/24, ...
  • slepian:
  • triang: 1/2, 3/4, 5/6, 7/8, 9/10, 11/12, ...
  • tukey: 3/4, 5/6, 7/8, 9/10, 11/12, 13/14, ...

See also "AF" graphs in https://holometer.fnal.gov/GH_FFT.pdf

from __future__ import division, print_function, absolute_import
import numpy as np
import scipy
from spectral import check_COLA # https://github.com/scipy/scipy/pull/6058
windows = np.unique(scipy.signal.windows._win_equiv.values())
windows = sorted(windows, key=lambda x: x.__name__)
for window in windows:
try:
print(window.__name__, end=': ')
for num in range(10):
if check_COLA(window(1000*(num+1), sym=False),
1000*(num+1), 1000*num):
print('{}/{}'.format(num, num+1), end=', ')
print()
except:
print()
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment