Python scipy.signal.deconvolve()的输出不';这似乎不是预期的结果

Python scipy.signal.deconvolve()的输出不';这似乎不是预期的结果,python,scipy,signals,Python,Scipy,Signals,我对scipy.signal.deconvolve()有问题 我试着回答,但没有用。 这是我的密码: n = 3 s = 240 p = np.linspace(-s*n, s*n, s*n*2) g = mlab.normpdf(p, 0, s) f1 = g/max(g) s = 1920 p = np.linspace(-s*n, s*n, s*n*2) g = mlab.normpdf(p, 0, s) g1 = g/max(g) 让信号像盒子一样 signal = g1 并使用

我对scipy.signal.deconvolve()有问题 我试着回答,但没有用。 这是我的密码:

n = 3

s = 240
p = np.linspace(-s*n, s*n, s*n*2)
g = mlab.normpdf(p, 0, s)
f1 = g/max(g)

s = 1920
p = np.linspace(-s*n, s*n, s*n*2)
g = mlab.normpdf(p, 0, s)
g1 = g/max(g)
让信号像盒子一样

signal = g1
并使用高斯滤波器

滤波器应比信号短

过滤器的大小应该比任何地方的0都大

gauss = f1
print gauss.min()  # = 0.013 >> 0
计算卷积(np.convolve和scipy.signal.convolve相同)

关键字argument mode=“same”确保卷积跨越相同的范围

形状作为输入数组

过滤=scipy.signal.convolve(信号,高斯,模式='same')

反褶积有n=len(信号)-len(高斯)+1个点

n = len(signal)-len(gauss)+1
所以我们需要通过

s = (len(signal)-n)/2
两边都有

deconv_res = np.zeros(len(signal))
deconv_res[s:len(signal)-s-1] = deconv
deconv = deconv_res
现在反褶积包含反褶积

扩展到原始形状(用零填充)

我们需要除以滤波器窗口的和,得到归一化为1的卷积

ax[2].plot(filtered/np.sum(gauss), color="#325cab", label="convoluted")
ax[3].plot(deconv, color="#ab4232", label="deconvoluted")
# ax[3].set_yscale('log')

for i in range(len(ax)):
    ax[i].set_xlim([0, len(signal)])
    ax[i].legend(loc=1, fontsize=11)
    if i != len(ax)-1 :
        ax[i].set_xticklabels([])

plt.show()    

假设反褶积曲线与原始高斯曲线相同。

看看awww,我应该写什么才能有30个符号?
#### Plot #### 
fig , ax = plt.subplots(nrows=4, figsize=(6,7))

ax[0].plot(signal, color="#907700", label="original")
ax[1].plot(gauss, color="#68934e", label="gauss filter")
ax[2].plot(filtered/np.sum(gauss), color="#325cab", label="convoluted")
ax[3].plot(deconv, color="#ab4232", label="deconvoluted")
# ax[3].set_yscale('log')

for i in range(len(ax)):
    ax[i].set_xlim([0, len(signal)])
    ax[i].legend(loc=1, fontsize=11)
    if i != len(ax)-1 :
        ax[i].set_xticklabels([])

plt.show()