<<

ESS 522

Exercise 2. of a Gaussian and

Note that your written answers can be brief but please turn in printouts of plots.

1. In class we have looked at the Fourier transform of continuous functions and we have shown that the Fourier transform of a delta (an impulse) is equally weighted in all frequencies. A sharp function in the time domain yields a very broad function in the frequency domain, and vice versa. This is a form of the uncertainty principle and a very important concept in signal analysis – it is not possible to have a very narrowband signal of short duration. We can demonstrate this by considering the Gaussian or that we will encounter later on in the class

The Gaussian distribution is given by 1 1 $ t 2 ' g(t) = 1 exp # , # * < t < * (1) 2 & 2 ) (2! ) " % 2" ( This function has a mean of zero and a root mean squared (RMS) deviation (a measure of its width) of τ, which is defined by " " # t 2g(t)dt # g(t)dt . (2) !" !" It turns out that the Fourier transform of a Gaussian is another Gaussian (showing so requires the use of complex variable theory).

(i) Write a MATLAB function that returns the Gaussian distribution given input arguments of a vector of times t and a value of RMS deviation tau. Plot an example.

(ii) Write a second function to calculate equation (2) and verify that the input Gaussian distribution has an RMS deviation of τ. (Note: since you are doing the integration numerically you will not show this exactly but you should be able to get pretty close provided your input times are fairly finely sampled and extend from -5τ to 5τ)

(iii) On the class web site you will find a function amplitudespectrum.m which computes the amplitude spectrum (the absolute value of the Fourier transform) of a time (or space) series. Explore qualitatively with the help of plots how changes in the width of the Gaussian function you create in the time domain (i.e., variations in parameter τ) affect the width of the amplitude spectrum.

(iv) By applying the function you wrote in (2) to the amplitude spectra of the Gaussian function with different values of τ, deduce a relationship between the width of a Gaussian in the time domain and the width of its amplitude spectrum.

2. The MATLAB file atg1year.mat which you can find on the web site contains one year’s worth of temperature data for the ATG roof. The first sample is dated 04/05/2005 19:27 UTC and the sample interval is 5 minutes.

1 ESS 522

(i) Plot the data. Are there any bad or suspect readings? How might you get rid of these? (There is no need to get rid of any bad data).

(ii) A common means to smooth data is to compute an N-point running mean. That is, each point is taken as an average of N points centered upon the point of interest – it is simplest to chose N odd with N = 2M + 1. Explain how this is equivalent to convolving the data with a time series of N points with values of 1/N.

(iii) Smooth the temperature data with this method using the MATLAB conv command for different choices of N. Note: that the MATLAB version of conv uses a built in function so you cannot see how it works but it performs convolution in the time domain just like we discussed in class. You will have to discard M points at either end of the convolved time series to get a time series of the same length as your input time series (or else you can make use of the 3rd argument of conv to do this for you). What is the best choice of N to get rid of daily (diurnal) fluctuations? Why is this value best? What happens at either end of the time series after convolving?

(iv) You can also attempt the convolution in the frequency domain for the optimal choice of N. Create a “boxcar” time series of the same length as the temperature data which is zero everywhere except for the first M+1 points and the last M points where it has a value 1/N. Do not try to convolve these with the conv command unless you fancy a coffee break because it will take a while to compute (at least on slower machines of 2005 vintage). Instead compute the FT of the temperature data and the boxcar using (MATLAB command fft), multiply the results together, then compute the inverse FT (MATLAB command ifft). Plot the result on top of the temperature time series obtained using conv. They should be the same except at the ends. Convolution in the frequency domain performs a cyclical convolution – we will explain what this is in class but you can think of the two time series wrapped around the edges of two disks which rotate relative to each other so that for each offset, every sample in one time series is matched with another for the convolution.

(v) Use the function amplitudespectrum to create a plot of the amplitude spectrum of the boxcar time series. Zoom in on the region around zero frequency and comment on its shape. Given that convolution is equivalent to multiplication what are the implications for using a boxcar (running mean) to eliminate high frequency noise. Again we will discuss this further in class.

(vi) We can also smooth the temperature data by convolving it with a Gaussian. Create a Gaussian function using the command you wrote for the last exercise whose RMS deviation τ is equivalent to the half-width of the boxcar. Multiply the Gaussian by a constant so that the sum of all the points in unity. Perform convolution in the time domain. Can you see any significant differences to the result from smoothing with a boxcar. Use the MATLAB zoom tool or function to look at a few days in detail.

(vii) Now pad Gaussian with zeros so that it is the same length as the temperature time series and use the amplitudespectrum command to create a plot of the amplitude spectrum. How does it differ from the plot for the boxcar? Again we will discuss this further in class.

2