Phys 229 Assignment.pdf

2
Assignment 4 : Fourier Transform The Fourier transform is a powerful technique for the decomposition of time series signals into a spectrum of sine waves. This assignment will help you understand Fourier transforms and how to use them in python. Submission: For all questions, include any input, output, plots, scripts and data files (that are not supplied to you) in the PDF that you hand in. Additionally uploaded files will not be marked. 1. Fourier transform of sine waves Download the python script fourier_transform.py from connect into your own directory and open it with spyder. The script creates a simple sine-wave signal and performs a Fourier transform. Upon execution, both input and output of the transform are plotted. a) Change the sine-wave signal to y ( t )=2.3 sin ( 2 π⋅ 3 t ) and plot the wave and Fourier transform output. b) Add two more sine waves to the signal with different amplitudes and frequencies < 30, such that y(t) is the superposition of three sine waves. Again plot the input and output of the Fourier transform. Explain how the three waves appear in the Fourier output and how frequencies and amplitudes of the different waves can be identified. 2. Fourier transform of a square wave Download the data file squareWave.csv from connect into your own directory. Instead of creating the time and wave signal in the script, load them from the data file and perform the Fourier transform. Again, report input signal and output signal, yet with the following adjustments: Change the y-axis limit of the wave plot such that the upper and lower boundaries of the square wave are clearly visible. For the Fourier transform output, only show frequencies < 10 Hz. The square wave can be decomposed to a series of sine waves. What are the frequencies of the main three (largest amplitudes) sine waves that the square wave is composed of? Identify the main three sine waves (largest amplitudes), state their frequencies and compare them with the frequency of the square wave. Hint: If you don't remember how to load data files in python, have a look at the script “plot_csv_data.py” that you can find on connect. The limits of the plot axes can be altered with plt.xlim() and plt.ylim(). Assignment 4 page 1 of 2

Transcript of Phys 229 Assignment.pdf

Page 1: Phys 229 Assignment.pdf

Assignment 4 : Fourier TransformThe Fourier transform is a powerful technique for the decomposition of time series signals into a spectrum of sine waves. This assignment will help you understand Fourier transforms and how to use them in python.

Submission: For all questions, include any input, output, plots, scripts and data files (that are not supplied to you) in the PDF that you hand in. Additionally uploaded files will not be marked.

1. Fourier transform of sine waves

Download the python script fourier_transform.py from connect into your own directory and open it with spyder. The script creates a simple sine-wave signal and performs a Fourier transform. Upon execution, both input and output of the transform are plotted.

a) Change the sine-wave signal to y (t)=2.3sin(2π⋅3 t ) and plot the wave and Fourier transform output.

b) Add two more sine waves to the signal with different amplitudes and frequencies < 30, such that y(t) is the superposition of three sine waves. Again plot the input and output of the Fourier transform. Explain how the three waves appear in the Fourier output and how frequencies and amplitudes of the different waves can be identified.

2. Fourier transform of a square wave

Download the data file squareWave.csv from connect into your own directory. Instead of creating the time and wave signal in the script, load them from the data file and perform the Fourier transform. Again, report input signal and output signal, yet with the following adjustments: Change the y-axis limit of the wave plot such that the upper and lower boundaries of the square wave are clearly visible. For the Fourier transform output, only show frequencies < 10 Hz. The square wave can be decomposedto a series of sine waves. What are the frequencies of the main three (largest amplitudes) sine waves that the square wave is composed of? Identify the main three sine waves (largest amplitudes), state theirfrequencies and compare them with the frequency of the square wave.

Hint: If you don't remember how to load data files in python, have a look at the script “plot_csv_data.py” that you can find on connect. The limits of the plot axes can be altered with plt.xlim() and plt.ylim().

Assignment 4 page 1 of 2

Page 2: Phys 229 Assignment.pdf

3. Finite series

Download the data files squareWave.csv, squareWave_1.csv and squareWave_2.csv from connect into your own directory. Load all three data sets in the script and plot the three signals together, using a legend and different colors to distinguish them. Compare the signals, are they following the same pattern? How are they different? Now, perform a Fourier transform of all three signals and plot the results together, again using a legend and different colors. Compare the frequency spectra: Do they share common frequencies? How do they differ from each other? Can you guess how the wave signals were created?

Hint: The plt.plot() command accepts an optional parameter “label=NAME”, and plt.legend creates a legend of all plotted lines with the content of “label” (in the above case it is NAME) as tags.

4. Noise in an open wire

Download the data file openWire.csv from connect into your own directory. This data is the noise measured on an oscilloscope that was connected to an open wire. Load the signal from the data file and plot it. Let's assume that this data is consistent with white noise. How does the Fourier transform of true white noise look like? Now, perform a Fourier transform of the measured data and plot the results. Do you find any differences w.r.t. the expectation for white noise? Is there any particular frequency thatstands out? Which value does it have, and where do you think does it come from?

Hint: To identify the frequency of peaks, change the axis limits to “zoom in” on it, and add a vertical line at the peak frequency via plt.axvline(frequency).

Assignment 4 page 2 of 2