% processMVPrawData
% =========================================================================
%
% USAGE:
%  Alter the pathnames where indicated in the comment line and then run.
%  With path to data specified correctly, all required data is loaded by
%  called subfunctions.
%
% DESCRIPTION:
%  Batch processes a directory containing .raw MVP text files and organises
%  them into structure arrays.
%
% OUTPUT
%  Structure arrays of MVP downcasts (MVPd) and upcasts (MVPu) containing
%  pressure, metadata, temperature, conductivity, salinity and sigmat.
%
% AUTHOR:
%  Dr. Susanne E. Craig, Bedford Institute of Oceanography
%
% VERSION NUMBER:
% 1.0 (18th June 2013)
%
% =========================================================================


clear
close all
clc

% Change path names as appropriate
addpath(genpath('/Users/scraig/Documents/Ross Sea/MVP/final MVP code')) % <==
path2dat = '/Users/scraig/Documents/Ross Sea/MVP/MVP data/'; % <==
path2save = '/Users/scraig/Documents/Ross Sea/MVP/'; % <==

% Get file names
s = getMVPdirRaw(path2dat);

% Preallocate the structures
[MVPd, MVPu] = iniRawStructs(s);

% Extract data
for n = 1:length(s)
    path2file = [path2dat s(n).name];
    [downcast, upcast] = loadMVPraw(path2file);
    MVPd(n,1) = downcast;
    MVPu(n,1) = upcast;
end

% Save a file
eval(['save ''' path2save 'MVPrawData'' MVPd MVPu'])
