r_figs_v.m 10.5 KB
function r_figs_v(nbF)
% R_FIGS - Produces some figures.
%
% Syntax:  r_figs_v
%
%
% Example:
%    r_figs_v
%
% Other m-files required: R_CHOOSE_HT
% Subfunctions: none
% MAT-files required: figs_v_data_5f_expNumber_camNumer_$rowNumber.mat 
%                     $fps$f_figs_v_data_exp.mat(produc by R_DATA_V)
%                     list.mat 
%
% See also: R_RECON, R_ISOLATE, R_DATA_V
%
% Author: Marie-Pier Marquis, Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% July 2014, Last revision: October 2014
% ______________________________________________________________________
%%
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)
ave           = info.average;  % from r_data_pos
aveStr        = num2str(ave);  % from r_data_pos
fps           = info.fps;
dt            = info.dt;       % data between 50+5*fps and 75+75*fps           
fpsStr        = num2str(fps);
dtStr         = num2str(dt);
type          = info.waveType;              % 1 if regular wave, 0 if irregular waves
sumRes        = info.sumResultV;
resV          = info.resultV;
figsDataV     = info.figsDataV;
vTitle        = info.vTitle;
TkeTitle      = info.TKETitle;
TkeDtTitle    = info.TkeDtTitle;
expTkeTitle   = info.expTkeTitle;
expTkeDtTitle = info.expTkeDt;

sumdir   = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'dt_',aveStr,'ave',sumRes];
datasum  = [sumdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'dt_',aveStr,'ave',sumRes,'.mat'];
if ~exist(sumdir,'dir')
    mkdir(sumdir)
end
cd(sumdir)
if exist(datasum,'file')
    load(datasum)
end


%% Create figures for each row of each experiment.
count_e = 0;  % experiment counter
for i = 1 : length(list1.exp) 
    if list1.nf(i)==nbF && list1.wt(i)==type && list1.exp(i)~=e1 &&...
            list1.exp(i)~=e2 
        
        count_e = count_e + 1;
        % Data from list1.
        exp     = num2str(list1.exp(i));     
        tp      = list1.tp(i);
        hs      = list1.hs(i);
        tpstr   = num2str(tp);
        hsstr   = num2str(hs);    % Wave period at model scale
    
        [h,t]   = r_choose_ht(hs,tp);
        count_r = 0;              % count rows
        for c = 1:4
            cam = num2str(c);
            for r = 1:4 
                row = num2str(r);
                count_r = count_r + 1;
                expdir   = [rootdir,'/',exp,'_multicam']; 
                resvdir  = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
                                  'dt_',aveStr,'ave',resV];
                datafile = [resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'dt_',...
                        aveStr,'ave',figsDataV,exp,'_',cam,'_',row,'.mat'];
                cd(expdir)
                if ~exist(resvdir,'dir')
                    mkdir(resvdir)
                end 
                
                if  exist(datafile,'file')
                    load(datafile)
                    cd(resvdir)
                    %% (vx,vy)
                    figure(1); clf
                    hold on 
                    for k = 1:nObjects
                        plot(time, vy(:,k), '-k','LineWidth',1,...
                              'MarkerSize',7);
                    end
                    hold off
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['speed\_exp',exp,'\_','cam',cam,'\_','row',row,]);
                    ylabel('\it{v}_{y} \rm(m/s)','FontSize',16,...
                              'FontName','Times');
                    xlim([time(1) time(end)])
                    ylim([0 (max(max(vy))+0.01)])       
                    print([vTitle,fpsStr,'fps',nbFStr,'f_',dtStr,'dt_',aveStr,'ave_',exp,'_',cam,...
                              '_',row,'.png'],'-dpng');  
                    
                    %% (vx,vy) m-order
                    figure(2); clf
                    hold on 
                    for k = 1:nObjects
                        plot(time, vym(:,k), '-k','LineWidth',1,...
                               'MarkerSize',7);
                    end
                    hold off
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['speed\_',num2str(m),'order\_','exp',exp,'\_',...
                        'cam',cam,'\_','row',row,]);
                    ylabel('\it{vm}_{y} \rm(m/s)','FontSize',16,...
                               'FontName','Times');
                    xlim([time(1) time(end)])
                    ylim([0 (max(max(vym))+0.01)])
                                  
                    print([vTitle,num2str(m),'order_',fpsStr,'fps',nbFStr,'f_',...
                        dtStr,'dt_',aveStr,'ave_',exp,'_',cam,'_',row,'.png'],'-dpng');  
                             
                    %% Histogram plot (vy)
                    figure(3); clf 
                    
                    subplot(2,2,[1,3]) % v  
                    bin1 = 0.002;
                    hist(rowVy,0:bin1:max(rowVy));
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['exp',exp,'\_','cam',cam,'\_','row',row,]);
                    xlabel('\itv_k \rm(m/s)','FontSize',16,'FontName',...
                             'Times');
                    xlim([0,max(rowVy)])            
                    
                    subplot(2,2,[2,4])
                    bin2 = 0.0001;
                    hist(rowTke,0:bin2:max(rowTke));
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['(\itT_p \rm= ',tpstr,',  \itH_s \rm=',...
                              hsstr,')']);
                    % Put the text 
                    tempo = numel(find((rowTke<bin2)==1));
                    text(max(rowTke)/6,tempo/2,['TKE = ',...
                        num2str(meanTke(h,t,count_r)),...
                            '(m^2/s^2)'],'FontSize',10,'FontName','Times');
                        
                    xlabel('\it0.5v_kv_k \rm(m^2/s^2)','FontSize',16,...
                            'FontName','Times');
                    xlim([0,max(rowTke)])

                    
                    print([TkeTitle,fpsStr,'fps',nbFStr,'f_',dtStr,'dt_',aveStr,'ave_',exp,'_',cam,...
                        '_',row,'.png'],'-dpng');
                                      
                    %% Histogram plot (vy dt)
                    figure(4); clf 
                                        
                    subplot(2,2,[1,3]) % v
                    
                    hist(rowVyDt,0:bin1:max(rowVyDt));
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['exp',exp,'\_','cam',cam,'\_','row',row,]);
                    xlabel('\itv_k \rm(m/s)','FontSize',16,'FontName',...
                              'Times');
                    xlim([0,max(rowVyDt)])
           
                    subplot(2,2,[2,4])
                    hist(rowTkeDt,0:bin2:max(rowTkeDt));
                    
                    set(gca,'FontSize',16,'FontName','Times')
                    title(['(\itT_p \rm= ',tpstr,',  \itH_s \rm=',...
                               hsstr,')']);
                    
                    % Put the text 
                    tempo = numel(find((rowTkeDt<bin2)==1));
                    text(max(rowTkeDt)/6,tempo/2,['TKE = ',...
                        num2str(meanTkeDt(h,t,count_r)),...
                        ' (m^2/s^2)'],'FontSize',10,'FontName','Times');
                    xlabel('\it0.5v_kv_k \rm(m^2/s^2)','FontSize',16,...
                        'FontName','Times');
                    xlim([0,max(rowTkeDt)])

                    print([TkeDtTitle,fpsStr,'fps',nbFStr,'f_',dtStr,'dt_',aveStr,'ave_',exp,'_',...
                        cam,'_',row,'.png'],'-dpng'); 
                    
                end
            end
        end
        %% Histogram plot (vy by experiment)
        
        datafile2 = [resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
                               figsDataV,exp,'.mat'];
                           
        cd(resvdir)
        if  exist(datafile2,'file')
            load(datafile2)
            figure(5); clf 
            
            subplot(2,2,[1,3]) % v
            hist(expVy,0:bin1:max(expVy));
                    
            set(gca,'FontSize',14,'FontName','Times')
            title(['exp',exp]);
            xlabel('\itv_k \rm(m/s)','FontSize',16,'FontName','Times');
            xlim([0,max(expVy)])
            
            subplot(2,2,[2,4])
            meanExpTke = nanmean(expTke);
            hist(expTke,0:bin2:max(expTke));
            
            set(gca,'FontSize',14,'FontName','Times')
            title(['(\itT_p \rm= ',tpstr,',  \itH_s \rm=',hsstr,')']);
            
            % Put the text 
            tempo = numel(find((expTke<bin2)==1));
            text(max(expTke)/6,tempo/2,['TKE = ',num2str(meanExpTke),' (m^2/s^2)'],'FontSize',10,'FontName','Times');
            xlabel('\it0.5v_kv_k \rm(m^2/s^2)','FontSize',16,'FontName','Times');
            xlim([0,max(expTke)])

            print([expTkeTitle,fpsStr,'fps',nbFStr,'f_',dtStr,'dt_',aveStr,'ave_',exp,'.png'],'-dpng');
                        
            
            figure(6); clf 
            
            subplot(2,2,[1,3]) % v
            hist(expVyDt,0:bin1:max(expVyDt));
                    
            set(gca,'FontSize',16,'FontName','Times')
            title(['exp',exp]);
            xlabel('\itv_k \rm(m/s)','FontSize',16,'FontName','Times');
            xlim([0,max(expVyDt)])
                    
            
            subplot(2,2,[2,4])
            meanExpTkeDt = nanmean(expTkeDt);
            hist(expTkeDt,0:bin2:max(expTkeDt));
            
            set(gca,'FontSize',16,'FontName','Times')
            title(['(\itT_p \rm= ',tpstr,',  \itH_s \rm=',hsstr,')']);
            
            % Put the text 
            tempo = numel(find((expTkeDt<bin2)==1));
            text(max(expTkeDt)/6,tempo/2,['TKE = ',num2str(meanExpTkeDt),' (m^2/s^2)'],'FontSize',10,'FontName','Times');
            xlabel('\it0.5v_kv_k \rm(m^2/s^2)','FontSize',16,'FontName','Times');
            xlim([0,max(expTkeDt)])

            print([expTkeDtTitle,fpsStr,'fps',nbFStr,'f_',dtStr,'dt_',aveStr,'ave_',exp,'.png'],'-dpng');
                        
        end
        
        
    end
    
end
end