% Converts ASCII files with ADCP and RCM9 data into netCDF
% format.
% The ASCII files with raw data format contains data 
% in the Belgiam coast.
% The data has been prepared for the MICORE project: www.micore.eu

% International Marine and Dredging Consultants, IMDC
% www.imdc.be
% Antwerp, Belgium
%
% Written by: Fernando Toro, Piet Haerens
%             fto@imdc.be
% Date: November 2009
% Modified:
% Date:

% Common input arguments
strInPathADCPWaves = fullfile('..', 'raw', 'ADCP','formaat 5_waves');
strInPathADCPCurrent = fullfile('..', 'raw', 'ADCP','formaat 6_current');
strInPathRCM9 = fullfile('..', 'raw','RCM9');
strOutPathADCPWaves = fullfile('..', 'netcdf','ADCP','waves');
strOutPathADCPCurrent = fullfile('..', 'netcdf','ADCP','current');
strOutPathRCM9 = fullfile('..', 'netcdf','RCM9');

% List of files to process

% vFiles = dir([strInPath,'*.txt']);
cInADCPWavesFile = {'Mariakerke_ADCP_wave_20090115_20090127_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090127_20090204_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090204_20090218_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090408_20090408_aangepast_c.txt'};

cInADCPCurrentFile = {'Mariakerke_ADCP_wave_20090115_20090127_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090127_20090204_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090204_20090218_aangepast_c.txt'; ...
           'Mariakerke_ADCP_wave_20090408_20090408_aangepast_c.txt'};

cInRCM9File = {'081212_090423_boven_c.txt'; ...
           '20081212_20090423_onder_c.txt'};

cOutADCPWavesFile = {'Mariakerke_ADCP_wave_20090115_20090127_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090127_20090204_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090204_20090218_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090408_20090408_aangepast_c.nc'};

cOutADCPCurrentFile = {'Mariakerke_ADCP_wave_20090115_20090127_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090127_20090204_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090204_20090218_aangepast_c.nc'; ...
           'Mariakerke_ADCP_wave_20090408_20090408_aangepast_c.nc'};

cOutRCM9File = {'081212_090423_boven_c.nc'; ...
           '20081212_20090423_onder_c.nc'};
       
% Make the job ADCPWaves
for i=1:size(cInADCPWavesFile,1)
    strInFile = cInADCPWavesFile{i};
    strOutFile = cOutADCPWavesFile{i};
    nLines = 15;
    bOK = ADCP2netcdf(strInPathADCPWaves, strInFile, strOutPathADCPWaves, strOutFile, nLines);
end

% Make the job ADCPCurrent
for i=1:size(cInADCPCurrentFile,1)
    strInFile = cInADCPCurrentFile{i};
    strOutFile = cOutADCPCurrentFile{i};
    nLines = 15;
    bOK = ADCP2netcdf(strInPathADCPCurrent, strInFile, strOutPathADCPCurrent, strOutFile, nLines);
end

% Make the job RCM9
for i=1:size(cInRCM9File,1)
    strInFile = cInRCM9File{i};
    strOutFile = cOutRCM9File{i};
    nLines = 11;
    bOK = RCM92netcdf(strInPathRCM9, strInFile, strOutPathRCM9, strOutFile, nLines);
end
