gonumgonum.org/v1/gonum/dsp/window/cmd/leakage

leakage command

The leakage program provides summary characteristics and a plot of spectral response for window functions or csv input. It is intended to be used to verify window behaviour against foreign implementations. For example, the behavior of a NumPy window can be captured using this python code:

import matplotlib.pyplot as plt
import numpy as np
from numpy.fft import fft

window = np.blackman(20)
print("# beta = %f" % np.mean(window))

plt.figure()

A = fft(window, 1000)
mag = np.abs(A)
with np.errstate(divide='ignore', invalid='ignore'):
    mag = 20 * np.log10(mag)
mag -= max(mag)
freq = np.linspace(0, len(window)/2, len(A)/2)

for m in mag[:len(mag)/2]:
	print(m)

plt.plot(freq, mag[:len(mag)/2])
plt.title("Spectral leakage")
plt.ylabel("Amplitude (dB)")
plt.xlabel("DFT bin")

plt.show()

and then be exported to leakage and compared with the Gonum implementation.

Version
v0.15.1 (latest)
Published
Aug 16, 2024
Platform
linux/amd64
Imports
18 packages
Last checked
12 hours ago

Tools for package owners.