X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=FFT_tools.py;h=91670785172b1072479d6b7b88f7622b28aa8f28;hp=b6b7b353ecf12dd25c9ed1da8be136ce50d223d8;hb=22367d5bba0e723b7a578070241686f165d66310;hpb=2229b7919df93e1b29af4e7617e95a195acf64c8 diff --git a/FFT_tools.py b/FFT_tools.py index b6b7b35..9167078 100644 --- a/FFT_tools.py +++ b/FFT_tools.py @@ -1,6 +1,7 @@ -#!/usr/bin/python +# Copyright + +"""Wrap :mod:`numpy.fft` to produce 1D unitary transforms and power spectra. -""" Define some FFT wrappers to reduce clutter. Provides a unitary discrete FFT and a windowed version. Based on numpy.fft.rfft. @@ -45,7 +46,6 @@ def ceil_pow_of_two(num) : return num def _test_rfft(xs, Xs) : - print "Test numpy rfft definition" # Numpy's FFT algoritm returns # n-1 # X[k] = SUM x[m] exp (-j 2pi km /n) @@ -70,6 +70,7 @@ def _test_rfft(xs, Xs) : "Mismatch on Parseval's, %g != 1/%d * %g" % (timeSum, n, freqSum) def _test_rfft_suite() : + print "Test numpy rfft definition" xs = [1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1] _test_rfft(xs, rfft(xs)) @@ -120,7 +121,6 @@ def unitary_rfft(data, freq=1.0) : return (freq_axis, trans) def _test_unitary_rfft_parsevals(xs, freq, freqs, Xs): - print "Test unitary rfft on Parseval's theorem" # Which should satisfy the discretized integral form of Parseval's theorem # n-1 n-1 # SUM |x_m|^2 dt = SUM |X_k|^2 df @@ -139,6 +139,7 @@ def _test_unitary_rfft_parsevals(xs, freq, freqs, Xs): % (lhs, rhs) def _test_unitary_rfft_parsevals_suite(): + print "Test unitary rfft on Parseval's theorem" xs = [1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1] dt = pi freqs,Xs = unitary_rfft(xs, 1.0/dt) @@ -161,6 +162,7 @@ def _test_unitary_rfft_rect(a=1.0, time_shift=5.0, samp_freq=25.6, samples=256) t = i*dt x[i] = _rect(a*(t-time_shift)) freq_axis, X = unitary_rfft(x, samp_freq) + #_test_unitary_rfft_parsevals(x, samp_freq, freq_axis, X) # remove the phase due to our time shift j = complex(0.0,1.0) # sqrt(-1) @@ -209,6 +211,7 @@ def _test_unitary_rfft_gaussian(a=1.0, time_shift=5.0, samp_freq=25.6, samples=2 t = i*dt x[i] = _gaussian(a, (t-time_shift)) freq_axis, X = unitary_rfft(x, samp_freq) + #_test_unitary_rfft_parsevals(x, samp_freq, freq_axis, X) # remove the phase due to our time shift j = complex(0.0,1.0) # sqrt(-1)