%======================================================================
%                    S E T _ C A S T _ P A R A M S . M 
%                    doc: Mon Apr 20 09:03:09 2015
%                    dlm: Thu Mar 30 09:58:57 2017
%                    (c) 2015 A.M. Thurnherr
%                    uE-Info: 148 14 NIL 0 0 72 2 2 4 NIL ofnI
%======================================================================

% NB: make sure to move the "current" symlink after updating
%	  official version

% LEG 1: [1:112]
% 	potentially good profiles (instruments?): [41:79]
%	bad, within potentially good: [41 44]
%	good: [42:43 45:79]
%
% LEG2: [113:207]
%	unprocessable: 189 (very shallow cast; ~40m)
%
% V1 processed: [1:40 42:43 45:188 190:207]
%	bad: 001-040 (bad WH150DL)
%		 080-095 (WH150DL bad beam)
%	     096-112 (WH600/WH300 combo)
%	???: 118-133 (WH300/WH300)

% V2 processed [041:079 113:188 190:207]
%	- to check how BT/SADCP comparisons stack up, comparatively
%	- some bad profiles (e.g. 19, 20) cannot be processed at all (out of memory)
%	- some V1 profiles collected with bad instruments may be okay (e.g. 001, 002);
%	  however, the situation is ambiguous at best => only process profiles
%	  collected with good instruments
%	- out-of-memory step 11: 19, 20, [21-41?], 42, [43-49?], 65-67, 69-79 (leg1)

% V3 [113:188 190:207] (leg 2)
% 	- yet another test of post-processed BT

% V4 [1:8 10:40 42:43 45:98 100:188 190:207]
%	- like V1, but using only bins [2:9] from the DL
%	- cannot process 9, 99

% V5 [42:43 45:79 113:117 134:188 190:207]
%	- like V4 but discarding bins 12-last

% V6 [1:8 10:40 42:43 45:95 113:188 190:207]
%	- like V4 but discarding far DL bins
%	- V6_4: bins 2-4
%	- V6_5: bins 2-5
%	- ...

% V7 [1:8 10:40 42:43 45:188 190:207]
%	- all processable profiles
%	- ignore bins 6-last in all WH150 data
%	- use only SADCP & BT constraints for 96-112 (blank out deep data)
%	- GOOD PROFILES: 1:40 42:43 45:79 113:188 190:207
%	- QC report uses IX_11
%	- V7 data were re-processed on 03/30 with IX_13 for final archiving; no netCDF

close all; figure(100);
more off;

%processing_version = 1;						% dual-head; BT & GPS
%processing_version = 2;						% DH; SADCP & GPS
%processing_version = 3;						% DH; SADCP & GPS; p.btrk_mode = 2;
%processing_version = 4;						% like V1 but masking DL bins 10:last
%processing_version = 5;						% like V1 but masking DL bins 12:last
%processing_version = 6;							% like V1 but masking DL bins #:last, where the output is in V6_#
processing_version = 7;							% final version: DH; BT/GPS/SADCP; bins 2-6 only for WH150; V.IX_11

f.ladcpdo = sprintf('../data/raw/%03dDL000.000',stn);
f.ladcpup = sprintf('../data/raw/%03dUL000.000',stn);    

f.res         = sprintf('V%d/%03d',processing_version,stn);
f.checkpoints = sprintf('checkpoints/%03d',stn);

if stn < 113
	f.sadcp = '../data/SADCP/Leg1.mat';
else
	f.sadcp = '../data/SADCP/Leg2.mat';
end

f.ctd = sprintf('../data/CTD/2Hz/%03d.2Hz',stn);
    f.ctd_header_lines      = 0;
    f.ctd_fields_per_line   = 11;
    f.ctd_pressure_field    = 2;
    f.ctd_temperature_field = 3;
    f.ctd_salinity_field    = 4;
    f.ctd_time_field        = 1;
    f.ctd_time_base         = 0;
    f.ctd_badvals			= -999;

f.nav = f.ctd;              
    f.nav_header_lines      = f.ctd_header_lines;
    f.nav_fields_per_line   = f.ctd_fields_per_line;
    f.nav_time_field        = f.ctd_time_field;
    f.nav_lat_field         = 10;
    f.nav_lon_field         = 11;
    f.nav_time_base         = f.ctd_time_base;    
    
%----------------------------------------------------------------------

ps.botfac 			= 1;					% defaults
ps.barofac 			= 1;
ps.sadcpfac 		= 0;
ps.fig3_colormap 	= 1;					% deep casts
ps.fig3_err_y_axis 	= 1;
p.btrk_mode 		= 3;					% BT: RDI before own
p.savecdf			= 0;

if stn==49									% default inverse method produces error, at least V6 & V7
	p.getdepth = 1;
end

if processing_version == 1
%	p.savecdf 		= 1;					% enable netCDF output to test new code supplied by Diana Cardoso
elseif processing_version == 2
	ps.botfac		= 0;
	ps.sadcpfac 	= 1;
elseif processing_version == 3
	ps.botfac		= 0;
	ps.sadcpfac 	= 1;
	p.btrk_mode 	= 2;
elseif processing_version == 4
	p.edit_mask_dn_bins = [10:39];
elseif processing_version == 5
	p.edit_mask_dn_bins = [12:39];
elseif processing_version == 6
	p.edit_mask_dn_bins = [21:39];
elseif processing_version == 7
%	p.savecdf = 1;
	ps.sadcpfac = 1;
	if stn<96 || stn>133 || (stn>=113 && stn<=117)		% WH150 
		p.edit_mask_dn_bins = [7:39];
	end
	if stn>=96 && stn<=112								% insufficient range; attempt to get okay deep and shallow velocities; not used 
		ps.barofac 	= 0;
	end
end

p.ladcp_station     = stn;
p.checkpoints       = [1]; 

p.cruise_id         = 'P16N';
p.whoami            = 'A.M. Thurnherr';
p.name              = sprintf('%s station #%d (V%d)',p.cruise_id,p.ladcp_station,processing_version);

p.saveplot_pdf      = [1:6 9:11 13:14];
p.saveplot_png      = [];
p.saveplot	        = [];

