[SciPy-user] newbie trouble with lfilter
Joseph Anderson
J.Anderson at hull.ac.uk
Fri Jan 18 16:50:33 EST 2008
Hello Stéfan,
Thanks for the reply on this.
As I look at Ticket #331, this doesn't exactly describe the situation I'm encountering. My problem involves supplying and recovering the state (for a 2-d array).
At least for a 2-d array (which is what I'm interested in for my problem), lfilter appears to work correctly, given the condition that one doesn't want to supply the initial state (zi) and recover the final state (zf) of the filter. The code listed below seems to work, giving the expected result.
For my application, however, it is important for me to be able to supply and recover the state.
I'm presuming, then, that the way forward for the immediate future is to just unwind my 2-d array by hand and process as 1-d arrays. Ah, well, but for the state problem, was working fine for me, otherwise.
# **************************************
# test filter: 2-d array
#
# **************************************
from numpy import *
from numpy.random import *
from scipy.signal import *
# order and cutoff
N = 1
freq = 0.1
# signal, two channels
x = array([uniform(-1., 1., 8), zeros(8)]).transpose()
# design filter
b, a = butter(N, freq)
# filter
y = lfilter(b, a, x, 0)
print "b, a:", b, a
print "x:", x
print "y:", y
My regards,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr Joseph Anderson
Lecturer in Music
School of Arts and New Media
University of Hull, Scarborough Campus,
Scarborough, North Yorkshire, YO11 3AZ, UK
T: +44.(0)1723.357341 T: +44.(0)1723.357370 F: +44.(0)1723.350815
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----Original Message-----
From: scipy-user-bounces at scipy.org on behalf of Stefan van der Walt
Sent: Fri 01/18/2008 7:27 AM
To: SciPy Users List
Subject: Re: [SciPy-user] newbie trouble with lfilter
Hi Joseph
On Thu, Jan 17, 2008 at 12:30:11PM -0000, Joseph Anderson wrote:
> Trying something different and changing zi to:
>
> zi = zeros(N * 2).reshape(N, 2)
>
> Results in a crash with the message:
>
> Process Python segmentation fault
This should never happen. A bug is filed at
http://projects.scipy.org/scipy/scipy/ticket/331
Regards
Stéfan
_______________________________________________
SciPy-user mailing list
SciPy-user at scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3853 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080118/72d88c14/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080118/72d88c14/attachment.ksh>
More information about the SciPy-User
mailing list