0
我试图找出卷积后出现的文物的原因,他们将在绘图arround x = -.0016和x = .0021(请参阅下面的代码)中看到。我对代码中定义的“lorentzian”函数(或langevin函数的导数)进行了卷积,并在函数“ditrib”中使用了2个Dirac脉冲。
我将不胜感激您的帮助。 谢谢 这里是我的代码:这个令人费解的信号的人为现象的原因是什么?
import numpy as np
import matplotlib.pyplot as plt
def Lorentzian(xx):
if not hasattr(xx, '__iter__'):
xx = [ xx ]
res = np.zeros(len(xx))
for i in range(len(xx)):
x = xx[i]
if np.fabs(x) < 0.1:
res[i] = 1./3. - x**2/15. + 2.* x**4/189. - x**6/675. + 2.* x**8/10395. - 1382. * x**10/58046625. + 4. * x**12/1403325.
else:
res[i] = (1./x**2 - 1./np.sinh(x)**2)
return res
amp = 18e-3
a = 1/.61e3
b = 5.5
t_min = 0
dt = 1/5e6
t_max = (10772) * dt
t = np.arange(t_min,t_max,dt)
x_min = -amp/b
x_max = amp/b
dx = dt*(x_min-x_max)/(t_min-t_max)
x = np.arange(x_min,x_max,dx)
func1 = lambda x : Lorentzian(b*(x/a))
def distrib(x):
res = np.zeros(np.size(x))
res[int(np.floor(np.size(x)/3))] = 1
res[int(3*np.floor(np.size(x)/4))] = 3
return res
func2 = lambda x,xs : np.convolve(distrib(x), func1(xs), 'same')
plt.plot(x, func2(x,x))
plt.xlabel('x (m)')
plt.ylabel('normalized signal')
你好。感谢您的帮助,我会尽力并回复您。 – MaximeMusterFrau
谢谢,它工作!你能向我解释为什么要这样做吗?先谢谢你。 – MaximeMusterFrau
当你颤抖一个Dirac脉冲时,你会得到一个步长,理想情况下,你只需要使用所有的“洛伦兹”而不是黑客的“有限范围的基座 - 但是因为它定义在+/-无穷远处...... – f5r5e5d