本文簡要介紹 python 語言中 numpy.blackman
的用法。
用法:
numpy.blackman(M)
返回布萊克曼窗口。
布萊克曼窗是使用餘弦和的前三項形成的錐度。它的設計目的是盡可能減少泄漏。它接近於最佳值,僅比 Kaiser 窗口差一點。
- M: int
輸出窗口中的點數。如果為零或更小,則返回一個空數組。
- out: ndarray
最大值歸一化為 1 的窗口(僅當樣本數為奇數時才會出現值 1)。
參數:
返回:
注意:
布萊克曼窗定義為
大多數對 Blackman 窗的引用來自信號處理文獻,它被用作平滑值的許多窗函數之一。它也被稱為變跡(表示“removing the foot”,即平滑采樣信號開始和結束處的不連續性)或錐形函數。它被稱為“near optimal” 錐形函數,幾乎與凱撒窗口一樣好(在某些方麵)。
參考:
Blackman, R.B. 和 Tukey, J.W.,(1958) 功率譜的測量,Dover Publications,紐約。
奧本海姆、A.V. 和 R.W. Schafer。 Discrete-Time 信號處理。新澤西州上薩德爾河:Prentice-Hall,1999 年,第 468-471 頁。
例子:
>>> import matplotlib.pyplot as plt >>> np.blackman(12) array([-1.38777878e-17, 3.26064346e-02, 1.59903635e-01, # may vary 4.14397981e-01, 7.36045180e-01, 9.67046769e-01, 9.67046769e-01, 7.36045180e-01, 4.14397981e-01, 1.59903635e-01, 3.26064346e-02, -1.38777878e-17])
繪製窗口和頻率響應:
>>> from numpy.fft import fft, fftshift >>> window = np.blackman(51) >>> plt.plot(window) [<matplotlib.lines.Line2D object at 0x...>] >>> plt.title("Blackman window") Text(0.5, 1.0, 'Blackman 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 Blackman window") Text(0.5, 1.0, 'Frequency response of Blackman 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()
相關用法
- Python numpy block用法及代碼示例
- Python numpy broadcast用法及代碼示例
- Python numpy byte_bounds用法及代碼示例
- Python numpy broadcast.nd用法及代碼示例
- Python numpy busday_offset用法及代碼示例
- Python numpy base_repr用法及代碼示例
- Python numpy bartlett用法及代碼示例
- Python numpy broadcast.size用法及代碼示例
- Python numpy broadcast.reset用法及代碼示例
- Python numpy broadcast_shapes用法及代碼示例
- Python numpy busdaycalendar用法及代碼示例
- Python numpy bitwise_xor用法及代碼示例
- Python numpy binary_repr用法及代碼示例
- Python numpy bitwise_and用法及代碼示例
- Python numpy broadcast.numiter用法及代碼示例
- Python numpy busday_count用法及代碼示例
- Python numpy broadcast.iters用法及代碼示例
- Python numpy broadcast_to用法及代碼示例
- Python numpy broadcast_arrays用法及代碼示例
- Python numpy broadcast.ndim用法及代碼示例
- Python numpy bmat用法及代碼示例
- Python numpy bincount用法及代碼示例
- Python numpy broadcast.index用法及代碼示例
- Python numpy bitwise_or用法及代碼示例
- Python numpy RandomState.standard_exponential用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.blackman。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。