Merge pull request #429 from pijyoi/fixfftslice

fix fft premature slicing away of 0 freq bin
This commit is contained in:
Luke Campagnola 2017-02-03 02:25:05 -08:00 committed by GitHub
commit 154b6bacb1

View File

@ -679,10 +679,11 @@ class PlotDataItem(GraphicsObject):
x2 = np.linspace(x[0], x[-1], len(x)) x2 = np.linspace(x[0], x[-1], len(x))
y = np.interp(x2, x, y) y = np.interp(x2, x, y)
x = x2 x = x2
f = np.fft.fft(y) / len(y) n = y.size
y = abs(f[1:len(f)/2]) f = np.fft.rfft(y) / n
dt = x[-1] - x[0] d = float(x[-1]-x[0]) / (len(x)-1)
x = np.linspace(0, 0.5*len(x)/dt, len(y)) x = np.fft.rfftfreq(n, d)
y = np.abs(f)
return x, y return x, y
def dataType(obj): def dataType(obj):