Skip to content

Commit

Permalink
update to process run 129 & 130
Browse files Browse the repository at this point in the history
  • Loading branch information
leewujung committed May 15, 2018
1 parent 460b834 commit 4cf645e
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 28 deletions.
57 changes: 33 additions & 24 deletions echo_info_fcn.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
% use SL to calibrate the spectrum
% save info extracted for each ping
% 2017 01 25 Clean up code to work with new beamforming results
% 2018 05 15 Add exceptions for missing SL data (run 130 before
% ping 95 is not usable)


function echo_info_fcn(data_path,ping_num,base_save_path,base_data_path,plot_show_opt)
Expand Down Expand Up @@ -139,14 +141,19 @@ function echo_info_fcn(data_path,ping_num,base_save_path,base_data_path,plot_sho
% Get SL for spectral calibration
SL = get_SL(run_num,ping_num_curr);

% Get raw echo spectrum (without any compensation)
no_spec = get_spectrum_mtm(no,A.data.sample_freq,win_perc);
wr_spec = get_spectrum_mtm(wr,A.data.sample_freq,win_perc);

% Compensation for all factors
no_spec = compensate_echo_spectrum(no_spec,SL,A);
wr_spec = compensate_echo_spectrum(wr_spec,SL,A);
if ~isempty(SL)
% Get raw echo spectrum (without any compensation)
no_spec = get_spectrum_mtm(no,A.data.sample_freq,win_perc);
wr_spec = get_spectrum_mtm(wr,A.data.sample_freq,win_perc);

% Compensation for all factors
no_spec = compensate_echo_spectrum(no_spec,SL,A);
wr_spec = compensate_echo_spectrum(wr_spec,SL,A);
else
no_spec = [];
wr_spec = [];
end

% Get echo stat
no_env = mf_env.env(no_r_idx(1):no_r_idx(2),no_a_idx(1):no_a_idx(2));
wr_env = mf_env.env(wr_r_idx(1):wr_r_idx(2),wr_a_idx(1):wr_a_idx(2));
Expand Down Expand Up @@ -217,24 +224,26 @@ function echo_info_fcn(data_path,ping_num,base_save_path,base_data_path,plot_sho
set(gca,'fontsize',12,'xtick',[1e4,1e6,1e8])
hold off
grid

subplot(133) % spectrum
cla
plot(no_spec.freq_vec/1e3,no_spec.pxx_dB_mean_comp,...
'color',corder(1,:),'linewidth',2);
hold on
plot(wr_spec.freq_vec/1e3,wr_spec.pxx_dB_mean_comp,...
'linewidth',2,'color',[153,204,255]/255);
ll = legend('no wreck','wreck');
set(ll,'fontsize',11,'location','southoutside')
ylim([-140 -100])
xlim([1.6 3.8])
xlabel('Frequency (kHz)','fontsize',14)
ylabel('Spectral density (dB/Hz)','fontsize',14)
set(gca,'fontsize',12,'xtick',1.6:0.4:3.8,'ytick',-140:10:-100)
grid on
box on

if ~isempty(SL)
subplot(133) % spectrum
cla
plot(no_spec.freq_vec/1e3,no_spec.pxx_dB_mean_comp,...
'color',corder(1,:),'linewidth',2);
hold on
plot(wr_spec.freq_vec/1e3,wr_spec.pxx_dB_mean_comp,...
'linewidth',2,'color',[153,204,255]/255);
ll = legend('no wreck','wreck');
set(ll,'fontsize',11,'location','southoutside')
ylim([-140 -100])
xlim([1.6 3.8])
xlabel('Frequency (kHz)','fontsize',14)
ylabel('Spectral density (dB/Hz)','fontsize',14)
set(gca,'fontsize',12,'xtick',1.6:0.4:3.8,'ytick',-140:10:-100)
grid on
box on
end

mtit(title_text,'fontsize',16);

saveSameSize_150(gcf,'file',fullfile(save_path,[save_fname,'.png']),...
Expand Down
18 changes: 17 additions & 1 deletion echo_info_fcn_runner.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
% 2018 01 13 Run echo_info_fcn in batch
% 2018 05 15 Run echo_info_fcn on Run 130 and 129 --> these are
% before dusk sessions to figure out how fluctuation
% shown in the beginning of Run 131

run_num_all = [131,79,87,94,103,115,120,124];
%run_num_all = [131,79,87,94,103,115,120,124];
run_num_all = [130,129];

base_data_path = '~/internal_2tb/trex/figs_results/';
base_save_path = '~/internal_2tb/trex/figs_results/';
Expand Down Expand Up @@ -49,6 +53,18 @@
wfm1 = 1;
wfm2 = 2;
data_path = 'subset_beamform_cardioid_coherent_run124';
case 129
ping_num1 = 1:2:210; % run 129
ping_num2 = 2:2:210; % run 129
wfm1 = 1;
wfm2 = 2;
data_path = 'subset_beamform_cardioid_coherent_run129';
case 130
ping_num1 = 1:2:170; % run 130
ping_num2 = 1:2:170; % run 130
wfm1 = 1;
wfm2 = 2;
data_path = 'subset_beamform_cardioid_coherent_run130';
case 131
ping_num1 = 1:2:1000; % run 131
ping_num2 = 2:2:1000; % run 131
Expand Down
21 changes: 20 additions & 1 deletion get_SL.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
% 2016 11 21
% 2017 01 23 Clean up
% 2017 02 19 Enable loading each individual MON file for each ping
% 2018 05 15 Add files for run 129 & 130
% Note exception for run 130 --don't process ping_num<95

% Load transmit waveform
if isunix
Expand All @@ -28,10 +30,27 @@
amp_mon_subpath = 'TREX13_MON_13-05-14_21-27-37-260';
case 124
amp_mon_subpath = 'TREX13_MON_13-05-15_21-11-39-716';
case 129
amp_mon_subpath = 'TREX13_MON_13-05-16_14-59-11-817';
case 130
amp_mon_subpath = 'TREX13_MON_13-05-16_16-52-54-133';
case 131
amp_mon_subpath = 'TREX13_MON_13-05-16_18-28-07-368';
end
amp_mon_file = sprintf('TREX13_MON_I%05d_P%05d.mat',run_num,ping_num);
if run_num==130
if ping_num < 95
S = [];
return
else
ping_num = ping_num-94;
end
amp_mon_file = sprintf('TREX13_MON_I%05d-restart_P%05d.mat',run_num,ping_num);
elseif run_num==129
S = [];
return
else
amp_mon_file = sprintf('TREX13_MON_I%05d_P%05d.mat',run_num,ping_num);
end

A = load(fullfile(amp_mon_path,amp_mon_subpath,amp_mon_file));

Expand Down
19 changes: 19 additions & 0 deletions subset_beamform_runner.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
% 2018 05 15 Make a runner script to extract and save a subset of
% beamformed data for faster access


addpath('~/code_matlab_dn/');
addpath(['~/code_git/trex_fish/Triplet_processing_toolbox']);
base_save_path = '~/internal_2tb/trex/figs_results/';
base_data_path = '~/internal_2tb/trex/figs_results/';

% Processing for run 130
%data_path = 'beamform_cardioid_coherent_run130';
%ping_num = 1:170;
%subset_beamform_fcn(data_path,ping_num,base_save_path,base_data_path);

% Processing for run 129
data_path = 'beamform_cardioid_coherent_run129';
ping_num = 1:210;
subset_beamform_fcn(data_path,ping_num,base_save_path,base_data_path);

6 changes: 4 additions & 2 deletions trex_fish_notes_2018.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@


************************************************
## 2018/05/14
## 2018/05/14-15
### Process run 129 and 130
- Need to process these two runs to figure out why there was high Emax and SI in AW1 before dusk. Was this a pattern from earlier during the day?
- May have to process data from other days before the overnight session to figure this out.
- Run 129 and 130 used the same 2 waveforms as run 131, which is the expt session we focus analysis on for the ms.
- Run 130: 170 pings
- Run 129: 210 pings

- Added `subset_beamform_runner` and updated `get_SL`, `echo_info_fcn`, `echo_info_fcn_runner` for processing these 2 runs.
- Run 130 was stopped and restarted so there were some confusion of file numbers. Jie noted that there were 96 good files in run 130. This number is consistent with the number of files in the run 131 HAARI folder. But I decided to only use the last 76 files (ping 95-170) since I can be certain that these are the files that did not have problem after the system was restarted.
- Run 129 HAARI folder is missing ping 131... added exceptions to `get_SL`.



Expand Down

0 comments on commit 4cf645e

Please sign in to comment.