What are the constraints on the divisor argument of scipy.signal.deconvolve to ensure numerical stability?

别来无恙 提交于 2019-12-21 20:36:45

问题


Here is my problem: I am going to process data coming from a system for which I will have a good idea of the impulse response. Having used Python for some basic scripting before, I am getting to know the scipy.signal.convolve and scipy.signal.deconvolve functions. In order to get some confidence in my final solution, I would like to understand their requirements and limitations.

I used the following test:
1. I built a basic signal made of two Gaussians.
2. I built a Gaussian impulse response.
3. I convolved my initial signal with this impulse response.
4. I deconvolved this convolved signal.
5. I compared this last signal to my initial one.
The outcome of this test was strongly dependent of how I defined my impulse response : either I managed to recover my initial signal, or the deconvolved signal was strongly diverging.

Here is the code:
I use python 3.4.2, numpy 1.8.2, and scipy 0.14.0.

import numpy as np  
from scipy import signal  


def gauss(x, amp = 1, mean = 0, sigma = 1):  
    return amp * np.exp(-(x - mean)**2 / (2 * sigma**2))  


step = 0.1  
x_os = np.arange(0, 200 + step, step)  
low = -5 # lower bound of the interval for the impulse response
up = 5  # upper bound of the interval for the impulse response
x_ir = np.arange(low, up + step, step)  

y_os1 = gauss(x_os, 160, 80, 5.0)  
y_os2 = gauss(x_os, 20, 20, 2.0)  
y_os = y_os1 + y_os2 # original signal  

y_ir = gauss(x_ir, 1 / (np.sqrt(2 * np.pi)), 0.0, 1.0) # impulse response 

y_c = signal.convolve(y_os, y_ir, 'full') # convoluted signal

y_d, _ = signal.deconvolve(y_c, y_ir) # deconvoluted signal

In the previous code, the divisor argument of scipy.signal.deconvolve is y_ir. I played with the parameters defining the interval on which y_ir is defined, e.g. [low, up, step]. To show you what puzzles me, let us take the three following sets :
1) [-5, 5, 0.1],
2) [-2, 2, 0.1],
3) and [-2, 2, 0.5] (note that step was not changed in the definition of y_os).

The following images show you the original signal along with the deconvolved signal for the three above-mentioned sets.
Original signal
Comparison of the deconvoluted signals

Can anyone explain this behaviour? Are there any requirements on divisor that guarantee proper behaviour of this function?

Thank you in advance.

来源:https://stackoverflow.com/questions/36204207/what-are-the-constraints-on-the-divisor-argument-of-scipy-signal-deconvolve-to-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!