Does Python / Scipy have firls () replacements (i.e. Weighted, Least Square, FIR Filter Design)?

I am porting code from Matlab to Python, and it is difficult for me to find a replacement for the firls () procedure. It is used to design least-square linear finite-impulse response (FIR) filters.

I looked at scipy.signal and nothing there looked like it was a trick. Of course, I was able to replace my remez and freqz algorithm, so good.

In one blog I found an algorithm that implemented this filter without weighting, but I need one with weights.

Thanks David

+3
source share
6 answers

, , , , - :

, Python firls:

  • firwin = 'boxcar'. Matlab, fir1 boxcar (, , ), firls.
  • firwin2 ( , fir2 Matlab), = 'boxcar'

Matlab firls :

Matlab:

F = [0 0.3  0.4 0.6  0.7 0.9];
A = [0  1   0  0  0.5 0.5];
b = firls(24,F,A,'hilbert');

Python:

F = [0, 0.3,  0.4, 0.6,  0.7, 0.9, 1]
A = [0,  1,   0,  0,  0.5, 0.5, 0]
bb = sig.firwin2( 25, F,A, window='boxcar', antisymmetric=True )

N = 25, (F = 1, A = 0), Python; = True ( )

+1

firwin = 'boxcar'...

boxcar, ( , "" - sinc ). - , -. .

dB/log.

Scipy, firls (FIR ), ( ).

REMEZ , - , ( , ). ( scipy remez - . )

python ( - ), kasiar, ( ( ) = 2.285 * ( - 1) * pi * width + 7.95). , firls, (, ).

+1

I found the implementation of firls () attached here in the SciPy 648 ticket

Minor changes to make it work:

  • Change the following two lines: bands, desired, weight = array(bands), array(desired), array(weight) if weight==None : weight = ones(len(bands)/2)

  • import roots from numpy instead of scipy.signal

+1
source

It seems unlikely that you will find exactly what you are looking for already written in Python, but maybe the Matlab function help page gives or links to the description of the algorithm?

0
source

Source: https://habr.com/ru/post/1739632/


All Articles