%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    LATEXtools                         %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  This  file  is  free software ;  it  is distributed  in  %
%%  the hope that  it  will  be  useful,  but  without  any  %
%%  warranty.  You  can  redistribute  it and/or modify  it  %
%%  under  the  terms  of  the  GNU  General Public License  %
%%  as  published  by  the   Free  Software  Foundation  at  %
%%       http://www.gnu.org/copyleft/gpl.html                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MVP_cruise_params (MATLAB SCRIPT)
%%
%% Initializes important metadata for running the MVP
%% processing scripts.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 21/04/16 : louise.rousselet@mio.osupytheas.fr :
%%            andrea.doglioli@mio.osupytheas.fr  : 
%%            alain.de-verneil@mio.osupytheas.fr : creation 
% 31/03/17: AP, LR, AdV and A. Petrenko - PHYBIO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LATEXtools_param
LATEXtools_cruise

%% The PATH where the MVP Folders are
switch cruise_name
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'PHYBIO'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Transect_Names = {'PL1_82_9'}% 'PL2_83_10' 'PL3_84_11' 'PL4_85_12' 'PL5_86-13'}; %Same name of the subsubdirectory of L0
Transect_Start = {'2017-03-21_090831'}; %Same time recorded in the first .raw filename of the correspondin transect
Transect_Stop ={'2017-03-21_102258'};%Same time recorded in the last .raw filenames of the correspondin transect

transchoice=1;%[1 2 3 4 5];

badprofile=[]; %for MVP_dynheight


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'ESSMVP'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Transect_Names = {'Pl1_4noeuds' 'PL2_6noeuds_2h' 'Pl3_6noeuds_10h' 'Pl4_8noeuds_1h_move_deck' 'Pl4_8noeuds_3h' 'pl5_8noeuds_1h_5hz' 'pl6_8noeuds_2h_5hz'};
Transect_Start = {'2016-05-06_115302' '2016-05-06_134645' '2016-05-06_173730' '2016-05-07_051231' '2016-05-07_070317' '2016-05-07_095455' '2016-05-07_112721'};
Transect_Stop ={'2016-05-06_124822' '2016-05-06_164824' '2016-05-07_040504' '2016-05-07_055650' '2016-05-07_092456' '2016-05-07_104734' '2016-05-07_123948'};

transchoice=1;%[1 2 3 4 5 6 7];

badprofile=[]; %for MVP_dynheight

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'OSCAHR'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Transect_Names = {'transect2_T0-T1' 'transect3_T1-T3' 'transect4_T3-T5' 'transect5_T5-T0' 'transect7_T13-T14' 'transect8_T14-T15'  'transect9_T15-T7' 'transect10_T7-T14' 'transect11_T14-T16' 'transect13_T17-T9' 'transect14_T9-T15'};
Transect_Start = {'2015-10-30_085652' '2015-10-30_143119' '2015-10-30_234911' '2015-10-31_062639' '2015-11-03_162247' '2015-11-03_203125' '2015-11-03_232147' '2015-11-04_025204' '2015-11-04_085209' '2015-11-04_200707' '2015-11-04_233352'};
Transect_Stop =  {'2015-10-30_115450' '2015-10-30_232206' '2015-10-31_055918' '2015-10-31_113454' '2015-11-03_180516' '2015-11-03_230243' '2015-11-04_022504' '2015-11-04_062339' '2015-11-04_111651' '2015-11-04_225540' '2015-11-05_060738'};

transchoice=[11] %[1 2 3 4 5 6 7 8 9 10 11];

badprofile=[]; %for MVP_dynheight


end %switch

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Instrument choice
instrType = 'AML_uCTD'; % SeaQuest % PHYBIO
%instrType = 'LOPC+uCTD'; % < This is the big fish % OSCAHR / ESSMVP
%instrType = 'LOPC+uCTD_Sal'; % < Big fish w/ uCTD, but also Salinity in .raw file. OUTPACE LDA
%instrType = 'LOPC+uSVP'; % <Big fish w/ Sound Velocity Profiler % OUTPACE LDB-> LDC

%% QUALITY CONTROL CHOICES
% qc_user: What level of processing will be done in L1toL2?
% qc_user=1; %'Processing option 1: Maximize cross-correlation of T/C gradients. (Quicker for at sea processing)');
qc_user=2; %'Processing option 2: Minimize variance in resulting salinity profile. (Much Slower) ');

% If qc_user = 2, should density variance be minimized, too? Should the
% "fast" or the slow algorithm be used?
dens_flag = 0; % 1=yes 0=no also use density
fast_flag = 1; % 1=yes 0=no for the fastest version of this method?

% Select which QC flag is used for L1toL2 treatment...
qc_flag = 0;

% Should we filter the data?
filter_flag = 0; % 0 = no filter, 1 = filter.

% Params for smoothing w/ butterworth low-pass filter.
tauPres = 2;
tauOthers = 0.25;

% Fluorescence conversion (if available)...
bit_input = 12;
volt_input = 5;

% parameters to build the regular pressure grid. The bin values are located
% at the CENTER of the binning, not at the edges.
presMin = 5; % Minimum pressure value (in dBar)
presMax = 350; % Maximum pressure
presDelta = 1; % Spacing of Bins.

% Color axes for plotting the Transect in MVP_L1toL2.m
color_axes = [14 18; 38 38.5; 1028 1030]; % Axes for Temp, Sal, and Dens

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% END OF USER CHOICES %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% L0, L1, and L2 Directories
% The subdirectory (or lack thereof) needs to be specified...
pathL0 = [dirin_MVP filesep 'L0' filesep Transect_Names{transchoice}]
pathL1 = [dirin_MVP filesep 'L1'];
pathL2 = [dirin_MVP filesep 'L2'];



%% The Names and Units of the variables the MVP is measuring
% The type of instrument, below are some examples.
%%% Find it in the .raw file

switch instrType

    case 'AML_uCTD' % ex: SEAQUEST and PHYBIO
        columnNames = {'pres' 'cond' 'temp'}; % Name of the variable sampled.
        columnUnits = {'dBar' 'mS/cm' 'deg C'}; % Units of sampled variables.
        dataFormat = '%f %f %f';
        fSample = 25; % The sampling rate, in Hz, of the MVP platform. 25 is default.

    case 'LOPC+uCTD' % ex: OSCAHR
        columnNames = {'pres'  'cond'  'temp' 'ADCcounts'  'LOPCcounts'};
        columnUnits = {'dBar'  'mS/cm' 'deg C' ''         'cnts/0.5s'};
        dataFormat = '%f %f %f %f %f';
        fSample = 25;

    case 'LOPC+uCTD_Sal' % ex: OUTPACE LDA
        columnNames = {'pres'  'cond'  'temp' 'psal' 'ADCcounts'  'LOPCcounts'};
        columnUnits = {'dBar'  'mS/cm' 'deg C' 'psu' ''         'cnts/0.5s'};
        dataFormat = '%f %f %f %f %f %f';
        fSample = 1;

    case 'LOPC+uSVP' % ex: OUTPACE LDB-> LDC
        columnNames = {'pres' 'soundVel' 'temp' 'ADCcounts' 'LOPCcounts'};
        columnUnits = {'dBar'  'm/s'  'deg C' ''  'cnts/0.5s'};
        dataFormat = '%f %f %f %f %f';
        fSample = 16;  

end

%% End of MVP_cruise_params
