[SciPy-user] FIR filter, calculated with Remez exchange algorithm ?
Stef Mientki
s.mientki at ru.nl
Sat Apr 21 05:28:00 EDT 2007
Travis Oliphant wrote:
> Stef Mientki wrote:
>
>> ok, I got the answer (I think)
>>
>> A slightly changed design, works perfect:
>>
>> filt_4 = signal.remez (25, (0, 0.01, 0.2, 0.5), (0.01, 1))
>>
>> The filterlength must be odd, because it's a high pass filter.
>> If the length is even, the respons at Nyquist is zero,
>> so my orginal example
>>
>> filt_4 = signal.remez (24, (0, 0.01, 0.2, 0.49), (0.01, 1))
>>
>> will try to create a transition band between 0.49 and 0.5,
>> which is much to steep for this filterlength.
>>
>> I never encountered this problem because MatLab,
>> and previous programs I used always corrected this themselfs.
>>
>> Now would it be possible to implement this behaviour in the library
>> (I think it's usefull for beginners and previous MatLab users)
>> if last amplitude band = 1 (because it also must be odd for bandstop filters)
>> make N odd
>> else
>> make N even
>>
>>
>>
> I guess the question is should we raise an error or just auto-correct.
> I'm thinking raising an error may help avoid this mis-learning. But,
> then again, if we document that it rounds up to the nearest odd-length
> under such conditions that may suffice.
>
>
thanks for your attention Travis,
I leave it up to the Scipy gurus, if and how to solve it,
personally I'm going to use a wrapper to solve the problem for the future.
BTW the problem was not described completely yet.
Untill now I didn't understand why I had so much trouble designing FIR
filters,
through Remez exchange algorithm,
while it always went very fluently in MatLab.
I think I understand now, why I was so distracted.
Coming from MatLab there are a few extra problems:
- The Signal Toolbox manual and MatLab help files contains many errors,
but using the fdatool hides this
- the MatLab-equivalent "firpm" specifies the filterorder (which is
Ntap-1) instead of Ntap
The solution in my opinion is simple
- for bandpass filters, always make the filter-length odd
- for differentiators, always make the filter-length even
Because FIR filters always have a relative large length, this is no
problem at all.
I've written my notes and an example how bad it can be, on my website:
http://oase.uci.kun.nl/~mientki/data_www/pic/jalcc/help/jallcc_swb_filters_2.html
cheers,
Stef Mientki
More information about the SciPy-User
mailing list