Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analog poles and zeros of elliptic filter are different from scipy #75

Open
ToGoOrNotToGo opened this issue Apr 1, 2023 · 2 comments
Open

Comments

@ToGoOrNotToGo
Copy link

The analog poles and zeros of the elliptic filter are different from scipy. Is this a bug or there are different elliptic prototype design?

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ellip.html#scipy.signal.ellip

@ar1st0crat
Copy link
Owner

Can you provide any particular examples?
I took example from scipy docs:

z, p, k = signal.ellip(4, 5, 40, 100, 'low', output='zpk', analog=True)

This yields

>>> z
array([0.+273.40311861j, 0.+133.09448631j, 0.-273.40311861j,
       0.-133.09448631j])
>>> p
array([-16.5821937 -47.62311966j,  -3.98841045-96.14415841j,
       -16.5821937 +47.62311966j,  -3.98841045+96.14415841j])
>>>
>>> k
0.009999999999999992

Then I did the same thing in NWaves:

var poles = PrototypeElliptic.Poles(4, 5, 40);
var zeros = PrototypeElliptic.Zeros(4, 5, 40);

This yields

// poles
-0.03988410446959738 + 0.9614415840538687 j
-0.16582193703773462 + 0.47623119659115304 j
-0.16582193703773465 + -0.4762311965911529 j
-0.03988410446959739 + -0.9614415840538687 j

// zeros
0 + -1.3309448630630392 j
0 + -2.73403118612638 j
0 + 2.7340311861263804 j
0 + 1.3309448630630392 j

Essentially, it's identical to scipy's results (in NWaves the gain k is not returned separately, it's already in zeros and poles):

>>> z * k
array([0.+2.73403119j, 0.+1.33094486j, 0.-2.73403119j, 0.-1.33094486j])
>>>
>>>
>>> p * k
array([-0.16582194-0.4762312j , -0.0398841 -0.96144158j,
       -0.16582194+0.4762312j , -0.0398841 +0.96144158j])

@ToGoOrNotToGo
Copy link
Author

ToGoOrNotToGo commented Apr 23, 2023

I worded that a bit confusingly. I didn't mean an analog filter, but a digital filter (poles and zeros are always analog!?). I know, analog filters are not supported in NWaves.
b, a = ellip(13, 0.009, 80, 0.05, output='ba')
This results in different values in a and b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants