% nbp1201_read_PCO2_chris.m
%
%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
%@@@@@@@@@@@@@   DATA SOURCE  @@@@@@@@@@@@@@@@@@
%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
% Merged pCO2 
% http://science.whoi.edu/users/mcgillic/nbp1201/science_drive/rttsg/
% File names:
% 20120107-combo-rttsg  % start: Jan-7-2012 22:13:27
% 20120108-combo-rttsg
% 20120109-combo-rttsg
% 20120110-combo-rttsg
% 20120111-combo-rttsg
% 20120112-combo-rttsg
% 20120113-combo-rttsg
% 20120114-combo-rttsg
% 20120115-combo-rttsg  % end:   Jan-15-2012 02:06:05
%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
% Read files on daily basis and create one mat file with all the data.

clear;

% Path.
path_part_1='/data2/antarctic_data2/nbp1201/underway/process_ship/';
path_part_2='rttsg_dir/';
path_name=[path_part_1 path_part_2];

d_uw_all=[];
for day=[7:15]
    if day<10
        day_str=['0' num2str(day)];
    else
        day_str=num2str(day);
    end
        fname=['201201' day_str '-combo-rttsg']; % e.g. 20120107-combo-rttsg
    %if ~isempty(fname) % data from one day file
        p=['load ' path_name fname ';'];
        eval(p);
        if strcmp(fname(1:4),'2012')
            % Data file variable.
            fname_var=['X' strrep(fname,'-','_')];
            % NOTE:
            % If file name contains some characters (in our case '-') or begins
            % with a number (also in our case), the variable name is not the same
            % as the file name and Matlab changes it. E.g.:
            % File name: 20120115-combo-rttsg;
            % Matlab created variable name: X20120115_combo_rttsg
            p=['d_uw= ' fname_var ';'];
            eval(p);
            d_uw_all=[d_uw_all;d_uw];
        else
            disp('Not considered file name');
            return;
        end
end  % For for day=[7:36]
rttsg_days_7_15=d_uw_all;
%size(rttsg_days_7_15)
% ANS: 10311x15
%%%save rttsg_days_7_15 rttsg_days_7_15;
