import matplotlib.pyplot as plt
import scipy.signal as sig
%matplotlib inline
n_points = 1025
window = sig.barthann(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Bartlett-Hann')
window = sig.bartlett(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Bartlett')
window = sig.blackman(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Blackman')
window = sig.blackmanharris(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Blackman-Harris')
window = sig.bohman(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Bohman')
(from the docs: included for correctness, equivalent to no window at all.)
window = sig.boxcar(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Boxcar')
window = sig.chebwin(n_points, at=100)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Dolph-Chebyshev (attenutation 100 dB)')
window = sig.cosine(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Cosine')
window = sig.flattop(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Flat Top')
window = sig.gaussian(n_points, std=130)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Gaussian ($\sigma$=130)')
window = sig.general_gaussian(n_points, sig=150, p=1.5)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Generalized Gaussian ($\sigma$=150, $p=1.5$)')
window = sig.hamming(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Hamming')
window = sig.hann(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Hann')
window = sig.kaiser(n_points, beta=14)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Kaiser (beta=14)')
window = sig.nuttall(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Nuttall')
window = sig.parzen(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Parzen')
window = sig.slepian(n_points, width=0.02)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('DPSS (width=0.002)')
window = sig.triang(n_points)
plt.figure(figsize=(12, 8))
plt.plot(window)
plt.xlim([0, n_points])
plt.title('Triangular')
arg_map = {
'barthann': [sig.barthann, dict(M=n_points)],
'bartlett': [sig.bartlett, dict(M=n_points)],
'blackman': [sig.blackman, dict(M=n_points)],
'blackmanharris': [sig.blackmanharris, dict(M=n_points)],
'bohman': [sig.bohman, dict(M=n_points)],
'boxcar': [sig.boxcar, dict(M=n_points)],
'chebwin': [sig.chebwin, dict(M=n_points, at=100)],
'cosine': [sig.cosine, dict(M=n_points)],
'flattop': [sig.flattop, dict(M=n_points)],
'gaussian': [sig.gaussian, dict(M=n_points, std=130)],
'general_gaussian': [sig.general_gaussian, dict(M=n_points, sig=150, p=1.5)],
'hamming': [sig.hamming, dict(M=n_points)],
'hann': [sig.hann, dict(M=n_points)],
'kaiser': [sig.kaiser, dict(M=n_points, beta=14)],
'nuttall': [sig.nuttall, dict(M=n_points)],
'parzen': [sig.parzen, dict(M=n_points)],
'selpian': [sig.slepian, dict(M=n_points, width=0.02)],
'triang': [sig.triang, dict(M=n_points)]
}
plt.figure(figsize=(15, 15))
plt.xlim([0, n_points])
for name, calldata in arg_map.iteritems():
function, args = calldata
window = function(**args)
plt.plot(window, label=name)
plt.legend()