FOURIER ANALYSIS using Python

Similar documents
ENGIN 211, Engineering Math. Fourier Series and Transform

SEISMIC WAVE PROPAGATION. Lecture 2: Fourier Analysis

Tutorial Sheet #2 discrete vs. continuous functions, periodicity, sampling

natural frequency of the spring/mass system is ω = k/m, and dividing the equation through by m gives

a k cos kω 0 t + b k sin kω 0 t (1) k=1

Time and Spatial Series and Transforms

CHAPTER 4 FOURIER SERIES S A B A R I N A I S M A I L

University of Connecticut Lecture Notes for ME5507 Fall 2014 Engineering Analysis I Part III: Fourier Analysis

Amplitude and Phase A(0) 2. We start with the Fourier series representation of X(t) in real notation: n=1

Image Acquisition and Sampling Theory

THE FOURIER TRANSFORM (Fourier series for a function whose period is very, very long) Reading: Main 11.3

f (t) K(t, u) d t. f (t) K 1 (t, u) d u. Integral Transform Inverse Fourier Transform

University of Leeds, School of Mathematics MATH 3181 Inner product and metric spaces, Solutions 1

Damped harmonic motion

Frequency- and Time-Domain Spectroscopy

Fourier Series and Fourier Transforms

FOURIER ANALYSIS. (a) Fourier Series

G52IVG, School of Computer Science, University of Nottingham

Continuous-time Fourier Methods

APPENDIX A. The Fourier integral theorem

Periodic functions: simple harmonic oscillator

PS403 - Digital Signal processing

Properties of Fourier Series - GATE Study Material in PDF

The (Fast) Fourier Transform

Fourier Series. Fourier Transform

ESE 250: Digital Audio Basics. Week 4 February 5, The Frequency Domain. ESE Spring'13 DeHon, Kod, Kadric, Wilson-Shah

Today s lecture. The Fourier transform. Sampling, aliasing, interpolation The Fast Fourier Transform (FFT) algorithm

IB Paper 6: Signal and Data Analysis

2 Fourier Transforms and Sampling

E2.5 Signals & Linear Systems. Tutorial Sheet 1 Introduction to Signals & Systems (Lectures 1 & 2)

Exploring Fourier Transform Techniques with Mathcad Document 1: Introduction to the Fourier Transform

x(t+ δt) - x(t) = slope δt t+δt

Communication Signals (Haykin Sec. 2.4 and Ziemer Sec Sec. 2.4) KECE321 Communication Systems I

Notes on Fourier Series and Integrals Fourier Series

2.3 Oscillation. The harmonic oscillator equation is the differential equation. d 2 y dt 2 r y (r > 0). Its solutions have the form

OSE801 Engineering System Identification. Lecture 05: Fourier Analysis

Mathematics for Chemists 2 Lecture 14: Fourier analysis. Fourier series, Fourier transform, DFT/FFT

Response to Periodic and Non-periodic Loadings. Giacomo Boffi.

Discrete Systems & Z-Transforms. Week Date Lecture Title. 9-Mar Signals as Vectors & Systems as Maps 10-Mar [Signals] 3

Generation of bandlimited sync transitions for sine waveforms

It is common to think and write in time domain. creating the mathematical description of the. Continuous systems- using Laplace or s-

Review Sol. of More Long Answer Questions

Fourier spectra of radially periodic images with a non-symmetric radial period

Outline. Introduction

Response to Periodic and Non-periodic Loadings. Giacomo Boffi. March 25, 2014

Tutorial 2 - Learning about the Discrete Fourier Transform

Solutions to Problems in Chapter 4

Fourier Series Tutorial

Examples of the Fourier Theorem (Sect. 10.3). The Fourier Theorem: Continuous case.

SIGNALS AND SYSTEMS: PAPER 3C1 HANDOUT 6a. Dr David Corrigan 1. Electronic and Electrical Engineering Dept.

2A1H Time-Frequency Analysis II

EE3210 Lab 3: Periodic Signal Representation by Fourier Series

ESS Dirac Comb and Flavors of Fourier Transforms

IB Paper 6: Signal and Data Analysis

ECE-700 Review. Phil Schniter. January 5, x c (t)e jωt dt, x[n]z n, Denoting a transform pair by x[n] X(z), some useful properties are

DIFFERENTIATION RULES

r 2 i(x; y; z; t) =0for 1<x<1; h <y<0and b<z<b; 2 =0 at y =0; =0 at y = =0 at z = (4) and appropriate

Time-Dependent Statistical Mechanics A1. The Fourier transform

ELEG 3124 SYSTEMS AND SIGNALS Ch. 5 Fourier Transform

MA 201: Differentiation and Integration of Fourier Series Applications of Fourier Series Lecture - 10

Fourier Transform for Continuous Functions

Bridge between continuous time and discrete time signals

23.6. The Complex Form. Introduction. Prerequisites. Learning Outcomes

Vibration Testing. an excitation source a device to measure the response a digital signal processor to analyze the system response

x = B sin ( t ) HARMONIC MOTIONS SINE WAVES AND SIMPLE HARMONIC MOTION Here s a nice simple fraction: y = sin (x) Differentiate = cos (x)

The Fourier Transform (and more )

General Inner Product and The Fourier Series

GATE EE Topic wise Questions SIGNALS & SYSTEMS

More on Fourier Series

23.4. Convergence. Introduction. Prerequisites. Learning Outcomes

Qualification Exam: Mathematical Methods

Introduction to Signal Analysis Parts I and II

multiply both sides of eq. by a and projection overlap

X. Chen More on Sampling

Square Root Raised Cosine Filter

Fourier series. Complex Fourier series. Positive and negative frequencies. Fourier series demonstration. Notes. Notes. Notes.

Problem Sheet 1 Examples of Random Processes

Chapter 8 The Discrete Fourier Transform

Lecture 6: Differential Equations Describing Vibrations

Fourier Integral. Dr Mansoor Alshehri. King Saud University. MATH204-Differential Equations Center of Excellence in Learning and Teaching 1 / 22

Brenda Rubenstein (Physics PhD)

The Fourier Transform

Vibration Testing. Typically either instrumented hammers or shakers are used.

4 The Continuous Time Fourier Transform

Tutorial 4. Fast Fourier Transforms Phase factors runs around on the unit circle contains Wave forms

EA2.3 - Electronics 2 1

ω 0 = 2π/T 0 is called the fundamental angular frequency and ω 2 = 2ω 0 is called the

DESIGN OF CMOS ANALOG INTEGRATED CIRCUITS

Review: Continuous Fourier Transform

INTRODUCTION TO REAL ANALYSIS II MATH 4332 BLECHER NOTES

Chapter 17: Fourier Series

Second Printing Errata for Advanced Engineering Mathematics, by Dennis G. Zill and Michael R. Cullen

Introduction to Vibration. Professor Mike Brennan

Each of these functions represents a signal in terms of its spectral components in the frequency domain.

Fourier Transform. Find the Fourier series for a periodic waveform Determine the output of a filter when the input is a periodic function


2 z = ±b and the bottom is the plane y = h. The free surface is located at y = (x; z; t), which is unknown. We assume irrotational flow and incompress

A1 Time-Frequency Analysis

Chapter 2. Signals. Static and Dynamic Characteristics of Signals. Signals classified as

(Refer Slide Time: 01:30)

Transcription:

(version September 5) FOURIER ANALYSIS using Python his practical introduces the following: Fourier analysis of both periodic and non-periodic signals (Fourier series, Fourier transform, discrete Fourier transform) he use of Simpson's rule for numerical integration. Fourier analysis is an extremely important tool in the investigation of signals of physical origin - essentially it decomposes a signal into constituent harmonic vibrations. Sometimes the signals are periodic, and the period can be measured directly. But Fourier analysis is also useful for investigating signals which are not periodic. In the first part of this practical you will deal with periodic signals, while in the second part you will see that the numerical method applies with very little modification also to the case of non-periodic signals (when it is known as the Discrete Fourier ransform, or DF.) Fourier series Any periodic function f(t), with period = /, can be represented as a Fourier series: n f ( t) a ( an cos( n t) bn sin( nt)) () he sine and cosine functions are harmonic functions, and the series () contains a possibly infinite set of harmonic functions with discrete frequencies ω n = nω, n =,... he frequency ω = ω is known as the fundamental frequency, and ω n, n >, are the harmonics. he coefficients a n and b n measure the amount of cos(nt) and sin(nt) present in the function f(t). he result of Fourier analysing a signal is a set of values for these coefficients for all n. Obviously in practice the coefficients will be obtained for all n up to some finite maximum N. he Fourier coefficients are evaluated using the orthogonality properties of sines and cosines: with period = /. dt n t k t n k sin( ) sin( ) nk, (a) n k dt cos( n t ) sin( k t ), (b) dt cos( n t ) cos( k t ) nk, (c) If we integrate each of the functions f(t), cos(nt) f(t), and sin(nt) f(t) over one period, and use equations () and (a)-(c), we obtain: a dt f ( t ) (3a)

a b k k dt f ( t ) cos( k t ) k=,,. (3b) dt f ( t ) sin( k t ) k=,,. (3c). Simpson's Rule A Fourier analysis program must perform the integrations shown in equations (3), for any function f(t) of interest. Simpson's rule will be used for this. (See Kreyzig Advanced Engineering Mathematics, Wiley, 7 th edn. 993, chapter 8.5.) Simpson's rule approximates the integral b dx f ( x) steps of equal length h=(b-a)/n where n is an even number, and using a by splitting the interval from x=a to x=b into n where x j = a + jh for j=,,,n-,n with h=(b-a)/n; in particular x =a and x n=b.. Problems. Write Python code for the computation of the integral I exp( x) dx using Simpson s rule (and n=5 steps). Compare your numerical result with the analytical value for I.. Write Python code to compute and plot the Fourier coefficents a k and b k for the following functions. Note that these functions are chosen so that you can check the performance of your program, as the functions are already in the form of equation (). (Set = in the numerical computations.) f(t) = sin t f(t) = cos t + 3 cos t - 4 cos 3t f(t) = sin t + 3 sin 3t + 5 sin 5t f(t) = sin t + cos 3t + 3 sin 5t 3. Analyse the square wave with period = /, where θ=ωt and f ( ) (a) Plot the function, compute the Fourier coefficients and compare your output with the analytic result:

b k a k k 35,, 4 / k k, 3, 5 k, 4, 6 b) Plot the reconstructed function, i.e. your evaluation of eqn.(), using,, 3, 5,,, and 3 terms. 4. Analyse the pulse train with period =π/ω and he analytic results, putting ω=π/, are: a = (/) - t f ( t) t a k = (/k) sin(k/) k =,,3... b k = (/k)(- cos(k/)) k =,,3... Modify the code given for the square wave appropriately. Plot an amplitude-frequency graph, as in. Fourier ransform for Non-Periodic Functions A non-periodic function f(t) may be expanded in terms of cosine and sine functions, but in this case the expansion is a Fourier integral over a continuous range of frequencies υ, instead of a sum over a discrete set of frequencies k. he Fourier integral may be viewed as the limit of a Fourier series () in the limit. he summation over n in equation () is replaced by an integration over υ, f ( t) d a( )cos t b( ) sin t (6) hen equations (3a)-(3c) are replaced by [For details see Kreyszig] a( ) dt f ( t) cos t (7a) b( ) dt f ( t) sin t (7b) It is frequently more convenient to use complex notation, remembering e it = cos(t) + i sin(t), and define

f ( t) it df( v) e (8) F( ) it dt f t e ( ) (9) (he factors / are conventional.) hen (8) is equivalent to (6), and (9) to (7a) and (7b). he function F(υ) is called the Fourier transform of f(t). If the signal function has the dimensions of energy, then the Fourier transform has the dimensions of power, and its magnitude F( ) is a measure of the total power in the signal at frequency. Note that F( ) e( F( ) ) m( F( ) ) a( ) b( ) (3). he Discrete Fourier ransform In practice, numerical solution of (7a) and (7b), or (9), will involve replacing the integration by a discrete summation (as will numerical solution of (6) or (8).) he exact integrals are approximated by a discrete Fourier transform (DF) as defined below. DFs are useful for analysing physical amplitude-time or intensity-time data. In such cases it is not known whether or not the signal is periodic, and even if it is, its period is unknown. Suppose we have a time-dependent physical signal represented by a function f(t), and we sample it N times at intervals h, from t = to t = (N-)h. (It is usual to use t= as the lower limit when making physical measurements). Define t m =mh m=,,,, N- () he function is approximated by the discrete set of values at these instants, and time =Nh becomes the period of the approximate function. We need to be the longest time over which we are interested in the behaviour of f(t), and we assume f( t + ) = f(t), i.e. f (t m) = f(t m+n) or in shorthand form, f m=f m+n. () In this case the lowest frequency in the DF will be υ = / = /(Nh). his is the fundamental in the case where the function f(t) is periodic and =. he frequency spectrum is the discrete spectrum υ n=n(/(nh)) = nυ, for n=,,., N. () he DF evaluates eqn(8a) and (8b) as and F n = f m e πiυ nt m = f m e m= m= πimn N f m = N F ne πiυ nt m = N F ne πimn/n n= n= (3a) (3b). [Note that there exists an orthogonality relation for sums that leads to an identity when inserting f m from (3b) into (3a) and reverse.] F n are generally complex numbers.

Not all the Fourier components F n are independent of each other and one can show that F N/-n = F * N/+n where F * n is the complex conjugate of F n. he highest frequency component is thus F N/-, corresponding to (see eqn.()) a frequency υ n=(n/-)/(nh)) =/(h) - /(Nh) /(h) for large N. his is called the Nyquist frequency υ Nyquist. If the signal has a component with frequency υ>υ Nyquist there are less than two sample points per period. In this case there will be one or more frequencies less than υ Nyquist for which the amplitude equals the true amplitude at the sample points, and these lower (incorrect) frequencies will appear in the calculated spectrum. his is known as aliasing. he power spectrum (see eqn(3)) of the DF is given by a plot of all the values P n = F n,real + F n,imaginary as a function of n, where F n,real is the real part of F n and F n,imaginary its imaginary part.. Exercises Modify your Python script for the Fourier series (and save the new version under a different name!) program to calculate the DF in the following examples, using the following relations for F n,real and F n,imaginary, F n,real = f m cos(πmn/n) m= F n,imaginary = f m sin(πmn/n) m= (4a) (4b). he original signal is then reconstructed via eqn(3b), resulting in f m = N (F n,real cos(πmn/n) + F n,real sin(πmn/n)) n= Remember that the effective fundamental frequency, υ, to be used in each case is determined by the total sampling time τ. Make your program evaluate and print out the sampling rate υ s as well as υ so that you can see how many Fourier components you would expect to be able to calculate accurately.. Derive eqn. (5) from eqn. (3b).. Consider the function f(t)=sin(.45π t). Set N=8 and h=. and plot the function for a total time τ=nh, together with the points where it is sampled. Write code that returns the Fourier components F n,real and F n,imaginary using eqns (4a) and (4b) and plot them as a function of n. You should find one dominant Fourier component f n=n/(nh). How does its value compare with what you expect for the frequency from the given function f(t) above? An ideal sampling time would contain a multiple of the period of the periodic signal being probed. Use this criterion to pick an ideal value for h, keeping N=8 fixed and perform your Fourier calculations. What do you see? (5)

Compute the Fourier components f n,real and f n,imaginary and plot these as a function of time t m=mh to reconstruct the initial function f(t). Include f(t) in this figure to see how well the reconstruction works. An ideal sampling time would contain a multiple of the period of the periodic signal being probed. Use this criterion to pick an ideal value for h, keeping N=8 fixed and perform your Fourier calculations. What do you see? 3. reat the function f(t)=cos(6πt) as one of unknown period, and sample it every second for time τ=nh (N=3, h=.6). Record the sampling frequency, and plot the spectrum (real and imaginary part of F n) and power spectrum as a function of n (ranging from to N-). Repeat the exercise with h=.5, h=.4, and h=., keeping N=3 fixed. Explain your results in the three cases. (Hint: in each case, calculate the function at each of the sampling instants.) Choose a sampling rate and total sampling time which will produce an exact result for the Fourier transform, i.e. in this case only one Fourier component will be finite. 4. Consider the function f(t)=sin(4πt). Set N=64 and h=. and perform the Fourier transform. What frequency component do you obtain? Now set N=3 and h=. and compute the resulting frequency component? Explain your result by computing the Nyquist frequency f Nyquist = /(h). 5. reat the function f(t)=cos(3t) as one of unknown period, and sample it every second for 8 seconds (h=, τ=8). Plot the coefficients as a function of frequency, and the power spectrum. Repeat the calculation, sampling the function every second for a total sampling time τ of 6, 3 and 64 seconds. Compare the spectra obtained. What went wrong in the first calculation? (his is known as leakage - the amplitude leaks into nearby frequency bins.) 6. Evaluate the DF for the damped sine wave: f(t) = sin t e -kt. For a suitable value of k (e.g..) choose τ long enough for the signal to have decreased to at least /e of its initial value. Make a plot of the function f(t) which also shows the sampled values. Plot real and imaginary parts of F n as functions of n, and also the power spectrum. Reconstruct the function from the DF, using equation (5), to check how good an approximation it is. 7. Evaluate the DF for a single pulse. f(t) = < t < f(t) = t <, t > Compare the power spectrum with that obtained in problem 4 of section.. Notice that increasing N for a fixed total time interval τ (i.e. decreasing h and increasing N so that Nh is unchanged) increases the number of lines in the frequency spectrum, so that in the limit N, h, the spectrum would become continuous. 8. Calculate and plot the power spectrum of the signal represented by the data file sampledata.dat. Can you guess what this data file represents?