-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_kernel_inversion_vs_vp_rho.m
executable file
·170 lines (149 loc) · 5.48 KB
/
test_kernel_inversion_vs_vp_rho.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
% Test inversion using surf96 kernels
%
% This version solves for Vs, Vp, and Rho by enforcing Vp/Vs and Rho/Vs of
% the starting model. The inversion includes kernels for Vs, Vp, Rho such
% that each iteration accounts for perturbations in all three.
%
% jbrussell 6/5/2020
% modified 11/23/2021
% modified 11/20/2022
%
clear
path2BIN = './bin_v3.30/'; % path to surf96 binary
PATH = getenv('PATH');
if isempty(strfind(PATH,path2BIN))
% setenv('PATH', [PATH,':',path2BIN]);
setenv('PATH', [path2BIN,':',PATH]);
end
addpath('./functions/')
% Make binary files executable
!chmod ++x ./bin_v3.30/*
%% Inversion regularization parameters
eps_data = 1; % data fit
eps_H = 0.05; % norm damping
eps_J = 0.001; % first derivative smoothing
eps_F = 2; % second derivative smoothing
eps_vpvs = 10; % enforce vp/vs ratio
eps_rhovs = 10; % enforce rho/vs ratio
z_dampbot = 150; % [km] damp to starting model below this depth
zmax = 400; % [km] maximum depth of model space
nmode = 0; % mode branch number (0=fund, 1=1st overtone, 2=2nd overtone, etc.)
% Other inversion parameters
nit = 8; % total number of iterations
nit_recalc_c = 1; % number of iterations after which to recalculate phase velocity and kernels
%% Generate the synthetic dataset for this test
%Read in MINEOS model and convert to SURF96 layered model format
cardname = 'Nomelt_taper_eta_crust_INVpconstr_xi1.06_GRL19_Line1_dist100.00km';
% Get MINEOS model
CARD = ['./MINEOS_CARD/',cardname,'.card'];
[truemod, discs] = card2mod(CARD,zmax); % true model
% % Keep track of discontinuities
% waterdepth = discs(1);
% seddepth = discs(2);
% mohodepth = discs(end);
% perturb true model
z = [0; cumsum(truemod(:,1))];
Ibot=find(z<=80); Ibot=Ibot(end);
truemod(2:Ibot,2) = truemod(2:Ibot,2)*1.1;
truemod(2:Ibot,3) = truemod(2:Ibot,3)*1.1;
truemod(2:Ibot,4) = truemod(2:Ibot,4)*1.1;
% GENERATE SYNTHETIC DATASET
% Calculate dispersion for perturbed starting model and true model (which is like the data)
vec_T = logspace(log10(10),log10(40),20);
cobs = dispR_surf96(vec_T,truemod,nmode); % "observations"
cstd = cobs * 0.01; % observation uncertainties
%% Starting model
% load starting model
% Get MINEOS model
CARD = ['./MINEOS_CARD/',cardname,'.card'];
[startmod, discs] = card2mod(CARD,zmax); % true model
vp_vs = startmod(:,2) ./ startmod(:,3); vp_vs(isinf(vp_vs))=0;
rho_vs = startmod(:,4) ./ startmod(:,3); rho_vs(isinf(rho_vs))=0;
% % Make homogeneous starting model
% zh2o = 1.618; % [km] water depth
% zmoho = 20; % [km] moho depth
% zmax = 200;
% z = [0 zh2o:2.5:zmoho zmoho+1:5:zmax];
% dz = [diff(z) 0];
% vs = 4.1*ones(size(dz)); vs(1)=0; % water
% vp = 1.75*vs; vp(1)=1.5;
% rho = vp / 2.5; rho(1)=1.03;
% startmod = [dz(:), vp(:), vs(:), rho(:)];
% % discs = [zmoho]; % [km] depth to sharp discontinuities
discs = []; % for this simple example, don't allow discontinuities
figure(1); clf;
box on; hold on;
h = plotlayermods(startmod(:,1),startmod(:,3),'-b');
h.LineWidth = 2;
xlabel('Vs (km/s)');
ylabel('Depth (km)');
title('Starting Model');
set(gca,'FontSize',18,'linewidth',1.5);
%% Do linearized inversion using surf96
cstart = dispR_surf96(vec_T,startmod,nmode); % "predictions";
[finalmod, cpre, vs_std] = run_surf96_inv_Rayl_Vs_Vp_Rho(cobs,cstd,vec_T,startmod,discs,eps_data,eps_H,eps_J,eps_F,eps_vpvs,eps_rhovs,z_dampbot,nit,nit_recalc_c,vp_vs,rho_vs,nmode);
%% Plot final kernels
figure(101); clf;
set(gcf,'position',[300 547 1281 422],'color','w')
Npers = length(vec_T);
clr = jet(Npers);
lgd = {};
[dcdvs, dcdvp, dudvs, dudvp, zkern, dcdrho, dudrho] = calc_kernel96(finalmod, vec_T, 'R', 1, 0,nmode);
subplot(1,3,1); box on; hold on;
for ip = 1:Npers
plot(dcdvs(:,ip),zkern,'-','color',clr(ip,:),'linewidth',2); hold on;
lgd{ip} = [num2str(vec_T(ip)),' s'];
end
xlabel('dc/dVs');
ylabel('Depth (km)');
set(gca,'fontsize',15,'linewidth',1.5,'ydir','reverse');
% legend(lgd,'location','eastoutside');
subplot(1,3,2);
for ip = 1:Npers
plot(dcdvp(:,ip),zkern,'-','color',clr(ip,:),'linewidth',2); hold on;
lgd{ip} = [num2str(vec_T(ip)),' s'];
end
xlabel('dc/dVp');
ylabel('Depth (km)');
set(gca,'fontsize',15,'linewidth',1.5,'ydir','reverse');
% legend(lgd,'location','eastoutside');
subplot(1,3,3);
for ip = 1:Npers
plot(dcdrho(:,ip),zkern,'-','color',clr(ip,:),'linewidth',2); hold on;
lgd{ip} = [num2str(vec_T(ip)),' s'];
end
xlabel('dc/d\rho');
ylabel('Depth (km)');
set(gca,'fontsize',15,'linewidth',1.5,'ydir','reverse');
pos = get(gca,'Position');
legend(lgd,'location','eastoutside');
set(gca,'position',pos);
%%
% Plot
figure(100); clf;
set(gcf,'position',[370 372 967 580]);
subplot(2,2,[1 3]); box on; hold on;
h = plotlayermods(truemod(:,1),truemod(:,3),'-k');
h.LineWidth = 2;
h = plotlayermods(startmod(:,1),startmod(:,3),'-b');
h.LineWidth = 2;
h = plotlayermods(finalmod(:,1),finalmod(:,3),'-r');
h.LineWidth = 2;
h = plotlayermods(finalmod(:,1),finalmod(:,3)-vs_std,'--r');
h.LineWidth = 2;
h = plotlayermods(finalmod(:,1),finalmod(:,3)+vs_std,'--r');
h.LineWidth = 2;
xlabel('Velocity');
ylabel('Depth');
set(gca,'FontSize',18,'linewidth',1.5);
legend({'true','start','final'},'Location','southwest')
% legend({'start','final'},'Location','southwest')
subplot(2,2,2); box on; hold on;
cpre = dispR_surf96(vec_T,finalmod,nmode);
plot(vec_T,cstart,'-ob','linewidth',2);
plot(vec_T,cpre,'-or','linewidth',2);
errorbar(vec_T,cobs,2*cstd,'sk','markersize',8,'markerfacecolor','k','linewidth',2);
legend({'c start','c final','c obs'},'Location','southeast')
xlabel('Period');
ylabel('Phase Velocity');
set(gca,'FontSize',18,'linewidth',1.5);