Hilary Weller

19th October 2015

This is brief introduction to and how it is used in atmospheric and oceanic science, for: Analysing data (eg climate data) • Numerical methods • of methods •

1

1 Fourier Any periodic, integrable , f (x) (defined on [ π,π]), can be expressed as a Fourier − series; an infinite sum of and cosines: ∞ ∞ a0 f (x) = + ∑ ak coskx + ∑ bk sinkx (1) 2 k=1 k=1

The a and b are the Fourier coefficients. • k k The sines and cosines are the Fourier modes. • k is the - number of complete that fit in the interval [ π,π] • − sinkx for different values of k

1.0 k =1 k =2 k =4 0.5

0.0

0.5

1.0 π π/2 0 π/2 π − − x

The is λ = 2π/k • The more Fourier modes that are included, the closer their sum will get to the function. •

2 Sum of First 4 Fourier Modes of a

1.0 Fourier Modes Original function 4 Sum of first 4 Fourier modes

0.5 2

0.0 0

2 0.5

4

1.0 π π/2 0 π/2 π π π/2 0 π/2 π − − − − x x

3

The first four Fourier modes of a square . The additional oscillations are “spectral ringing”

Each can be represented by motion around a circle. ↓ The motion around each circle has a speed and a radius. These represent the wavenumber and the Fourier coefficients. Which is which?

speed is wavenumber, radius is coefficient 4 Equivalently, equation (1) can be expressed as an infinite sum of exponentials using the relation eiθ = cosθ + isinθ where i = √ 1: − ∞ ∞ ∞ a0 ikx f (x) = + ∑ ak coskx + ∑ bk sinkx = ∑ Ake . (2) 2 k=1 k=1 k= ∞ − Exercise

Evaluate the Aks in terms of the aks and bks.

5

2 The Fourier Transform transforms a function f which is defined over space (or time) into • the domain, so that it is defined in terms of Fourier coefficients. The Fourier transform calculates the Fourier coefficients as: • 1 π 1 π ak = f (x)cos(kx)dx , bk = f (x)sin(kx)dx π ˆ π π ˆ π − − 3 Discrete Fourier Transform A discrete Fourier Transform converts a list of 2N + 1 equally spaced samples of a real valued, periodic function, fn, to the list of the first 2N + 1 complex valued Fourier coefficients: N 1 iπnkx/N Ak = ∑ fn e− . N n= N − The truncated : N ikx f (x) ∑ Ake ≈ k= N − is an approximation to the function f which fits the sampled points, fn, exactly. On a computer this is done with a (or fft). The inverse Fourier transform (sometimes called ifft) transforms the Fourier coefficients back to the f values (transforming from spectral back to real space): fft f0, f1, f2, f2N A0,A1, A2N ··· −−−→ifft ··· A ,A , A f , f , f , f 0 1 ··· 2N −−−→ 0 1 2 ··· 2N

6 4 Differentiation and Interpolation If we know the Fourier coefficients, Ak, of a function f then we can calculate the gradient of f at any point, x: If ∞ ∞ ∞ ikx f (x) = ∑ ak coskx + ∑ bk sinkx = ∑ Ake (3) k=0 k=0 k= ∞ − then ∞ ∞ ∞ ikx f 0(x) = ∑ kak sinkx + ∑ kbk coskx = ∑ i k Ake . (4) k=0 − k=0 k= ∞ − and the second : ∞ ∞ ∞ 2 2 2 ikx f 00(x) = ∑ k ak coskx ∑ k bk sinkx = ∑ k Ake . (5) k=0 − − k=0 k= ∞ − − These have spectral accuracy; the order of accuracy is as high as the number of points. Similarly equation 1 or 2 can be used directly to interpolate f onto an undefined point, x. Again, the order of accuracy is spectral. 5 Spectral Models ECMWF use a spectral model. • The prognostic variables are transformed between physical and spectral space using ffts • and iffts. Gradients are calculated very accurately in spectral space • 6 Wave Power and Frequency If a function, f , has Fourier coefficients, a and b , then wavenumber k has power a2 + b2. • k k k k A plot of wave frequency versus power is referred to as the power spectrum. Before we • learn how power spectra are used, we will have some revision questions... 7

7 Recap Questions 1. In the Fourier decomposition ∞ ∞ a0 f (x) = + ∑ ak coskx + ∑ bk sinkx 2 k=1 k=1 what are:

(a) the Fourier coefficients (the ak and the bk) (b) the Fourier modes (the sines and cosines) (c) the (or ) (the ks) 2 2 (d) the power of a given wavenumber (ak + bk) 2. How would you describe the : 1 π 1 π ak = f (x)cos(kx)dx , bk = f (x)sin(kx)dx π ˆ π π ˆ π − − (a Fourier transform)

3. Given a list of 2N + 1 equally spaced samples of a real valued, periodic function, fn, how would you describe the following operation to convert this into a a list of N + 1 values: N 1 iπknx/N Ak = ∑ fn e− N n= N − (a discrete Fourier transform) 4. What is the wavelength of a wave described by sin4x (2π/4)

8 8 Analysing Power Spectra Daily rainfall at a station in the Middle East for 21 years

60 daily rainfall Fourier filtered using 40 wave numbers Obervations about the 50 Truncated Fourier 40 filtered rainfall: 30 very smooth (only low 20 rainfall (mm) • wavenumbers included) 10 includes negative values 0 • – “spectral ringing” 0 5 10 15 20 years

Power Spectrum of Middle East Rainfall 100

10-1 Observations 10-2

10-3 dominant frequency at one year power • 10-4 (annual cycle) -5 power at high frequencies (ie 10 • 10-6 daily variability) 10-1 100 101 102 Number per year number per year = wavenumber 365/total number of days × 9

Time Series of the Nino 3 sea surface temperature (SST) The SST in the Nino 3 region of the equatorial Pacific is a diagnostic of El Nino 30 raw 2 years and slower 29 annual cycle How were the dashed lines generated? 28 Annual cycle is the • 27 Fourier mode at 1 year

26 The “two years and SST (deg C) • slower” filtered data is 25 the sum of all the

24 Fourier modes of these frequencies. 23 1990 1995 2000 2005 2010 Power Spectrum of Nino 3 SST 1 Observations 0.1 Dominant frequency at 1 year (annual 0.01 • cycle) 0.001 power Less power at high frequencies (SST • 0.0001 varies slowly) 1e−05 Power at 1-10 years (El Nino every 3-7 • 1e−06 years) 0.01 0.1 1 10 Frequency (per year)

10 of the Quasi-Biennial Oscillation (QBO) The QBO is an oscillation of the equatorial zonal wind between easterlies and westerlies in the tropical stratosphere which has a period of 28 to 29 months:

Power Spectrum of QBO 8 10 Observations 107 6 Dominant frequency at 10 • 105 close to 2 years 4 power 10 Less power at high 3 • 10 frequencies 102 Less power at long 101 • time-scales 10-2 10-1 100 101 frequency (per year)

11