Euler
Euler

Reputation: 141

Fourier transform of non periodic signal

I'm trying to calculate the Fourier transform of non periodical data in python, with non periodical I mean this. Usually we use have periodical data:

x=[0,1,2,3,4,5,6,7] 
y=[1,0,2,0,1,0,1,0]

And the Fourier transform and the frequency domain can be obtained easily,

from scipy.fft import fft, fftfreq, fftshift

f=fftfreq(len(x), dx)

fy=fft(y)

And with that we can easily calculate the Fourier transform using scipy fft, but in the case our data is not exactly periodical, for example,

x=[0,1,1.5,1.7,3,4,5...]
y=[...]

Anyone have some idea of how can be possible to obtain the Fourier transform using python if it's possible, or the mathematics principles that are used.

Upvotes: 0

Views: 1411

Answers (2)

Warren Weckesser
Warren Weckesser

Reputation: 114841

For such data, you can use least-squares spectral analysis. SciPy includes the function scipy.signal.lombscargle that computes the Lomb-Scargle periodogram. The docstring has an example; see Discrete fourier transformation from a list of x-y points for another example.

Upvotes: 3

ZVY545
ZVY545

Reputation: 404

You can't do an FFT of an unevenly sampled signal. That invalidates the assumptions of the math the FFT is based upon.

You'll have to resample the signal so you have evenly spaced samples.

Read this for more information: https://dsp.stackexchange.com/questions/8488/what-is-an-algorithm-to-re-sample-from-a-variable-rate-to-a-fixed-rate

Upvotes: 1

Related Questions