# Fourier Series as a Low Pass Filter

After 10 years of experience in the specialty, after graduating from the institute, the very first case came when it was necessary to recall the Fourier transform from the course of special sections of mathematical analysis.

Let’s say we have a signal with a very noisy high-frequency component. For specifics, let it be a graph of natural light versus time. Here is an example like this:

In this case, the lowest frequency component of this signal is of interest. The one with a period of 24 hours. It is necessary to determine the amplitude and phase of the very first harmonic. This signal is measured by real physical sensors and written to a text *.csv file.

``````1986, 1412.500,  17.75, 10:11:39, 13/7/2023, 1517844955
1987, 1410.833,  17.75, 10:11:59, 13/7/2023, 1517844975
1988, 1410.833,  17.75, 10:12:19, 13/7/2023, 1517844995
1989, 1410.000,  17.75, 10:12:39, 13/7/2023, 1517845015
1990, 1413.333,  17.75, 10:12:59, 13/7/2023, 1517845035
1991, 1415.833,  17.75, 10:13:19, 13/7/2023, 1517845055
1992, 1420.833,  17.75, 10:13:39, 13/7/2023, 1517845075
1993, 1424.167,  17.75, 10:13:59, 13/7/2023, 1517845095
...``````

X axis is the 6th column, Y axis is the 2nd column. In this case, the task is to isolate the phase of this signal.

How to isolate the phase of a noisy signal?

It is clear that it is necessary to somehow generalize this signal. Pass it through a low pass filter.

If we pass the signal through a digital moving average filter (FIR filter), the output signal will shift in phase to the right and the real phase will be distorted. We need another way.

It is known from higher mathematics that any periodic and piecewise continuous function can be represented as a sum of sines of different amplitudes and different phases according to formula (1)

In this implementation, the DFT time complexity is O(N^2) where N is the number of elements in the signal sample.

Here is the spectrum of this signal. Here is the period in hours.

The modulus of the complex number will be the amplitude of the sine, the argument of the complex number will be the phase of the sine. Further, we simply substitute these numbers into the formula (1) and the result of the filtering is obtained.

Here are some expansions in a Fourier series up to the first harmonic. As you can see, the phase was determined quite reliably.

By the way, the Fourier series is an excellent option for compressing periodic data. Instead of a huge periodic signal log file, you simply store an array of several pairs of real coefficients for the amplitude and phase of this particular harmonic of the Fourier series. Further, according to these coefficients, the function is approximately restored to the degree of accuracy that you need. However, there is a loss in the quality of the original signal. That is, the Fourier series can be used to compress experimental data.

Advantages of a low-pass filter on the Fourier transform

–If we calculate the DFT, reset the high frequencies and calculate the inverse DFT, then the phase of those low-frequency harmonics that we left does not change.

–Fourier transform based filter suitable for post-processing

Disadvantages of a low-pass filter on the Fourier transform

–It is difficult to imagine the operation of such a filter in real time. After all, you need a lot of calculations O (n ^ 2). Ideally, you want to calculate the Fourier transform for the last N cycles, discard high-frequency harmonics and calculate the inverse Fourier transform. It’s still O(n) steps. And all this should happen in one cycle. But this is prohibitively many calculations compared to the same FIR filter.

–Need to know the lowest frequency in advance. The resulting Fourier series formula will draw the signal with a period equal to the sample size multiplied by the sampling period.

–Fourier transform is not suitable for non-periodic signals.

Conclusion

From the Fourier transform, you can make a low-pass filter. The Fourier transform is great at finding not only frequencies within a signal, but also finding the phases of those frequencies.

Fourier series theory is great for post-processing a periodic signal, if you need to highlight some individual frequencies in this signal.

Dictionary

 Acronym Decryption FIR finite impulse response DFT Discrete Fourier Transform