-
Notifications
You must be signed in to change notification settings - Fork 9
/
a7_c_stack_grv.m
205 lines (175 loc) · 5.06 KB
/
a7_c_stack_grv.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
% Program to stack group velocity maps from each event
clear;
isfigure = 1;
setup_parameters
workingdir = parameters.workingdir;
% phase_v_path = './eikonal/'
group_v_path = [workingdir,'eikonal_grv/'];
r = 0.10;
load seiscmap
comp = parameters.component;
periods = parameters.periods;
lalim = parameters.lalim;
lolim = parameters.lolim;
gridsize = parameters.gridsize;
min_csgoodratio = parameters.min_csgoodratio;
min_phv_tol = parameters.min_phv_tol;
max_phv_tol = parameters.max_phv_tol;
is_raydense_weight = parameters.is_raydense_weight;
err_std_tol = parameters.err_std_tol;
min_event_num = parameters.min_event_num;
issmoothmap = parameters.issmoothmap;
smooth_wavelength = parameters.smooth_wavelength;
event_bias_tol = parameters.event_bias_tol;
xnode=lalim(1):gridsize:lalim(2);
ynode=lolim(1):gridsize:lolim(2);
Nx=length(xnode);
Ny=length(ynode);
[xi yi]=ndgrid(xnode,ynode);
phvmatfiles = dir([group_v_path,'/*_eikonal_grv_',comp,'.mat']);
GV_mat = zeros(Nx,Ny,length(phvmatfiles),length(periods));
raydense_mat = zeros(Nx,Ny,length(phvmatfiles),length(periods));
for ie = 1:length(phvmatfiles)
temp = load([group_v_path,phvmatfiles(ie).name]);
eventgrv = temp.eventgrv;
event_ids(ie) = {eventgrv(1).id};
disp(eventgrv(1).id);
for ip=1:length(periods)
ind = find(eventgrv(ip).GV < min_phv_tol);
eventgrv(ip).GV(ind) = NaN;
ind = find(eventgrv(ip).GV > max_phv_tol);
eventgrv(ip).GV(ind) = NaN;
if eventgrv(ip).goodnum./eventgrv(ip).badnum < min_csgoodratio(ip)
disp('not enough good cs measurement');
eventgrv(ip).GV(:) = NaN;
end
GV_mat(:,:,ie,ip) = eventgrv(ip).GV;
raydense_mat(:,:,ie,ip) = eventgrv(ip).raydense;
end
end
avggrv = average_GV_mat(GV_mat, raydense_mat, parameters);
% Calculate std, remove the outliers
GV_mat = 1./GV_mat;
for ip=1:length(periods)
for i = 1:Nx
for j=1:Ny
avggrv(ip).GV_std(i,j) = nanstd(GV_mat(i,j,:,ip));
ind = find( abs(GV_mat(i,j,:,ip) - 1./avggrv(ip).GV(i,j)) > err_std_tol*avggrv(ip).GV_std(i,j));
GV_mat(i,j,ind,ip) = NaN;
end
end
end
GV_mat = 1./GV_mat;
% calculate the averaged phase velocity again
avggrv = average_GV_mat(GV_mat, raydense_mat, parameters);
% remove bias events
for ip=1:length(periods)
avg_GV = avggrv(ip).GV;
mean_phv = nanmean(avg_GV(:));
badnum = 0;
for ie=1:length(event_ids)
GV = GV_mat(:,:,ie,ip);
diff_phv = GV-avg_GV;
diff_percent = nanmean(diff_phv(:))/mean_phv*100;
if abs(diff_percent) > event_bias_tol;
% matfile = dir(fullfile('eikonal',[char(event_ids(ie)),'*.mat']));
% load(fullfile('eikonal',matfile(1).name));
matfile = dir(fullfile(workingdir,'eikonal',[char(event_ids(ie)),'*.mat']));
load(fullfile(workingdir,'eikonal',matfile(1).name));
evla = eventgrv(1).evla;
evlo = eventgrv(1).evlo;
epi_dist = distance(evla,evlo,mean(lalim),mean(lolim));
badnum = badnum+1;
ind = find(~isnan(GV(:)));
stemp = sprintf('remove %s: id %d, ip %d, dist %f, bias: %f percent, good pixels: %d', char(event_ids(ie)),ie,ip,epi_dist, diff_percent,length(ind));
disp(stemp)
GV_mat(:,:,ie,ip) = NaN;
end
end
end
% calculate the averaged phase velocity again
avggrv = average_GV_mat(GV_mat, raydense_mat, parameters);
% re-Calculate std
for ip=1:length(periods)
for i = 1:Nx
for j=1:Ny
avggrv(ip).GV_std(i,j) = nanstd(GV_mat(i,j,:,ip));
end
end
end
% fill in information
for ip=1:length(periods)
avggrv(ip).xi = xi;
avggrv(ip).yi = yi;
avggrv(ip).xnode = xnode;
avggrv(ip).ynode = ynode;
avggrv(ip).period = periods(ip);
end
if issmoothmap
disp(['Smoothing map based on wavelength']);
for ip=1:length(periods)
disp(ip);
D = smooth_wavelength*nanmean(avggrv(ip).GV(:))*periods(ip);
GV = smoothmap(xi,yi,avggrv(ip).GV,D);
GV(find(isnan(avggrv(ip).GV))) = NaN;
avggrv(ip).GV = GV;
end
end
save([workingdir,'eikonal_grv_stack_',comp,'.mat'],'avggrv','GV_mat','GV_mat','raydense_mat','event_ids');
% plot section
if isfigure
N=3; M = floor(length(periods)/N)+1;
figure(89)
clf
title('stack for dynamics phv')
for ip = 1:length(periods)
subplot(M,N,ip)
ax = worldmap(lalim, lolim);
set(ax, 'Visible', 'off')
h1=surfacem(xi,yi,avggrv(ip).GV);
% set(h1,'facecolor','interp');
title(['Periods: ',num2str(periods(ip))],'fontsize',15)
avgv = nanmean(avggrv(ip).GV(:));
if isnan(avgv)
continue;
end
caxis([avgv*(1-r) avgv*(1+r)])
colorbar
load seiscmap
colormap(seiscmap)
end
drawnow;
figure(90)
clf
sgtitle('Std for dynamics grv')
for ip = 1:length(periods)
subplot(M,N,ip)
ax = worldmap(lalim, lolim);
set(ax, 'Visible', 'off')
h1=surfacem(xi,yi,avggrv(ip).GV_std);
% set(h1,'facecolor','interp');
title(['Periods: ',num2str(periods(ip))],'fontsize',15)
colorbar
load seiscmap
colormap(seiscmap)
meanstd = nanmean(avggrv(ip).GV_std(:));
if ~isnan(meanstd)
caxis([0 2*meanstd])
end
end
drawnow;
figure(95)
clf
for ip = 1:length(periods)
subplot(M,N,ip)
ax = worldmap(lalim, lolim);
set(ax, 'Visible', 'off')
h1=surfacem(xi,yi,avggrv(ip).sumweight);
% set(h1,'facecolor','interp');
title(['Periods: ',num2str(periods(ip))],'fontsize',15)
colorbar
load seiscmap
colormap(seiscmap)
end
drawnow;
end