kaiser in Numpy – Python

Kaiser window is a taper formed by using a Bessel function.
Syntax : numpy.kaiser(M, beta)
Parameters :
M : [int] Number of points in the output window. If zero or less, an empty array is returned.
beta : [float] Shape parameter for window.Returns:
out : [array] The window, with the maximum value normalized to one (the value one appears only if the number of samples is odd).
Example:
import numpy as np print(np.kaiser(12, 14)) |
Output:
[ 7.72686684e-06 3.46009194e-03 4.65200189e-02 2.29737120e-01 5.99885316e-01 9.45674898e-01 9.45674898e-01 5.99885316e-01 2.29737120e-01 4.65200189e-02 3.46009194e-03 7.72686684e-06]
Plotting the window and its frequency response –
For Window :
import numpy as np import matplotlib.pyplot as plt from numpy.fft import fft, fftshift window = np.kaiser(51, 14) plt.plot(window) plt.title("Kaiser window") plt.ylabel("Amplitude") plt.xlabel("Sample") plt.show() |
Output:
For frequency :
import numpy as np import matplotlib.pyplot as plt from numpy.fft import fft, fftshift window = np.kaiser(51, 14) plt.figure() A = fft(window, 2048) / 25.5mag = np.abs(fftshift(A)) freq = np.linspace(-0.5, 0.5, len(A)) response = 20 * np.log10(mag) response = np.clip(response, -100, 100) plt.plot(freq, response) plt.title("Frequency response of Kaiser window") plt.ylabel("Magnitude [dB]") plt.xlabel("Normalized frequency [cycles per sample]") plt.axis("tight") plt.show() |
Output:




