[英]How to get rid of variable amplitude in cosine function using python-scipy?
after a complex FFT analysis, I got my data as ` 经过复杂的FFT分析后,我得到的数据为
y=np.array([-0.31757207, -0.759897 , -0.97481323, -0.90067096, -0.56201419,
-0.06141066, 0.45184696, 0.82654122, 0.95429599, 0.80098432,
0.41565507, -0.08528661, -0.55350349, -0.85289024, -0.89924892,
-0.6838725 , -0.27446443, 0.20632688, 0.61789554, 0.84295248,
0.82091852, 0.56394004, 0.15139964, -0.29481341, -0.64650262,
-0.80602096, -0.73317927, -0.45486384, -0.0552602 , 0.3498015 ,
0.64649953, 0.75486814, 0.64997615, 0.36696461, -0.01077531,
-0.37629244, -0.62928397, -0.70331519, -0.58277349, -0.30541445,
0.04956568, 0.38413122, 0.60823604, 0.66362602, 0.53848173,
0.26941065, -0.06930203, -0.38601383, -0.59612545, -0.6442082 ,
-0.5182447 , -0.25246689, 0.08181356, 0.39497462, 0.60264688,
0.6480463 , 0.51731067, 0.24376628, -0.10019951, -0.42181997,
-0.63254052, -0.67215727, -0.52601037, -0.23032442, 0.13622702,
0.47298468, 0.68464621, 0.70816855, 0.53165966, 0.19956061,
-0.19797826, -0.54920882, -0.75206661, -0.74391156, -0.52103408,
-0.14180003, 0.28818356, 0.64528143, 0.82341019, 0.76573576,
0.48295615, 0.05224223, -0.40355087, -0.75089961, -0.88488436,
-0.76111445, -0.41051563, 0.06797007, 0.53521743, 0.85248562,
0.92285209, 0.72105995, 0.30251038, -0.21178154, -0.67024193,
-0.935627 , -0.92637938, -0.64190028, -0.16383967, 0.36735054,
0.79386302, 0.98768951, 0.88930233, 0.52608786, 0.00477518,
-0.52006527, -0.89210845, -1.00012051, -0.8114311 , -0.3818889 ,
0.16075761, 0.65507887, 0.95427369, 0.97001733, 0.69866763,
0.22200955])
Which, when plotted produces this: 绘制时会产生以下结果:
This is a cosine function with variable amplitude. 这是幅度可变的余弦函数。 I'm looking for a way to get rid of the amplitude envelope to obtain normal cosine function which I can fit.
我正在寻找一种摆脱振幅包络的方法,以获得适合的正常余弦函数。
from matplotlib.pyplot import plot, figure 从matplotlib.pyplot导入图,图中
from numpy import array, exp, arange, real, append 从numpy导入数组,exp,范围,真实,追加
from scipy.fftpack import fft, ifft 从scipy.fftpack导入fft,ifft
w = fft(y) w = fft(y)
f = arange(0,y.size) f =范围(0,y.size)
cf = 10 #central freq cf = 10#中央频率
wd = 0.5 #width wd = 0.5#宽度
gate1 = exp(-((f-cf)/(0.707106*wd))**(2*2)) gate1 = exp(-(((f-cf)/(0.707106 * wd))**(2 * 2))
gate2 = append([0],gate1[::-1])[:-1] #symmetrize gate2 = append([0],gate1 [::-1])[:-1] #symmetrize
gate = gate1+gate2 门=门1 +门2
w_f = w*gate w_f = w *门
figure(1) 图1)
plot(abs(w)) 情节(绝对(瓦特))
plot(abs(w_f)) 情节(绝对(w_f))
figure(2) 图(2)
plot(real(ifft(w_f))) 情节(真实(ifft(w_f)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.