Discussion:
seeking scipy examples of swept-coefficient (time varying) filters
(too old to reply)
Robert Poor
2020-03-08 23:38:46 UTC
Permalink
I've been pleased with ease of use of the scipy.signal package for implementing bandpass filters: the `signal.butterworth()`, `signal.sosfilt_zi()` and `signal.sosfilt()` functions do just what I expect for a filter with constant center frequency and bandwidth.

But now I'd like to make the frequency and bandwidth settings be time varying functions themselves, and I'm not sure how to do that.

One nuance: I'm processing a buffer at a time, so I need to capture the filter state at the end of one buffer and re-initialize the filter state at the onset of the next.

Can anyone offer guidance or examples on how to do that, preferably in scipy?
r***@klatunetworks.com
2020-03-09 00:21:22 UTC
Permalink
Lattice filters are stable if the coefficients for the recursive part
of the filter are in the range (-1,+1). One can ramp between, or
even switch between two such sets of coefficients without instabilities.
... I should probably rephrase my question to "can anyone offer guidance on implementing lattice filters in scipy?"
Robert Poor
2020-03-09 00:28:50 UTC
Permalink
I should have mentioned: as Steve Pope points out in:

https://groups.google.com/d/msg/comp.dsp/bAUKDSnvLzw/ejI-J-aQzusJ
Lattice filters are stable if the coefficients for the recursive part
of the filter are in the range (-1,+1). One can ramp between, or
even switch between two such sets of coefficients without instabilities.
... I should probably rephrase my question to be "can anyone offer guidance or examples of implementing lattice filters in scipy?"
Steve Pope
2020-03-10 00:12:55 UTC
Permalink
Post by Robert Poor
https://groups.google.com/d/msg/comp.dsp/bAUKDSnvLzw/ejI-J-aQzusJ
Lattice filters are stable if the coefficients for the recursive part
of the filter are in the range (-1,+1). One can ramp between, or
even switch between two such sets of coefficients without instabilities.
... I should probably rephrase my question to be "can anyone offer
guidance or examples of implementing lattice filters in scipy?"
I have no familiarity with scipy, unfortauntely. You may want
to ask this question on Stack Exchange.

Lattice filters are an excellent choice if you need to vary the
coefficients on a sample by sample (or otherwise rapid) basis,
but I think you said you are processing blocks of data, with
coefficients fixed between blocks, so in that case any of the
basic filter topologies will be equivalent.

One the other hand, if after filtering, you need to "stitch"
the blocks together, and want to do some sort of smothing between
blocks so that there is not a glitch, lattice topology might make
that easiter.

Steve
Robert Poor
2020-03-10 02:22:56 UTC
Permalink
...I think you said you are processing blocks of data, with
coefficients fixed between blocks
That's half right: I am processing blocks of data, but the coefficients will be changing on a sample-by-sample basis.

I think I can construct a lattice filter from first principles in scipy (with luck), so what I really need to learn is how to derive the A[n] and B[n] coefficients as a function of the human readable parameters: center frequency and bandwidth.
Steve Pope
2020-03-10 19:57:37 UTC
Permalink
Post by Robert Poor
That's half right: I am processing blocks of data, but the coefficients
will be changing on a sample-by-sample basis.
I think I can construct a lattice filter from first principles in scipy
(with luck), so what I really need to learn is how to derive the A[n]
center frequency and bandwidth.
Great. That is a filter synthesis problem of which there are
many methods.

Steve

Loading...