numpy.
hamming
把吊床窗户还给我。
汉明窗是用加权余弦形成的锥形窗。
输出窗口中的点数。如果小于或等于零,则返回空数组。
最大值规范化为1的窗口(只有当样本数为奇数时,才会显示值1)。
参见
bartlett
blackman
hanning
kaiser
笔记
汉明窗定义为
System Message: WARNING/2 (w(n)=0.54-0.46cos\左(\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.54-0.46cos\� ��(\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> ....46cos\左(\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.54-0.46cos\� ��(\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> ....46cos\左(\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, 416 bytes). Transcript written on math.log.
哈明是以R.W.Hamming的名字命名的,他是J.W.Tukey的合伙人,在Blackman和Tukey中有描述。建议在时间域内平滑截断的自方差函数。对汉明窗的大多数引用来自信号处理文献,它被用作平滑值的许多窗函数之一。它也被称为变迹(意思是“去除脚”,即平滑采样信号开始和结束时的不连续性)或渐缩函数。
工具书类
Blackman,R.B.和Tukey,J.W.,(1958)功率谱测量,多佛出版社,纽约。
E.R.Kanasewich,“地球物理学中的时序分析”,阿尔伯塔大学出版社,1975年,第109-110页。
维基百科,“窗口函数”,https://en.wikipedia.org/wiki/window_function
W.H.Press、B.P.Flannery、S.A.Teukolsky和W.T.Vetterling,“数字食谱”,剑桥大学出版社,1986年,第425页。
实例
>>> np.hamming(12) array([ 0.08 , 0.15302337, 0.34890909, 0.60546483, 0.84123594, # may vary 0.98136677, 0.98136677, 0.84123594, 0.60546483, 0.34890909, 0.15302337, 0.08 ])
绘制窗口和频率响应:
>>> import matplotlib.pyplot as plt >>> from numpy.fft import fft, fftshift >>> window = np.hamming(51) >>> plt.plot(window) [<matplotlib.lines.Line2D object at 0x...>] >>> plt.title("Hamming window") Text(0.5, 1.0, 'Hamming 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)) >>> 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 Hamming window") Text(0.5, 1.0, 'Frequency response of Hamming 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()