This is a common function in the numpy library. It generates a cosine window function or a Gaussian function, which is used to filter or highlight an object.
Input parameters: M. -Output: vector of one row and M columns
Code example 1:
#numpy.hanningimport numpy as np
import matplotlib.pyplot as plt
window=np.hanning(50)print('w2:',window)
plt.plot(window)
plt.show()
import numpy as np
window_len=50
window ='hanning'
w1 =getattr(np, window)(window_len)print('w1:',w1)
Output:
w1:[0.0.004104990.016352570.036541620.064340650.099293190.140825320.18825510.240803720.297608330.357736210.420200050.483974210.548011510.611260470.672682530.731269150.786058330.836150450.880722980.919044050.950484430.974527870.990779580.99897270.99897270.990779580.974527870.950484430.919044050.880722980.836150450.786058330.731269150.672682530.611260470.548011510.483974210.420200050.357736210.297608330.240803720.18825510.140825320.099293190.064340650.036541620.016352570.004104990.]
Process finished with exit code 0