Sei sulla pagina 1di 18

DATA PROCESSING AND

INVERSE THEORY:
PRACTICAL EXERCISES REPORT

Rafael Fernando Daz Gaztelu


3777901

Geophysical Data Processing: Exercise 1


1) Fourier transform of sine and cosine
a) Calculate analytically the Fourier transform of
1 2j t 2j
(e
+e
2

f (t)=cos(2 M t)=

FT ( f (t))=F ()= e2j t

f (t)=cos(2 M t)

1 2j t 2j
(e
+e
2
M

dt=

1 + 2j ( )t 2j (+
+e
(e
2
M

)t

) dt

1
( M ) (+ 0) ]
2[

b) What is the Fourier transform of


f (t)=sin (2 M t )=

f (t)=sin (2 M t )

1 2j t 2j
(e
e
2j

FT ( f (t))=F ()= e2j t

1 2j t 2j
(e
e
2j
M

dt=

1 + 2j ( )t 2j (+
e
(e
2j
M

)t

) dt

j
(+ M )( 0 ) ]
2[
c) Use matlab to compute the Discrete Fourier Transform of f (t)=cos(2 M t) and
f (t)=sin (2 M t ) and plot the amplitude and phase spectra; use M =5Hz
Why is the computed result different from the analytical result?
t=[0:0.001:4.95]
frax=[0:0.101:500];
nu=5;
f=cos(2*pi*nu*t);
g=fft(f)
subplot(3,1,1)
plot(t,f);
subplot(3,1,2)
plot(t,g)
axis([-1 6 -1000 2000])
subplot(3,1,3)
plot(frax,g)
axis([-100 600 -1000 2000])

2) Time and frequency domain. Link the ten given functions in the time domain to their
counterparts in the frequency domain.

3) Properties of the Fourier transform. The Fourier transform of f(t) is defined by:
+

FT ( f (t) )=F ()= f (t) e2j t dt

The inverse Fourier transform is given by:

FT ( F ( ))= f (t )= F ()e
1

2j t

dt

Demonstrate the following properties of the Fourier Transform:


a) Similarity:
1
)
FT ( f ( t))= F (

2j t

FT ( f ( t ))= f ( t) e

dt

1
1
>0 FT ( f ( t ))= f ( t) e2j t dt= u= dt = f ( u) e2 j u du =

du= dt
1
F
=
( )

<0 FT ( f ( t ))=
=

1
1
f (t )e2j t dt= u= dt = f ( u)e2 j u du =


du=dt

1
F()

QED

b) Linearity:
FT ( f (t)+ g (t ))= F ()+ G()
FT ( f + g)= ( f + g) e2j t d = f e2j t d + g 2j t d =
2j t
2j t
d + g
d = F ()+G ()
= f
QED
c) Time shifting
2j
FT ( f (t ))=e
F ( )
Let t '=tt 0 so t=t ' t 0
+

FT ( x (tt 0 ))= x (tt 0 )e

jt

j (t 't0)

dt= x (t ' )e

jt

dt ' =e

jt'
2j t
x (t ') e
dt '= X ( j )e

QED

d) Differentiation in the time domain


d
FT
f (t) =2j F ( )
dt
+
+
d
d +
d 2j t
2j t
f (t)=
F ()e
d = F ( ) e
d = (2j F ()) e2j t d =

dt
dt
dt

= FT 1 (2j F ())

QED

e) Proof the convolution theorem.


(i)

FT ( f g)=FT ( f ) FT ( g )

( g (t)e

) [

dt d = u=t

du=dt
2j (u )
2j
2j u
f ( )( g (u)e
dt ) d = f ( )e
d g (u)e
du=FT ( f ) FT ( g )

FT ( f g)=

f () g (t)d e2j t dt= f ( )

2j t

=
QED

(ii) FT ( f g)= FT ( f )FT (g )


2j t
2j ' t
2j t
FT ( f g )= f g e
dt= ( F ( ' ) e
d ' ) g (t )e
dt =
=

F ( ')( g (t) e2j( ' )t dt ) d = F ( ' ) G(2j ( ' )) d ' =F ()G( )


QED

4) Fourier transform of boxcar function.


Boxcar function f(t), centered at t=0 is given by:
T
T
1 <t<
2
2
f (t)=
T T
0,5 t= ,
2 2
0
else
a) Calculate FT(f(t))
+

FT ( f (t))=F ()= f ( t) e

2j t

T
2

dt= e

2j t

e2j t
dt=
2j

T
2
T

sin( T )
sin ( T )
=T

= T sinc( T )
The rectangular pulse function g(t), centered at t=T/2, is defined as:
1 0<t<T
g (t )=0,5 t=0,T
0
else
b) Calculate FT(g(t)).

[ ]
T
2
T
t=+
2
dt=d
=t

( )

g (t )= f t

T
2

( ( ))

T
FT f t+
= f (t) e2j (t T / 2) d = e2j 2j T / 2 d =e j T e2j d =e j T F ()
2

0
0
c) Use Matlab to plot the amplitude and phase spectra of FT(f(t)) and FT(g(t))
t=[-10:1:10]
nu=[0:0.005:0.1]
f=vogon(t)
h=vogon2(t)
fur=fft(f)
gur=fft(h)
subplot(2,3,1)
plot(t,f)
axis([-10 10 0 5])
title('Centered Boxcar function')
xlabel('Time')
ylabel('Amplitude')
subplot(2,3,2)
plot(nu,fur)
axis([0 0.1 -10 10])
title('Centered Boxcar AS')
xlabel('Frequency')
ylabel('Amplitude')
subplot(2,3,3)
plot(nu,angle(fur))

axis([0 0.1 -10 10])


title('Centered Boxcar PS')
xlabel('Frequency')
ylabel('< Amplitude')
subplot(2,3,4)
plot(t,h)
axis([-10 10 0 5])
title('Boxcar function')
xlabel('Time')
ylabel('Amplitude')
subplot(2,3,5)
plot(nu,gur)
axis([0 0.1 -10 10])
title('Boxcar AS')
xlabel('Frequency')
ylabel('Amplitude')
subplot(2,3,6)
plot(nu,angle(gur))
axis([0 0.1 -10 10])
title('Boxcar PS')
xlabel('Frequency')
ylabel('< Amplitude')

Geophysical Data Processing: Exercise 2


1) Sampling theorem
We study the influence of sampling rate and signal length. The time signal f(t) is given by:
f (t)=cos(2 1 t )+cos (2 2 t )
with frequencies 1=12.5 Hz and 2 =75 Hz .
a) Discretise the continous function using as time intervals t=2ms , 4ms ,8ms respectively,
plot these results.
b) Compute the amplitude spectra and display results.
t1=[0:0.002:1]
t2=[0:0.004:1]
t3=[0:0.008:1]
nu1=12.5
nu2=75
f1=cos(2*pi*nu1*t1)+cos(2*pi*nu2*t1)
f2=cos(2*pi*nu1*t2)+cos(2*pi*nu2*t2)
f3=cos(2*pi*nu1*t3)+cos(2*pi*nu2*t3)
subplot(3,1,1)
plot(t1,f1)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 2 ms')
subplot(3,1,2)
plot(t2,f2)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 4 ms')
subplot(3,1,3)
plot(t3,f3)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 8 ms')

c) Explain results and compute aliasing frequency. Look at the amplitude spectra. What does theory
tell you and what happened to the side lobes?
According to the Nyquist (or sampling) theorem, the minimum frequency able to sample without
losing information is C = MAX =2 2=2 75 Hz=150 Hz which yields a time lapse of
t C =6.67 ms .
Sampling at t 1=2 ms and t 2 =4 ms are still ok, this means that no information is lost,
unlike t 2 =8 ms , which yields a frequency under C , and it is even visible in the amplitude
spectrum plot that it gives a poor display of the function.
d) Extend the signal length by adding zeros at the end. Plot the resulting amplitude spectra of the
extended signal and explain.
t1=[0:0.002:1]
t2=[0:0.004:1]
t3=[0:0.008:1]
nu1=12.5
nu2=75
f1=cos(2*pi*nu1*t1)+cos(2*pi*nu2*t1)
f2=cos(2*pi*nu1*t2)+cos(2*pi*nu2*t2)
f3=cos(2*pi*nu1*t3)+cos(2*pi*nu2*t3)
F1=[f1,zeros(1,5)]
F2=[f2,zeros(1,5)]
F3=[f3,zeros(1,5)]
T1=[t1,zeros(1,5)]
T2=[t2,zeros(1,5)]
T3=[t3,zeros(1,5)]
subplot(3,1,1)
plot(T1,F1)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 2 ms')
subplot(3,1,2)
plot(T2,F2)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 4 ms')
subplot(3,1,3)
plot(T3,F3)
xlabel('Time')
ylabel('Amplitude')
title ('Time lapse of 8 ms')

2) In exercise (1) we have seen that the spectrum of the finite cosine corresponds to two sinc
functions centered at frequency of the cosine. In order to supress the side lobes of the spectral
window different time windows can be used, Barlett or Triangular Window, Hanning Window or
Gaussian Window. Compute the spectra for the same signal as in exercise (1) but use the three
windowing functions mentioned above.
t=[0:0.001:1]
nu1=12.5
nu2=75
L=1001
f=cos(2*pi*nu1*t)+cos(2*pi*nu2*t)
w=bartlett(L)
y=hann(L)
m=gausswin(L)
w=w'
y=y'
m=m'
h=w.*f
k=y.*f
s=m.*f
subplot(3,1,1)
plot(t,h)
xlabel('Time')
ylabel('Amplitude')
title ('Bartlett or Triangular Window')
subplot(3,1,2)
plot(t,k)
xlabel('Time')
ylabel('Amplitude')
title ('Hanning Window')
subplot(3,1,3)
plot(t,s)
xlabel('Time')
ylabel('Amplitude')
title ('Gaussian Window')

Geophysical Data Processing: Exercise 3


1) Discrete convolution.
Code a function which performs a discrete convolution between two arbitrary sequences x0,x1,...xn
and x0,x1,...xm.(also called wavelets).
a) Perform direct convolution in the time domain.
b) Perform the operation in the Z-domain
c) Think of the sequences x1, x2 and y=conv(x1,x2) as vectors and try to write the convolution as a
matrix multiplication.
d) Check all results with the intrinsic function conv.
%MASTER PROGRAM EVERYTHING
x=input('Enter the first wavelet, x:')
h=input('Enter the second wavelet, h:')
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
Y
k=m+n-1
u=zeros(1,k)
for j=1:n
for n=1:m
u(j+n-1)=u(j+n-1)+h(j)*x(n);
end
end
xm=toeplitz([x(1) zeros(1,length(h)-1) ], [x zeros(1,length(h)-1) ]);
g1=h*xm
subplot(2,2,1);
stem(Y)
ylabel('Y[n]');
xlabel('----->n');
title('Convolution in the time domain')
subplot(2,2,2);
stem(u)
ylabel('Y[n]');
xlabel('----->n');
title('Convolution in the Z-domain')
subplot(2,2,3);
stem(g1)
xlabel('-----> n');
ylabel('Y(n)');
title('Convolution as a matrix multiplication');
subplot(2,2,4)
g=conv(x,h)
stem(g)
xlabel('-----> n');
ylabel('Y(n)');
title('Convolution using intrinsic conv(x,h)');

For the wavelets:


x=[1,0,-1,2]
y=[5,-5,4,0,1,-1]
These are the plots that are produced:

The last graphs displays the intrinsic conv operation.


2) Discrete correlation. Code a function which performs a discrete correlation between two
arbirtrary wavelets. The function needs to return both the value and the time lag.
a) Perform direct correlation in the time domain.
b) Apply a variable substitution to write a correlation as a convolution. You can now check your
routine (a) using the Matlab intrinsic conv.
x=input('Enter the sequence 1: ');
h=input('Enter the sequence 2: ');
y=xcorr(x,h);
figure;
subplot(3,1,1);
stem(x);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 1');
subplot(3,1,2);
stem(fliplr(y));
stem(h);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 2');
subplot(3,1,3);
stem(fliplr(y));
xlabel('n->');
ylabel('Amplitude->');
title('Output sequence');
disp('The resultant is');
fliplr(y);

3) Linear filtering.
The wavelet b is given by [0,-1,0,1,2,4,3,1,0]. The delay filter f is given by [0,0,0,0,1].
a) Apply the delay filter to wavelet b. Plot the original and the delayed wavelet.
b) Compute and visualise the cross-correlation between b and b*f and explain how the time
difference between b and b*f can be estimated.
c) Perturb f with random noise. Compute and visualise the cross-correlation between the two
waveforms and determine the time shift.
b=[0,-1,0,1,2,4,3,1,0]
f=[0,0,0,0,1]
t=[0:1:14]
disp('DELAYED WAVELET:')
h=conv(b,f)
disp('CROSS CORRELATION:')
g=crosscorr(b,h)
disp('TIME DELAY:')
tau=-1+length(f)
amp=0.50
disp('RANDOM NOISE:')
noise=amp*rand(1,length(f))-amp/2
disp('PERTURBED f:')
fnew=f+noise
disp('DELAYED WAVELET W/ NOISE:')
hnoise=conv(b,fnew)
disp('CROSS CORRELATION W/ NOISE:')
gnoise=crosscorr(b,hnoise)
disp('AUTOCORRELATION OF NOISE:')
autocorr=crosscorr(noise,noise)
subplot(3,3,1)
stem(b)
axis([0 15 -5 5])
title('ORIGINAL WAVELET')
subplot(3,3,2)
stem(h)
axis([0 15 -5 5])
title('DELAYED WAVELET')
subplot(3,3,3)
stem(f)
axis([0 15 -5 5])
title('FILTER F')
subplot(3,3,4)
stem(fnew)
title('F WITH NOISE')
axis([0 20 -2 2])
subplot(3,3,5)
stem(hnoise)
title('DELAYED WAVELET WITH NOISE')
axis([0 20 -2 10])
subplot(3,3,6)
stem(gnoise)
title('CROSSCORRELATION WITH NOISE')
subplot (3,3,7)
stem(noise)
title('THE NOISE')
subplot (3,3,8)
stem(autocorr)
title('NOISE AUTOCORRELATION')

Geophysical Data Processing: Exercise 4


1) Notch filter. The discrete signal f(t) is given by f (t)=cos( 2 1 t) and it is perturbed by noise
characterised by g (t )=cos (2 2 t) with frequencies 1=12.5 Hz and 2 =50 Hz . The
signal is recorded at interval =4 ms , use N=512 samples. The noise hast to be eliminated form
the signal by filtering it with a notch filter.
Y ( z ) B( z )
a) Show that for any LTI filter the transfer function is given by H ( z )=
=
where the
X ( z ) A( z )
coefficients of B(z) and A(z) are the filter coefficients bi and aj. Find the filter coefficients of the
notch filter and compute and visualise the impulse response for =0,05, =0,1 and =-0,01.
b) Compute the frequency response. What other possibility can you think of to get the frequency
response?
c) Apply the filter to the signal and investigate the influence of different values for .
nu1=12,5
nu2=50
tau=0.004
t=[0:0.01:5.12]
nus=[0:0.01:5.12]
epsilon=0.05
f1=cos(2*pi*nu1*t)
f2=cos(2*pi*nu2*t)
f=f1+f2
Z=exp(2*j*pi*nus*tau)
Z0=exp(-2*j*nu2*tau)
ZP=(1+epsilon)*exp(-2*j*nu2*tau)
A=(Z-Z0)
B=(Z-ZP)
C=(Z-conj(Z0))
D=(Z-conj(ZP))
C=C'
D=D'
H=(A*C)/(B*D)
filtered=conv(f,H)
subplot(3,1,1)
stem(f)
subplot(3,1,2)
stem(filtered)

2) Butterworth filter. A Butterworth filter is a common form of a low pass filter defined by the
following amplitude spectrum.
1
F ( )=F ( ) F ( )=
2n
1+
C
Where C is the cut-off frequency, n is the number of poles which determines the rate of decay of the
() is the complex conjugate of F().
filter and F
a) Use the bilinear transformation to find an expression for F(z) for a second order Butterworth
filter (n=2). An expression can be obtained in the form F(z)=A(z)/B(z), where A(z) and B(z) are
polynomials in z.
b) Construct a second order (n=2) recursive Butterworth filter and give the impulse response.
c) Give the frequency response of a second-order Butterworth filter.
d) Apply the Butterworth filter to remove the noise from the signal in exercise 1.

( )

j c
j c
c
2sin 3 / 4 2 sin 3 / 4
F ( s )=
=
+
( ss 1)( ss 2)
( ss 1)
(ss 2 )
The bilinear transformation:
1z
1 1z
2j =2
=
1+z
j 1+z
Then:
c
sin ( C sin 3 / 4 ) e cos 3 / 4 z 1
sin 3 /4
=
F ( s)=
12cos( C sin 3 /4) e cos 3 / 4 z1+e 2 cos 3 / 4 z2
2
1
2
C (1+2z +z )
=
2
2
1
2
2
44 C cos 3 / 4+ c +(8+2 C ) z +(4+4 C cos 3 / 4+C ) z
C

Geophysical Data Processing: Exercise 5


1) The problem is to find the inverse wavelet h of length 2 of the wavelet g=(6,5,1). First find the
inverse by series expansion of its Z-transform.
In the time domain we had: g=(6,5,1). Its Z-Transform is then: G(Z)=6+5Z+Z2
If we are looking for an H(Z) that does the trick: G(Z)H(Z)=1, then:

H ( Z )=

1
, so:
G(Z )

1 5
H ( Z )= + Z which in the time domain is: h=(1/6,5/12)
6 12
In a second approach find the optimum inverse wavelet. What is the best deconvolution operator in
this case and why?
So

The best deconvolution operator would be the Wiener Filter, also known as the Optimal Inverse
Filter. Is the best approach because it minimises the error.
We have g=(6,5,1) and h=(h0,h1) is its inverse.
Convolving both of them:
g*h=(6h0 , 6h1 +5h0 , 5h1+h0, h1).
The error is:
ERR=( gh)=(6h 01, 6h 1+5h0 , 5h1+h0, h 1)
and its energy:
E 2=(6h 01)2+( 6h1+5h0 )2+(5h 1+h0 )2+h21=62 h20+62 h21+70 h1 h012 h01
The energy function has to be minimum, so:
E2
E2
df =
dh0+
dh1 =0 this means that the partial derivatives have to be zero.
h0
h1
So:
E2
=124 h 0+70 h112=0
h0 =0,02
h0
so h=(1/50,-7/500)
E2
=124 h 1+70 h 0=0
h1 =0,014
h 1
Substituting in the expression for the energy we get: E2=0,77, whereas the energy of the error when
doing the polynomial division is E2d=16,34. Therefore we can conclude that the Wiener filter yields
a much better approximation.

2) Consider the function x(t)=cos (20t) with 0=0,5Hz. Sample x(t) every second. Take six samples
in total. What happens if you sample every two seconds? In what follows we only consider the case
of a sampling interval of 1 second? Calculate the autocorrelation of x(t). Calculate the prediction
filter of length 2 which gives x6, the 7th sample of x(t). Compare the prediction to the true value. In
general, the predicted values of x(t) are given by x(t)*f(t). Give the succesive errors for these
predictions (r1,r2...) and comment.
nu=0.5
t1=[0:1:5]
t2=[0:2:5]
t3=[0:0.16:1]
x1=cos(2*pi*nu*t1)
x2=cos(2*pi*nu*t2)
x3=cos(2*pi*nu*t3)
g=xcorr(x1,x1)
h=xcorr(x2,x2)
w=xcorr(x3,x3)
subplot(3,1,1)
plot(t1,x1)
title('Sampling every second')
subplot(3,1,2)
plot(t2,x2)
title('Sampling every 2 seconds')
subplot(3,1,3)
plot(t3,x3)
title('Sampling interval of 1 second')
figure
subplot(3,1,1)
stem(g)
title('Autocorrelation of x1')
subplot(3,1,2)
stem(h)
title('Autocorrelation of x2')
subplot(3,1,3)
stem(w)
title('Autocorrelation of x3')

Geophysical Data Processing: Exercise 6


sigma=0.1
G=[ 0.3338 1.6971 0
2.0309 0
0
2.0309
0
2.0110 0
0
2.0110 0
0.4883
0
2.0012 0
0
2.0012 0
0
0
2.0012 0
0
2.0012 0
0
0
2.0110 0
0
2.0110 0
0
0.4883;
0
1.6971 0.3338 0
0
2.0309 0
2.0309;
0
0
0
1.6971 0
0
0.3338
2.0309;
0
0
0
2.0110 2.0110 1.5227 0
0
0
0
2.0012 2.0012 2.0012 0
0
0
0
2.0012 2.0012 2.0012 0
0
0
0.4883 2.0110 2.0110 1.5227 0
0.3338 2.0309 2.0309 1.6971 0
0
0
m=[50 60 50 60 58 60 50 60 50];
mt=m'
%SOLVING THE FORWARD PROBLEM:
d=G*mt
%SOLVING BY LEAST SQUARES
GT=transpose(G)
mls=(inv(GT*G))*GT*d
Cm=sigma*(inv(GT*G))
R=(inv(GT*G))*(GT*G)
%SOLVING BY ALTERNATIVE MODDEL (MINIMUM NORM)
mmns=GT*inv(G*GT)*d
%SOLVING BY A MORE GENERAL MODEL(REGULARISED MNS)
Cd=(d-sigma*d)'*(d-sigma*d)
Cmm=(mt-sigma*mt)'*(mt-sigma*mt)
mrmns=inv(GT*inv(Cd)*G+inv(Cmm))*GT*inv(Cd)*d

0
1.5227
2.0012
2.0012
1.5227

0;
0;
0;
0;

0
2.0309
0
0
0
0
0

0.4883
0;
0;
0;
0];

%initial model, least squares, minimum norm and regularised mns


[mt,mls,mmns,mrmns]

Potrebbero piacerti anche