[SciPy-user] scipy.signal.firwin

Tom K. tpk@kraussfamily....
Sat Mar 21 12:49:52 CDT 2009

```

Tom K. wrote:
>
>
> Bugzilla from ndbecker2@gmail.com wrote:
>>
>> Jan Rauberg wrote:
>>
>>> Lev Givon <lev <at> columbia.edu> writes:
>>>
>>>>
>>
>>>> If you want to create a high-pass filter, just specify the cutoff to
>>>> firwin and flip the signs of the obtained coefficients, i.e.,
>>>>
>>>> b = -firwin(N,cutoff)
>>>>
>>>> L.G.
>>>>
>>>
>>>
>>> Thank you for the fast response. But in the way as you described I get
>>> an
>>> inverted low pass figure. That's not a high pass and no solution for my
>>> problem too. Perhaps there is another solution? J.R.
>>
>> A trivial (not ideal) solution is G(z) = 1-H(z)
>>
>>
>
> Simple inversion won't do the trick - you can invert the spectrum as Jan
> suggests, or shift the entire spectrum by pi radians.
>
> Example:
>
> from scipy import signal
> import numpy as np
>
> N=11
> h=signal.firwin(11, .3)
> n=np.arange(-(N/2), (N/2)+1)
>
> 1) spectrum inversion G(z) = 1-H(z)
> How: Subtract original filter from a kronecker delta function.
> g=(n==1)-h
>
> 2) shift entire spectrum by pi radians
> How: Elementwise multiply by (-1)**n
> g1=(-1)**n*h
>
> The resulting highpass filters will have different characteristics:
>  g is complementary filter to h (bandwidth is pi-bandwidth(h))
>  g1 has same bandwidth as h
>
> These techniques won't work for even length filters, but you probably
> won't want an even length highpass filter anyway because of the null at pi
>
>   - Tom K.
>
>
>
And now, with my typos fixed:
N=11
h=signal.firwin(N, .3)
n=np.arange(-(N/2), (N/2)+1)
g=(n==0)-h  # (n==0) has a single "1" where n[k]==0, and zeros else
g1=(-1)**n*h  # (-1)**n is [-1, +1, -1, ...] with a "+1" at n[k]==0

--
View this message in context: http://www.nabble.com/scipy.signal.firwin-tp22587139p22638571.html
Sent from the Scipy-User mailing list archive at Nabble.com.

```