forked from jbrussell/mat-LRTdisp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha3_pick_LRT.m
executable file
·111 lines (95 loc) · 3.33 KB
/
a3_pick_LRT.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
% Interactively pick dispersion from radon panel
%
% J. Russell
% github.com/jbrussell
clear;
setup_parameters;
% Load precalculated LRT
load([LRTmatpath,'LRT_',method,'.mat']);
% Load PA5 dispersion
load('./pa5_5km/dispersion_pa5_5km_b5.mat');
% Normalization option for plotting
is_globnorm = 1; % 1 for normalize radon panel by global max; 0 for column norm
% Parameters for tracing dispersion curves
min_peak_prom = 0.3; % Minimum peak prominence, threshold for peak height
min_peak_dist = 0.1; % Minimum separation between chosen peaks [km/s]
Npers = 25; % Number for periods
pers = logspace(log10(20),log10(150),Npers); % period vector
% Organize dipsersion
BRANCHES=5;
for ii = 1:BRANCHES
DISP(ii).n = ii-1;
DISP(ii).cv = dat{ii}(:,6);
DISP(ii).gv = dat{ii}(:,7);
DISP(ii).cvq = dat{ii}(:,8);
DISP(ii).Tq = dat{ii}(:,9);
DISP(ii).T = dat{ii}(:,10);
% plot(Tq(1:10:end),cvq(1:10:end),'--','color',[.5 .5 .5],'linewidth',1);
end
% Load waveforms
load(mat.ndata);
Delta = deg2km(Delta)';
%% Find peaks
if is_globnorm
absR_Tv = abs(mat.R_Tv)./prctile(mat.R_Tv(:),99);
else
absR_Tv = abs(mat.R_Tv)./max(abs(mat.R_Tv));
end
phv_trace = [];
per_trace = [];
phv_trace_std = [];
ipk = 0;
for iper = 1:Npers
[~,I_per] = min(abs(mat.per_vec-pers(iper)));
[pks,locs,w,p] = findpeaks(absR_Tv(:,I_per),mat.phv_vec,'MinPeakProminence',min_peak_prom,'MinPeakDistance',min_peak_dist);
for ii = 1:length(pks)
ipk = ipk+1;
phv_trace(ipk) = locs(ii);
per_trace(ipk) = pers(iper);
phv_trace_std(ipk) = w(ii)*0.2; % 20% of peak corresponds to 0.90
end
if 0
figure(99); clf; hold on;
findpeaks(R_Tv(:,I_per),mat.phv_vec,'MinPeakProminence',min_peak_prom,'MinPeakDistance',min_peak_dist,'Annotate','extents');
% plot(mat.phv_vec,R_Tv(:,I_per)); hold on;
plot(locs,pks,'or');
pause;
end
end
%% MANUAL PICKING OF DISPERSION CURVE
[picks_LRT] = pick_LRT_disp(absR_Tv, mat, per_trace, phv_trace, phv_trace_std);
if ~exist(picks_out_path)
mkdir(picks_out_path);
end
% Save picks to mat file
if ~isempty(picks_LRT)
save([picks_out_path,'LRTpicks_',method,'.mat'],'picks_LRT');
end
%%
% Plot picks to double check
figure(4); clf;
FS = 15;
if is_globnorm
imagesc(mat.per_vec, mat.phv_vec, abs(mat.R_Tv)./prctile(mat.R_Tv(:),99)); hold on;
% contour(mat.per_vec, mat.phv_vec, abs(mat.R_Tv)./prctile(mat.R_Tv(:),99)>=0.9,[1],'-w','linewidth',2); hold on;
else
imagesc(mat.per_vec, mat.phv_vec, abs(mat.R_Tv)./max(abs(mat.R_Tv))); hold on;
end
clr = lines(length(picks_LRT));
for itr = 1:length(picks_LRT)
errorbar(picks_LRT(itr).per,picks_LRT(itr).phv,picks_LRT(itr).phv_std,'-o','Color',clr(itr,:),'LineWidth',1.5);
end
% errorbar(per_trace,phv_trace,phv_trace_std,'or','MarkerFaceColor',[1 1 1],'linewidth',1.5,'markersize',7);
for ii = 1:BRANCHES
plot(DISP(ii).Tq(1:10:end),DISP(ii).cvq(1:10:end),'-','color',[0 0 0],'linewidth',1.5);
end
caxis([0 1]);
xlim([min(mat.per_vec) max(mat.per_vec)]);
ylim([mat.v_min mat.v_max]);
title(method,'Interpreter','none'); ylabel('Velocity (km/s)'); xlabel('Period (s)');
set(gca,'YDir','normal','FontSize',FS,'linewidth',1.5,'TickDir','out');
colormap([ones(30,3).*[0.2665 0.0033 0.3273]; viridis(100)]);
pos = get(gca,'Position');
cb = colorbar;
set(cb,'linewidth',1.5);
set(gca,'Position',pos);