Waves - Spectra Noise & Correlations - Lecture

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 114

Lecture notes on Waves/Spectra

Noise, Correlations and ….

W. Gekelman
Lecture 1, December 6,2003
All signals (sound, light, waves, mathematical functions) can be broken down into
Fundamental building blocks. These are called the elements of the spectra:

A prism creates a spectrum of colors from white light.


The spectrum has all the component colors or
elements that the “white” light is made of.

The prism is a spectrum analyzer for light.


The wave is made up of electric and magnetic fields. In vacuum the equation for
the propagation of light is a differential equation which looks like:

! !
∂ E 1 ∂ E
2 2 The light is moving in the z direction at speed c
= 2 2 C = 186,000 mi/sec=3X108 meter/s
∂z 2
c ∂t E is the electric field of the wave

The solution of this equation is very simple:

  z t    z t 
E = A sin 2π  −   + cos 2π  −  
  λ T    λ T 

With T the wave period, T=1/f and f the frequency


λ is the wavelength (how long from crest to crest) and the wave satisfies
λf = c (This is called the dispersion relation. It relates the frequency and
wavelength
To mathematically understand wave and spectra we have to go back to sines and
cosines:
Review: y = sin(at) (the sine)
at is the “argument” of the sine. It is in radians
2π (radians) = 360 (degrees)

a=1

a=3

How long is the wavelength here?


The sine can also be expressed as an infinite series

sinx = Limit of y as k -> ∞ where y is:

k=0 k=3

k=30
k=6
We can add sines and cosines up. Adding them is just like writing z= a+b

y = sinx+sin4x

y = sin2x+cosx

y=sin2x-cosx
k=0 y1 = sin(πx)

k =1 ; y = y1 + sin(2πx)/3

k = 3 ; y = y1 +y2+ sin(7πx)/7
Lets sum up 50 terms!

By summing many sine terms the series converges to a shape that


does not look like a sine function . In this case the summation is a
square wave. Note that the wave repeats itself with a period of 4.0
units.
Mathematical functions (that are periodic) can all be expressed as an infinite sum
of sines and cosines each multiplied by the right constant (like 1/3 or 1/7 as in the
previous example)

If F(z) is any periodic function the it can be proven that :

∞ ∞
F(z) = B0 + ∑ Am sin(mkz ) + ∑ Bm cos( mkz)
m =1 m =1

This is a function of z which a position like x or y. You can also have a series
which describes a function F(t), function of time. The mathematics doesn’t care!
This spiral is a function you cant use This is Pascal’s snail. No Fourier
Fourier Series to describe series here either!
There are many other kinds of series, the ones we just showed are called
Taylor series or power series. You can also construct series out of sines and
cosines:
y

As n goes to infinity the series becomes a spike at x = 0


The mathematical form of the Fourier Series is:
∞ ∞
F(z) = B0 + ∑ Am sin(mkz ) + ∑ Bm cos( mkz) B0 is a constant
m =1 m =1

Am and Bm are the mth component of the spectrum of the wave.


They are called the Fourier coefficients.
Note k = 2π/λ where λ is the wavelength in the z direction.

What are the A’s and B’s?


z+ λ
1
B0 =
λ ∫ F(z)dz
z
What do these symbols mean??
z+ λ
2
Am =
λ ∫ F(z)sin(mkz)dz z is a spatial position, k is a constant.
z
This is a series representing a
z+λ function that changes in space. Time
2
Bm =
λ ∫ F(z)cos(mkz )dz is fixed.
z
z+ λ F(z)
2
Am =
λ ∫ F(z)sin(mkz)dz
z

This function repeats itself z


every distance λ along the z
axis. λ

What this “integral” means is for every position z within one wavelength take the
function F(z) , which could be an experimental measurement, multiply by the
sine:
sin(mkz)= sin(2πmz/λ)
Then go to the next z (which is a very small distance away), multiply by the next
sine and add it to the first. This is the same as adding an infinite number of
terms together.
z+ λ
The integral is really infinite sum 2
Am =
λ ∫ F(z)sin(mkz)dz
For example z

2
Am = F ( z0 ) sin(mkz0) + F ( z1) sin(mkz1) + F( z2 ) sin(mkz2) +.......F( zn ) sin(mkzn )
λ
where z1 − z0 = ε and ε →0

The infinite number of terms occurs because the difference in z positions at


which you evaluate stuff is so small it is just about zero!
An integral is the area under
A curve. Here y=f(x)=3 (a constant!) x =5


x =0
3dx = 3x |50 = 3(5) − 3(0) = 15

y=3

dx

The integral means take a dx (which is very) , multiply by the value of y above the
Dx, shift your dx and keep on doing it until you hit the limit for x.
f(x)= .75x
i.e. formula for
the line is y=x

dx must be close to zero or it doesn’t touch y=x!


For each dx that you choose y is different. For
the dx near x=o, y=0; for the dx near x=4, y=4!

4
3 x2 4 3 16 1 1
∫0 .75xdx = 4 ( 2 |0 ) = 4 ( 2 − 0) = 6 Area= 2 (base × height ) = 2 ( 4 × 3) = 6
The Fourier series for a function which changes in time is :



x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f =
n =1 T
2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0

There is an alternate and equivalent way to write x(t)


x ( t ) = a0 + ∑ X n cos( nωt + θ n ) θ n is the phase of each term
n =1

 bn 
where X n = a + b 2
n
2
n θ n = tan   n=1,2,3...
−1

 an 
Now lets introduce the concept of spectra
WE know that any time series (such as our data) can be
represented by a series:

x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f
n =1
The spectra of x(t) tells us how much of each frequency is present in the
signal. Suppose the signal is composed of one sine wave only :
x(t) = 3sin(2πf1t)

spectra of a single frequency wave


x(f)

f1
Suppose the signal is composed of two sine waves :
x(t) = 3sin(2πf1t)+sin(2πf2t) ; where f2 = 3 f1

spectra of two frequency wave

x(f)

f1 f2

Now there are two lines, one for each frequency


Now suppose that there are many frequencies in our
waveform because there are many simultaneous
waves in the media

x(t)

Now the spectrum is continuous

x(f)

f
Lecture notes on Waves/Spectra
Noise, Correlations and ….

W. Gekelman
Lecture 2, January 17,2004
From the first lecture we discovered that any periodic mathematical function can be
expressed as an infinite power series, a Fourier series:


x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f =
n =1 T
2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0

Our data is a function of t (time) and we collect it for T seconds. So we exploit


the math by saying that our acquired data is one period long. It repeats again
and again in a mathematical space in Fourier land.

Each an or bn tells us “how much power” is in the nth frequency. Therefore each
an or bn is a term in the spectrum.
Here the spectrum is continuous so there
Power are an infinite number of a’s and b’s in the
Fourier series!

Frequency
(color for light, pitch for sound)
Questions for today:

1) How do we find all the a’s and b’s from our data? (In other words how do
we actually do a Fourier transform?)
2) What is phase?
3) What does phase have to do with Fourier Transforms ?
4) What is an inverse Fourier Transform?
5) Are there any pitfalls in using digitally acquired data?
6) Once we have a spectra are we all done or is there something else?
Some noise is truly random and is not made up of waves

V(t)

Take a voltage and measure the


voltage as a function of time across a
resistor, V(t). Its average is zero
because there is no battery in the
circuit but:
Resistor
V(t)
V(f) Spectrum of “white noise”
V(f) ∝ 1/f

t (time)
f (frequency)
1. How can we tell is what we have is random noise or if it is made out of waves?
2. If the noise is not random what is it made out of?
3. If our data has random noise in it and a valuable signal as well, how do we
separate the signal from the noise?
4. What is the importance of the frequency spectrum?
5. How do we get the spectrum from x(t) ?
6. Is the spectrum enough to tell us about what the noise is composed of?
7. What are the techniques of extracting a valuable signal from an enormous
background of noise (where the noise is a million times larger than the signal)?
8. How do you do all of these when your data is digital? Digital data is collected at
discrete time steps (example one sample per microsecond). It is not continuous
in time
These are complicated issues. Lets first concern ourselves with a signal that
looks like random noise but is actually made up of many waves.

Some of the answer :


1) We get the spectrum from the Fourier transform
2) The noise may be made of waves so we must determine information
about each of these waves. This information is contained in the
dispersion relation. (relation between frequency and wavelength)
If the noise is made of waves they may damp out (get smaller), or grow
as we move further away from the source of the waves.
Sometimes the waves can interact with each other as they travel away
from their source. They could give “birth” to new waves, which would
make the spectrum different from place to place.

How do we find the answer to question 2 ?


Much of the answer lies in what are called correlations.
The purpose of these lectures is to teach you what these correlations are and
how to calculate them for data.
The purpose of these lectures is to teach you what these correlations are and
how to calculate them for data you acquire in the laboratory.
To do this we have to learn some mathematical concepts.
a) What complex numbers are
b) How complex numbers are related to sines and cosines.
c) How complex numbers are related to the wave properties.
d) What Fast Fourier transforms (FFT) are.
e) How FFT’s are related to correlation functions
f) How to use all this to analyze your data.
The use of phase is a key part in this analysis. To continue our
analysis we have to introduce another mathematical entity:

Complex Numbers
This is all due to a famous identity due to DeMoivre:

e = cos θ + i sin θ

where i = -1
e is a transcendental number like π
e = 2.7182818284590452…. Or by an infinite series:
1 1 1 1 1 1 1
e = 1+ + + + + + + , with = = 1/ 6
1! 2! 3! 4! n! 3! 3 • 2i1
Properties of e:
eaeb=ea+b ea/eb=ea-b (ea)b = eab
multiplication and division become addition and subtraction !

y = ex ; how do you find x if you know what y is?


This introduces us to a new mathematical function the natural logarithm.
It has the property such that
ln(y) = x
Graph of y = ex
y

Graph of y = lnx

x
So lets reiterate now that we know what e is:

e = cos θ + i sin θ

where i = -1
e is related to sines and cosines as well as logs. Since sines and
cosines are solutions to the wave equation so is e!

e − iθ = cos θ − i sin θ We will see where this comes from soon

eiθ − e − iθ = cos θ + i sin θ − cos θ + i sin θ


iθ − iθ
e −e
Therefore : sinθ =
2i
iθ − iθ
e +e
Similarly : cosθ =
2
e = cos θ + i sin θ

where i = -1

e is related to sines and cosines as well as logs. Since sines and


cosines are solutions to the wave equation so is e!

Any complex number may be written as:


Thus it looks like complex numbers
z" = a + ib The ∼ means complex are just the right thing to use in
Fourier Analysis
also: z" = zeiθ
z = a 2 + b2 magnitude of X
−1 b
θ = tan ( ) phase
a
So what’s a complex or imaginary number??
• Many years ago mathematicians had a big problem with the concept of
zero
• After that they had a big problem with the concept of negative numbers
• After that they had a big problem with the concept of infinity
• After that they had a big problem with the concept of transcendental
numbers such as π ( π = 3.141592654…..and on forever)
• Now You are having a big problem with complex numbers!

They have a real part and an


imaginary part (the part
Im z multiplied by i) therefore you
can draw one complex
number on two axis

Re z example: z=1+i
Review :A complex number z=x+iy=Aeiθ = Α(cosθ+isinθ)
These are all equivalent representations. What do they look
like?

iy Example
z= Im(eix)
z= Im(cosx+isinx)=sinx

What would z=ei2πt look like?


This is the equation for as
circle!!!
ž =e2πit =cos(2πt)+isin(2πt)=x+iy

iy

When t=0 x=1, y=0, (cosθ =1, sinθ = 0) ,When t =0.5 x= -1, y =0 ,
When t = 0.1 cos(.2θ)= 0.809, sin(.2θ) = 0.588 ; (.809)2+(.588)2 = 1
How do you multiply two complex numbers?
Normally if a and b and real numbers then ab=ba if a = b then you get b2
ž is a complex number then z2 = ž ž* = (x+iy)(x-iy) = x2+y2+ixy-ixy=x2+y2

Here ž* is called the complex conjugate of z


To take the complex conjugate replace i by –i whenever you see it

That’s why in the previous example we get the equation


of a circle from ž =ei2πt

Another example what does Look like?

( x + iy )( x − iy ) = e2π iz e −2π iz = 1
x 2 + y 2 + ixy − ixy = x 2 + y 2 = 1 for any value of z
x + iy = e 2π iz = cos ( 2π z ) + i sin ( 2π z )
Equate the real and imaginary parts (they are two seperate axis)
x = cos ( 2π z ) y= sin ( 2π z )
Lecture notes on Waves/Spectra
Noise, Correlations and ….

W. Gekelman
Lecture 3, January 31,2004
From the first lecture we discovered that any periodic mathematical function can be
expressed as an infinite power series, a Fourier series:


x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f =
n =1 T
2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0

Our data is a function of t (time) and we collect it for T seconds. So we exploit


the math by saying that our acquired data is one period long. It repeats again
and again in a mathematical space in Fourier land.

Each an or bn tells us “how much power” is in the nth frequency. Therefore each
an or bn is a term in the spectrum.
So lets reiterate now that we know what e is:

e = cos θ + i sin θ

where i = -1
e is related to sines and cosines as well as logs. Since sines and
cosines are solutions to the wave equation so is e!

e − iθ = cos θ − i sin θ We will see where this comes from soon

eiθ − e − iθ = cos θ + i sin θ − cos θ + i sin θ


iθ − iθ
e −e
Therefore : sinθ =
2i
iθ − iθ
e +e
Similarly : cosθ =
2
Review :A complex number z=x+iy=Aeiθ = Α(cosθ+isinθ)
These are all equivalent representations. What do they look
like?

iy Example
z= Im(eix)
z= Im(cosx+isinx)=sinx

What would z=ei2πt look like?


This is the equation for as
circle!!!
ž =e2πit =cos(2πt)+isin(2πt)=x+iy

iy

When t=0 x=1, y=0, (cosθ =1, sinθ = 0) ,When t =0.5 x= -1, y =0 ,
When t = 0.1 cos(.2θ)= 0.809, sin(.2θ) = 0.588 ; (.809)2+(.588)2 = 1
It’s a spiral (in the picture the x and y
axis have the arrows)
So here’s what we are going to do:

• We will use infinite series to represent all mathematical functions


(note your data is a function x(t), you just happen to measure it! )
• Instead of saying that the series are sums of sines and cosines we
will represent them as series of Ansin(2πnt+Φn)
• Sometimes instead of using Ansin(2πnt+Φn)
we will use complex numbers and write each term as
xn(t) = Anei(2πnt+Φn)
Note xn(t) is the nth sine term in the time series , not the nth time
step!!!!

You will see how we do this as we go on to analyze the data


The purple continuous signal is the actual waveform but you digitize it at
discrete times where the red dots are.

How do you get the spectrum?


Are they any pitfalls.
The biggest pitfall is called aliasing. Suppose you have a signal varying very
rapidly in time and your digitizers have a time response which is too slow:

Instances where you digitize

“Fake” low frequency wave you think you


have

True high frequency data


How do you get rid of aliasing?

Amplifier
Detector

Low pass filter


To remove aliasing
Scope/ Computer and
Analog to Digital
The low pass filter does it. Converter

Sometimes amplifiers have low pass filters.


Your digital data x(t) is a series to begin with since data is
acquired at t1 = t0 + dt, t2 = t1 + dt, t3 = t2 +dt …etc

Suppose you have N time samples in your data (the digitizer can store
1024 numbers). Suppose the digitizer takes data every microsecond (dt =
1µs).
The total length in time of your record is T=Ndt = 1024*10-6 =1.024X10-3
sec = 1.023 ms. ≈ 1 ms.
This is called Tp or the Nyquist frequency
What is the lowest frequency you can measure in your data?
Answer flow = 1/(2dt) = 1/2X10-3 = 5X102 sec = 500 Hz

What is the highest frequency you can measure?

Ans: If you sample at 1 MHz then


Our digital data is a function of time x(t) and can be represented as:

x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f
n =1

2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0

But since time is not continuous after we digitize t=m∆t, ∆t are the timesteps we
digitize at:
N
2
 cos nωm sin nωm 
x m ≡ x ( m∆t ) = a0 + ∑  an + bn  ω =2π f
m =1  N N 

Note the time has been replaced by m/N and the limit does not go to infinity but to
N/2 (the longest period we can measure due to the Nyquist limit!).
The weights an and bn are also discrete and the formulas:

2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0
Become: 2 N
nωm
an =
N
∑ xm cos
m =1 N
2 N
nωm
bn =
N

m =1
xm sin
N
N
1
a0 =
N
∑x
m =1
m =< x >= 0

For a0 we assume that the signals are made of waves and the average value for
all waves is zero (<x> is the average value of x)
How many mathematical operations does it take to find all
the a’s and b’s ???. We have collected N time steps of data

1. For every n and m evaluate θ=2πnm/N


2. Find sinθ and cos θ
3. Compute xnsinθ and yncosθ
4. Sum all the terms m=1,2,3….N/2
5. Go to next value of n and start again

This procedure takes approximately N2 multiply add operations


If N = 1024 then 1,048,576. operations are required
Since finding the spectra is very important mathematicians have found a way to
rapidly perform these mathematical operations and get the same result. This is
called the:

How this is implemented is complicated and you may learn it one day in an
advanced math course in college but the bottom line is the FFT requires
number of operations = N/2p for data sets where the number of time
steps is a power of 2 namely N=2p.
Since 210 = 1024 , number of operations = 1024/(2*10)=52
Many math packages do FFT’s including PVwave. When you do an FFT of one of
your signals what do you get back?
Suppose I go into the lab and digitize a signal of B(t) where B is one
component of the magnetic field. B(t) is due to waves. B(t) has 5001 time
steps. The data looks like:
The PVwave command to do the FFT is > bfft=fft(B,-1)
When you do this what do you get?

This does not look like a spectrum at all. Also it looks like the result is mirrored
about the point in the center. What is going on ?
Lecture notes on Waves/Spectra
Noise, Correlations and ….

W. Gekelman
Lecture 4, February 28, 2004
Our digital data is a function of time x(t) and can be represented as:

x ( t ) = a0 + ∑ ( an cos nωt + bn sin nωt ) ω =2π f
n =1

2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3...
T 0

But since time is not continuous after we digitize t=m∆t, ∆t are the timesteps we
digitize at:
N
2
 cos nωm sin nωm 
x m ≡ x ( m∆t ) = a0 + ∑  an + bn  ω =2π f
m =1  N N 

Note the time has been replaced by m/N and the limit does not go to infinity but to
N/2 (the longest period we can measure due to the Nyquist limit!).
Prescription
• We will use infinite series to represent all mathematical functions

(note your data is a function x(t), you just happen to measure it! )
• Instead of saying that the series are sums of sines and cosines we
will represent them as series of Ansin(2πnt+Φn)
• Sometimes instead of using Ansin(2πnt+Φn)
we can use complex numbers and write each term as
xn(t) = Anei(2πnt+Φn)
Note xn(t) is the nth sine term in the time series , not the nth time
step!!!!

You will see how we do this today!


The weights an and bn are also discrete and the formulas:

2 T
a n = ∫ x ( t ) cos nωtdt n = 0,1,2,3...
T 0 This requires n2
2 T
b n = ∫ x ( t ) sin nωtdt n =1,2,3... operations!
T 0
Become: 2 N
nωm
an =
N
∑ xm cos
m =1 N
2 N
nωm
bn =
N

m =1
xm sin
N
N
1
a0 =
N
∑x
m =1
m =< x >= 0

For a0 we assume that the signals are made of waves and the average value for
all waves is zero (<x> is the average value of x)
Since finding the spectra is very important mathematicians have found a way to
rapidly perform these mathematical operations and get the same result. This is
called the:

How this is implemented is complicated and you may learn it one day in an
advanced math course in college but the bottom line is the FFT requires

number of operations = N/2p for data sets where the number of time
steps is a power of 2 namely N=2p.

Since 210 = 1024 , number of operations = 1024/(2*10)=52


Many math packages do FFT’s including PVwave. When you do an FFT of one of
your signals what do you get back?
Suppose I go into the lab and digitize a signal of B(t) where B is one
component of the magnetic field. B(t) is due to waves. B(t) has 5001 time
steps. The data looks like:
The PVwave command to do the FFT is > bfft=fft(B,-1)
When you do this what do you get?

This does not look like a spectrum at all. Also it looks like the result is mirrored
about the point in the center. What is going on ?
The power spectrum which shows us the power of the wave as a
function of frequency. There is a large peak at 2000!

Lets find out how to get from the complex fft fo here, and what the axis mean
The only way to find out is find the FFT of a function that we know all about.
Lets do a sine calculated for 512 time steps.
;
; A PVwave program to play with spectra
; a single sine wave to see what’s what
; W. Gekelman Dec 2003
;
datin = fltarr(512) ; declare array (make space for it)
for i = 0 , 511 do begin ; 512 points
datin(i) = 1.0*sin(2*!pi*float(i)/16.0)
endfor
plot, datin ; plot the sine wave
dfft = fft(datin,-1) ; take fourier transform
;
; examine fft (which is complex)
;
plot, dfft
; examine power in fft abs(dfft)=sqrt(re(dfft)^2+Im(dfft)^2)
plot, abs(dfft)
plot, abs(dfft(0:256)) ; look only in allowed Nyquist part
plot, abs(dfft(0:64)) ; look at the beginning
;
; examine what the real and complex parts look like
;
plot , Real(dfft)
plot, Imaginary(dfft)
end
What does the sine wave look like over the 512 timesteps ?

It has 16 cycles… WHY? Check the equation.


What does the Fast Fourier Transform look like?

This looks strange because the FFT returns both the real and imaginary part of the
function. If you ask wave it will tell you that dfft is a complex array of 512 points. It
is symmetric about the midpoint (x=256). What do we do next?
Lets calculate the power spectra (we will discuss what this is later) by:

power − spec = Re al ( fft ) 2 + Im aginary ( fft ) 2


Re member if y=a+ib then y* y = a 2 + b2

This is the power spectra.


Note there are two peaks
still symmetric about x=256.
Each has a value of ½ since
the Fourier transform
assigns half the power to
negative frequencies and
half to positive frequencies.

Lets look at the low


frequency mode.
2π t  2π i 
y = sin( ) = sin  
T  16 

The spectrum has a peak at t = 32, Does this make sense?

 2π t   2π t  t = 1,2,3, (discrete steps)


y = sin   = sin   ; when t =16 we go through 1 cycle
 T   16 
Suppose 512 steps is 1 second
1 time step is 1/512 seconds
If we have 16 cycles in 512 steps then each cycle is .01325 sec, f = 32 Hz !!!
What’s the lowest frequency we can see?
Answer flow = 1/(2dt) (Nyguist limit…last lecture)
1/2 cycle in 512 steps. flowest is 2 second.
What’s the highest frequency we can see?
It takes at least 2 steps to define 1 cycle
2 time steps = 2/512 seconds = .00390635 seconds
f (highest) = 256 Hz
Note that it is no accident that the spectrum goes from 0-256 instead of 0-512. This
is because the highest frequency is determined by the requirement that it takes two
points per cycle at the very least to determine a wave period.
The Real and Imaginary Parts of the Fourier Transform:

Real Part Imaginary Part

Since y = Acosθ + iBsinθ (a + ib)


In this case y = sinθ (not some other complicated thing) so that the imaginary part
happens to be our function and the Real part is a million times smaller. Its not
exactly zero because the data is digital not continuous in time.
What is the data is truly random? i.e. pure noise

Random data generated by a


random number generator

The power spectra of the completely


random data. All frequencies are
present and they are, in turn,
randomly distributed
Once again lets look at the magnetic field data and the Fast Fourier Xform

The magnetic field data looks like


noise just as the random data in the
previous slide.

The magnetic field spectrum has peaks


and looks quite different than the
previous picture. There are magnetic
waves in this data at frequency 500 and
2500 (in the units of this graph)
If we have a complete spectrum (the real and imaginary parts) the INVERSE Fourier
Transform allows us to go from frequency space into temporal space.

Symbolically !x (t ) = FFT −1[ x! ( f )]


Where FFT-1 is the inverse FFT and both x(t) and x(f) are complex, they have
the amplitude and phase stored.

What good is it? Suppose we have found our spectra in the previous slide and
we want to get rid of all of the signal except for the peak, and see what that
looks like in time.

This is two sine waves added


together
y = sin(2πt/16)+sin(2πt/48)
The spectrum is:

Low frequency High frequency

If we go into the fft of the original signal and cut out the high frequency
Component (we have to do this with the complex fft) and then do an inverse
FFT
In wave > bnew = fft(bfft,+1) +1 means do inverse fft

Complex fft with high frequency cut out


New array (function of
time)
After digital filter. We got rid of the high frequency sine wave. This is the real
part. Note the imaginary part of bnew is close to zero at all time for this one!
The spectra can tell us if there is a signal present in the data and what the
frequencies of the waves which are in the noise. Are there other techniques we
can use that tell us more about the waves in the noise?
1) How long do they last before they disappear?
Answer Autocorrelation functions
2) Can we separate one wave from the noise and look at it?
Answer Digital Filtering and Cross Spectral Functions
3) Can we find the dispersion relation (how the frequencies and wavelengths are
related) from studying the noise?
Answer Two point Correlation Functions.

Let us examine these techniques one by one


Lecture notes on Waves/Spectra
Noise, Correlations and ….

W. Gekelman
Lecture 5, March 27, 2004
The spectra can tell us if there is a signal present in the data and what the
frequencies of the waves which are in the noise. Are there other techniques we
can use that tell us more about the waves in the noise?
1) How long do they last before they disappear?
Answer Autocorrelation functions
2) Can we separate one wave from the noise and look at it?
Answer Digital Filtering and Cross Spectral Functions
3) Can we find the dispersion relation (how the frequencies and wavelengths are
related) from studying the noise?
Answer Two point Correlation Functions.

Let us examine these techniques one by one


Since we are interested in waves and they are all sines and cosines, the first thing
we must do is subtract out the average value of our data from the data record.
If there are n time steps then:

u ( tn ) is the data we just digitized


n
1
u ≡µ=
N
∑ u (t )
n =1
n average

x ( t n ) = u ( tn ) − µ : data with mean value removed

u(t)
µ

t
u(t)

If the data has a trend in it (here shown


in red) you have to subtract it out as well

There are procedures for this but this wont happen in our
experiment so we will not discuss how to do it
The autocorrelation function tells us the time interval over which a correlation in the
noise exists. If the noise is made entirely of waves, and the waves move through
the plasma (or other medium) without decaying as they travel, the autocorrelation
will be large for all time.

For digital data the autocorrelation is defined as: You get one value of R for
each delay time τ
1 N
Rxx (τ ) = Lim ∑ x (t )x (t + τ ) If x is continuous
N →∞ N
t =1

IF x is digital and the data is taken at intervals r∆t


(suppose ∆t is .01 second then r∆t=0,.01,.02,.03 when r =0,1,2,3..)
then :
1 N −r 1 N −r
Rxx ( r∆t ) = ∑
N − r n =1
x ( t ) x ( t + r ∆t ) ≡ ∑
N − r n =1
xn xn +1

r= 0,1,2,3,…m where m<n


What does this mean?
For a particular r∆t multiply the function x(r∆t) by the function x(t+r∆t)

r∆t

Then do it again and again. For each term you have to slide the data over by a
timestep of ∆t and multiply all the terms. Note that all the term to the right of the
“red” data are zero as are the terms to the left of the blue data. For the
autocorrelation function there is only time history of data. We do this to find out
how long the data are correlated for.

Note the 1/(N-r) guarantees that when r=0 Rxx is 1.0 !


What is the correlation of a sine wave with itself?
Let us assume that the sine wave is continuous.
When r=0 (first point) we get Rxx(0) =1/2 why?

All the terms go like sin(t)*sin(t)=sin2(t)

The area under each lump is 1/4


There are 2 lumps per-period so the area under the period is ½. If there are N
periods we have to divide the outcome by N. Therefore Rxx(0) = 1/2
y = sin(2πt/T) Original function (note it goes on forever!)

1/2

Rxx = 1/2sin(2πt/T) Autocorrelation function-calculated


From the definition (Try it can you get this?)
Now lets look at the digital sine wave data we used as an example for the FFT.
What will the autocorrelation look like? Can you guess?
To do the correlation in PVwave is very easy. If the sine wave is called ysin and has
512 data points then all you have to do in wave is type:
ycor=autocorrelation(ysin,511)
This creates an array which is 512 points long and is the autocorrelation of ysin (the
first argument).

Red=sine wave
data

White:
autocorrelation

time
Why does the autocorrelation
decay in time ?

Answer: because the data does not go on forever!

What we have is a sine wave multiplied by a rectangular function which is 1


from t>0 until the 512 points and then it is zero!

1.0

t=0 t = 512 (steps)


sin ( 2π x )
Autocorrelation of:

Random “white y=
noise” only with a ( 2π x )
time interval x

This causes the taper

Rxx
These cause what is
known as “leakage”

Therefore the cosine function of the infinitely long (in time) autocorrelation of the
sine wave is multiplied by this, which tapers it off.
How do we get around this? Take a the longest possible record. This widens the first
lobe of the sine wave. This is the same sinx and autocorrelation when the record
length is 4096.

Autocorrelation
Of first 512
points

Orig.
Sine
wave
This is the autocorrelation of the magnetic field shown previously (and in red).
Note here the record is 5000 time steps long. It is correlated for less than 50 time
steps (1/100 of the time)
The autocorrelation function and spectra are related to each other by
The Fourier Transform!!

Spectra of x(t)x(t+r∆t) = Fourier Transform of the Autocorrelation function

Formally


S xx ( f ) = ∫
−∞
Rxx (τ )e − i 2π f τ dτ
This was proven by Von Neuman and is part of the mathematics of cybernetics or
Information. This was essential for the development of computers
Lecture notes on Waves/Spectra
Noise, Correlations and ….

References: Random Data 3rd Ed, Bendat and


Piersol,Wiley Interscience

Beall, Kim and Powers, J. Appl. Phys, 53, W. Gekelman


3923 (1982) Lecture 6, April 27, 2004
Lecture 7, June 12,2004
The autocorrelation function and spectra are related to each other by
The Fourier Transform!!

Spectra of x(t)x(t+r∆t) = Fourier Transform of the Autocorrelation function

Formally


S xx ( f ) = ∫
−∞
Rxx (τ )e − i 2π f τ dτ
This was proven by Von Neuman and is part of the mathematics of cybernetics or
Information. This was essential for the development of computers
Huh ?
Suppose you have many waves which start from point a

The waves change as they move !


a

They pass a probe at point b


which detects them

They pass another probe at c


point c which detects them
How well are the waves which pass point a correlated with the waves that pass
point b ?

The waves can decay as they move, or grow. The frequencies of the waves
that make up the signal can change as they move as well.

1) The Cross correlation function tells us how strongly the signal at probe a is
correlated (or related) with that at probe b.
2) The Cross Spectral Function tells us how the signals to the probes are
related frequency by frequency
3) There is (as we can guess) a relation between these functions and FFT’s
The Cross Correlation function is similar to the autocorrelation except now we
have two signals x(t) and y(t). These are the signals from the two probes
respectively.

Rxx is the cross correlation function

! 1 N −r
Rxy ( r∆t ) = ∑
N − r n =1
xn yn + r r = 0,1,2,3,...m with m<N

x is the digital data at probe a so xn = x(t0 +n∆t)


y is the digital data at probe b yn = y(t0+[n+r]∆t)

Lets think about what this means. There are a total of N time steps in the data. N
= 1,2,3,4…N. For each value of r we have to sum the product of x and y over all
the n’s. This gives us one value for R. W then have to do the sum/product N-r
times.
" " "
Rxy = Bx B y
*

(complex) cross spectral density y component of complex Fourier


transform of B
Here is the example of one component (By)of the magnetic field of a wave
(Alfven wave) acquired in an experiment on the LAPD device at UCLA. The data
was acquired as a function of time (each ∆t = 0.01 µsec) at the same (x,y)
location three meters apart.

By at second plane 2
By at first data
meters away
plane
What does the cross correlation look like?

200 = 2 µs

green = cross correlation

The signals are well correlated for about 3 µs ! white = By on closest


plane
What about the dispersion relation of the waves? Suppose we have many
frequencies in the noise , not like the case just displayed. We want to find out what

ω/k = ?.
For light in vacuumω = c where c = 3X10
m8
in general
things are simple k sec
ω
In general = f(ω ) here the phase velocity is a complicated function of ω
k
ω= 2πf and we can get f from the spectra (Fourier Transform)
What about k ?
Remember k is the wavenumber where k = 2π/λ

How do we use mathematical techniques to get k


from the data ?
Note there are is a spectrum of frequencies in the data so there will also be a
spectrum of k
We must measure the wavelength* by moving one probe with respect to the other.
If we move a probe a distance such that our received signal is 180 degrees out of
Phase from where we taken our first measurement we have moved by one
wavelength.

distance (x)

Distance so phase changes by π; we travelled ½ λ

* Strictly speaking the wave could move in any direction so we have to find its wavelength in
all three directions. For now lets discuss wave moving along the x axis only!
1) The wavelength is related to phase changes
2) If we have two probes in the plasma separated by a distance δx, and they
are both simultaneously recording wave data then
the phase change between them is:

3) δθ = k δx k is the wavenumber

Now we have many, many waves going all superimposed and each time we
record data from the two probes it looks different (because the waves are
random)

How do we use this data to find the dispersion relation?


We want the dispersion relation because it tells us which waves they are!
1) We have recorded n experiments (repetition of the same experiment) each with
r time steps from two probes. The probes record the signals at time intervals ∆t.
2) Call the signal from the first probe B1(r1∆t) and that from the second probe
B2(r2∆t)
3) Since we have many frequencies in the recorded data we first do an FFT of
both signals to get:
N
1
B1 ( x, ω ) =
N
∑ 1(
B
l =1
x , l ∆ t ) e − iωl ∆t

Now the magnetic field has a real and an imaginary component and is frequency
space There is a similar expression for B2
Now that we have Fourier Transformed each B field we now use
them to find the cross spectral function H.
Position of probe
B2

∑B (x , ω ) B2 ( x2 j , ω )
M
1
H ( χ ,ω ) =
ˆ
" *
1 1j
M j =1

Complex conjugate of
χp = x2 –x1
M = number of events in Fourier transform of B1
(probe separation) which B1 and B2 were
simultaneously stored
H ( χ p ,ω ) =
M
1
ˆ
"
M
∑ B ( x ,ω ) B ( x ,ω )
j =1
*
1j 1 2j 2

Note H is a complex function since it comes from Fourier Transforms


which give us complex functions

H ( χ p , ω ) = C (ω ) + iQ (ω )
"
ˆ

Real Part of H Imaginary Part of H


The local wavenumber is :

kˆ (ω ) =
1 
tan 
Q ( ω
−1) 

χp  P (ω ) 

Probe separation

Real and Imaginary Parts of the


Cross Spectral Function
An example:

Two probes 96 cm apart,


measurement of Bx

Spectra of one of
the signals

Phys. Plasmas, M. Van Zeeland, W. Gekelman, S. Vincena, J.Maggs,


10, 1243 (2003)
Suspected Wave
(Kinetic Alfvén Wave)

2 1/ 2
ω  ω  k   2

= 1 −  +
 

  VA
k||   ωci   ρ cs  
 
B2 qB
VA = ≈ 5 X 107 cm/s ωci = ≈ 7.2 X 105
µ0nM I MI
cs
ρs = ≈ 7mm
ωci

ion cyclotron
−1 Q ( ω )
1  
k (ω ) =
frequency
ˆ tan  
χp  P ( ω ) 
ion acoustic wave
speed
The Power Spectra Come from the Fourier Transforms of
each Probe. We investigated this in previous lectures

! 1 M *
S1 (ω ) = ∑
M j =1
B 1 j ( x1 , ω ) B1 j ( x1 , ω )

! 1 M *
S2 (ω ) = ∑
M j =1
B 2 j ( x2 , ω ) B2 j ( x1 , ω )

symbol
denotes
average
The Coherency Spectrum is:

H ( χ ,ω )
ˆ
"
γ (ω ) = χ = x2 − x1
Sˆ 1 (ω ) Sˆ2 (ω )

Denominator guarantees that γ(ω) is between zero


and one!
|Ey| incident ‘O’ mode microwaves

δz horn = 33 cm

Plasma
frequency
Resonance
Correlations
(400 positions)*(3 componets)*(6000
timesteps)*(50 shots)=3.6X108 numbers

B0 Machine axis
Fixed Probe

Movable
Probe
(computer controlled)
|< B" ym B" xf* >|
Coherency γ Byf − Bxm = From 2 plane correlation
|< B" ym >||< B" xf >| measurement

Ave phase

Im ( < B" ym B" xf* > )


tan (θ ) =
Re ( < B" ym B" xf* > )

θ = 2.55 radians
δz = 66 cm
T=1000µsec Parallel Ion Flow in a Perpendicular Plane

Time during
spontaneous
fluctuations

+0.05

Mach y
(cm) Correlation
number Measurements
are Made
in this Region
-0.25

 I 
M || = 12 ln Sat −Upstrem 
 I Sat − Downstream 

x (cm)
Density Fluctuations Due to Drift Waves
Frequency:
0.2Fci

+10

∆n
(%)
n

-10

You might also like