lec09

advertisement
Environmental Data Analysis with MatLab
Lecture 9:
Fourier Series
SYLLABUS
Lecture 01
Lecture 02
Lecture 03
Lecture 04
Lecture 05
Lecture 06
Lecture 07
Lecture 08
Lecture 09
Lecture 10
Lecture 11
Lecture 12
Lecture 13
Lecture 14
Lecture 15
Lecture 16
Lecture 17
Lecture 18
Lecture 19
Lecture 20
Lecture 21
Lecture 22
Lecture 23
Lecture 24
Using MatLab
Looking At Data
Probability and Measurement Error
Multivariate Distributions
Linear Models
The Principle of Least Squares
Prior Information
Solving Generalized Least Squares Problems
Fourier Series
Complex Fourier Series
Lessons Learned from the Fourier Transform
Power Spectra
Filter Theory
Applications of Filters
Factor Analysis
Orthogonal functions
Covariance and Autocorrelation
Cross-correlation
Smoothing, Correlation and Spectra
Coherence; Tapering and Spectral Analysis
Interpolation
Hypothesis testing
Hypothesis Testing continued; F-Tests
Confidence Limits of Spectra, Bootstraps
purpose of the lecture
detect and quantify periodicities in data
importance of periodicities
Stream Flow
Neuse River
discharge, cfs
365 days
1 year
time, days
Air temperature
Black Rock Forest
365 days
1 year
Air temperature
Black Rock Forest
1 day
time, days
temporal periodicities
and their periods
astronomical
other natural
anthropogenic
rotation
ocean waves
electric power
daily
a few seconds
60 Hz
revolution
yearly
sinusoidal oscillation
f(t) = C cos{ 2π (t-t0) / T }
cosine example
3
2
amplitude, C
d(t)
d(t)
1
0
-1
-2
period, T
-3
0
10
20
30
delay, t0
40
50
60
time, time,
t
t
70
80
90
lingo
temporal
spatial
f(t) = C cos{ 2π t / T }
f(x) = C cos{ 2π x / λ }
amplitude, C
amplitude, C
period, T
wavelength, λ
frequency, f=1/T
-
angular frequency, ω=2 π /T
f(t) = C cos(ωt)
wavenumber, k=2 π / λ
f(x) = C cos(kx)
spatial periodicities
and their wavelengths
natural
anthropogenic
sand dunes
furrows plowed
in a field
hundreds of meters
tree rings
a few millimeters
few tens of cm
pairing sines and cosines
to avoid using time delays
derived using trig identity
A
B
A
A=C cos(ωt0)
B=C sin(ωt0)
B
A2=C cos2 (ωt0)
2
2
B =C sin (ωt0)
A2+B2=C2 [cos2 (ωt0)+sin2 (ωt0)]
= C2
Fourier Series
linear model containing nothing but
sines and cosines
ω’s are auxiliary
variables
A’s and B’s are
model parameters
two choices
values of frequencies?
total number of frequencies?
surprising fact about time series with
evenly sampled data
Nyquist frequency
values of frequencies?
evenly spaced, ωn = (n-1)Δ ω
minimum frequency of zero
maximum frequency of fny
total number of frequencies? N/2+1
number of model parameters, M
= number of data, N
implies
Number of Frequencies
why N/2+1 and not N/2 ?
first and last sine are omitted from the
Fourier Series since they are
identically zero:
cos(½NΔω t)
col 1
cos(0t)
time, s
-2
0
0
col 2 t)
cos(Δω
2
-2
0
0
col 3
sin(Δωt)
2
-2
0
0
col 4 t)
cos(2Δω
2
-2
0
0
2
col 5
sin(2Δω
t)
-2
0
0
2
col 32
-2
0
5
5
5
5
5
5
10
10
10
10
10
10
15
15
15
15
15
15
20
20
20
20
20
20
25
25
25
25
25
25
30
30
30
30
30
30
0
Nyquist Sampling Theorem
another way of stating it
when m=n+N
note evenly
sampled times
Step 1: Insert discrete frequencies and times into
l.h.s. of equations.
ωn = (n-1)Δ ω and tk = (k-1) Δt
Step 2: Insert discrete frequencies and times into
r.h.s. of equations.
ωn = (n-1+N)Δ ω and tk = (k-1) Δt
Step 3: Note that l.h.s equals r.h.s.
same as l.h.s.
same as l.h.s.
Step 4: Identify unique region of ω-axis
when m=n+N
or when
ωm=ωn+2ωny
only a 2ωny interval of the ω -axis is unique
say from
-ωny to +ωny
Step 5: Apply symmetry of sines and cosines
cos(ω t) has same shape as cos(-ω t)
and
sin(ω t) has same shape as sin(-ω t)
so really only the
0 to ωny
part of the ω-axis is unique
equivalent points on the ω-axis
w
-wny
0
wny
2wny
3wny
d1 (t) = cos(w1t), with w1=2Dw
2
d1(t)
1
d1(t)
0
-1
-2
0
5
10
15
20
d2(t) = cos{w2t}, with w2=(2+N)Dw,
time, t
time, t
2
d2(t)
1
d2(t)
0
-1
-2
0
5
10
15
time, t
20
time, t
problem of aliasing
high frequencies
masquerading as low frequencies
solution:
pre-process data to remove high
frequencies
before digitizing it
Discrete Fourier Series
d = Gm
Least Squares Solution
est
T
-1
T
m = [G G] G d
has substantial simplification
… since it can be shown that …
frequency and time setup
in MatLab
% N = number of data, presumed even
% Dt is time sampling interval
t = Dt*[0:N-1]’;
Df = 1 / (N * Dt );
Dw = 2 * pi / (N * Dt);
Nf = N/2+1;
Nw = N/2+1;
f = Df*[0:N/2];
w = Dw*[0:N/2];
Building G in MatLab
% set up G
G=zeros(N,M);
% zero frequency column
G(:,1)=1;
% interior M/2-1 columns
for i = [1:M/2-1]
j = 2*i;
k = j+1;
G(:,j)=cos(w(i+1).*t);
G(:,k)=sin(w(i+1).*t);
end
% nyquist column
G(:,M)=cos(w(Nw).*t);
solving for model parameters
in MatLab
gtgi = 2* ones(M,1)/N;
gtgi(1)=1/N;
gtgi(M)=1/N;
mest = gtgi .* (G'*d);
how to plot the model parameters?
A’s and B ’s
plot
against frequency
power spectral density
big at frequency ω when
when sine or cosine at the frequency
has a large coefficient
alternatively, plot
amplitude spectral density
amplitude
density
spectral
spectrum
Stream Flow
2000
all interesting frequencies near origin,
so plot period, T=1/f instead
1000
0
amplitude
density
spectral
spectrum
Neuse River
3000
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
frequency, cycles per day
frequency, cycles per day
0.4
0.45
0.5
900
1000
2000
60.0 days
182.6 days
1500
1000
365.2 days
500
0
0
100
200
300
400
500
600
period, days
period, days
700
800
Download