2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example:...

17
1 A particularly useful class of solutions: u( x, t ) = Ae i(ωt ± kx ) = A [cos( ωt ± kx ) + i sin( ωt ± kx )] k=wavenumber, v=speed, w=angular frequency This constitute a function of both wave number and frequency. To analyze the spectral characteristics we need to use a 2D Fourier Transform . 2D Fourier Transform (2DFT) In fact, k could be a vector k in 3D, then we have several dimensions! F ( k x , k y ) = f ( x , y )e j ( k x x + k y y ) dxdy −∞ −∞ Definition : The 2DFT of a function f(x,y) is defined as f ( x, y ) = 1 (2π ) 2 F ( k x , k y )e j ( k x x + k y y ) dk x dk y −∞ −∞ Then inverse 2DFT is v = w k (k expressed in radians/sec) Wave Equation (2D) 2 u( x, t ) x 2 = 1 v 2 2 u( x, t ) t 2 km

Transcript of 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example:...

Page 1: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

1

A particularly useful class of solutions:

u(x,t) = Aei(ωt±kx ) = A[cos(ωt ± kx) + isin(ωt ± kx)]

k=wavenumber, v=speed, w=angular frequency

This constitute a function of both wave number and frequency. To analyze the spectral characteristics we need to use a 2D Fourier Transform.

2D Fourier Transform (2DFT)

In fact, k could be a vector k in 3D, then we have several dimensions!

F(kx,ky ) = f (x,y)e− j(kxx+kyy )dxdy−∞

∫−∞

Definition: The 2DFT of a function f(x,y) is defined as

f (x,y) =1

(2π )2F(kx,ky )e

j(kxx+kyy )dkxdky−∞

∫−∞

Then inverse 2DFT is

v =wk

(k expressed in radians/sec)

Wave Equation (2D)

∂ 2u(x, t)∂x 2

=1v 2∂ 2u(x, t)∂t 2

km

Page 2: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

2

Other examples:

F(k,ω) = Ae− j (ωt+kx ) dxdt−∞

∫−∞

∫Back to 1D seismic wave solution (assume propagating in +x direction):

k=spatial frequency, w=angular frequency=2p/T

Image compression or blurring/deblurring

As simple as doing these:(1) Load the image into a 2D matrix(2) Perform fft (2D) on this matrix(3) Multiplying frequencies with a function (of

frequency), or simply remove small coefficients(4) Fft back to the space-time domain

Image decompression:For a digital image, it is usually much simpler to save the coefs of number of discrete frequencies rather than the whole image. If need to reconstruct image, do Inv FT.

Page 3: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

2D FT seismic example: Velocity filter (I.e. F-k filter or dip filter)A seismic line contains 24 receivers, with 25 m spacing between two adjacent stations. The time shift is 15 ms/trace. The total length of each seismogram is 1 sec, with sampling rate of 0.001 sec. Find the seismic velocity (or propagation speed) of the medium using 12 Hz wavelet.

Page 4: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

4

2D fft Numerical example (dip filter)

(see program fkdip.m)

w = 3.14159*2.0*12.0; % w=2*pi*freqdelta = 0.001; % sampling intervalss = -0.015; % phase delay between adjacent seismographsY=[];time=(0:delta:1.0); m=length(time); % number of time pointsfor i=1:24

ss = ss+0.015; xx=w*time-ss*w; y = cos(xx);Y = [Y y'];

end

Sample code:

Fill matrix columns by sinusoids

Computes w*(t-phi)

15 ms

25 m

Page 5: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

5

2D FFT Algorithm:1D FT a column of Y

Save the coef in the same column

Once columns all become coefs, do 1D transform a row at a time, replace old coefs with new coefs

Now, to compute velocity, dof/k = (12 cycles/sec) / (7.2 cycles/km) = 1.67 km/s = phase vel

Spatial wavenumber (cycles/km)

Matlab function:fft2()

Why the artifact?

Page 6: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

6

Discretization and Discrete SignalsSo far, we have talked about continuous functions and Fourier Series/Transforms for them. Realistically, observations are better stored and operated on as discretesample points.

An infinite discrete signal fs(t) is obtained by sampling f(t)every Dt seconds,

fs(t) = f (t) δ(t − kΔt)k=−∞

Where Dt is called the sampling interval (or sample rate). Time series: Discrete time function

discrete step function

Page 7: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

7

t=-4:6; % time axis, discrete at 1 sec per sample

ft=[0 -3 1 0 1 2 1 0 -1 0 0]; % make a function f(t)

figure; % start figure environment

subplot(2,2,1); % make a figure with 4 subfigs,

% 2 rows, 2 columns, plot 1st.

stem(t,ft, 'filled'); % make a stem plot with filled circles

title('any discrete function'); xlabel('t(sec)'); ylabel('f(t)');

subplot(2,2,2); % set up second panel

delta=[]; % declare delta to be an array

for i=1: length(t)

if(t(i)<0)

delta(i)=0.0; discrete_sig.m

else

delta(i)=1;

end

end

stem(t,delta, 'filled'); % make a stem plot with filled circles

title('discrete delta function'); xlabel('t(sec)'); ylabel('f(t)');

subplot(2,2,3); % set up 3rd panel

for i=1: length(t)

if(t(i)<0)

delta(i)=0.0;

else

delta(i)=t(i);

end

end

stem(t,delta, 'filled'); % make a stem plot with filled circles

title('discrete unit ramp function'); xlabel('t(sec)'); ylabel('f(t)');

subplot(2,2,4); % set up 4th panel

delta=cos(t);

stem(t,delta, 'filled'); % make a stem plot with filled circles

title('discrete unit cosine function'); xlabel('t(sec)'); ylabel('f(t)');

Page 8: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

8

What happens otherwise? ALIASING!

Idea of Nyquist Frequency:A continuous signal can be well restored by a discrete signal with sampling interval Dt --->0. For a given time series with sampling interval Dt, the highest frequency that can be restored is 1/(2Dt) which is the Nyquist Frequency of the time series.

fNyquist =1

2Δt; Δt = sampling interval

= fs/2; f s = 1/Δt = sampling frequency

fNyquist ≥ fmax fmax = max frequency of a bandlimitted signalTo be �authentic�

fs2≥ fmax ⇒ f s ≥ 2 fmax

i.e.: fs must be greater or equal to twice the fmax of the signal!

Aliasing Problem

Page 9: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

9

See provided matlab code nyquist_spec.m

P

S Rayleigh

0.1 sec sampling

0.2 sec sampling

0.8 sec sampling

Page 10: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

10

Example of sampling without aliasing:

(see attached Matlab code nyquist_gt_fmax_4panels.m)

Experiment Setup:

Sinosoidal, signal frequency = 25 Hz

Example of

sampling

causing aliasing:

(see attached

Matlab code

nyquist_150hz.m).

Signal freq=150 Hz

Fn =1/(2*0.002)=250 Hz

Fn =125 Hz

Folding Frequency and Aliasing

Page 11: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

11

Effect of Undersampling:

(2) Introduce aliasing, I.e., frequencies above the Nyquist

are lost after sampling, but reappears at frequencies

below the Nyquist. The high frequencies are not �lost�per say, but actually folded back onto the spectrum as

low frequencies. --> contamination of low frequencies.Computation of Alias frequency

(1) Bandlimit the spectrum of a continuous signal, with

the highest frequency equals the Nyquist frequency.

Solution to undersampling:

(1) Nothing can be done about effect (1)

(2) People typically use some type of filter to remove high

frequency signals above Nyquist. Then do Fourier spectrum.

fa = 2mfN − f s

fa is the folding (aliasing) frequency, f s is the signal (or input)frequency, m is the smallest integer such that f a< fNExample:

Suppose fs=65 Hz, fN=62.5 Hz, find alias frequency.

Guess m=0, fa = 65 Hz > fN, no

Guess m=1, fa = 60 Hz < fN, yes

Graphically,

fn=62.5FREQ (Hz)

fs=65fa=60

Page 12: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

A few important pointsNon-Matlab issues:

Input is a real function, so symmetric amp spectrum (why? As proved before F(-w)=F*(w), which yields same |F(w)|)

As demonstrated, nonzero average --> 0 frequency (this is one of the reasons that seismologists detrend the data before doing fft or filter, see nyquist_spec_const.m, see next page).Nonzero frequencies seem to shift to lower end (close to 0) when under-sampled due to Aliasing.

Matlab issues:

F(k) = x(n)n=1

N

∑ e− j*2π *(k−1)*(n−1)/N where 1≤ k ≤N

FFT(x) returns the discrete Fourier transform (DFT) of vector x. For length N input vector x, the DFT is a length N vector F, with elements

n is t in the discrete sense, 2p(k-1)/N is related to frequency w.

Examples: dft_simple.m, dft_simple_odd.m, dft_fftshift.m

f (n) =1N

X(k)k=1

N

∑ e j*2π *(k−1)*(n−1)/N where 1≤ n ≤N

Do you see a potential problem in this formulation?

Page 13: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

13

The code is different from the earlier version by this line:

ff=load('regional_EQ.V');t=ff(:,1);ft=ff(:,2);

ft=ft+2e-6;Adds a constant shift to the original time series.

Gets back an average (actually, Matlab gives SUM, I divided by the number of data to get the average) at the zero freq!

Page 14: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

14

1. In mathematics, the Discrete Fourier Transform (DFT) is a specific kind of Fourier transform.

Ins and Outs of Discrete Fourier Transform (DFT)

2. Requires a continuous function being Sampled at specific time/spatial points.

3. Only evaluates enough frequency samples to reconstruct the time-segmented finite samples

4. Assumes the limited time samples are from 1 period (hence the range is limited from 0à2 PI (or –PI to PI) and this periodicity repeats forever. A window function is often added to remove high-freq contamination (recall: time limited signal cannot be band-limited)-à a little bit of artifactsNot too big since the frequencies at super high freq usually have small amps.

5. For the same reason as 4, inverse DFT (IFFT) will not be able to reconstruct the infinite time series from a non-infinite time series.

Page 15: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

15

The DFT maps a discrete signal into the frequency domain where the limit of w is [0, 2p).

Suppose: time series has N points, then the waxis can be discretised as

ωk =k ⋅ 2πN

, k = 0, 1, ..., N -1

N= length of Fourier Transform, and

X(ωk ) = xne− jω kn

n= 0

N−1

∑ ,

k = 0, 1, 2, .., (N -1)So the DFT maps the N-point time series to N-point coefficients Xk = X(wk) in frequency domain!

0

2pp

w

N=8

Nyquist at w=p

complex coefficient ordering in Matlab.Matlab considers frequencies from 0 ---> 2p

0

(2p)p

(-p)

p/2

3p/2 (-p/2)

after fftshift, move 0 freq to center

0 p-df(-p)

N/2+11 N

Check program dft_simple.m for unshifted frequency storage, useful for visualization (careful here!). Questions: (1) What does it say about the coefficients (complex vs. real)? (2) What can I say about the time series?

Page 16: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

16

>> type dft_simple.m

% this little code finds DFT of a simple time series.

z=[1, 2, 3, 4, 5, 6];w=fft(z)

>> dft_simplew =Columns 1 through 321.0000 -3.0000 + 5.1962i -3.0000 + 1.7321iColumns 4 through 6-3.0000 -3.0000 - 1.7321i -3.0000 - 5.1962i

>> type dft_simple_shift.m

% this little code finds shifted DFT of a simple time series.

z=[1, 2, 3, 4, 5, 6];w=fft(z);w=fftshift(w)

>> dft_simple_shiftw =

Columns 1 through 3-3.0000 -3.0000 - 1.7321i -3.0000 - 5.1962iColumns 4 through 621.0000 -3.0000 + 5.1962i -3.0000 + 1.7321i

Unshifted DFT storage in matlab

shifted DFT storage in matlab

Page 17: 2D Fourier Transform (2DFT)ygu/courses/geoph426/notes/... · 2019-09-23 · 2D FT seismic example: Velocity filter (I.e. F -k filter or dip filter) A seismic line contains 24 receivers,

17

% this program demonstrates the input pattern for matlab,% as well as symmetry of Fourier transforms for real even and real odd functionsz=[4 1 0 1 4]fft(z)

Output: (Not symmetric due to MATLAB corkiness, this input is actually regarded as a shifted symmetric func, which is multiplication of F(w) by a complex exponential10.0000 4.7361 + 3.4410i 0.2639 + 0.8123i

0.2639 - 0.8123i 4.7361 - 3.4410i

Replace the input byz=[0 1 4 4 1]fft(z)

Output: 10.0000 -5.8541 0.8541 0.8541 -5.8541(which is real symmetric spectrum!!)

Real Odd funcz=[0 1 4 -4 -1]fft(z)

Symmetric function input/Fourier symmetry (see code symmetry_fft.m)

Output: 0 0 - 6.6044i 0 + 6.4329i 0 - 6.4329i 0 + 6.6044i (Complex Odd Spectrum!!)