Ticket #581 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

chebwin improvement: use the Chebyshev polynomial

Reported by: akumar Owned by: somebody
Priority: normal Milestone: 0.7.0
Component: scipy.signal Version:
Keywords: Cc: akumar@…

Description

Hi!

I noticed that the Dolph Chebyshev I wrote earlier was not working due to some issues with the hyperbolic functions. For example:

In [2]: signal.chebwin(20, 50)
Out[2]: 
array([ NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,
        NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN])

In [3]: signal.chebwin(10, 50)
Out[3]: array([ NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN,  NaN])

I prodded it a bit, and found that the issue lies with the way I am calculating the Chebyshev polynomial. After two hours, I gave up and tried using the special.chebyt function, only to find that it works perfectly.

All values are matching the Matlab generated ones (from my test). I am attaching diff of signaltools.py, which applies against the HEAD of SVN. Please consider adding it.

Thanks.

Kumar Appaiah

Attachments

chebwin_patch.diff (1.4 KB) - added by akumar 4 years ago.
chebwin fix: patch applies to SVN HEAD
chebwin.py (1.1 KB) - added by akumar 4 years ago.
Fixed chebwin function
chebwin-fix.patch (1.6 KB) - added by rmay 4 years ago.
Patch against SVN head that makes chebwin work for high orders
test_chebwin.py (1.5 KB) - added by rmay 3 years ago.
Test cases for chebwin. These values are sensible in both the time and frequency domains.

Change History

Changed 4 years ago by akumar

chebwin fix: patch applies to SVN HEAD

Changed 4 years ago by akumar

Fixed chebwin function

Changed 4 years ago by akumar

Referring to http://projects.scipy.org/pipermail/scipy-user/2008-February/015574.html gives a solution to this bug. Is there any chance of this making it into SciPy??

Thanks.

Kumar

Changed 4 years ago by cdavid

  • priority changed from high to normal

Changed 4 years ago by rmay

Patch against SVN head that makes chebwin work for high orders

Changed 4 years ago by rmay

Ok, the attached patch makes chebwin work for me, on at least 52nd and 53rd order windows. I'm willing to submit test case(s) if someone can give me guidance on how I'm supposed to test something like this. Do I just accept the current output of my code as working and use that as truth? Anyhow, can we get this in for 0.7?

Changed 4 years ago by rmay

I guess I should clarify, for those who didn't read the mailing list post. The built in chebyt uses an expansion, which becomes less accurate as you increase the order. Since the chebyshev window uses an (n-1)th order polynomial for a window with n points, this becomes a problem. I was able to hit a problem with just 53 points, which really isn't *that* many for a window function. This patch changes chebwin to go back to using the analytical definition of the Chebyshev (Tn) polynomial, and it corrects the previous implementation to work for all of the domain of Tn.

Changed 3 years ago by rmay

Test cases for chebwin. These values are sensible in both the time and frequency domains.

Changed 3 years ago by stefan

  • status changed from new to closed
  • resolution set to fixed

Thanks, Kumar and Ryan, for supplying patches and tests. Fixed in r4662.

Note: See TracTickets for help on using tickets.