close all
clear all

% addpath(genpath('/Volumes/Chem/ARGO_PROCESSING/MFILES/FLOATS/'));
% addpath(genpath('/Users/Mau/Documents/MBARIprojects/CPF/CPFPROCESSING'));
% addpath(genpath('/Users/Mau/Documents/MATLABhelp_new/ARGO_PROCESSING-master/')); %

addpath(genpath('\\atlas\Chem\ARGO_PROCESSING\MFILES\FLOATS\'));
addpath(genpath('C:\Users\magdalena\Documents\ARGO_PROCESSING-master\'))

%% PURPOSE: Process all CPF profile data from a mission. Calculates BGC
% parameters and saves each profile in .mat file
% under the same directory tree. All done in calc_BGC.m
% Here, I'm just looping through al profiles.

% Specify path to data/mission
% % ='/Volumes/CPF/CPF003/Data/TankTests/2021-8-25T21-57-38/'; % latest tank test
% path_data='/Volumes/CPF/CPF003/Data/TankTests/2021-8-31T16-23-33/';
% path_data='/Volumes/CPF/CPF003/Data/TankTests/2021-9-3T18-48-26/';

% mission='Paragon Tests/2021-9-16T16-33-30/';
% % mission='TankTests/2021-9-9T21-6-13/';
% % mission='TankTests/2021-9-9T17-33-2/';
% path_data=['/Volumes/CPF/CPF003/Data/',mission];

% Use paths below if running on windows
mission='ParagonTests\MICRORIDER\OvernightMission\2021-10-21T18-34-19\';
dirs.root='\\atlas\ProjectLibrary\CPF\CPF003\';
dirs.mission=mission;

path_data=[dirs.root,'Data\',mission];
dirs.data=path_data;

dirs.cal=[dirs.root,'SensorData\'];
%%
dirs.temp=path_data;
msg_list   = dir([dirs.temp,'*.msg']); % get list of file names to process

nf=length(msg_list);

HR=cell(nf,1);
LR=cell(nf,1);

for f=1:nf
    msg_file=msg_list(f).name;
    cast=regexp(msg_file,'\d+(?=\.msg)','once','match');
    [HR{f},LR{f},INFO]=calc_BGC(dirs,cast); % this function saves in .mat file format
                                           % '/Volumes/CPF/CPF003/Data/matfiles/...
                                           % using the same directory tree
                                           % as input
end

