r_figs.m 7.61 KB
function r_figs(expNumber,camNumber, rowNumber)
% R_FIGS - Produces some figures.
%
% Syntax:  r_figs(expNumber,camNumber)
%
% Inputs:
%    expNumber - The experiment identifier
%    camNumber - The camera number
%    rowNumber - The row number
%
% Example:
%    r_figs(201307231525,1,4)
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: data_expNumber_camNumber_rowNumber.mat (produced by
%                              R_RECON)
%                     figs_data_expNumber_camNumer_$rowNumber.mat (produced
%                              by R_FIGS_DATA) 
%                     list.mat 
%
% See also: R_RECON, R_ISOLATE, R_FIGS_DATA
%
% Author: Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% 14 October 2013
% ______________________________________________________________________
%%
cstr = num2str(camNumber);
estr = num2str(expNumber);
rstr = num2str(rowNumber);

rootdir  = '/Users/marie-pier/Desktop/MP/images/multicam';
%rootdir = '/Volumes/hd2/bgo_first/images/multicam';
%rootdir = '/Volumes/DyData/data/bgo_first/images/multicam';
expdir   = [rootdir,'/',estr,'_multicam'];
datafile1 = [expdir,'/data_',estr,'_',cstr,'_',rstr]; % 5fps
%datafile = [expdir,'/data_','25_',estr,'_',cstr,'_',rstr];  % 25fps
%datafile2 = [ expdir,'/figs_data_',estr,'_',cstr,'_',rstr];
datafile2 = [ expdir,'/results','/figs_data_5f_',estr,'_',cstr,'_',rstr];
listfile = [rootdir,'/list.mat'];
resdir  = [expdir,'/results'];
cd(expdir)

load(datafile1)
load(datafile2)
load(listfile)

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

cd(resdir)

ii     = find(list.exp == expNumber);
tp     = list.tp(ii);
tpms   = tp./10;            % Wave period at model scale
hs     = list.hs(ii);
hsms   = hs./100;           % Wave height at model scale
tpstr  = num2str(tp);
hsstr  = num2str(hs);
nFrames  = size(xpos,1);
nObjects = size(xpos,2);


%% Figure 1 - Mean displacement of floes in the wave propagation direction
% Retrieve the mean start position of all floes
% by averaging over the first 10 seconds (from 40 to 50s)

meanDisp = str2num(meanDisp);
% deltaStd   = ((iStdPos).^2 + (fStdPos).^2).^(1/2);
deltaStd = (iStdPos + fStdPos);
meanStd  = mean(deltaStd);
figure(1); clf

hold on
errorbar(delta, deltaStd.*ones(nObjects,1),'ok','MarkerSize',8,'MarkerFaceColor','black');
plot(1:nObjects,zeros(nObjects,1),'-k');
plot(1:nObjects,meanDisp.*ones(nObjects,1),'--b');
plot(1:nObjects,meanDisp.*ones(nObjects,1)+ meanStd.*ones(nObjects,1),'--r');
plot(1:nObjects,meanDisp.*ones(nObjects,1)- meanStd.*ones(nObjects,1),'--r');
hold off


% hold on
% plot(1:nObjects,delta,'ok','MarkerSize',8,'MarkerFaceColor','black');
% plot(1:nObjects,zeros(nObjects,1),'-k');
% plot(1:nObjects,meanDisp.*ones(nObjects,1),'--r');
% hold off

set(gca,'FontSize',16,'FontName','Times','XTick',1:nObjects);
title(['exp',estr,'\_','cam',cstr,'\_','row',rstr,' (\itT_p \rm= ',tpstr,', \itH_s \rm=',hsstr,')']);
xlabel('Floe number','FontSize',16,'FontName','Times');
ylabel('\Delta\ity \rm(m)','FontSize',16,'FontName','Times');
xlim([0 nObjects+1])
ylim([-0.4 0.4])
text(1,0.3,['(\Delta\ity\rm)_{ave} = ',num2str(meanDisp),' m'],'FontSize',16,'FontName','Times');

print(['disp_',estr,'_',cstr,'_',rstr,'.png'],'-dpng'); % 5 fps
% print(['disp_','25_',estr,'_',cstr,'_',rstr,'.png'],'-dpng'); % 25 fps
%% Figure 2 - (x,y)
figure(2); clf
subplot(2,1,1)
hold on
for k = 1:nObjects
    plot(time,floe(k,:,1),'-k','LineWidth',1,'MarkerSize',7);
end
hold off

set(gca,'FontSize',16,'FontName','Times')
title(['exp',estr,'\_','cam',cstr,'\_','row',rstr,' (\itT_p \rm= ',tpstr,', \itH_s \rm=',hsstr,')']);
ylabel('\it{x}_{k} \rm(m)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)]) %#ok<*COLND>

subplot(2,1,2)
hold on
for k = 1:nObjects
    plot(time,floe(k,:,2),'-k','LineWidth',1,'MarkerSize',7);
    plot(40:50,iPos(k).*ones(11,1),'-r','LineWidth',2);
    plot((60+5*tpms):(60+15*tpms),fPos(k).*ones(size(fPos(k))),'-r','LineWidth',2);
    
end
hold off

set(gca,'FontSize',16,'FontName','Times')
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{y}_{k} \rm(m)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-5 1])

print(['xy_',estr,'_',cstr,'_',rstr,'.png'],'-dpng'); % 5 fps
% print(['xy_','25_',estr,'_',cstr,'_',rstr,'.png'],'-dpng'); % 25 fps

%% Figure 3 - (vx,vy)
fs = nan.*ones(nFrames , 1);
fs(1 : nFrames) = 5;   % 5fps
% fs(1 : nFrames) = 25;  %25 fps
 figure(3); clf
 
 subplot(2,1,1) %vy
 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(['exp',estr,'\_','cam',cstr,'\_','row',rstr,' (\itT_p \rm= ',tpstr,', \itH_s \rm=',hsstr,')']);
ylabel('\it{v}_{y} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.5 0.5])

subplot(2,1,2) %vx
hold on
for k = 1:nObjects
    plot(time, vx(:,k), '-k','LineWidth',1,'MarkerSize',7);
end 
hold off
 
set(gca,'FontSize',16,'FontName','Times')
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{v}_{x} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.2 0.2])

print(['v_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  % 5fps
% print(['v_','25_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  %25 fps

%% Histogram plot (vy)
figure(4); clf
hist(vy);






%% Figure 5 - (vx,vy) 2-order

vx2   = nan.*ones(nFrames, nObjects);
vy2   = nan.*ones(nFrames, nObjects);
dt2   = 2*(1./fs); 

for k = 1:nObjects
    for n = 1:nFrames-2
        vx2(n, k)   = (floe(k,n+2,1) - floe(k,n,1))./dt2(n);
        vy2(n, k)   = (floe(k,n+2,2) - floe(k,n,2))./dt2(n);
    end
end

figure(5); clf

subplot(2,1,1)
hold on
for k = 1:nObjects
    plot(time, vy2(:,k), '-k','LineWidth',1,'MarkerSize',7)
end 
hold off
 
set(gca,'FontSize',16,'FontName','Times')
title(['exp',estr,'\_','cam',cstr,'\_','row',rstr,' (\itT_p \rm= ',tpstr,', \itH_s \rm=',hsstr,')']);
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{v2}_{y} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.5 0.5])


subplot(2,1,2)
hold on
for k = 1:nObjects
    plot(time, vx2(:,k), '-k','LineWidth',1,'MarkerSize',7)
end 
hold off
 
set(gca,'FontSize',16,'FontName','Times')
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{v2}_{x} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.2 0.2])

print(['v2_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  %5 fps
% print(['v2_','25_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  %25 fps

%% Figure 6 - (vx,vy) m-order

m=4;
vxm   = nan.*ones(nFrames, nObjects);
vym   = nan.*ones(nFrames, nObjects);
dtm   = m*(1./fs);


for k = 1:nObjects
    for n = 1:nFrames-m
        vxm(n,k)   = (floe(k,n+m,1) - floe(k,n,1))./dtm(n);
        vym(n,k)   = (floe(k,n+m,2) - floe(k,n,2))./dtm(n);
    end
end


figure(6); clf

subplot(2,1,1)
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(['exp',estr,'\_','cam',cstr,'\_','row',rstr,' (\itT_p \rm= ',tpstr,', \itH_s \rm=',hsstr,')']);
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{vm}_{y} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.5 0.5])


subplot(2,1,2)
hold on
for k = 1:nObjects
    plot(time, vxm(:,k), '-k','LineWidth',1,'MarkerSize',7)
end 
hold off
 
set(gca,'FontSize',16,'FontName','Times')
xlabel('\itt \rm(s)','FontSize',16,'FontName','Times');
ylabel('\it{vm}_{x} \rm(m/s)','FontSize',16,'FontName','Times');
xlim([time(1) time(end)])
ylim([-0.2 0.2])

print(['vm_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  % 5fps
% print(['vm_','25_',estr,'_',cstr,'_',rstr,'.png'],'-dpng');  %25 fps