Analyzing the frequency components of a signal with a Fast Fourier Transform
In this recipe, we will show how to use a Fast Fourier Transform (FFT) to compute the spectral density of a signal. The spectrum represents the energy associated to frequencies (encoding periodic fluctuations in a signal). It is obtained with a Fourier transform, which is a frequency representation of a time-dependent signal. A signal can be transformed back and forth from one representation to the other with no information loss.
In this recipe, we will illustrate several aspects of the Fourier transform. We will apply this tool to weather data spanning 20 years in France obtained from the US National Climatic Data Center.
How to do it...
Let's import the packages, including
scipy.fftpack
, which includes many FFT- related routines:>>> import datetime import numpy as np import scipy as sp import scipy.fftpack import pandas as pd import matplotlib.pyplot as plt %matplotlib inline
We import...