r_data_v_all.m 4.89 KB
function r_data_v_all( nbF )
% R_DATA - Runs R_DATA_POS in batch mode and saves summary data.
%
% Syntax:  r_data_pos_al()
%
% Inputs: 
%     nbF          - The number of floes (40 or 80)
%
% Example:
%    r_data_pos_al(80)
%
% Other m-files required: R_CREATE_FLOE, R_FILL_DATE, R_CHOOSE_HT
%                         Image Processus Toolbox
% Subfunctions: none
% MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
%                     list1.mat 
%
% See also: R_RECON, R_LIST, R_FIGS_POS, R_FIGS_SUMMARY_POS
%
% Author: Marie-Pier Marquis, Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% July 2014, Last revision: January 2014
% ________________________________________________________________________
%% Don't forget to change parameters into r_data_v

nbFStr  = num2str(nbF);
e1      = 201307241037; % same experiment as 201307241018
e2      = 201307241056; % same experiment as 201307241018

% e1      = 201307251513; % same experiment as 201307251413
% e2      = 201307251532; % same experiment as 201307251413

rootdir   = r_root(nbF);
listfile2 = [rootdir, '/info.mat'];
listfile  = [rootdir,'/list1.mat'];
load(listfile) 
load(listfile2)

fps     = info.fps;
type    = info.waveType;
fpsStr  = num2str(fps);
res        = info.result;
int1       = info.int1; % from r_data_pos
int2       = info.int2; % from r_data_pos 
int3       = info.int3; % from r_data_pos
int4       = info.int4; % from r_data_pos
ave        = info.average;  % from r_data_pos
aveStr     = num2str(ave);  % from r_data_pos
int1v    = info.int1v;     
int2v    = info.int2v;     
int3v    = info.int3v;      
int4v    = info.int4v;   % Data between int1 + int3*tpms and int2 + int4*tpms
dt      = info.dt;      %data between 50+5*fps and 75+75*fps in r_data_v
dtStr   = num2str(dt);
m       = 2;              % secon order speed
sumRes  = info.sumResultV;
resV    = info.resultV;
figsdata   = info.figsData;



sumdir   = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,sumRes]; 

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

%% Initialization
stdTkeDt  = nan.*ones(6,10,16);
stdTke    = nan.*ones(6,10,16);
meanTke   = nan.*ones(6,10,16);
meanTkeDt = nan.*ones(6,10,16);

%% Create data file for each row of each experiment.
for i = 1 : length(list1.exp) 
    if list1.nf(i)==nbf && list1.wt(i)==type && list1.exp(i)~=e1 &&...
            list1.exp(i)~=e2
        % Data from list1.
        exp       = num2str(list1.exp(i));     
        tp        = list1.tp(i);
        hs        = list1.hs(i);        
        [h,t]     = r_choose_ht(hs,tp);     % hs and tp are listed from 0 to
                                           % 6 (for hs) and 0 to 10 (tp)
        rowCounter   = 0;                     % counter of rows
        % Initialization
        expTke    = nan;
        expVy     = nan;
        expTkeDt = nan;
        expVyDt   = nan;
        
        for c = 1:4
            cam = num2str(c);
            for r = 1:4                
                row       = num2str(r);
                rowCounter   = rowCounter + 1;
                
                expdir    = [rootdir,'/',exp,'_multicam'];
                resvdir   = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
                                  resV];     
                resdir  = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',aveStr,res];
                datafile2 = [resdir,figsdata,fpsStr,'fps_',nbFStr,...
                                  'f_',aveStr,'_',exp,'_',cam,'_',row,'.mat'];                                                
                cd(expdir)                
                if ~exist(resvdir,'dir')
                    mkdir(resvdir)
                end
                if ~exist(resdir,'dir')
                    mkdir(resdir)
                end
                cd(resdir)
                if exist(datafile2,'file')
                   [expVy,expTke,expTkeDt,expVyDy,meanTke,meanTkeDt,stdTkeDt,...
                       stdTke,vx,vy,vxm,vym] = r_data_v(h,t,rowCounter,int1v,...
                       int2v,int3v,int4v,expVy,expTke,expTkeDt,expVyDy,meanTke,meanTkeDt,stdTkeDt,...
                       stdTke)
                end
            end
        end
        
        %% Put together values by experiment
       
        disp(' Saving data ... ');
        save([resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
            '_figs_v_data_',exp],...
            'expVy','expTke','expTkeDt','expVyDt','time',...
            'nObjects','-v7.3');        
        disp(' Done! ');
        
        %% re-initialize variables
        for xx = 1 : numel(vx)
           vx(xx)  = nan;
           vy(xx)  = nan;
           vxm(xx) = nan;
           vym(xx) = nan;
        end
                
    end    
end

disp(' Saving summary data ... ');
        save([sumdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
            '_summary_results_v'],...
            'meanTke','meanTkeDt','stdTkeDt',...
            'stdTke','-v7.3');        
disp(' Done! ');
end












end