-
Notifications
You must be signed in to change notification settings - Fork 1
/
summarize_run_fcn.m
164 lines (136 loc) · 4.5 KB
/
summarize_run_fcn.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
% 2017 02 15 Plot variation of total energy within boundary
% Use output from echo_info
function A = summarize_run_fcn(run_num,ping_all,wfm_num,plot_opt)
%
% INPUT
% run_num
% ping_all all ping numbers to be included
% wfm_num waveform number used
% plot_opt whether to plot or not
if isunix
addpath('~/code_matlab_dn/saveSameSize');
base_save_path = '~/internal_2tb/trex/figs_results/';
base_data_path = '~/internal_2tb/trex/figs_results/';
else
addpath('F:\Dropbox\0_CODE\MATLAB\saveSameSize');
base_save_path = 'F:\trex\figs_results';
base_data_path = 'F:\trex\figs_results';
end
% Set up data_path
data_path = sprintf('echo_info_run%03d',run_num);
% Set up various paths
ss = strsplit(data_path,'_');
run_num = str2double(ss{end}(4:end));
[~,script_name,~] = fileparts(mfilename('fullpath'));
script_name = script_name(1:end-4);
save_path = fullfile(base_save_path,script_name);
if ~exist(save_path,'dir')
mkdir(save_path);
end
save_fname = sprintf('%s_run%03d_wfm%d',script_name,run_num,wfm_num);
% Get results
energy_in_bnd = nan(length(ping_all),1);
si_W1 = nan(length(ping_all),1);
si_W2 = nan(length(ping_all),1);
max_W1 = nan(length(ping_all),1);
max_W2 = nan(length(ping_all),1);
ping_time = nan(length(ping_all),1);
for iP=1:length(ping_all)
% Load file and set filename
ping_num = ping_all(iP);
scat_fname = sprintf('%s_ping%04d.mat',data_path,ping_num);
%disp(['Processing ',scat_fname])
S = load(fullfile(base_data_path,data_path,scat_fname));
energy_in_bnd(iP) = S.energy_in_bnd;
si_W1(iP) = S.stat_wr.scint;
si_W2(iP) = S.stat_no.scint;
max_W1(iP) = max(S.env_wr(:));
max_W2(iP) = max(S.env_no(:));
ping_time(iP) = S.time_hh;
end
% Adjust time after midnight
ping_time(ping_time<12)=ping_time(ping_time<12)+24;
% Store everything into A
A.energy_in_bnd = energy_in_bnd;
A.si_W1 = si_W1;
A.si_W2 = si_W2;
A.max_W1 = max_W1;
A.max_W2 = max_W2;
A.ping_time = ping_time;
% Get plotting ranges
energy_in_bnd_log = 10*log10(energy_in_bnd);
max_W1_log = 10*log10(max_W1);
max_W2_log = 10*log10(max_W2);
yrange_e = [floor(min(energy_in_bnd_log)/5)*5,...
ceil(max(energy_in_bnd_log)/5)*5];
yrange_w = [floor(min([max_W1_log;max_W2_log])/5)*5,...
ceil(max([max_W1_log;max_W2_log])/5)*5];
yrange_s = [0 30];
% Plotting
if plot_opt
% Plot -- against ping time
figure('position',[675 90 570 890])
subplot(311)
plot(ping_time,energy_in_bnd_log);
title('Total energy')
ylim(yrange_e)
set(gca,'xtick',16:2:32,'xticklabel',num2str([16:2:22,0:2:8]'),...
'ytick',yrange_e(1):5:yrange_e(2))
grid
subplot(312)
plot(ping_time,max_W1_log);
hold on
plot(ping_time,max_W2_log);
title('Max echo level');
ylim(yrange_w)
set(gca,'xtick',16:2:32,'xticklabel',num2str([16:2:22,0:2:8]'),...
'ytick',yrange_w(1):5:yrange_w(2))
grid
legend('W1','W2','location','best')
subplot(313)
plot(ping_time,si_W1);
hold on
plot(ping_time,si_W2);
title('Scintillation index')
ylim([0 20])
set(gca,'xtick',16:2:32,'xticklabel',num2str([16:2:22,0:2:8]'),...
'ytick',[0,1,5:5:20])
grid
xlabel('Hour of day')
legend('W1','W2','location','best')
suplabel(sprintf('Run %d, wfm %d',run_num,wfm_num),'t'); % super title
% Save figure
saveSameSize_150(gcf,'file',fullfile(save_path,[save_fname,'_time.png']),...
'format','png');
% Plot --- against ping number
figure('position',[675 90 570 890])
subplot(311)
plot(ping_all,energy_in_bnd_log);
title('Total energy')
ylim(yrange_e)
set(gca,'ytick',yrange_e(1):5:yrange_e(2))
grid
subplot(312)
plot(ping_all,max_W1_log);
hold on
plot(ping_all,max_W2_log);
title('Max echo level');
ylim(yrange_w)
set(gca,'ytick',yrange_w(1):5:yrange_w(2))
legend('W1','W2','location','best')
grid
subplot(313)
plot(ping_all,si_W1);
hold on
plot(ping_all,si_W2);
title('Scintillation index')
ylim([0 20])
set(gca,'ytick',[0,1,5:5:20])
grid
xlabel('Ping number')
legend('W1','W2','location','best')
suplabel(sprintf('Run %d, wfm %d',run_num,wfm_num),'t'); % super title
% Save figure
saveSameSize_150(gcf,'file',fullfile(save_path,[save_fname,'_pingnum.png']),...
'format','png');
end