extended IFFT

If I have a waveform xsuch as

x = [math.sin(W*t + Ph) for t in range(16)]

with arbitrary Wand Ph, and I calculate its (Real) FFT fusing

f = numpy.fft.rfft(x)

I can get the original xwith

numpy.fft.irfft(f)

Now, what if I need to expand the range of the reconstructed waveform by the number of samples left and right? That is, the waveform is ysuch that len(y) == 48, y[16:32] == xand y[0:16], y[32:48]are periodic extensions of the original waveform.

In other words, if the FFT assumes that its input is an endless function f(t)that has been selected above t = 0, 1, ... N-1, how can I restore the values f(t)for t<0and t>=N?

: , x : , x = range(16) x = np.random.rand(16), .wav.

+5
3

, , ? y , len (y) == 48, y [16:32] == x y [0:16], y [32:48] .

x, .

, FFT , f (t), t = 0, 1,... N-1, f (t) t < 0 t >= N?

"N- FFT ", N. , , , , N N N .

W, N. . N N.

, .

, . - . , , . , . "" . . , , ( ).

. , sin (W * t + p) W p, . 10 16.

+3

, :

>>> x1 = np.random.rand(4)
>>> x2 = np.concatenate((x1, x1))
>>> x3 = np.concatenate((x1, x1, x1))
>>> np.fft.rfft(x1)
array([ 2.30410617+0.j        , -0.89574460-0.26838271j, -0.26468792+0.j        ])
>>> np.fft.rfft(x2)
array([ 4.60821233+0.j        ,  0.00000000+0.j        ,
       -1.79148921-0.53676542j,  0.00000000+0.j        , -0.52937585+0.j        ])
>>> np.fft.rfft(x3)
array([ 6.91231850+0.j        ,  0.00000000+0.j        ,
        0.00000000+0.j        , -2.68723381-0.80514813j,
        0.00000000+0.j        ,  0.00000000+0.j        , -0.79406377+0.j        ])

, - 3 :

np.concatenate((np.fft.irfft(f),) * 3)

, :

>>> a = np.arange(4)
>>> f = np.fft.rfft(a)
>>> n = 3
>>> ext_f = np.zeros(((len(f) - 1) * n + 1,), dtype=f.dtype)
>>> ext_f[::n] = f * n
>>> np.fft.irfft(ext_f)
array([ 0.,  1.,  2.,  3.,  0.,  1.,  2.,  3.,  0.,  1.,  2.,  3.])
+3

, FFT, IFFT (FFT()), . , , , , Sinc. - -. , / , . , , , , - IFFT - .

+1
source

All Articles