VOOZH about

URL: https://towardsdatascience.com/the-fourier-transform-2-understanding-phase-angle-a85ad40a194e/

⇱ Fourier Transform, Applied (2): Understanding phase angle | Towards Data Science


Fourier Transform, Applied (2): Understanding phase angle

Understanding phase angle

2 min read

Understanding the basics of FFT phase

In the previous post, the visualizations exclusively addressed the magnitude of the Fourier transform. Here, we will expand on the missing piece: phase!

Check out the previous articles in the series!

The Fourier Transform (1)


In the previous post, I showed how the magnitude of the Fourier transform could be used to estimate the frequency components of a signal. With just frequency, though, we can’t perfectly reconstruct a signal; we need phase!

👁 Figure 1: Three identical sinusoids offset in phase. Image by author.
Figure 1: Three identical sinusoids offset in phase. Image by author.

What if we look at a pure tone audio file, but we shift the signal left to right?

In our previous audio example, this presents a challenge. All three of the signals to the left (Figure 1) have the same frequency. The rate of oscillation between high pressure and low pressure is the same. The only difference is the starting position, shifting left to right.

We can express this as a "phase shift." The three signals are the same frequency, just offset in the starting position in the oscillation. Looking at the three generating equations, respectively – 0.5 cos(5x), 05 cos(5x + 1), and 0.5 * cos(5x + 2) – this offset is expressed as the summed value in the cosine expression, i.e. 0, 1, and 2.

👁 Figure 2: The approximate phase recovered using the np.angle of the Fourier transform. Image by author.
Figure 2: The approximate phase recovered using the np.angle of the Fourier transform. Image by author.

This phase information is also expressed in the Fourier transform and can be recovered with the numpy "angle" function. If we look at the phase value at the same index as the frequency with the maximum magnitude, we can identify the phase offset associated with that frequency component. Here (Figure 2), the Fourier transform recovers 0, 1, and 2 from the equations above!


Understanding-Fourier/fourier_2 at master · peterbbryan/Understanding-Fourier


Give the article a clap if the repo or text were valuable to you! Thanks for reading!


Check out the next article in the series!

The Fourier Transform (3): Magnitude and phase encoding in complex data


Written By

Peter Barrett Bryan

Towards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.

Write for TDS

Related Articles