Exercise 8: Using Fourier Transform to get the spectrum of a data series.

8.1 Math background.

Lets assume we have data (f(t) consisting of tidal height taken each hour and we want to compute the spectrum of the data to see what the main components of the tidal signal are.

Without going into the detailed math (integrals and so on) it is sufficient here to say that the amplitude spectrum = absolute value of the fourier transform (FT) of the data.

When we take the FT of data we get back estimates of the amplitude and phase of each frequency component comprising the data. So for frequency f we will get a value A*exp(i*B). This is a complex number and can also be represented as A*cos(B) + i * A*sin(B) = c + i * d.

Given c + i * d we have that A= sqr(c^2+d^2) and B = atan(d/c).

Lets do an example.

8.2 Generate data and get the spectrum

We can simulate tidal data by generating a periodic function y(t) = cos(2*pi*f1) + sin(2*pi*f2); where f1 = 2 cycles / day and f2 = 1 cycle /day or (m/24) cycles /hr ) and the time interval is one hour.

You must use a number of data points that is a multiple of 2, ie 2,4,8,16,32,64,128 etc. The FT program requires this.

After generating the time function use tools/data analysis/fourier transform to get the transform. This will return the complex numbers c + i* d. To get the spectrum you must calculate sqr(c^2+d^2) . You can use the IMABS function to do this.

Then make a plot of the spectrum and versus frequency. The frequency scale must be calculated as follows. The max frequency is given by fmax = 1/2*(sample time interval). The frequency interval is given by fmax/ (number of frequencies) and the number of frequencies is = (no. time samples/2) + 1