更新时间:2023-02-26 16:55:18
deconvolve
返回两个数组,即商和余数。因此,尝试:
deconvolve
returns two arrays, the quotient and the remainder. So try:
f, r = signal.deconvolve(s, s_f)
长期以来, deconvolve
尚无适当的文档字符串,但其中有一个文档字符串。 github上的master分支: https://github.com/ scipy / scipy / blob / master / scipy / signal / signaltools.py#L731
For a long time, deconvolve
has not had a proper docstring, but it has one in the master branch on github: https://github.com/scipy/scipy/blob/master/scipy/signal/signaltools.py#L731
文档字符串显示了反卷积
。这是另一个( sig
是 scipy.signal
和 np
numpy
):
The docstring shows an example of the use of deconvolve
. Here's another (sig
is scipy.signal
and np
is numpy
):
要进行反卷积的信号是 z
,并且滤波器系数在 filter
中:
The signal to be deconvolved is z
, and the filter coefficients are in filter
:
In [9]: z
Out[9]:
array([ 0.5, 2.5, 6. , 9.5, 11. , 10. , 9.5, 11.5, 10.5,
5.5, 2.5, 1. ])
In [10]: filter = np.array([0.5, 1.0, 0.5])
应用解卷积
:
In [11]: q, r = sig.deconvolve(z, filter)
In [12]: q
Out[12]: array([ 1., 3., 5., 6., 5., 4., 6., 7., 1., 2.])
将过滤器应用于 q
以验证我们是否返回了 z
:
Apply the filter to q
to verify that we get back z
:
In [13]: sig.convolve(q, filter)
Out[13]:
array([ 0.5, 2.5, 6. , 9.5, 11. , 10. , 9.5, 11.5, 10.5,
5.5, 2.5, 1. ])
通过构造,这是一个非常干净的示例。其余为零:
By construction, this is a very clean example. The remainder is zero:
In [14]: r
Out[14]: array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
当然,您不会总是得到如此出色的结果。
Of course, you won't always get such nice results.