13.07.2014 Views

pdf - Madagascar

pdf - Madagascar

pdf - Madagascar

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Homework 5<br />

Thomas Bayes<br />

This homework has two parts.<br />

ABSTRACT<br />

1. Theoretical questions related to covariance estimation.<br />

2. Missing data interpolation for ocean floor topography using covariance estimation.<br />

PREREQUISITES<br />

Completing the computational part of this homework assignment requires<br />

• <strong>Madagascar</strong> software environment available from<br />

http://www.ahay.org/<br />

• L A TEX environment with SEGTEX available from<br />

http://www.ahay.org/wiki/SEGTeX<br />

To do the assignment on your personal computer, you need to install the required<br />

environments. Please ask for help if you don’t know where to start.<br />

The homework code is available from the <strong>Madagascar</strong> repository by running<br />

svn co http://svn.code.sf.net/p/rsf/code/trunk/book/geo391/hw5<br />

THEORY<br />

1. The following equality for the posterior model covariance was given in lecture<br />

notes without a proof:<br />

Ĉ m = ( F T C −1<br />

n<br />

Prove it.<br />

)<br />

F + C −1 −1<br />

m = Cm − C m F ( ) T F C m F T −1<br />

+ C n F Cm . (1)


2<br />

2. Suppose that we use the gradient operator for data interpolation:<br />

min |∇m| 2 . (2)<br />

This approach roughly corresponds to minimizing the surface area and represents<br />

the behavior of a soap film or a thin rubber sheet.<br />

The corresponding inverse model covariance operator is the negative Laplacian<br />

C −1<br />

m = ∇ T ∇ = −∇ 2 . The corresponding covariance operator corresponds to<br />

the Green’s function G(x) that solves<br />

In 2-D, the Green’s function has the form<br />

with some constant A.<br />

−∇ 2 G = δ(x − x 0 ) . (3)<br />

G(x) = A − ln |x − x 0|<br />

2π<br />

To derive equation (4), we can introduce polar coordinates around x 0 with the<br />

radius r = |x−x 0 | and note that the Laplacian operator for a radially-symmetric<br />

function φ(r) in polar coordinates takes the form<br />

Away from the point x 0 , solving<br />

∇ 2 φ = 1 r<br />

1<br />

r<br />

d<br />

dr<br />

d<br />

dr<br />

(<br />

r dφ )<br />

dr<br />

(4)<br />

(5)<br />

(<br />

r dG )<br />

= 0 (6)<br />

dr<br />

leads to G(r) = A + B ln r. To find the constant B, we can integrate ∇ 2 G<br />

over a circle with some small radius ɛ around the origin and apply the Green’s<br />

theorem<br />

∫∫<br />

−1 =<br />

∮<br />

∇ 2 Gdx dy =<br />

∇G · ⃗ds =<br />

∫ 2π<br />

0<br />

∂G<br />

∂r<br />

∣ ɛ dθ = 2π B . (7)<br />

r=ɛ<br />

Derive the model covariance function G(x) which corresponds to replacing equation<br />

(2) with equation<br />

min ∣ ∣ ∇ 2 m ∣ ∣ 2 (8)<br />

and approximates the behavior of a thin elastic plate.


3<br />

Figure 1: (a) Water depth measurements from one day of SeaBeam acquisition. (b)<br />

Mask for locations of known data.<br />

MISSING OCEAN-FLOOR DATA INTERPOLATION<br />

SeaBeam is an apparatus for measuring water depth both directly under a boat and<br />

somewhat off to the sides of the boat’s track. In this part of the assignment, we will<br />

use a benchmark dataset from Claerbout (2008): SeaBeam data from a single day of<br />

acquisition. The original data are shown in Figure 1a.<br />

Program interpolate.c implements two alternative methods: regularized inversion<br />

using convolution with a multi-dimensional filter and preconditioning, which uses<br />

the inverse operation (recursive deconvolution or polynomial division on a helix) for<br />

model reparameterization.<br />

Our first attempt is to use the Laplacian-factor filter from the previous homework.<br />

The results from the two methods are shown in Figure 2. They are not very successful<br />

in hiding the “acquisition footprint”.<br />

Next, we will try to estimate the model covariance from the available data. The<br />

covariance can be estimated using two alternative methods: the fast Fourier transform<br />

(FFT) method (Marcotte, 1996) and the prediction-error filter (PEF) method<br />

(Claerbout and Brown, 1999). Random realizations of model patterns from the two<br />

methods and the corresponding 2-D Fourier spectra are shown in Figures 3 and 4.<br />

Our new attempt to interpolate missing data using the helical prediction-error<br />

filter is shown in Figure 5.


4<br />

Figure 2: Left: missing data interpolation using regularization by convolution with a<br />

Laplacian factor. Right: missing data interpolation using model reparameterization<br />

by deconvolution (polynomial division) with a Laplacian factor.<br />

Figure 3: Left: data pattern generated using FFT method for covariance estimation.<br />

Right: its Fourier spectrum.


5<br />

Figure 4: Left: data pattern generated using PEF method for inverse covariance<br />

estimation. Right: its Fourier spectrum.<br />

Figure 5: Left: missing data interpolation using regularization by convolution with<br />

a prediction-error filter. Right: missing data interpolation using model reparameterization<br />

by deconvolution (polynomial division) with a prediction-error filter.


6<br />

seabeam/interpolate.c<br />

1 /∗ Multi−dimensional missing data i n t e r p o l a t i o n . ∗/<br />

2<br />

3 #include <br />

4<br />

5 int main ( int argc , char∗ argv [ ] )<br />

6 {<br />

7 int na , ia , n i t e r , n , i ;<br />

8 float a0 , ∗mm, ∗ zero ;<br />

9 bool prec , ∗known ;<br />

10 char ∗ l a g f i l e ;<br />

11 s f f i l t e r aa ;<br />

12 s f f i l e in , out , f i l t , lag , mask ;<br />

13<br />

14 s f i n i t ( argc , argv ) ;<br />

15 in = s f i n p u t ( ” in ” ) ;<br />

16 f i l t = s f i n p u t ( ” f i l t ” ) ;<br />

17 /∗ f i l t e r f o r i n v e r s e model covariance ∗/<br />

18 out = s f o u t p u t ( ” out ” ) ;<br />

19<br />

20 n = s f f i l e s i z e ( in ) ;<br />

21<br />

22 i f ( ! s f g e t b o o l ( ” prec ”,& prec ) ) prec=true ;<br />

23 /∗ I f y , use p r e c o n d i t i o n i n g ∗/<br />

24 i f ( ! s f g e t i n t ( ” n i t e r ”,& n i t e r ) ) n i t e r =100;<br />

25 /∗ Number o f i t e r a t i o n s ∗/<br />

26<br />

27 i f ( ! s f h i s t i n t ( f i l t , ”n1”,&na ) ) s f e r r o r ( ”No n1=” ) ;<br />

28 aa = s f a l l o c a t e h e l i x ( na ) ;<br />

29<br />

30 i f ( ! s f h i s t f l o a t ( f i l t , ”a0”,&a0 ) ) a0 =1.;<br />

31<br />

32 /∗ Get f i l t e r l a g s ∗/<br />

33 i f (NULL == ( l a g f i l e = s f h i s t s t r i n g ( f i l t , ” l a g ” ) ) ) {<br />

34 for ( i a =0; i a < na ; i a++) {<br />

35 aa−>l a g [ i a ]= i a +1;<br />

36 }<br />

37 } else {<br />

38 l a g = s f i n p u t ( l a g f i l e ) ;<br />

39 s f i n t r e a d ( aa−>lag , na , l a g ) ;<br />

40 s f f i l e c l o s e ( l a g ) ;<br />

41 }<br />

42<br />

43 /∗ Get f i l t e r v a l u e s ∗/


7<br />

44 s f f l o a t r e a d ( aa−>f l t , na , f i l t ) ;<br />

45 s f f i l e c l o s e ( f i l t ) ;<br />

46<br />

47 /∗ Normalize ∗/<br />

48 for ( i a =0; i a < na ; i a++) {<br />

49 aa−>f l t [ i a ] /= a0 ;<br />

50 }<br />

51<br />

52 mm = s f f l o a t a l l o c (n ) ;<br />

53 zero = s f f l o a t a l l o c (n ) ;<br />

54 known = s f b o o l a l l o c (n ) ;<br />

55<br />

56 /∗ s p e c i f y known l o c a t i o n s ∗/<br />

57 mask = s f i n p u t ( ”mask” ) ;<br />

58 s f f l o a t r e a d (mm, n , mask ) ;<br />

59 s f f i l e c l o s e ( mask ) ;<br />

60<br />

61 for ( i =0; i < n ; i++) {<br />

62 known [ i ] = ( bool ) (mm[ i ] != 0 . 0 f ) ;<br />

63 zero [ i ] = 0 . 0 f ;<br />

64 }<br />

65<br />

66 /∗ Read input data ∗/<br />

67 s f f l o a t r e a d (mm, n , in ) ;<br />

68<br />

69 i f ( prec ) {<br />

70 s f m a s k i n i t ( known ) ;<br />

71 s f p o l y d i v i n i t (n , aa ) ;<br />

72 s f s o l v e r p r e c ( sf mask lop , s f c g s t e p , s f p o l y d i v l o p ,<br />

73 n , n , n , mm, mm, n i t e r , 0 . , ”end” ) ;<br />

74 } else {<br />

75 s f h e l i c o n i n i t ( aa ) ;<br />

76 s f s o l v e r ( s f h e l i c o n l o p , s f c g s t e p , n , n , mm, zero ,<br />

77 n i t e r , ”known” , known , ”x0” , mm, ”end” ) ;<br />

78 }<br />

79<br />

80 s f f l o a t w r i t e (mm, n , out ) ;<br />

81<br />

82 e x i t ( 0 ) ;<br />

83 }


8<br />

1 from r s f . p r o j import ∗<br />

seabeam/SConstruct<br />

2<br />

3 # Download data<br />

4 Fetch ( ’ apr18 . h ’ , ’ seab ’ )<br />

5 Flow ( ’ data ’ , ’ apr18 . h ’ , ’ dd form=n a t i v e ’ )<br />

6<br />

7 def grey ( t i t l e ) :<br />

8 return ’ ’ ’<br />

9 grey p c l i p =100 l a b e l s z =10 t i t l e s z =12<br />

10 transp=n y r e v e r s e=n<br />

11 l a b e l 1=l o n g i t u d e l a b e l 2=l a t i t u d e t i t l e =”%s ”<br />

12 ’ ’ ’ % t i t l e<br />

13<br />

14 def sgrey ( t i t l e ) :<br />

15 return ’ ’ ’<br />

16 grey l a b e l s z =10 t i t l e s z =12 a l l p o s=y<br />

17 transp=n y r e v e r s e=n t i t l e =”%s ”<br />

18 l a b e l 1 =1/ l o n g i t u d e l a b e l 2 =1/ l a t i t u d e<br />

19 ’ ’ ’ % t i t l e<br />

20<br />

21 # Bin to r e g u l a r g r i d<br />

22 Flow ( ’ bin ’ , ’ data ’ ,<br />

23 ’ ’ ’<br />

24 window n1=1 f1=2 | math output =’(2978− input )/387 ’ |<br />

25 bin head=$SOURCE n i t e r =150 nx=160 ny=160 xkey=0 ykey=1<br />

26 ’ ’ ’ )<br />

27<br />

28 # Mask f o r known data<br />

29 Flow ( ’msk ’ , ’ bin ’ ,<br />

30 ’ ’ ’<br />

31 math output=”abs ( input )” |<br />

32 mask min=0.001 | dd type=f l o a t<br />

33 ’ ’ ’ )<br />

34<br />

35 Plot ( ’ bin ’ , grey ( ’ Binned ’ ) )<br />

36 Plot ( ’msk ’ , grey ( ’Mask ’ ) + ’ a l l p o s=y ’ )<br />

37<br />

38 Result ( ’ data ’ , ’ bin msk ’ , ’ SideBySideAniso ’ )<br />

39<br />

40 # Laplacian f a c t o r i z a t i o n<br />

41<br />

42 Flow ( ’ lag0 . asc ’ , None ,<br />

43 ’ ’ ’


9<br />

44 echo 1 160 n1=2 n=160 ,160<br />

45 data format=a s c i i i n t in=$TARGET<br />

46 ’ ’ ’ )<br />

47 Flow ( ’ lag0 ’ , ’ lag0 . asc ’ , ’ dd form=n a t i v e ’ )<br />

48<br />

49 Flow ( ’ f l t 0 . asc ’ , ’ lag0 ’ ,<br />

50 ’ ’ ’<br />

51 echo −1 −1 a0=2 n1=2 l a g=$SOURCE<br />

52 data format=a s c i i f l o a t in=$TARGET<br />

53 ’ ’ ’ , s t d i n =0)<br />

54 Flow ( ’ f l t 0 ’ , ’ f l t 0 . asc ’ , ’ dd form=n a t i v e ’ )<br />

55<br />

56 Flow ( ’ l a p f l t l a p l a g ’ , ’ f l t 0 ’ ,<br />

57 ’ wilson eps=1e−3 lagout=${TARGETS[ 1 ] } ’ )<br />

58<br />

59 # Missing data i n t e r p o l a t i o n with Laplacian<br />

60<br />

61 n i t e r =100<br />

62<br />

63 program = Program ( ’ i n t e r p o l a t e . c ’ )<br />

64<br />

65 for prec in ( 0 , 1 ) :<br />

66 i n t e r p=’ l i n t e r p%d ’ % prec<br />

67 Flow ( interp , ’ bin msk l a p f l t %s ’ % program [ 0 ] ,<br />

68 ’ ’ ’<br />

69 . / ${SOURCES[ 3 ] } prec=%d n i t e r=%d<br />

70 mask=${SOURCES[ 1 ] } f i l t =${SOURCES[ 2 ] }<br />

71 ’ ’ ’ % ( prec , n i t e r ) )<br />

72 Plot ( interp , grey ( ’%s p r e c o n d i t i o n i n g ’ %<br />

73 ( ’ Without ’ , ’ With ’ ) [ prec ] ) )<br />

74 Result ( ’ lseabeam ’ , ’ l i n t e r p 0 l i n t e r p 1 ’ , ’ SideBySideAniso ’ )<br />

75<br />

76 # Random r e a l i z a t i o n o f white noise<br />

77 seed = 102012 # CHANGE ME! ! !<br />

78<br />

79 Flow ( ’ white ’ , ’ bin ’ ,<br />

80 ’ ’ ’<br />

81 noise rep=y seed=%d var =0.02<br />

82 ’ ’ ’ % seed )<br />

83<br />

84 # Covariance e s t i m a t i o n by FFT<br />

85<br />

86 import r s f . r e c i p e s . s p a t i a l s t a t s as s t a t s<br />

87<br />

88 par = d i c t ( val=’ bin ’ , ind=’msk ’ ,


10<br />

89 nx=160,ny=160,nz=1,<br />

90 dx =0.00337373 ,<br />

91 dy =0.00338847 ,<br />

92 dz=1)<br />

93<br />

94 r u l e s = {}<br />

95 s t a t s . c o v a r i a n c e ( par , r u l e s )<br />

96 for case in r u l e s . keys ( ) :<br />

97 Flow ( case , r u l e s [ case ] [ 0 ] , r u l e s [ case ] [ 1 ] )<br />

98<br />

99 Flow ( ’ fcov ’ , ’ bin cov ’ ,<br />

100 ’ ’ ’<br />

101 window n1=160 n2=160 |<br />

102 f f t 1 | f f t 3 a x i s=2 |<br />

103 math output=”abs ( input )”<br />

104 ’ ’ ’ )<br />

105 Flow ( ’ rand2 ’ , ’ white fcov ’ ,<br />

106 ’ ’ ’<br />

107 f f t 1 | f f t 3 a x i s=2 |<br />

108 math f c o v=${SOURCES[ 1 ] } output=”input ∗ f c o v ” |<br />

109 f f t 3 a x i s=2 inv=y | f f t 1 inv=y<br />

110 ’ ’ ’ )<br />

111 Plot ( ’ rand2 ’ , grey ( ’FFT Pattern ’ ) )<br />

112<br />

113 Flow ( ’ frand2 ’ , ’ rand2 ’ , ’ s p e c t r a 2 ’ )<br />

114 Plot ( ’ frand2 ’ , sgrey ( ’FFT Spectrum ’ ) )<br />

115<br />

116 Result ( ’ rand2 ’ , ’ rand2 frand2 ’ , ’ SideBySideAniso ’ )<br />

117<br />

118 # Covariance e s t i m a t i o n by PEF<br />

119<br />

120 # Estimate PEF<br />

121 Flow ( ’ pef l a g ’ , ’ bin msk ’ ,<br />

122 ’ ’ ’<br />

123 p e f maskin=${SOURCES[ 1 ] } l a g=${TARGETS[ 1 ] }<br />

124 a=5,3 n i t e r =50<br />

125 ’ ’ ’ )<br />

126<br />

127 Flow ( ’ rand ’ , ’ white pef ’ ,<br />

128 ’ h e l i c o n f i l t =${SOURCES[ 1 ] } div=y ’ )<br />

129 Plot ( ’ rand ’ , grey ( ’REF Pattern ’ ) )<br />

130<br />

131 Flow ( ’ frand ’ , ’ rand ’ , ’ s p e c t r a 2 ’ )<br />

132 Plot ( ’ frand ’ , sgrey ( ’PEF Spectrum ’ ) )<br />

133


11<br />

134 Result ( ’ rand ’ , ’ rand frand ’ , ’ SideBySideAniso ’ )<br />

135<br />

136 # Missing data i n t e r p o l a t i o n with PEF<br />

137<br />

138 n i t e r =20 # CHANGE ME! ! !<br />

139<br />

140 for prec in ( 0 , 1 ) :<br />

141 i n t e r p=’ i n t e r p%d ’ % prec<br />

142 Flow ( interp , ’ bin msk pef %s ’ % program [ 0 ] ,<br />

143 ’ ’ ’<br />

144 . / ${SOURCES[ 3 ] } prec=%d n i t e r=%d<br />

145 mask=${SOURCES[ 1 ] } f i l t =${SOURCES[ 2 ] }<br />

146 ’ ’ ’ % ( prec , n i t e r ) )<br />

147 Plot ( interp , grey ( ’%s p r e c o n d i t i o n i n g ’ %<br />

148 ( ’ Without ’ , ’ With ’ ) [ prec ] ) )<br />

149 Result ( ’ seabeam ’ , ’ i n t e r p 0 i n t e r p 1 ’ , ’ SideBySideAniso ’ )<br />

150<br />

151 End ( )<br />

Your task:<br />

1. Change directory to hw5/seabeam<br />

2. Run<br />

scons view<br />

to reproduce the figures on your screen.<br />

3. Modify the SConstruct file to implement the following tasks:<br />

(a) Find the number of iterations required for both methods shown in Figure 5<br />

to achieve similar results.<br />

(b) To provide a more quantitative comparison, modify the interpolate.c<br />

program to output a measure of convergence (such as the least-squares<br />

misfit) as a function of the number of iterations 1 . Generate figures comparing<br />

convergence with and without preconditioning.<br />

4. A method for generating multiple realizations of missing data interpolation is:<br />

(a) Start with a random realization m 0 such as the one shown in 4 or 3.<br />

(b) Instead of estimating m such that K m = d, estimate x such that<br />

K x = d − K m 0 .<br />

1 You can study the interfaces to the sf solver and sf solver prec programs. See https:<br />

//sourceforge.net/p/rsf/code/HEAD/tree/trunk/api/c/bigsolver.c


12<br />

(c) The estimate for m is then ̂m = ̂x + m 0 .<br />

Implement several realizations of missing data interpolation using several realizations<br />

of m 0 . You can do it by modifying either SConstruct or interpolate.c.<br />

5. Include your results in the paper.<br />

6. EXTRA CREDIT for implementing missing data interpolation using the FFT<br />

method for model covariance.<br />

COMPLETING THE ASSIGNMENT<br />

1. Change directory to hw5.<br />

2. Edit the file paper.tex in your favorite editor and change the first line to have<br />

your name instead of Bayes’s.<br />

3. Run<br />

sftour scons lock<br />

to update all figures.<br />

4. Run<br />

sftour scons -c<br />

to remove intermediate files.<br />

5. Run<br />

scons <strong>pdf</strong><br />

to create the final document.<br />

6. Submit your result (file paper.<strong>pdf</strong>) on paper or by e-mail.<br />

REFERENCES<br />

Claerbout, J., 2008, Image estimation by example: Environmental soundings image<br />

enhancement: Stanford Exploration Project.<br />

Claerbout, J., and M. Brown, 1999, Two-dimensional textures and prediction-error<br />

filters: 61st Mtg., Eur. Assn. Geosci. Eng., Session:1009.<br />

Marcotte, D., 1996, Fast variogram computation with FFT: Computers and Geosciences,<br />

22, 11751186.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!