r_data_figs_summary.m 11.7 KB
function  r_data_figs_summary
% R_DATA_FIGS_SUMMARY - Produces data for r_figs_summary.
%
% Syntax:  data = r_data_figs_summary
%
% Example:
%    r_data_figs_summary(201307231525,1,4);
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: list.mat
%                     figs_data_5f_$expNumber_$camNumber_$rowNumber
%
% See also: R_FIGS_SUMMARY

% Author: Marie-Pier Marquis, Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% July 201%fPos(k)    = nanmean(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));
    %fStdPos(k) = nanstd(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));%fPos(k)    = nanmean(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));
    %fStdPos(k) = nanstd(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));
% ____________________________________
%%
rootdir  = '/Users/marie-pier/Desktop/MP/images/multicam';
listfile = [rootdir,'/list.mat'];
sumdir  = [rootdir,'/summary_results'];

load(listfile)

if ~exist(sumdir,'dir')
    mkdir(sumdir)
end

cd(sumdir)


%% Initialisation 
estr     = nan.*ones(13,1);
estr(1)  = 201307231525;
estr(2)  = 201307231605;
estr(3)  = 201307231625;
estr(4)  = 201307231730;
estr(5)  = 201307231748;
estr(6)  = 201307240926;
estr(7)  = 201307240941;
estr(8)  = 201307240958;
estr(9)  = 201307241018;
estr(10) = 201307241121;
estr(11) = 201307241158;
estr(12) = 201307241410;
estr(13) = 201307241427;
estr  = num2str(estr);


%tp        = nan.*ones(size(estr,1));
%hs        = nan.*ones(size(estr,1));
dyAve     = nan.*ones(13,4,4);
meanStd   = nan.*ones(13,4,4);
Std_hs2    = nan.*ones(10,13,16);
Std_hs4    = nan.*ones(10,13,16);
Std_hs8    = nan.*ones(10,13,16);
Std_hs10   = nan.*ones(10,13,16);

dy_hs2    = nan.*ones(10,13,16);
dy_hs4    = nan.*ones(10,13,16);
dy_hs8    = nan.*ones(10,13,16);
dy_hs10   = nan.*ones(10,13,16);


%% Reading of datafile1 (xPos, yPos,...) and datafile2 (meanDisp, vx,vy,...).
%  Sort data by wave heigt, wave period and main displacement. For 80
%  floes, there are 4 multidimensional arrays 10x13x4x4 (10 wave periods,
%  13 experiences, 4 cameras and 4 rows) for each wave height.

for k = 1:13    
    exp = estr(k,:);
    expdir1 = [rootdir,'/',exp,'_multicam'];
    expdir2 = [expdir1,'/results'];
    cd(expdir2)
    count = 1;
    for c = 1:4
        cam = num2str(c);
        for r = 1:4  
            row = num2str(r);             
            nameFile  = ['figs_data_5f_',exp,'_',cam,'_',row,'.mat']; 
            
            if  ~exist(nameFile,'file')
                dyAve(k,c,r) = nan;  
                meanStd(k,c,r)      = nan;
            else
                load(nameFile)
                dyAve(k,c,r)    = str2num(meanDisp);
                deltaStd        = (iStdPos)+ (fStdPos);
                meanStd(k,c,r)  = mean(deltaStd);
            end
            
            %estr2 = str2num(exp);
            ii  = find(list.exp == str2num(exp));
            tp  = list.tp(ii);
            hs  = list.hs(ii);
            if hs == 2                
                if     tp == 6.5               
                    Std_hs2(1,k,count) = meanStd(k,c,r);
                    dy_hs2(1,k,count)  = dyAve(k,c,r);                    
                elseif tp == 8.0                   
                    Std_hs2(2,k,count) = meanStd(k,c,r);
                    dy_hs2(2,k,count)  = dyAve(k,c,r);                    
                elseif tp == 9.5       
                    Std_hs2(3,k,count) = meanStd(k,c,r);
                    dy_hs2(3,k,count)  = dyAve(k,c,r);                    
                elseif tp == 11.0      
                    Std_hs2(4,k,count) = meanStd(k,c,r);
                    dy_hs2(4,k,count)  = dyAve(k,c,r);                    
                elseif tp == 12.5      
                    Std_hs2(5,k,count) = meanStd(k,c,r);
                    dy_hs2(5,k,count)  = dyAve(k,c,r);                    
                elseif tp == 14.0      
                    Std_hs2(6,k,count) = meanStd(k,c,r);
                    dy_hs2(6,k,count)  = dyAve(k,c,r);                    
                elseif tp == 15.5     
                    Std_hs2(7,k,count) = meanStd(k,c,r);
                    dy_hs2(7,k,count)  = dyAve(k,c,r);                    
                elseif tp == 17.0
                    Std_hs2(8,k,count) = meanStd(k,c,r);
                    dy_hs2(8,k,count)  = dyAve(k,c,r);                    
                elseif tp == 18.5     
                    Std_hs2(9,k,count) = meanStd(k,c,r);
                    dy_hs2(9,k,count)  = dyAve(k,c,r);                    
                elseif tp == 20.0
                    Std_hs2(10,k,count) = meanStd(k,c,r);
                    dy_hs2(10,k,count)  = dyAve(k,c,r);                    
                end               
                
            elseif hs == 4                
                if     tp == 6.5        
                    Std_hs4(1,k,count) = meanStd(k,c,r);
                    dy_hs4(1,k,count)  = dyAve(k,c,r);                    
                elseif tp == 8.0     
                    Std_hs4(2,k,count) = meanStd(k,c,r);
                    dy_hs4(2,k,count)  = dyAve(k,c,r);                    
                elseif tp == 9.5       
                    Std_hs4(3,k,count) = meanStd(k,c,r);
                    dy_hs4(3,k,count)  = dyAve(k,c,r);                    
                elseif tp == 11.0   
                    Std_hs4(4,k,count) = meanStd(k,c,r);
                    dy_hs4(4,k,count)  = dyAve(k,c,r);                    
                elseif tp == 12.5        
                    Std_hs4(5,k,count) = meanStd(k,c,r);
                    dy_hs4(5,k,count)  = dyAve(k,c,r);                    
                elseif tp == 14.0    
                    Std_hs4(6,k,count) = meanStd(k,c,r);
                    dy_hs4(6,k,count)  = dyAve(k,c,r);                    
                elseif tp == 15.5    
                    Std_hs4(7,k,count) = meanStd(k,c,r);
                    dy_hs4(7,k,count)  = dyAve(k,c,r);                    
                elseif tp == 17.0       
                    Std_hs4(8,k,count) = meanStd(k,c,r);
                    dy_hs4(8,k,count)  = dyAve(k,c,r);                    
                elseif tp == 18.5    
                    Std_hs4(9,k,count) = meanStd(k,c,r);
                    dy_hs4(9,k,count)  = dyAve(k,c,r);                    
                elseif tp == 20.0   
                    Std_hs4(10,k,count) = meanStd(k,c,r);
                    dy_hs4(10,k,count)  = dyAve(k,c,r);                    
                end
                
            elseif hs == 8                
                if     tp == 6.5  
                    Std_hs8(1,k,count) = meanStd(k,c,r);
                    dy_hs8(1,k,count)  = dyAve(k,c,r);                    
                elseif tp == 8.0     
                    Std_hs8(2,k,count) = meanStd(k,c,r);
                    dy_hs8(2,k,count)  = dyAve(k,c,r);                    
                elseif tp == 9.5     
                    Std_hs8(3,k,count) = meanStd(k,c,r);
                    dy_hs8(3,k,count)  = dyAve(k,c,r);                    
                elseif tp == 11.0    
                    Std_hs8(4,k,count) = meanStd(k,c,r);
                    dy_hs8(4,k,count)  = dyAve(k,c,r);                    
                elseif tp == 12.5          
                    Std_hs8(5,k,count) = meanStd(k,c,r);
                    dy_hs8(5,k,count)  = dyAve(k,c,r);                    
                elseif tp == 14.0  
                    Std_hs8(6,k,count) = meanStd(k,c,r);
                    dy_hs8(6,k,count)  = dyAve(k,c,r);                    
                elseif tp == 15.5 
                    Std_hs8(7,k,count) = meanStd(k,c,r);
                    dy_hs8(7,k,count)  = dyAve(k,c,r);                    
                elseif tp == 17.0            
                    Std_hs8(8,k,count) = meanStd(k,c,r);
                    dy_hs8(8,k,count)  = dyAve(k,c,r);                    
                elseif tp == 18.5   
                    Std_hs8(9,k,count) = meanStd(k,c,r);
                    dy_hs8(9,k,count)  = dyAve(k,c,r);                    
                elseif tp == 20.0  
                    Std_hs8(10,k,count) = meanStd(k,c,r);
                    dy_hs8(10,k,count)  = dyAve(k,c,r);                    
                end
                
            elseif hs == 10                
                if     tp == 6.5        
                    Std_hs10(1,k,count) = meanStd(k,c,r);
                    dy_hs10(1,k,count)  = dyAve(k,c,r);                    
                elseif tp == 8.0           
                    Std_hs10(2,k,count) = meanStd(k,c,r);
                    dy_hs10(2,k,count)  = dyAve(k,c,r);                    
                elseif tp == 9.5  
                    Std_hs10(3,k,count) = meanStd(k,c,r);
                    dy_hs10(3,k,count)  = dyAve(k,c,r);                    
                elseif tp == 11.0 
                    Std_hs10(4,k,count) = meanStd(k,c,r);
                    dy_hs10(4,k,count)  = dyAve(k,c,r);                    
                elseif tp == 12.5     
                    Std_hs10(5,k,count) = meanStd(k,c,r);
                    dy_hs10(5,k,count)  = dyAve(k,c,r);                    
                elseif tp == 14.0   
                    Std_hs10(6,k,count) = meanStd(k,c,r);
                    dy_hs10(6,k,count)  = dyAve(k,c,r);                    
                elseif tp == 15.5  
                    Std_hs10(7,k,count) = meanStd(k,c,r);
                    dy_hs10(7,k,count)  = dyAve(k,c,r);                    
                elseif tp == 17.0  
                    Std_hs10(8,k,count) = meanStd(k,c,r);
                    dy_hs10(8,k,count)  = dyAve(k,c,r);                    
                elseif tp == 18.5   
                    Std_hs10(9,k,count) = meanStd(k,c,r);
                    dy_hs10(9,k,count)  = dyAve(k,c,r);                    
                elseif tp == 20.0 
                    Std_hs10(10,k,count) = meanStd(k,c,r);
                    dy_hs10(10,k,count)  = dyAve(k,c,r);                    
                end
            end
            count = count + 1;            
        end  
    end
end


%% Sum data to obtain 1x10x16 multidimensional array 
% the function ''nansum'' puts zero if we have a sum of only nan values.

s_Std_hs2  = nansum(Std_hs2(:,:,:),2);
s_Std_hs4  = nansum(Std_hs4(:,:,:),2);
s_Std_hs8  = nansum(Std_hs8(:,:,:),2);
s_Std_hs10 = nansum(Std_hs10(:,:,:),2);

s_dy_hs2  = nansum(dy_hs2(:,:,:),2);
s_dy_hs4  = nansum(dy_hs4(:,:,:),2);
s_dy_hs8  = nansum(dy_hs8(:,:,:),2);
s_dy_hs10 = nansum(dy_hs10(:,:,:),2);

% Convert the zeros is nan

for r = 1 : 16
    for t = 1 : 10
        
        if s_Std_hs2(t,:,r) == 0   
            s_Std_hs2(t,:,r) = nan;                  
        end
        if s_Std_hs4(t,:,r) == 0   
            s_Std_hs4(t,:,r) = nan;                  
        end
        if s_Std_hs8(t,:,r) == 0   
            s_Std_hs8(t,:,r) = nan;                  
        end
        if s_Std_hs10(t,:,r) == 0   
            s_Std_hs10(t,:,r) = nan;                  
        end
        
        
        if s_dy_hs2(t,:,r) == 0   
            s_dy_hs2(t,:,r) = nan;                  
        end
        if s_dy_hs4(t,:,r) == 0   
            s_dy_hs4(t,:,r) = nan;                  
        end
        if s_dy_hs8(t,:,r) == 0   
            s_dy_hs8(t,:,r) = nan;                  
        end
        if s_dy_hs10(t,:,r) == 0   
            s_dy_hs10(t,:,r) = nan;                  
        end
                
    end  
end







%% Saving data

disp(' Saving data ... ');

save([sumdir,'/figs_summary_80f'],'dy_hs2','dy_hs4','dy_hs8','dy_hs10',...
    's_dy_hs2','s_dy_hs4','s_dy_hs8','s_dy_hs10','s_Std_hs2',...
    's_Std_hs4','s_Std_hs8','s_Std_hs10','-v7.3');
disp(' Done! ');  


end