[Scipy-svn] r2240 - in trunk/Lib: sandbox signal
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Oct 5 01:55:20 EDT 2006
Author: oliphant
Date: 2006-10-05 00:55:13 -0500 (Thu, 05 Oct 2006)
New Revision: 2240
Added:
trunk/Lib/sandbox/oliphant/
Modified:
trunk/Lib/signal/signaltools.py
Log:
Add flat top window
Modified: trunk/Lib/signal/signaltools.py
===================================================================
--- trunk/Lib/signal/signaltools.py 2006-10-02 08:17:40 UTC (rev 2239)
+++ trunk/Lib/signal/signaltools.py 2006-10-05 05:55:13 UTC (rev 2240)
@@ -668,7 +668,25 @@
w = w[:-1]
return w
+def flattop(M,sym=1):
+ """The M-point Flat top window.
+ """
+ if M < 1:
+ return array([])
+ if M == 1:
+ return ones(1,'d')
+ odd = M % 2
+ if not sym and not odd:
+ M = M+1
+ a = [0.2156, 0.4160, 0.2781, 0.0836, 0.0069]
+ n = arange(0,M)
+ fac = n*2*pi/(M-1.0)
+ w = a[0] - a[1]*cos(fac) + a[2]*cos(2*fac) - a[3]*cos(3*fac) + a[4]*cos(4*fac)
+ if not sym and not odd:
+ w = w[:-1]
+ return w
+
def bartlett(M,sym=1):
"""The M-point Bartlett window.
"""
@@ -734,6 +752,8 @@
w = w[:-1]
return w
+
+
def kaiser(M,beta,sym=1):
"""Returns a Kaiser window of length M with shape parameter beta.
"""
@@ -1214,7 +1234,8 @@
winfunc = nuttall
elif winstr in ['barthann', 'brthan', 'bth']:
winfunc = barthann
-
+ elif winstr in ['flattop', 'flat', 'flt']:
+ winfunc = flattop
elif winstr in ['kaiser', 'ksr']:
winfunc = kaiser
elif winstr in ['gaussian', 'gauss', 'gss']:
More information about the Scipy-svn
mailing list