4

我遇到了伪真实数据反卷积的问题。我想做的是创建一些脉冲轮廓,与高斯卷积,添加一些小噪声并反卷积。然而,这种轻微差异的添加(具有有限数量的测量)将破坏反卷积结果。

原始脉冲的图像,脉冲与 scipy.signal.convolve 以及稍后描述的函数进行卷积

正如您在该图中看到的,两个卷积配置文件的配置文件“几乎”相同。然而...

这是反卷积后的数据

你可以看到我得到了两个完全不同的结果:/任何想法如何处理这个问题?

我使用的代码在这里:

import random
import numpy
import matplotlib.pyplot as plt
import scipy.signal

def create_pulse(lenght, peak):
    #creates pulse shape
    pulse_zeros = numpy.zeros(lenght)

    for i in range(len(pulse_zeros)):
        if i <= peak:
            pulse_zeros[i] = float(i)/float(peak)
        if i > peak:
            pulse_zeros[i] = float((len(pulse_zeros)-i)*peak)/(float(i)*(len(pulse_zeros)-peak))
    return pulse_zeros


plt.plot(create_pulse(200,10))
plt.show()


def normalize(data):
    data = data/max(data)
    return data


def mesh_up(pulse, region_l, sigma, repetitons):
    #convolves mutliple pulses via addition at random points with sigma distribution around region_l/2
    pulse_len = len(pulse)
    region = numpy.zeros(region_l)
    starts = numpy.random.normal(loc= region_l/2, scale= sigma, size = repetitons).round().astype(numpy.int)

    for pos in starts:
        #print(pos)
        region[pos: pos + pulse_len] += pulse

    return region



def one_up(pulse, region_l, sigma, repetitons):
    #create pulse for scipy convolve
    pulse_len = len(pulse)
    region = numpy.zeros(region_l)
    starts = [int(region_l/2)]

    for pos in starts:
        #print(pos)
        region[pos: pos + pulse_len] += pulse

    return region



result_a = mesh_up(create_pulse(200,10), 1000, 25/1.42, 10000)

signal = one_up(create_pulse(200,10), 1000, 25, 1)
result_b = scipy.signal.convolve(signal, gauss, mode='same')

plt.plot(signal, label = 'original')
plt.plot(normalize(result_a), label = 'rand_generated')
plt.plot(normalize(result_b), label = 'convolve')
plt.legend()
plt.show()


gauss = numpy.exp(-((numpy.linspace(0,100,101)-50.)/float(25.))**2 )

plt.plot(gauss)
plt.show()


deconv_a,  _ = scipy.signal.deconvolve(normalize(result_a), gauss)
deconv_b,  _ = scipy.signal.deconvolve(normalize(result_b), gauss)

plt.plot(normalize(deconv_a), label = 'rand_generated')
plt.plot(normalize(deconv_b), label = 'convolve')
plt.legend()
plt.show()
4

0 回答 0