High-pass, Low-pass and Band-pass Filtering


Program objectives

The high-pass, low-pass and band-pass filterings are techniques used to remove spectral components for a frequency given (or a frequency interval). These classical filtering techniques are described in detail by Papoulis (1962) and Bath (1974). You can compute these filtering techniques by means of the present program, as it will be described below.

Program description

The SPECTRUM program and its files, which are needed to run this application, are enclosed into a ZIP file named "spectrum.zip". When you have got the ZIP file and you have uncompressed this file, you have five files named spectrum.exe, spectrum.dat, series.dat, segnal1.dat and segnal2.dat. The file named spectrum.dat contains the names of the input files with the spectra to be analysed by the program spectrum.exe. The maximum number of records in each input file that the program can handle is 50000. This file also contains the number of files to be analysed (in the first line) and the file names of the output files, which will be generated by the SPECTRUM program, with the results of the filtering selected. In this example, the input files named espectro1.dat and espectro2.dat are generated by the SERIES program which provides us the spectra to be analysed using the files series.dat, segnal1.dat and segnal2.dat. The results of the SERIES program are enclosed in the files espectro1.dat and espectro2.dat. These files are used, as sample files, to run the SPECTRUM program.

Running the program

Firstly, we need obtain the input files espectro1.dat and espectro2.dat, to be analysed with the SPECTRUM program. For it, the SERIES program can be very useful. This program can be run with the input files: series.dat, segnal1.dat and segnal2.dat, which are enclosed in the ZIP file named spectrum.zip. After that, the files espectro1.dat and espectro2.dat are obtained and we can run the SPECTRUM program using these files and the file named spectrum.dat. When we run this program the following menu is displayed:

Filtering menu:
===========

0. Restitution of the signal without any filtering.
1. High-pass filtering.
2. Low-pass filtering.
3. Band-pass filtering.

... select the option (0,1,2,3):

Then, we can do each action shown in this menu entering the corresponding number, as it will be described below.

Restitution of the signal without any filtering (option 0)

When you enter the number 0, the program computes the inverse FFT of the spectra enclosed in the files espectro1.dat and espectro2.dat, without any filtering. This option can be very useful, because it allows the computation the inverse FFT for any spectrum, provided by any program, to obtain its corresponding time signal. In this example, the output files signal1.dat and signal2.dat, generated by the SPECTRUM program, contain the same data as the enclosed in the files segnal1.dat and segnal2.dat, as it can be seen in Figure 1. The origin time of the time series contained in the output files signal1.dat and signal2.dat will be always zero, because the FFT spectra have not any information about this time (Bath, 1974).
Fig. 1. (a) Time signal contained in the file segnal1.dat. (b) Time signal contained in the file segnal2.dat

High-pass filtering (option 1)

When you enter the number 1, the program performs a high-pass filtering of the time signal, applying a cosine-rectangular window to the spectra (Bath, 1974), as it is shown in Figure 2. For it, the program asks the period in which the high-pass filter will be located, this question is asked by the text:

Maximum period (in seconds):

In this example, the period selected has been 2 s. The amplitude spectra windowed can be seen in Figure 3. When the SPECTRUM program has finished the output files signal1.dat and signal2.dat are generated. These files contain the inverse FFT of the spectra contained in the input files espectro1.dat and espectro2.dat, high-pass filtered to the period of 2 s. Figure 4 shows the results of this filtering in the time domain. The program also generates an output data file containing the frequency window applied to the spectra (printed in two columns: period, amplitude). This file has the name window.dat.
Fig. 2. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat. The vertical bar (black line) shows the period selected to perform the high-pass filtering.
Fig. 3. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat, high-pass filtered to 2 s of period. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat, high-pass filtered to 2 s of period. The vertical bar (black line) shows the period selected to perform the high-pass filtering.
Fig. 4. (a) Time-signal high-pass filtered to 2 s of period, contained in the file signal1.dat. (b) Time-signal high-pass filtered to 2 s of period, contained in the file signal2.dat

Low-pass filtering (option 2)

When you enter the number 2, the program performs a low-pass filtering of the time signal, applying a cosine-rectangular window to the spectra (Bath, 1974), as it is shown in Figure 5. For it, the program asks the period in which the low-pass filter will be located, this question is asked by the text:

Minimum period (in seconds):

In this example, the period selected has been 1 s. The amplitude spectra windowed can be seen in Figure 6. When the SPECTRUM program has finished the output files signal1.dat and signal2.dat are generated. These files contain the inverse FFT of the spectra contained in the input files espectro1.dat and espectro2.dat, low-pass filtered to the period of 1 s. Figure 7 shows the results of this filtering in the time domain. The program also generates an output data file containing the frequency window applied to the spectra (printed in two columns: period, amplitude). This file has the name window.dat.
Fig. 5. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat. The vertical bar (black line) shows the period selected to perform the low-pass filtering.
Fig. 6. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat, low-pass filtered to 1 s of period. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat, low-pass filtered to 2 s of period. The vertical bar (black line) shows the period selected to perform the low-pass filtering.
Fig. 7. (a) Time-signal low-pass filtered to 2 s of period, contained in the file signal1.dat. (b) Time-signal low-pass filtered to 2 s of period, contained in the file signal2.dat

Band-pass filtering (option 3)

When you enter the number 3, the program performs a band-pass filtering of the time signal, applying a cosine-rectangular window to the spectra (Bath, 1974), as it is shown in Figure 8. For it, the program asks the periods in which the band-pass filter will be located, this question is asked by the text:

Minimum period (in seconds): Maximum period (in seconds):

In this example, the period interval selected has been from 1 to 2 s. The amplitude spectra windowed can be seen in Figure 9. When the SPECTRUM program has finished the output files signal1.dat and signal2.dat are generated. These files contain the inverse FFT of the spectra contained in the input files espectro1.dat and espectro2.dat, band-pass filtered into the period interval (1, 2) s. Figure 10 shows the results of this filtering in the time domain. The program also generates an output data file containing the frequency window applied to the spectra (printed in two columns: period, amplitude). This file has the name window.dat.
Fig. 8. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat. The vertical bars (black line) show the period interval selected to perform the band-pass filtering.
Fig. 9. (a) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro1.dat, band-pass filtered into the period interval from 1 to 2 s. (b) Cosine-rectangular window considered (red line) and the amplitude spectrum (blue line) contained in the file espectro2.dat, band-pass filtered into the period interval from 1 to 2 s. The vertical bars (black line) show the period interval selected to perform the band-pass filtering.
Fig. 10. (a) Time-signal band-pass filtered into the period interval of (1, 2) s, contained in the file signal1.dat. (b) Time-signal band-pass filtered into the period interval of (1, 2) s, contained in the file signal2.dat

References

Bath M., 1974. Spectral analysis in Geophysics. Elsevier, Amsterdam.

Papoulis A., 1962. The Fourier integral and its applications. McGraw-Hill, New York.