-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain_synthetic_test.m
221 lines (184 loc) · 7.8 KB
/
main_synthetic_test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
addpath('.\functions\')
load('.\data\data_synth_3layers_oil_water.mat')
load('.\data\cmaps.mat')
% Number of iterations
n_it = 5000;
% Trace to be inverted from the 2D model
trace = 25;
%% Input data
real_seismic = real_seismic_aki;
SNR = 10;
real_seismic(:,:,1) = real_seismic(:,:,1) + sqrt(mean(var(real_seismic(:,:,1)))/SNR)*noise_mean0_std1(:,:,1);
real_seismic(:,:,2) = real_seismic(:,:,2) + sqrt(mean(var(real_seismic(:,:,2)))/SNR)*noise_mean0_std1(:,:,2);
real_seismic(:,:,3) = real_seismic(:,:,3) + sqrt(mean(var(real_seismic(:,:,3)))/SNR)*noise_mean0_std1(:,:,3);
real_seismic(:,:,4) = real_seismic(:,:,4) + sqrt(mean(var(real_seismic(:,:,4)))/SNR)*noise_mean0_std1(:,:,4);
real_seismic1d(:,:) = real_seismic(:,trace,:);
real_log_vp = log(real_vp(1:end-1,trace));
real_log_vs = log(real_vs(1:end-1,trace));
real_log_rho = log(real_rho(1:end-1,trace));
real_facies_well = real_facies(1:end-1,trace);
I = size(real_log_vp,1);
prob_map = ones(I,1,length(PRIOR_elasticLog))/length(PRIOR_elasticLog);
%% Input parameters
SNR = SNR;
SNR_par = SNR*[1 1 1 1]
% Transition matrix:
P = [0.90 0.055 0.035;
0.20 0.8 0;
0.2 0.2 0.60];
PRIOR_ = PRIOR_elasticLog;
[ INVERSION ] = GaussianMixMCMC_metropolis(real_seismic1d, theta, SNR_par, wavelet, PRIOR_, n_it, prob_map, P);
%% DISPLAY/SHOW RESULTS
INVERSION_ = INVERSION ;
time_well = [2000:4:2000+(I-1)*4]';
time_well_fine = [2000:2:2000+(I-1)*4+2]';
time = time_well;
figure
ax1 = subplot(1,6,1)
pcolor([1 2],[time_well time_well],[real_facies_well real_facies_well])
shading flat
ylim([time(1) time(end)])
set(gca,'Ydir','reverse')
colormap(ax1,cmap_3facies)
title('Reference facies')
xticks([])
ylabel('Time (ms)','FontSize',12)
ax1 = subplot(1,6,2)
imagesc(INVERSION_.FACIES.samples)
colormap(ax1,cmap_3facies)
title('MChain')
ax1 = subplot(1,6,3)
pcolor([1 2],[time_well time_well],[INVERSION_.FACIES.likely INVERSION_.FACIES.likely])
title('Estimated Facies')
shading flat
set(gca,'Ydir','reverse')
xticks([])
colormap(ax1,cmap_3facies)
c = colorbar;
c.Label.String = 'Shale Brine Oil';
set(c,'YTick',[])
c.Label.FontSize = 12;
ax1 = subplot(1,6,4)
plot((real_log_vp),time)
pcolor(exp(INVERSION_.VP.axis)',[time_well],[INVERSION_.VP.probability])
%colormap(ax1,cmap_prop)
colormap(ax1,mycmap_prob)
shading flat
hold all
plot(exp(real_log_vp),time,'k','linewidth',2)
plot(exp(INVERSION_.VP.map),time,'b','linewidth',2)
plot(exp(INVERSION_.VP.mean),time,'c','linewidth',2)
plot( exp(PRIOR_(2).MU(1))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(1))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(2).MU(1) + 2*sqrt(PRIOR_(2).C(1,1)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(2).MU(1) - 2*sqrt(PRIOR_(2).C(1,1)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(1) + 2*sqrt(PRIOR_(1).C(1,1)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(1).MU(1) - 2*sqrt(PRIOR_(1).C(1,1)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
set(gca,'Ydir','reverse')
ylim([time(1) time(end)])
grid
xlabel('P-impedance (m/s g/cm^3)','FontSize',12)
yticks([])
ax1 = subplot(1,6,5)
plot((real_log_vs),time)
pcolor(exp(INVERSION_.VS.axis)',[time_well],[INVERSION_.VS.probability])
shading flat
hold all
plot(exp(real_log_vs),time,'k','linewidth',2)
plot(exp(INVERSION_.VS.map),time,'b','linewidth',2)
plot(exp(INVERSION_.VS.mean),time,'c','linewidth',2)
plot( exp(PRIOR_(2).MU(2))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(2))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(2).MU(2) + 2*sqrt(PRIOR_(2).C(2,2)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(2).MU(2) - 2*sqrt(PRIOR_(2).C(2,2)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(2) + 2*sqrt(PRIOR_(1).C(2,2)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(1).MU(2) - 2*sqrt(PRIOR_(1).C(2,2)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
set(gca,'Ydir','reverse')
ylim([time(1) time(end)])
grid
xlabel('S-impedance (m/s g/cm^3)','FontSize',12)
%colormap(ax1,cmap_prop)
colormap(ax1,mycmap_prob)
ax1 = subplot(1,6,6)
%pcolor(exp(axis_rhob_fine)',[time_well_fine],[probability_rhob_fine])
pcolor(exp(INVERSION_.RHOB.axis)',[time_well],[INVERSION_.RHOB.probability])
shading flat
hold all
plot(exp(real_log_rho),time,'k','linewidth',2)
plot(exp(INVERSION_.RHOB.map),time,'b','linewidth',2)
plot(exp(INVERSION_.RHOB.mean),time,'c','linewidth',2)
plot( exp(PRIOR_(1).MU(3))*ones(size(time)),time,'--')
plot( exp(PRIOR_(2).MU(3))*ones(size(time)),time,'--')
set(gca,'Ydir','reverse')
xlabel('Density (g/cm^3)','FontSize',12)
ylim([time(1) time(end)])
grid
colormap(ax1,mycmap_prob)
c = colorbar;
c.Label.String = 'Probability';
c.Label.FontSize = 12;
set(c,'YTick',[])
plot( exp(PRIOR_(2).MU(3))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(3))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(2).MU(3) + 2*sqrt(PRIOR_(2).C(3,3)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(2).MU(3) - 2*sqrt(PRIOR_(2).C(3,3)))*ones(size(time)),time,'--','color',[1 1 0.15],'linewidth',2)
plot( exp(PRIOR_(1).MU(3) + 2*sqrt(PRIOR_(1).C(3,3)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
plot( exp(PRIOR_(1).MU(3) - 2*sqrt(PRIOR_(1).C(3,3)))*ones(size(time)),time,'--','color',[0.35 0.8 0.35],'linewidth',2)
legend('Posterior ','Reference model','MAP','Mean','Shale prior','Sand prior')
%%%%%%%%%%%%%%%%
figure
Id = I-1;
n_synth = 500;
n_it = size(INVERSION_.SYNTHETIC(1:Id ,:),2);
iterations = round( rand(n_synth,1)*(n_it-0.8*n_it) + 0.8*n_it );
sy_mean = mean(INVERSION_.SYNTHETIC(1:Id ,iterations),2);
ax1 = subplot(1,3,1)
plot(real_seismic1d(:,1),time,'k','linewidth',2)
hold all
plot(sy_mean,time(1:end-1),'c','linewidth',2)
grid
%plot(real_seismic(:,1) - INVERSION_.SYNTHETIC(1:I,iterations),repmat(time,1,n_synth),'r','linewidth',1)
plot(INVERSION_.SYNTHETIC(1:Id,iterations),repmat(time(1:end-1),1,n_synth),'r','linewidth',1)
plot(sy_mean,time(1:end-1),'c','linewidth',2)
plot(real_seismic1d(:,1),time,'k','linewidth',2)
ylim([time(1) time(end)])
%xlim([ -0.1 0.1 ])
set(gca,'Ydir','reverse')
title('Angle-stack 8^o')
ylabel('Time (ms)','FontSize',12)
sy_mean = mean(INVERSION_.SYNTHETIC(Id +1:2*Id ,iterations),2);
ax1 = subplot(1,3,2)
plot(real_seismic1d(:,2),time,'k','linewidth',2)
hold all
plot(sy_mean,time(1:end-1),'c','linewidth',2)
grid
%plot(real_seismic(:,2) - INVERSION_.SYNTHETIC(I+1:2*I,iterations),repmat(time,1,n_synth),'r','linewidth',1)
plot(INVERSION_.SYNTHETIC(Id +1:2*Id ,iterations),repmat(time(1:end-1),1,n_synth),'r','linewidth',1)
plot(sy_mean,time(1:end-1),'c','linewidth',2)
plot(real_seismic1d(:,2),time,'k','linewidth',2)
ylim([time(1) time(end)])
%xlim([ -0.1 0.1 ])
set(gca,'Ydir','reverse')
title('Angle-stack 18^o')
%yticks([])
sy_mean = mean(INVERSION_.SYNTHETIC(2*Id +1:3*Id ,iterations),2);
ax1 = subplot(1,3,3)
plot(real_seismic1d(:,3),time,'k','linewidth',2)
hold all
plot(sy_mean,time(1:end-1),'c','linewidth',2)
grid
%plot(real_seismic(:,3) - INVERSION_.SYNTHETIC(2*I+1:3*I,iterations),repmat(time,1,n_synth),'r','linewidth',1)
plot(INVERSION_.SYNTHETIC(2*Id+1:3*Id,iterations),repmat(time(1:end-1),1,n_synth),'r','linewidth',1)
plot(sy_mean,time(1:end-1),'c','linewidth',2)
plot(real_seismic1d(:,3),time,'k','linewidth',2)
ylim([time(1) time(end)])
%xlim([ -0.1 0.1 ])
set(gca,'Ydir','reverse')
title('Angle-stack 28^o')
legend('Reference seismic', 'Synthetics mean' ,'Synthetic seismic')
%yticks([])
figure
semilogx(INVERSION_.log_likelihood,'LineWidth',2)
grid
xlabel('MCMC Steps/Iteration')
ylabel('Log Likelihood ')