numpy.
hanning
返回汉宁窗口。
汉宁窗是用加权余弦形成的锥形窗。
输出窗口中的点数。如果小于或等于零,则返回空数组。
最大值规范化为1的窗口(只有当 M 很奇怪)
参见
bartlett
blackman
hamming
kaiser
笔记
汉宁窗的定义如下:
System Message: WARNING/2 (w(n)=0.5-0.5cos\左(\frac{2\pi{n}}{M-1}\右))
latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Undefined control sequence. <argument> ... \begin {split}w(n)=0.5-0.5cos\� ��(\frac {2\pi {n}}{M-1}... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "B7. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "A6. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Undefined control sequence. <argument> ...0.5cos\左(\frac {2\pi {n}}{M-1}\� ��)\end {split} l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "8F. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "B3. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Undefined control sequence. <argument> ... \begin {split}w(n)=0.5-0.5cos\� ��(\frac {2\pi {n}}{M-1}... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "B7. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "A6. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Undefined control sequence. <argument> ...0.5cos\左(\frac {2\pi {n}}{M-1}\� ��)\end {split} l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "8F. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Invalid UTF-8 byte "B3. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...��(\frac{2\pi{n}}{M-1}\右)\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 412 bytes). Transcript written on math.log.
汉宁是以奥地利气象学家朱利叶斯·冯·汉恩的名字命名的。它也被称为余弦钟。有些作者喜欢称之为汉明窗,以避免与非常相似的汉明窗混淆。
对汉宁窗的大多数引用来自信号处理文献,在那里它被用作平滑值的许多窗口函数之一。它也被称为变迹(意思是“消除脚”,即在采样信号的开始和结束处平滑不连续)或渐缩函数。
工具书类
Blackman,R.B.和Tukey,J.W.,(1958)功率谱测量,多佛出版社,纽约。
E.R.Kanasewich,“地球物理学中的时序分析”,阿尔伯塔大学出版社,1975年,第106-108页。
维基百科,“窗口函数”,https://en.wikipedia.org/wiki/window_function
W.H.Press、B.P.Flannery、S.A.Teukolsky和W.T.Vetterling,“数字食谱”,剑桥大学出版社,1986年,第425页。
实例
>>> np.hanning(12) array([0. , 0.07937323, 0.29229249, 0.57115742, 0.82743037, 0.97974649, 0.97974649, 0.82743037, 0.57115742, 0.29229249, 0.07937323, 0. ])
绘制窗口及其频率响应:
>>> import matplotlib.pyplot as plt >>> from numpy.fft import fft, fftshift >>> window = np.hanning(51) >>> plt.plot(window) [<matplotlib.lines.Line2D object at 0x...>] >>> plt.title("Hann window") Text(0.5, 1.0, 'Hann window') >>> plt.ylabel("Amplitude") Text(0, 0.5, 'Amplitude') >>> plt.xlabel("Sample") Text(0.5, 0, 'Sample') >>> plt.show()
>>> plt.figure() <Figure size 640x480 with 0 Axes> >>> A = fft(window, 2048) / 25.5 >>> mag = np.abs(fftshift(A)) >>> freq = np.linspace(-0.5, 0.5, len(A)) >>> with np.errstate(divide='ignore', invalid='ignore'): ... response = 20 * np.log10(mag) ... >>> response = np.clip(response, -100, 100) >>> plt.plot(freq, response) [<matplotlib.lines.Line2D object at 0x...>] >>> plt.title("Frequency response of the Hann window") Text(0.5, 1.0, 'Frequency response of the Hann window') >>> plt.ylabel("Magnitude [dB]") Text(0, 0.5, 'Magnitude [dB]') >>> plt.xlabel("Normalized frequency [cycles per sample]") Text(0.5, 0, 'Normalized frequency [cycles per sample]') >>> plt.axis('tight') ... >>> plt.show()