MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / blackman_harris

Function blackman_harris

numpy_ml/utils/windows.py:4–40  ·  view source on GitHub ↗

The Blackman-Harris window. Notes ----- The Blackman-Harris window is an instance of the more general class of cosine-sum windows where `K=3`. Additional coefficients extend the Hamming window to further minimize the magnitude of the nearest side-lobe in the frequency r

(window_len, symmetric=False)

Source from the content-addressed store, hash-verified

2
3
4def blackman_harris(window_len, symmetric=False):
5 """
6 The Blackman-Harris window.
7
8 Notes
9 -----
10 The Blackman-Harris window is an instance of the more general class of
11 cosine-sum windows where `K=3`. Additional coefficients extend the Hamming
12 window to further minimize the magnitude of the nearest side-lobe in the
13 frequency response.
14
15 .. math::
16 \\text{bh}(n) = a_0 - a_1 \cos\left(\\frac{2 \pi n}{N}\\right) +
17 a_2 \cos\left(\\frac{4 \pi n }{N}\\right) -
18 a_3 \cos\left(\\frac{6 \pi n}{N}\\right)
19
20 where `N` = `window_len` - 1, :math:`a_0` = 0.35875, :math:`a_1` = 0.48829,
21 :math:`a_2` = 0.14128, and :math:`a_3` = 0.01168.
22
23 Parameters
24 ----------
25 window_len : int
26 The length of the window in samples. Should be equal to the
27 `frame_width` if applying to a windowed signal.
28 symmetric : bool
29 If False, create a 'periodic' window that can be used in with an FFT /
30 in spectral analysis. If True, generate a symmetric window that can be
31 used in, e.g., filter design. Default is False.
32
33 Returns
34 -------
35 window : :py:class:`ndarray <numpy.ndarray>` of shape `(window_len,)`
36 The window
37 """
38 return generalized_cosine(
39 window_len, [0.35875, 0.48829, 0.14128, 0.01168], symmetric
40 )
41
42
43def hamming(window_len, symmetric=False):

Callers

nothing calls this directly

Calls 1

generalized_cosineFunction · 0.85

Tested by

no test coverage detected