Ticket #581: chebwin-fix.patch
| File chebwin-fix.patch, 1.6 KB (added by rmay, 4 years ago) |
|---|
-
signaltools.py
old new 854 854 M = M+1 855 855 856 856 # compute the parameter beta 857 beta = cosh(1.0/(M-1.0)*arccosh(10**(at/20.))) 857 order = M - 1.0 858 beta = cosh(1.0/order * arccosh(10**(abs(at)/20.))) 858 859 k = r_[0:M]*1.0 859 860 x = beta*cos(pi*k/M) 860 861 #find the window's DFT coefficients 861 p = zeros(x.shape) * 1.0862 for i in range(len(x)):863 if x[i] < 1:864 p[i] = cos((M - 1) * arccos(x[i]))865 else:866 p[i] = cosh((M - 1) * arccosh(x[i]))862 # Use analytic definition of Chebyshev polynomial instead of expansion 863 # from scipy.special. Using the expansion in scipy.special leads to errors. 864 p = zeros(x.shape) 865 p[x > 1] = cosh(order * arccosh(x[x > 1])) 866 p[x < -1] = (1 - 2*(order%2)) * cosh(order * arccosh(-x[x < -1])) 867 p[numpy.abs(x) <=1 ] = cos(order * arccos(x[numpy.abs(x) <= 1])) 867 868 868 869 # Appropriate IDFT and filling up 869 870 # depending on even/odd M 870 871 if M % 2: 871 w = real(fft(p)) ;872 n = (M + 1) / 2 ;873 w = w[:n] / w[0] ;872 w = real(fft(p)) 873 n = (M + 1) / 2 874 w = w[:n] / w[0] 874 875 w = concatenate((w[n - 1:0:-1], w)) 875 876 else: 876 877 p = p * exp(1.j*pi / M * r_[0:M]) 877 w = real(fft(p)) ;878 n = M / 2 + 1 ;879 w = w / w[1] ;880 w = concatenate((w[n - 1:0:-1], w[1:n])) ;878 w = real(fft(p)) 879 n = M / 2 + 1 880 w = w / w[1] 881 w = concatenate((w[n - 1:0:-1], w[1:n])) 881 882 if not sym and not odd: 882 883 w = w[:-1] 883 884 return w
