removed old code for kaiser window and use numpy method directly

This commit is contained in:
2026-03-19 12:41:08 +01:00
parent ee389d8290
commit df34447ef2
+4 -28
View File
@@ -1,7 +1,5 @@
import numpy
import sys
from . import autophase
from functools import reduce
class DamarisFFT:
@@ -26,21 +24,19 @@ class DamarisFFT:
start, stop = stop, start
# do nothing if one uses clip as a "placeholder"
if start == None and stop == None:
if start is None and stop is None:
return self
if start == None:
if start is None:
start = self.x[ 0 ]
if stop == None:
if stop is None:
stop = self.x[ -1 ]
# check if data is fft which changes the start/stop units
if self.xlabel == "Frequency / Hz":
isfft = True
start = self.x.size * (0.5 + start / self.sampling_rate)
stop = self.x.size * (0.5 + stop / self.sampling_rate)
else:
isfft = False
# get the corresponding indices
start *= self.sampling_rate
stop *= self.sampling_rate
@@ -147,7 +143,6 @@ class DamarisFFT:
"""
Symmetric centered window (bartlett)
"""
apod = numpy.bartlett( self.x.size )
for i in range( 2 ):
self.y[ i ] = self.y[ i ] * apod
@@ -157,26 +152,7 @@ class DamarisFFT:
"""
Symmetric centered window (kaiser)
"""
if use_scipy == None:
# modified Bessel function of zero kind order from somewhere
def I_0( x ):
i0 = 0
fac = lambda n: reduce( lambda a, b: a * (b + 1), list(range( n)), 1 )
for n in range( 20 ):
i0 += ((x / 2.0) ** n / (fac( n ))) ** 2
return i0
t = numpy.arange( self.x.size, type=numpy.Float ) - self.x.size / 2.0
T = self.x.size
# this is the window function array
apod = I_0( beta * numpy.sqrt( 1 - (2 * t / T) ** 2 ) ) / I_0( beta )
else:
# alternative method using scipy
import scipy
apod = scipy.kaiser( self.x.size, beta )
apod = numpy.kaiser( self.x.size, beta )
for i in range( 2 ):
self.y[ i ] = self.y[ i ] * apod
return self