GET_WINDOW
Window functions are weighting sequences used in spectral analysis and filter design to control sidelobes and leakage.
This function returns a one-dimensional window of length N that can be used in FFT and filtering workflows. Different window families trade off main-lobe width and sidelobe attenuation.
Excel Usage
=GET_WINDOW(window, nx, fftbins, shape)
window(str, required): Window family name.nx(int, required): Number of samples in the output window.fftbins(bool, optional, default: true): If True, create a periodic window for FFT use; otherwise symmetric.shape(float, optional, default: null): Optional shape parameter for parameterized windows.
Returns (list[list]): Window coefficients as a single-row 2D array.
Example 1: Periodic Hann window
Inputs:
| window | nx |
|---|---|
| hann | 8 |
Excel formula:
=GET_WINDOW("hann", 8)
Expected output:
| Result | |||||||
|---|---|---|---|---|---|---|---|
| 0 | 0.146447 | 0.5 | 0.853553 | 1 | 0.853553 | 0.5 | 0.146447 |
Example 2: Symmetric Hamming window
Inputs:
| window | nx | fftbins |
|---|---|---|
| hamming | 9 | false |
Excel formula:
=GET_WINDOW("hamming", 9, FALSE)
Expected output:
| Result | ||||||||
|---|---|---|---|---|---|---|---|---|
| 0.08 | 0.214731 | 0.54 | 0.865269 | 1 | 0.865269 | 0.54 | 0.214731 | 0.08 |
Example 3: Tukey window with shape parameter
Inputs:
| window | nx | shape |
|---|---|---|
| tukey | 16 | 0.25 |
Excel formula:
=GET_WINDOW("tukey", 16, 0.25)
Expected output:
| Result | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.5 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0.5 |
Example 4: Boxcar window for basic weighting
Inputs:
| window | nx |
|---|---|
| boxcar | 6 |
Excel formula:
=GET_WINDOW("boxcar", 6)
Expected output:
| Result | |||||
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 |
Python Code
Show Code
from scipy.signal import get_window as scipy_get_window
def get_window(window, nx, fftbins=True, shape=None):
"""
Generate a window function vector for signal processing.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.get_window.html
This example function is provided as-is without any representation of accuracy.
Args:
window (str): Window family name.
nx (int): Number of samples in the output window.
fftbins (bool, optional): If True, create a periodic window for FFT use; otherwise symmetric. Default is True.
shape (float, optional): Optional shape parameter for parameterized windows. Default is None.
Returns:
list[list]: Window coefficients as a single-row 2D array.
"""
try:
if int(nx) <= 0:
return "Error: nx must be a positive integer"
if shape is None:
win_spec = window
else:
win_spec = (window, float(shape))
result = scipy_get_window(win_spec, int(nx), fftbins=bool(fftbins))
return [result.tolist()]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Window family name.
Number of samples in the output window.
If True, create a periodic window for FFT use; otherwise symmetric.
Optional shape parameter for parameterized windows.