-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_large_echogram.m
107 lines (89 loc) · 3.51 KB
/
plot_large_echogram.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
% Function to plot overall echogram
data_path = 'beamform_cardioid_coherent_run131';
if isunix
addpath('~/internal_2tb/Dropbox/0_CODE/MATLAB/saveSameSize');
addpath(['~/internal_2tb/trex/trex_fish_code/Triplet_processing_toolbox'])
base_data_path = '/media/wu-jung/wjlee_apl_1/trex_results/';
base_save_path = '/home/wu-jung/internal_2tb/trex/figs_results';
else
addpath('F:\Dropbox\0_CODE\MATLAB\saveSameSize');
addpath('F:\trex\trex_fish_code\Triplet_processing_toolbox')
base_data_path = '\\10.95.97.212\Data\wjlee';
base_save_path = 'F:\trex\figs_results';
end
% Set up various paths
ss = strsplit(data_path,'_');
run_num = str2double(ss{end}(4:end));
bf_type = ss{2};
coh_type = ss{3};
[~,script_name,~] = fileparts(mfilename('fullpath'));
script_name = script_name(1:end-4);
save_path = fullfile(base_save_path,...
sprintf('%s_%s_%s_run%03d',script_name,bf_type,coh_type,run_num));
if ~exist(save_path,'dir')
mkdir(save_path);
end
% Set params
ping_num = 31;
sm_len = 100;
% Plotting
fname = sprintf('beamform_%s_%s_run%03d_ping%04d.mat',...
bf_type,coh_type,run_num,ping_num);
A = load(fullfile(base_data_path,data_path,fname));
save_fname = sprintf('%s_%s_%s_run%03d_ping%04d',...
script_name,bf_type,coh_type,run_num,ping_num);
% Get envelope and smooth/subsample
env = nan(size(A.data.beam_mf_in_time));
env_sm = nan(size(env));
for iA=1:size(env,2)
env(:,iA) = abs(hilbert(A.data.beam_mf_in_time(:,iA)));
env_sm(:,iA) = smooth(env(:,iA),sm_len);
end
env_sm = env_sm(1:sm_len:end,:);
% Get plotting params
A.data.range_beam_sm = A.data.range_beam(1:sm_len:end);
[~,cut_in_range] = min(abs(A.data.range_beam_sm)); % range closest to 0m
cut_in_angle = find(abs(diff(A.data.polar_angle))>1); % angle jump during beamforming
[amesh1,rmesh1] = meshgrid(A.data.polar_angle(1:cut_in_angle),...
A.data.range_beam_sm(cut_in_range:end));
[amesh2,rmesh2] = meshgrid(A.data.polar_angle(cut_in_angle+1:end),...
A.data.range_beam_sm(cut_in_range:end));
[X1,Y1] = pol2cart(amesh1/180*pi,rmesh1);
[X2,Y2] = pol2cart(amesh2/180*pi,rmesh2);
% Echo level calibration
total_gain_crd_coh = A.param.gain_load -...
A.param.gain_sys -...
A.param.gain_beamform -...
A.param.gain_pc;
% Rough transmission loss compensation
TL_comp = repmat(30*log10(A.data.range_beam_sm(cut_in_range:end))',...
1,size(X1,2));
% Get bathymetry
[Map_X,Map_Y,Map_Z,wrecgps] = func_load_map_targets(A.param.map_coord);
% Plot
figure
h1 = pcolor(X1/1e3,Y1/1e3,...
20*log10(env_sm(cut_in_range:end,1:cut_in_angle))+...
total_gain_crd_coh-3 +TL_comp);
hold on
h2 = pcolor(X2/1e3,Y2/1e3,...
20*log10(env_sm(cut_in_range:end,cut_in_angle+1:end))+...
total_gain_crd_coh-3 +TL_comp);
set(h1,'edgecolor','none');
set(h2,'edgecolor','none');
axis equal
colormap(jet)
caxis([180 210])
colorbar
axis([-7 7 -7 7])
xlabel('Distance (km)','fontsize',14)
ylabel('Distance (km)','fontsize',14)
gray = [1 1 1]*130/255;
[c,hmap]=contour(Map_X/1000,Map_Y/1000,Map_Z,[0:-4:-30],'color',gray);
clabel(c,hmap,'fontsize',8,'linewidth',0.5,'Color',gray);
title(sprintf('Ping %04d, %02d:%02d:%02d',ping_num,...
A.data.time_hh_local,A.data.time_mm_local,A.data.time_ss_local))
% Save plot
% epswrite(fullfile(save_path,[save_fname,'.eps']));
saveSameSize_600(gcf,'file',fullfile(save_path,[save_fname,'.png']),...
'format','png');