There is a set of functions for FFT (Fourier Transforms) in SciPy. They are easy to use, given the amount of processing that needs to take place.
We can perform a FFT using coding as follows:
from scipy.fftpack import fft
import numpy as np
x = np.array([2.0, 1.0, 2.0, 1.0, 2.0])
fft(x)
Here, we have a small dataset to analyze. The data points represent a small signal set we have to evaluate. When taken under Jupyter, we get a display as the following:
Note that even for this small set of data, the transform operation was busy for several seconds.
We could also use a generated dataset as in this coding:
from scipy.fftpack import fft
import numpy as np
# how many points
n = 100
spacing = 1.0 / 250.0
x = np.linspace(0.0, n*spacing, n)
y = np.sin(30.0 * np.pi * x) + 0.5 * np.sin(7.0 * np.pi * x)
yf = fft(y)
xf = np.linspace(0.0, 1.0/(2.0*spacing), n//2)
#plot the data to get a visual
import matplotlib.pyplot as plt
plt.plot(xf, 2.0/n * np.abs(yf[0:n//2]))
plt.grid()
plt.show()
Running this script under Jupyter generates this graphic of the data points in a new screen:
This looks along the lines of what we expected, with a big and small wave in the display.