Commit c3efb040d9665b39b958c3a2073fd5e8561392d1

Authored by Marie-Pier Marquis
1 parent 0a5994a4
Exists in master

Ajout de fonction pour reconnaitre les floes à partir de cercle. Reconnait plus …

…facilement les floes, par exmple pour le 39% de concentration.
r_cam_filter.m
... ... @@ -25,13 +25,13 @@ function [rf , bf , gf , yf] = r_cam_filter(camNumber , filter)
25 25 % Subfunctions: none
26 26 % MAT-files required: none
27 27 %
28   -% See also: R_ISOLATE, R_RECON
  28 +% See also: R_ISOLATE, R_RECON, R_FILTDESIGN
29 29  
30 30 % Authors: Marie-Pier Marquis, Dany Dumont
31 31 % UQAR/ISMER
32 32 % email: dany_dumont@uqar.ca
33 33 % Website: http://www.ismer.ca/dumont-dany
34   -% June 2014; Last revision:
  34 +% June 2014; Last revision: October 2014
35 35  
36 36  
37 37 %% Initialize the color filter
... ... @@ -41,6 +41,8 @@ gf.init = false;
41 41 bf.init = false;
42 42 yf.init = false;
43 43  
  44 +% Parameters are choosed after the analyse of the different filters applied
  45 +% to the image. The fonction r_filtdesign helps to choose de parameters.
44 46 if nb == 80
45 47 if camNumber ==1
46 48  
... ...
r_chose_ht.m renamed to r_choose_ht.m
1   -function [h,t] = r_chose_ht(hs,tp)
2   -% R_FIGS - Produces some figures.
  1 +function [h,t] = r_choose_ht(hs,tp)
  2 +% R_CHOOSE_HT - Chooses a number respectively from 1 to 3 and 1 to 10 for
  3 +% the wave height and the time period.
3 4 %
4   -% Syntax: r_figs_v
  5 +% Syntax: [h,t] = r_choose_ht(hs,tp)
5 6 %
  7 +% Inputs:
  8 +% hs - The wave height
  9 +% tp - The time period
  10 +% Outputs:
  11 +% h - Number from 1 to 5
  12 +% t - Number from 1 tp 10
6 13 %
7 14 % Example:
8   -% r_figs_v
  15 +% [h, t] = r_choose_ht(2, 20)
  16 +% h = 1 and t = 10
9 17 %
10 18 % Other m-files required: none
11 19 % Subfunctions: none
12   -% MAT-files required: data_expNumber_camNumber_rowNumber.mat (produced by
13   -% R_RECON)
14   -% figs_v_data_5f_expNumber_camNumer_$rowNumber.mat (produced
15   -% by R_DATA_V)
16   -% list.mat
  20 +% MAT-files required: none
17 21 %
18   -% See also: R_RECON, R_ISOLATE, R_DATA_V
  22 +% See also:
19 23 %
20 24 % Author: Marie-Pier Marquis, Dany Dumont
21 25 % UQAR/ISMER
... ...
r_create_floe.m
1 1 function [floe] = r_create_floe(nFrames,nObjects,xpos,ypos,c,a,s,camNumber)
2   -% R_DATA - Creates the variable ''floe'' that contains the x-position of
  2 +% R_CREATE_FLOE - Creates the variable ''floe'' that contains the x-position of
3 3 % the floe, its y-position, its shape, its aera and its color.
4 4 %
5 5 % Syntax:
6 6 % [floe] = r_create_floe(nFrames,nObjects,xpos,ypos,c,a,s,camNumber)
7 7 %
  8 +% Inputs:
  9 +% nFrame - The number of frame
  10 +% nObjects - The number of object
  11 +% xpos - The x-position
  12 +% ypos - The y-position
  13 +% c - The color of the object
  14 +% a - The area of the object
  15 +% s - The shape of the object
  16 +% camNumber - The camera number
8 17 %
9 18 % Example:
10   -% [floe] = r_create_floe(nFrames,nObjects,xpos,ypos,c,a,s,camNumber)
  19 +% [floe] = r_create_floe(250,5,2,450,c,a,s,4)
11 20 %
12 21 % Other m-files required: none
13 22 % Subfunctions: none
14   -% MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
  23 +% MAT-files required: none
15 24 %
16   -% See also: R_RECON, R_DATA_POS
  25 +% See also: r_data_pos
17 26 %
18 27 % Author: Marie-Pier Marquis, Dany Dumont
19 28 % UQAR/ISMER
20 29 % email: dany_dumont@uqar.ca
21 30 % Website: http://www.ismer.ca/dumont-dany
22   -% July 2014
  31 +% July 2014 Last revision : October 2014
23 32 % ________________________________________________________________________
24 33 %%
25 34 % Sort data by position along the y-axis
... ...
r_data.m deleted
... ... @@ -1,316 +0,0 @@
1   -function r_data_pos
2   -% R_DATA - Produces data for r_figs and r_figs_summary.
3   -%
4   -% Syntax: r_data
5   -%
6   -%
7   -% Example:
8   -% r_data
9   -%
10   -% Other m-files required: none
11   -% Subfunctions: none
12   -% MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
13   -% list1.mat
14   -%
15   -% See also: R_RECON, R_LIST, R_FIGS, R_FIGS_SUMMARY
16   -%
17   -% Author: Marie-Pier Marquis, Dany Dumont
18   -% UQAR/ISMER
19   -% email: dany_dumont@uqar.ca
20   -% Website: http://www.ismer.ca/dumont-dany
21   -% July 2014
22   -% ________________________________________________________________________
23   -%%
24   -rootdir = '/Users/marie-pier/Desktop/MP/images/multicam';
25   -%rootdir = '/Volumes/hd2/bgo_first/images/multicam';
26   -%rootdir = '/Volumes/DyData/data/bgo_first/images/multicam';
27   -listfile = [rootdir,'/list1.mat'];
28   -sumdir = [rootdir,'/summary_results'];
29   -load(listfile)
30   -
31   -if ~exist(sumdir,'dir')
32   - mkdir(sumdir)
33   -end
34   -
35   -e1 = 201307241037;
36   -e2 = 201307241056;
37   -
38   -nbf = 80; % floes number
39   -type = 1; % 1 if regular wave, 0 if irregular waves
40   -j = 0; % count the number of experiments
41   -Std_hs = nan.*ones(4,10,13,16);
42   -dy_hs = nan.*ones(4,10,13,16);
43   -
44   -
45   -for i = 1 : length(list1.exp)
46   - if list1.nf(i)==nbf && list1.wt(i)==type && list1.exp(i)~=e1 && list1.exp(i)~=e2
47   -
48   - exp = num2str(list1.exp(i));
49   - j = j + 1;
50   - tp = list1.tp(i);
51   - tpms = tp./10; % Wave period at model scale
52   - hs = list1.hs(i);
53   - count = 0; % count the number of rows
54   -
55   - for c = 1:4
56   - cam = num2str(c);
57   -
58   - for r = 1:4
59   - count = count + 1;
60   - row = num2str(r);
61   - expdir = [rootdir,'/',exp,'_multicam'];
62   - datafile = [expdir,'/data_',exp,'_',cam,'_',row,'.mat'];
63   - resdir = [expdir,'/results'];
64   - cd(expdir)
65   -
66   - if ~exist(resdir,'dir')
67   - mkdir(resdir)
68   - end
69   -
70   - if exist(datafile,'file')
71   - load(datafile)
72   - %disp(j);
73   -
74   -
75   -
76   -
77   -
78   -
79   -
80   - % Sort data by position along the y-axis
81   -
82   - nFrames = size(xpos,1);
83   - nObjects = size(xpos,2);
84   - floe = nan.*ones(nObjects,nFrames,5);
85   - for n = 1:nFrames
86   - [sy,u] = sort(ypos(n,:),'descend');
87   - if nObjects == 5
88   - for k = 1:nObjects
89   - if k == 1
90   - u1 = u(k);
91   - %u = find(ypos(n,:) > 500); %#ok<*NODEF>
92   - if ~isnan(sy(k))
93   - floe(k,n,1) = xpos(n,u1);
94   - floe(k,n,2) = ypos(n,u1);
95   - floe(k,n,3) = c(n,u1);
96   - floe(k,n,4) = s(n,u1);
97   - floe(k,n,5) = a(n,u1);
98   - end
99   -
100   - elseif k == 2
101   - u2 = u(k);
102   - %u = find(ypos(n,:) > 390 & ypos(n,:) < 500);
103   - if ~isnan(sy(k))
104   - floe(k,n,1) = xpos(n,u2);
105   - floe(k,n,2) = ypos(n,u2);
106   - floe(k,n,3) = c(n,u2);
107   - floe(k,n,4) = s(n,u2);
108   - floe(k,n,5) = a(n,u2);
109   - end
110   -
111   - elseif k == 3
112   - u3 = u(k);
113   - %u = find(ypos(n,:) > 250 & ypos(n,:) < 390);
114   - if ~isnan(sy(k))
115   - floe(k,n,1) = xpos(n,u3);
116   - floe(k,n,2) = ypos(n,u3);
117   - floe(k,n,3) = c(n,u3);
118   - floe(k,n,4) = s(n,u3);
119   - floe(k,n,5) = a(n,u3);
120   - end
121   -
122   - elseif k == 4
123   - u4 = u(k);
124   - %u = find(ypos(n,:) > 150 & ypos(n,:) < 250);
125   - if ~isnan(sy(k))
126   - floe(k,n,1) = xpos(n,u4);
127   - floe(k,n,2) = ypos(n,u4);
128   - floe(k,n,3) = c(n,u4);
129   - floe(k,n,4) = s(n,u4);
130   - floe(k,n,5) = a(n,u4);
131   - end
132   -
133   - elseif k == 5
134   - u5 = u(k);
135   - %u = find(ypos(n,:) < 150);
136   - if ~isnan(sy(k))
137   - floe(k,n,1) = xpos(n,u5);
138   - floe(k,n,2) = ypos(n,u5);
139   - floe(k,n,3) = c(n,u5);
140   - floe(k,n,4) = s(n,u5);
141   - floe(k,n,5) = a(n,u5);
142   - end
143   - end
144   - end
145   -
146   - elseif nObjects == 3
147   - for k = 1:nObjects
148   - if k == 1
149   - u1 = u(k);
150   - %u = find(ypos(n,:) > 500);
151   - if ~isnan(sy(k))
152   - floe(k,n,1) = xpos(n,u1);
153   - floe(k,n,2) = ypos(n,u1);
154   - floe(k,n,3) = c(n,u1);
155   - floe(k,n,4) = s(n,u1);
156   - floe(k,n,5) = a(n,u1);
157   - end
158   -
159   - elseif k == 2
160   - u2 = u(k);
161   - %u = find(ypos(n,:) > 250 & ypos(n,:) < 390);
162   - if ~isnan(sy(k))
163   - floe(k,n,1) = xpos(n,u2);
164   - floe(k,n,2) = ypos(n,u2);
165   - floe(k,n,3) = c(n,u2);
166   - floe(k,n,4) = s(n,u2);
167   - floe(k,n,5) = a(n,u2);
168   - end
169   -
170   - elseif k == 3
171   - u3 = u(k);
172   - %u = find(ypos(n,:) < 150);
173   - if ~isnan(sy(k))
174   - floe(k,n,1) = xpos(n,u3);
175   - floe(k,n,2) = ypos(n,u3);
176   - floe(k,n,3) = c(n,u3);
177   - floe(k,n,4) = s(n,u3);
178   - floe(k,n,5) = a(n,u3);
179   - end
180   - end
181   - end
182   -
183   - else
184   - disp(' Error');
185   - return
186   - end
187   - end
188   -
189   -
190   -
191   - % Some unit conversion
192   - % From pixel length to meters
193   - if c == 1
194   - floe(:,:,1) = 0.01.*floe(:,:,1) - 0.1;
195   - elseif c == 2
196   - floe(:,:,1) = 0.01.*floe(:,:,1) + 3.9;
197   - elseif c == 3
198   - floe(:,:,1) = 0.01.*floe(:,:,1) + 7.9;
199   - elseif c == 4
200   - floe(:,:,1) = 0.01.*floe(:,:,1) + 11.9;
201   - end
202   - floe(:,:,2) = -0.01.*floe(:,:,2) + 1.0;
203   -
204   - % From number of pixel area to meter square
205   - floe(:,:,5) = 0.0001.*floe(:,:,5);
206   -
207   -
208   -
209   -
210   -
211   -
212   - % For Figure 1 - Mean displacement of floes in the wave
213   - % propagation direction
214   - % Retrieve the mean start position of all floes by
215   - % averaging over the first 10 seconds (from 40 to 50s)
216   -
217   - iPos = nan.*ones(nObjects,1);
218   - fPos = nan.*ones(nObjects,1);
219   - iStdPos = nan.*ones(nObjects,1);
220   - fStdPos = nan.*ones(nObjects,1);
221   -
222   - for k = 1:nObjects
223   - iPos(k) = nanmean(squeeze(floe(k,time < 50,2)));
224   - iStdPos(k) = nanstd(squeeze(floe(k,time < 50,2)));
225   - %fPos(k) = nanmean(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));
226   - %fStdPos(k) = nanstd(squeeze(floe(k,time >= (60 + 5.*tpms) & time <= (60+15.*tpms),2)));
227   - fPos(k) = nanmean(squeeze(floe(k,time >= (75 + 5.*tpms) & time <= (75+15.*tpms),2)));
228   - fStdPos(k) = nanstd(squeeze(floe(k,time >= (75 + 5.*tpms) & time <= (75+15.*tpms),2)));
229   - end
230   -
231   - delta = fPos - iPos;
232   - meanDisp = mean(delta);
233   - deltaStd = (iStdPos)+ (fStdPos);
234   - meanStd = mean(deltaStd);
235   -
236   -
237   -
238   - % Saving data for each experiment and each row
239   -
240   - disp(' Saving data ... ');
241   - save([resdir,'/figs_data_5f_',exp,'_',cam,'_',row],...
242   - 'floe','delta','deltaStd','meanDisp','meanStd',...
243   - 'iStdPos','fStdPos','iPos','fPos','-v7.3');
244   - disp(' Done! ');
245   -
246   -
247   -
248   -
249   - % Sort data by wave heigt, wave period and main
250   - % displacement.
251   -
252   -
253   - if hs == 2
254   - h = 1;
255   - elseif hs == 4
256   - h = 2;
257   - elseif hs == 8
258   - h = 3;
259   - elseif hs == 10
260   - h = 4;
261   - end
262   -
263   -
264   - if tp == 6.5
265   - t = 1;
266   - elseif tp == 8.0
267   - t = 2;
268   - elseif tp == 9.5
269   - t = 3;
270   - elseif tp == 11.0
271   - t = 4;
272   - elseif tp == 12.5
273   - t = 5;
274   - elseif tp == 14.0
275   - t = 6;
276   - elseif tp == 15.5
277   - t = 7;
278   - elseif tp == 17.0
279   - t = 8;
280   - elseif tp == 18.5
281   - t = 9;
282   - elseif tp == 20.0
283   - t = 10;
284   - end
285   -
286   -
287   - Std_hs(h,t,j,count) = meanStd;
288   - dy_hs(h,t,j,count) = meanDisp;
289   -
290   -
291   -
292   -
293   -
294   - end
295   -
296   -
297   -
298   - end
299   - end
300   - end
301   -end
302   -
303   -% Fait un vecteur pour pouvoir faire le graphique sommaire
304   -s_Std_hs = nansum(Std_hs(:,:,:,:),3);
305   -s_dy_hs = nansum(dy_hs(:,:,:,:),3);
306   -%% Saving summary data
307   -
308   -disp(' Saving summary data ... ');
309   -
310   -save([sumdir,'/figs_summary_80f'],'Std_hs','dy_hs','s_Std_hs',...
311   - 's_dy_hs','fPos','-v7.3');
312   -disp(' Done! ');
313   -
314   -end
315   -
316   -
r_data_pos.m
1   -function r_data_pos
2   -% R_DATA - Produces data for r_figs_pos and r_figs_summary_pos.
  1 +function [StdHs, dyHs] = r_data_pos(expNumber, camNumber, rowNumber,...
  2 + StdHs, dyHs , hs, tp, tpms, rowCounter)
  3 +% R_DATA - Produces data for r_figs_pos tand r_figs_summary_pos.
3 4 %
4 5 % Syntax: r_data_pos
5 6 %
... ... @@ -7,151 +8,109 @@ function r_data_pos
7 8 % Example:
8 9 % r_data_pos
9 10 %
10   -% Other m-files required: none
  11 +% Other m-files required: R_CREATE_FLOE, R_FILL_DATE, R_CHOOSE_HT
  12 +% Image Processus Toolbox
11 13 % Subfunctions: none
12 14 % MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
13   -% list1.mat
  15 +% list1.mat
14 16 %
15   -% See also: R_RECON, R_LIST, R_FIGS, R_FIGS_SUMMARY
  17 +% See also: R_RECON, R_LIST, R_FIGS_POS, R_FIGS_SUMMARY_POS
16 18 %
17 19 % Author: Marie-Pier Marquis, Dany Dumont
18 20 % UQAR/ISMER
19 21 % email: dany_dumont@uqar.ca
20 22 % Website: http://www.ismer.ca/dumont-dany
21   -% July 2014
  23 +% July 2014, Last revision: October 2014
22 24 % ________________________________________________________________________
23   -%%
24   -
  25 +%% Open files
25 26 fps = 5;
26   -int1 = 75;
27   -int2 = 75;
28   -int3 = 5;
29   -int4 = 30;
  27 +int1 = 60; % Mean begins at int1 + int3*tpms
  28 +int2 = 60; % Mean ends at int2 + int4*tpms
  29 +int3 = 5; % Mean begins at int1 + int3*tpms
  30 +int4 = 15; % Mean ends at int2 + int4*tpms
30 31 nbF = 80;
31   -ave = 3; % 1 : mean 60+5*tpms to 60+15*tpms
32   - % 2 : mean 75+5*tpms to 75+75*tpms
33   - % 3 : mean 75+5*tpms to 75+30*tpms
  32 +ave = 1; % 1 : mean 60+5*tpms to 60+15*tpms
  33 +% 2 : mean 75+5*tpms to 75+75*tpms
  34 +% 3 : mean 75+5*tpms to 75+30*tpms
34 35 fpsStr = num2str(fps);
35 36 nbFStr = num2str(nbF);
36 37 aveStr = num2str(ave);
  38 +cam = num2str(camNumber);
  39 +exp = num2str(expNumber);
  40 +row = num2str(rowNumber);
  41 +rootdir = ['/MP_oceanographie/MP/images/multicam_',nbFStr,'f'];
  42 +expdir = [rootdir,'/',exp,'_multicam'];
  43 +datafile = [expdir,'/data_',exp,'_',cam,'_',row,'.mat'];
  44 +resdir = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',aveStr,'_results'];
  45 +cd(expdir)
37 46  
38   -rootdir = ['/MP_oceanographie/MP/images/multicam_',nbFStr,'f'];
39   -listfile = [rootdir,'/list1.mat'];
40   -sumdir = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',aveStr,'_summary_results'];
41   -load(listfile)
42   -
43   -if ~exist(sumdir,'dir')
44   - mkdir(sumdir)
  47 +if ~exist(resdir,'dir')
  48 + mkdir(resdir)
45 49 end
46 50  
47   -e1 = 201307241037; % same experiment as 201307241018
48   -e2 = 201307241056; % same experiment as 201307241018
49   -% e3 = 201307231605;
50   -e4 = 201307241121;
51   -e5 = 201307241158;
52   -nbf = 80; % floes number
53   -type = 1; % 1 if regular wave, 0 if irregular waves
54   -Std_hs = nan.*ones(5,10,16);
55   -dy_hs = nan.*ones(5,10,16);
56   -
57   -for i = 1 : length(list1.exp)
58   - if list1.nf(i)==nbf && list1.wt(i)==type && list1.exp(i)~=e1 &&...
59   - list1.exp(i)~=e2
60   -
61   - exp = num2str(list1.exp(i));
62   - tp = list1.tp(i);
63   - tpms = tp./10; % Wave period at model scale
64   - hs = list1.hs(i);
65   - row_c = 0; % Count the number of rows
66   -
67   - for ca = 1:4
68   - cam = num2str(ca);
69   - camNumber = ca;
70   -
71   - for r = 1:4
72   - row_c = row_c + 1;
73   - row = num2str(r);
74   - expdir = [rootdir,'/',exp,'_multicam'];
75   - datafile = [expdir,'/data_',exp,'_',cam,'_',row,'.mat'];
76   - %datafile = [expdir,'/data_25_',exp,'_',cam,'_',row,'.mat'];
77   - resdir = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',aveStr,'_results'];
78   - cd(expdir)
79   -
80   - if ~exist(resdir,'dir')
81   - mkdir(resdir)
82   - end
83   -
84   - if exist(datafile,'file') && row_c ~= 7 && row_c ~= 10
85   - load(datafile)
86   -
87   - % Sort data by position along the y-axis
88   - nFrames = size(xpos,1);
89   - nObjects = size(xpos,2);
90   - floe_d = nan.*ones(nObjects,nFrames); % detrend data
91   - floe_f = nan.*ones(nObjects,nFrames); % filtered data
92   - [floe] = r_create_floe(nFrames,nObjects,xpos,ypos,c,a,s,camNumber);
93   -
94   - floe_pos = nan.*ones(5,size(ypos,1));
95   - h = fdesign.lowpass('Fp,Fst,Ap,Ast',2*((1/tpms)+0.1)/fps,2*((1/tpms)+0.2)/fps,1,60);
96   - d = design(h,'equiripple');
97   -
98   - for k = 1:nObjects
99   - floe_pos(k,:) = r_fill_data( floe(k,:,2) );
100   - floe_d(k,:) = detrend(floe_pos(k,:),'constant');
101   - floe_f(k,:) = filtfilt(d.Numerator,1,floe_d(k,:));
102   - end
103   -
104   -
105   - % Mean displacement of floes in the wave propagation direction
106   - % Retrieve the mean start position of all floes by
107   - % averaging over the first 10 seconds (from 40 to 50s)
  51 +load(datafile)
  52 +%% Sort data by position along the y-axis
  53 +nFrames = size(xpos,1);
  54 +nObjects = size(xpos,2);
  55 +% Use r_create_floe
  56 +[floe] = r_create_floe(nFrames,nObjects,xpos,ypos,...
  57 + c,a,s,camNumber);
  58 +% Initialization
  59 +floePos = nan.*ones(5,size(ypos,1));
  60 +floeD = nan.*ones(nObjects,nFrames); % detrend data
  61 +floeF = nan.*ones(nObjects,nFrames); % filtered data
  62 +% Filter parameters as a function of the wave period
  63 +h = fdesign.lowpass('Fp,Fst,Ap,Ast',...
  64 + 2*((1/tpms)+0.1)/fps,2*((1/tpms)+0.2)/fps,1,60);
  65 +d = design(h,'equiripple');
  66 +% Filtering data
  67 +for k = 1:nObjects
  68 + floePos(k,:) = r_fill_data( floe(k,:,2) );
  69 + floeD(k,:) = detrend(floePos(k,:),'constant');
  70 + floeF(k,:) = filtfilt(d.Numerator,1,floeD(k,:));
  71 +end
  72 +%% Mean displacement of floes in the wave propagation
  73 +% direction. Retrieve the mean start position of all
  74 +% floes by averaging over the first 10 seconds.
  75 +% (from 40 to 50s)
108 76  
109   - iPos = nan.*ones(nObjects,1);
110   - fPos = nan.*ones(nObjects,1);
111   - iStdPos = nan.*ones(nObjects,1);
112   - fStdPos = nan.*ones(nObjects,1);
  77 +iPos = nan.*ones(nObjects,1);
  78 +fPos = nan.*ones(nObjects,1);
  79 +iStdPos = nan.*ones(nObjects,1);
  80 +fStdPos = nan.*ones(nObjects,1);
113 81  
114   - for k = 1:nObjects
115   - iPos(k) = nanmean(squeeze(floe_f(k,time < 50)));
116   - iStdPos(k) = nanstd(squeeze(floe_f(k,time < 50)));
117   - fPos(k) = nanmean(squeeze(floe_f(k,time >= (int1 + int3.*tpms) & time <= (int2+int4.*tpms))));
118   - fStdPos(k) = nanstd(squeeze(floe_f(k,time >= (int1 + int3.*tpms) & time <= (int2+int4.*tpms))));
119   - end
120   -
121   - delta = fPos - iPos;
122   - meanDisp = mean(delta);
123   - deltaStd = (iStdPos)+ (fStdPos);
124   - meanStd = mean(deltaStd);
125   -
126   - % Saving data for each experiment and each row
127   - disp(' Saving data ... ');
128   - save([resdir,'/figs_data_',fpsStr,'fps_',nbFStr,'f_',...
129   - aveStr,'_',exp,'_',cam,'_',row],'floe','delta',...
130   - 'deltaStd','meanDisp','meanStd','iStdPos',...
131   - 'fStdPos','iPos','fPos','nObjects','time',...
132   - 'nFrames','floe_f','-v7.3');
133   - disp(' Done! ');
134   -
135   - % Sort data by wave heigt, wave period and main
136   - % displacement.
137   -
138   - [h,t] = r_chose_ht(hs,tp);
139   -
140   - Std_hs(h,t,row_c) = meanStd;
141   - dy_hs(h,t,row_c) = meanDisp;
142   -
143   - end
144   - end
145   - end
146   - end
  82 +for k = 1:nObjects
  83 + iPos(k) = nanmean(squeeze(floeF(k,time < 50)));
  84 + iStdPos(k) = nanstd(squeeze(floeF(k,time < 50)));
  85 + fPos(k) = nanmean(squeeze(floeF(k,time >=...
  86 + (int1 + int3.*tpms) & time <= (int2+int4.*tpms))));
  87 + fStdPos(k) = nanstd(squeeze(floeF(k,time >=...
  88 + (int1 + int3.*tpms) & time <= (int2+int4.*tpms))));
147 89 end
148 90  
149   -%% Saving summary data
150   -disp(' Saving summary data ... ');
151   -save([sumdir,'/figs_summary_',fpsStr,'fps_',nbFStr,'f_',aveStr],...
152   - 'Std_hs','dy_hs','fPos','-v7.3');
  91 +delta = fPos - iPos;
  92 +meanDisp = mean(delta);
  93 +deltaStd = (iStdPos)+ (fStdPos);
  94 +meanStd = mean(deltaStd);
  95 +
  96 +%% Saving data for each experiment and each row
  97 +disp(' Saving data ... ');
  98 +save([resdir,'/figs_data_',fpsStr,'fps_',nbFStr,'f_',...
  99 + aveStr,'_',exp,'_',cam,'_',row],'floeF','delta',...
  100 + 'deltaStd','meanDisp','meanStd','iStdPos',...
  101 + 'fStdPos','iPos','fPos','nObjects','time',...
  102 + 'nFrames','-v7.3');
153 103 disp(' Done! ');
154   -
  104 +
  105 +%% Sort data by wave heigt, wave period and main
  106 +% displacement.
  107 +
  108 +[h,t] = r_choose_ht(hs,tp);
  109 +
  110 +StdHs(h,t,rowCounter) = meanStd;
  111 +dyHs(h,t,rowCounter) = meanDisp;
  112 +
  113 +
155 114 end
156   -
  115 +
157 116  
... ...
r_data_pos_all.m 0 → 100644
... ... @@ -0,0 +1,90 @@
  1 +function r_data_pos_all
  2 +% R_DATA - Runs R_DATA_POS in batch mode and saves summary data.
  3 +%
  4 +% Syntax: r_data_pos_al
  5 +%
  6 +%
  7 +% Example:
  8 +% r_data_pos_al
  9 +%
  10 +% Other m-files required: R_CREATE_FLOE, R_FILL_DATE, R_CHOOSE_HT
  11 +% Image Processus Toolbox
  12 +% Subfunctions: none
  13 +% MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
  14 +% list1.mat
  15 +%
  16 +% See also: R_RECON, R_LIST, R_FIGS_POS, R_FIGS_SUMMARY_POS
  17 +%
  18 +% Author: Marie-Pier Marquis, Dany Dumont
  19 +% UQAR/ISMER
  20 +% email: dany_dumont@uqar.ca
  21 +% Website: http://www.ismer.ca/dumont-dany
  22 +% July 2014, Last revision: October 2014
  23 +% ________________________________________________________________________
  24 +%% Don't forget to change parameters into r_data_pos
  25 +fps = 5;
  26 +nbF = 80;
  27 +type = 1; % 1 if regular wave, 0 if irregular waves
  28 +e1 = 201307241037; % same experiment as 201307241018
  29 +e2 = 201307241056; % same experiment as 201307241018
  30 +ave = 1; % 1 : mean 60+5*tpms to 60+15*tpms
  31 + % 2 : mean 75+5*tpms to 75+75*tpms
  32 + % 3 : mean 75+5*tpms to 75+30*tpms
  33 +fpsStr = num2str(fps);
  34 +nbFStr = num2str(nbF);
  35 +aveStr = num2str(ave);
  36 +
  37 +%% Open files
  38 +rootdir = ['/MP_oceanographie/MP/images/multicam_',nbFStr,'f'];
  39 +listfile = [rootdir,'/list1.mat'];
  40 +sumdir = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',aveStr,...
  41 + '_summary_results'];
  42 +load(listfile)
  43 +if ~exist(sumdir,'dir')
  44 + mkdir(sumdir)
  45 +end
  46 +
  47 +%% Initialization
  48 +StdHs = nan.*ones(5,10,16);
  49 +dyHs = nan.*ones(5,10,16);
  50 +
  51 +%% Different data, experiment by experiment.
  52 +for i = 1 : length(list1.exp)
  53 + if list1.nf(i)==nbF && list1.wt(i)==type && list1.exp(i)~=e1 &&...
  54 + list1.exp(i)~=e2
  55 + % Data from list1.
  56 + expNumber = list1.exp(i);
  57 + exp = num2str(expNumber);
  58 + tp = list1.tp(i);
  59 + tpms = tp./10; % Wave period at model scale
  60 + hs = list1.hs(i);
  61 +
  62 + % Count the number of rows
  63 + rowCounter = 0;
  64 + for ca = 1:4
  65 + cam = num2str(ca);
  66 + for r = 1:4
  67 + rowCounter = rowCounter + 1;
  68 + row = num2str(r);
  69 + expdir = [rootdir,'/',exp,'_multicam'];
  70 + datafile = [expdir,'/data_',exp,'_',cam,'_',row,'.mat'];
  71 + cd(expdir)
  72 + if(exist(datafile,'file'))
  73 + [StdHs, dyHs] = r_data_pos(expNumber, ca,r,StdHs,...
  74 + dyHs , hs, tp, tpms, rowCounter);
  75 +
  76 + end
  77 + end
  78 + end
  79 + end
  80 +end
  81 +
  82 +%% Saving summary data
  83 +disp(' Saving summary data ... ');
  84 +save([sumdir,'/figs_summary_',fpsStr,'fps_',nbFStr,'f_',aveStr],...
  85 + 'StdHs','dyHs','-v7.3');
  86 +disp(' Done! ');
  87 +
  88 +end
  89 +
  90 +
... ...
r_data_v.m
1 1 function r_data_v
2 2 % R_FIGS_DATA - Produces data for r_figs_v and r_figs_summary_v.
3 3 %
4   -% Syntax: r_data_v
  4 +% Syntax: R_DATA_V
5 5 %
6 6 %
7 7 % Example:
8 8 % r_data_v
9 9 %
10   -% Other m-files required: none
  10 +% Other m-files required: R_CHOOSE_HT
11 11 % Subfunctions: none
12   -% MAT-files required: data_$expNumber_$camNumber.mat (produced by R_RECON)
13   -% list1.mat
  12 +% MAT-files required: list1.mat
14 13 % figs_data_5f_$expNumber_$camNumber_$rowNumber.mat
15 14 %
16   -% See also: R_FIGS_V, R_FIGS_SUMMARY_V, R_LIST
  15 +% See also: R_FIGS_V, R_FIGS_SUMMARY_V
17 16 %
18 17 % Author: Marie-Pier Marquis, Dany Dumont
19 18 % UQAR/ISMER
20 19 % email: dany_dumont@uqar.ca
21 20 % Website: http://www.ismer.ca/dumont-dany
22   -% July 2014
  21 +% July 2014, Last revision: October 2014
23 22 % ______________________________________________________________________
24 23 %%
25 24 fps = 5;
26   -int1 = 50;
27   -int2 = 75;
28   -int3 = 5;
29   -int4 = 75;
  25 +int1 = 50;
  26 +int2 = 75;
  27 +int3 = 5;
  28 +int4 = 75; % Data between int1 + int3*tpms and int2 + int4*tpms
30 29 nbF = 80;
31 30 dt = 1; %data between 50+5*fps and 75+75*fps
32 31  
... ... @@ -39,52 +38,52 @@ nbf = 80; % floes number
39 38 type = 1; % 1 if regular wave, 0 if irregular waves
40 39 m = 2; % secon order speed
41 40  
  41 +%% Open files
42 42 rootdir = ['/MP_oceanographie/MP/images/multicam_',nbFStr,'f'];
43 43 listfile = [rootdir,'/list1.mat'];
44   -sumdir = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'_summary_results_v'];
  44 +sumdir = [rootdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
  45 + '_summary_results_v'];
45 46 load(listfile)
46   -
47 47 if ~exist(sumdir,'dir')
48 48 mkdir(sumdir)
49 49 end
50 50  
51   -std_h_tke_dt = nan.*ones(5,10,16);
52   -std_h_tke = nan.*ones(5,10,16);
53   -mean_h_tke = nan.*ones(5,10,16);
54   -mean_h_tke_dt = nan.*ones(5,10,16);
  51 +%% Initialization
  52 +stdTkeDt = nan.*ones(5,10,16);
  53 +stdTke = nan.*ones(5,10,16);
  54 +meanTke = nan.*ones(5,10,16);
  55 +meanTkeDt = nan.*ones(5,10,16);
55 56  
  57 +%% Create data file for each row of each experiment.
56 58 for i = 1 : length(list1.exp)
57 59 if list1.nf(i)==nbf && list1.wt(i)==type && list1.exp(i)~=e1 &&...
58   - list1.exp(i)~=e2
59   -
  60 + list1.exp(i)~=e2
  61 + % Data from list1.
60 62 exp = num2str(list1.exp(i));
61 63 tp = list1.tp(i);
62 64 hs = list1.hs(i);
63   - [h,t] = r_chose_ht(hs,tp); % hs and tp are listed from 0 to
  65 + [h,t] = r_choose_ht(hs,tp); % hs and tp are listed from 0 to
64 66 % 5 (for hs) and 0 to 10 (tp)
65 67 count_r = 0; % counter of rows
66   - exp_h_tke = nan;
67   - exp_h_vy = nan;
68   - exp_h_tke_dt = nan;
69   - exp_h_v_dt = nan;
  68 + % Initialization
  69 + expTke = nan;
  70 + expVy = nan;
  71 + expTkeDt = nan;
  72 + expVyDt = nan;
70 73  
71 74 for c = 1:4
72 75 cam = num2str(c);
73   -
74 76 for r = 1:4
75 77 row = num2str(r);
76 78 count_r = count_r + 1;
  79 +
77 80 expdir = [rootdir,'/',exp,'_multicam'];
78   - datafile = [expdir,'/data_',exp,'_',cam,'_',row,'.mat'];
79   - %datafile = [expdir,'/data_25_',exp,'_',cam,'_',row,'.mat'];
80   - resvdir = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'_results_v'];
  81 + resvdir = [expdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
  82 + '_results_v'];
81 83 resdir = [expdir,'/',fpsStr,'fps_',nbFStr,'f_1_results'];
82   - datafile2 = [resdir,'/figs_data_',fpsStr,'fps_',nbFStr,'f_1',...
83   - '_',exp,'_',cam,'_',row,'.mat'];
84   - cd(expdir)
85   - if exist(datafile,'file')
86   - load(datafile)
87   - end
  84 + datafile2 = [resdir,'/figs_data_',fpsStr,'fps_',nbFStr,...
  85 + 'f_1','_',exp,'_',cam,'_',row,'.mat'];
  86 + cd(expdir)
88 87 if ~exist(resvdir,'dir')
89 88 mkdir(resvdir)
90 89 end
... ... @@ -101,8 +100,8 @@ for i = 1 : length(list1.exp)
101 100 dt = 1/fps;
102 101 for k = 1:nObjects
103 102 for n = 1:nFrames -1
104   - vx(n, k) = abs((floe_f(k,n+1) - floe_f(k,n))/dt);
105   - vy(n, k) = abs((floe_f(k,n+1) - floe_f(k,n))/dt);
  103 + vx(n, k) = abs((floeF(k,n+1) - floeF(k,n))/dt);
  104 + vy(n, k) = abs((floeF(k,n+1) - floeF(k,n))/dt);
106 105 end
107 106 end
108 107  
... ... @@ -112,45 +111,45 @@ for i = 1 : length(list1.exp)
112 111 dtm = m*(dt);
113 112 for k = 1:nObjects
114 113 for n = 1:nFrames-m
115   - vxm(n,k) = abs((floe_f(k,n+m) - floe_f(k,n))/dtm);
116   - vym(n,k) = abs((floe_f(k,n+m) - floe_f(k,n))/dtm);
  114 + vxm(n,k) = abs((floeF(k,n+m) - floeF(k,n))/dtm);
  115 + vym(n,k) = abs((floeF(k,n+m) - floeF(k,n))/dtm);
117 116 end
118   - end
119   -
  117 + end
120 118  
121 119 %% histogram of velosity for each row of each experiment
122   - s_h_vy = nan.*ones(numel(vy),1);
  120 + rowVy = nan.*ones(numel(vy),1);
123 121 for p = 1 : numel(vy)
124   - s_h_vy(p) = vy(p);
  122 + rowVy(p) = vy(p);
125 123 end
126   - s_h_tke = 0.5.*(s_h_vy.^2);
127   - exp_h_vy = [exp_h_vy, s_h_vy'];
128   - exp_h_tke = [exp_h_tke, s_h_tke'];
  124 + rowTke = 0.5.*(rowVy.^2);
  125 + expVy = [expVy, rowVy'];
  126 + expTke = [expTke, rowTke'];
129 127  
130   - std_h_tke(h,t,count_r) = nanstd(s_h_tke);
131   - mean_h_tke(h,t,count_r) = nanmean(s_h_tke);
  128 + stdTke(h,t,count_r) = nanstd(rowTke);
  129 + meanTke(h,t,count_r) = nanmean(rowTke);
132 130 %% histogram of velosity for delta t
133 131  
134   - vy_dt = nan.*ones(numel(int1+int3*fps:int2+int4*fps),nObjects);
  132 + vy_dt = nan.*ones(numel(int1+int3*fps:int2+...
  133 + int4*fps),nObjects);
135 134 for k = 1:nObjects
136 135 vy_dt(:,k) = vy(int1+int3*fps:int2+int4*fps,k);
137 136 end
138   - s_h_v_dt = nan.*ones(numel(vy_dt),1);
  137 + rowVyDt = nan.*ones(numel(vy_dt),1);
139 138 for p = 1 : numel(vy_dt)
140   - s_h_v_dt(p) = vy_dt(p);
  139 + rowVyDt(p) = vy_dt(p);
141 140 end
142   - s_h_tke_dt = 0.5.*(s_h_v_dt.^2);
143   - exp_h_tke_dt = [exp_h_tke_dt, s_h_tke_dt'];
144   - exp_h_v_dt = [exp_h_v_dt, s_h_v_dt'];
  141 + rowTkeDt = 0.5.*(rowVyDt.^2);
  142 + expTkeDt = [expTkeDt, rowTkeDt'];
  143 + expVyDt = [expVyDt, rowVyDt'];
145 144  
146   - std_h_tke_dt(h,t,count_r) = nanstd(s_h_tke_dt);
147   - mean_h_tke_dt(h,t,count_r) = nanmean(s_h_tke_dt);
  145 + stdTkeDt(h,t,count_r) = nanstd(rowTkeDt);
  146 + meanTkeDt(h,t,count_r) = nanmean(rowTkeDt);
148 147 %% Saving data
149 148 disp(' Saving data ... ');
150   - save([resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'_figs_v_data_',...
151   - exp,'_',cam,'_',row],'vx','vy','vxm','vym',...
152   - 's_h_vy','s_h_tke','s_h_v_dt','s_h_tke_dt',...
153   - 'time','nObjects','-v7.3');
  149 + save([resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
  150 + '_figs_v_data_',exp,'_',cam,'_',row],...
  151 + 'vx','vy','vxm','vym','rowVy','rowTke',...
  152 + 'rowVyDt','rowTkeDt','time','nObjects','m','-v7.3');
154 153 disp(' Done! ');
155 154  
156 155 end
... ... @@ -160,8 +159,9 @@ for i = 1 : length(list1.exp)
160 159 %% Put together values by experiment
161 160  
162 161 disp(' Saving data ... ');
163   - save([resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'_figs_v_data_',exp],...
164   - 'exp_h_vy','exp_h_tke','exp_h_v_dt','exp_h_tke_dt','time',...
  162 + save([resvdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
  163 + '_figs_v_data_',exp],...
  164 + 'expVy','expTke','expTkeDt','expVyDt','time',...
165 165 'nObjects','-v7.3');
166 166 disp(' Done! ');
167 167  
... ... @@ -177,8 +177,9 @@ for i = 1 : length(list1.exp)
177 177 end
178 178  
179 179 disp(' Saving summary data ... ');
180   - save([sumdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,'_summary_results_v'],...
181   - 'mean_h_tke','mean_h_tke_dt','std_h_tke_dt',...
182   - 'std_h_tke','-v7.3');
  180 + save([sumdir,'/',fpsStr,'fps_',nbFStr,'f_',dtStr,...
  181 + '_summary_results_v'],...
  182 + 'meanTke','meanTkeDt','stdTkeDt',...
  183 + 'stdTke','-v7.3');
183 184 disp(' Done! ');
184 185 end
... ...
r_fft.m
1 1 function r_fft(expNumber,camNumber,rowNumber)
2   -% R_FFT - Produces figures to help where we have to fiter position data.
  2 +% R_FFT - Produces figures to see where we have to fiter position data.
3 3 %
4 4 % Syntax:
5 5 % r_fft(expNumber,camNumber,rowNumber)
6 6 %
  7 +% Inputs:
  8 +% expNumber - The experiment number