source: issm/trunk/test/IsmipHomResults/plotting_scripts/plot_exp_c.m@ 7938

Last change on this file since 7938 was 7938, checked in by Mathieu Morlighem, 14 years ago

removed all clear all close all and merged with ISSM's results

  • Property svn:executable set to *
File size: 13.1 KB
Line 
1%-----------------------------------------------------------------
2% Author: James Fishbaugh, Laura Perichon & Frank Pattyn
3% Date: 06/03/2008
4% Description: Reads experiment data and generates a plot
5% of a region of one standard deviation from the
6% mean for the different types of models used.
7%----------------------------------------------------------------
8
9%--------------------------------------------------------
10% THIS IS THE FILE IO SECTION WHERE THE DATA FILES ARE
11% READ AND VALUES STORED
12%--------------------------------------------------------
13
14%clear all; %ISSM->THIS LINE HAS BEEN CHANGED
15%close all; %ISSM->THIS LINE HAS BEEN CHANGED
16
17% The names of the folders (also prefix for filenames)
18dirs = {'aas1' 'aas2' 'ahu1' 'ahu2' 'bds1' 'cma1' 'cma2' 'dpo1' ...
19 'fpa1' 'fpa2' 'fsa1' 'jvj1' 'lpe1' 'mbr1' 'mmr1' 'mtk1' ...
20 'oga1' 'oso1' 'rhi1' 'rhi2' 'rhi3' 'rhi4' 'rhi5' 'spr1' ...
21 'ssu1' 'tpa1' 'yko1'};
22% dirs = {'dpo1' 'lpe1' 'rhi4' 'rhi5'};
23% The entries in this vector correspond to the vector of directory names
24% For example: aas2 is full stokes, ahu1 is not, ahu2 is not, etc
25% NOTE: THIS NEEDS TO BE CHECKED FOR ACCURACY
26fullStokesMask = [1 1 0 0 0 1 0 0 ...
27 0 1 0 1 0 0 1 0 ...
28 1 0 1 0 1 0 0 1 ...
29 1 0 1];
30% fullStokesMask = [0 0 0 0];
31% The location of the data (this is the path to the directory where all the
32% sub dirs lie)
33% NOTE: CHANGE THIS TO THE LOCATION OF YOUR DATA
34%location = 'C:\Documents and Settings\frankp\My Documents\work\ismip_all\ismip_mat\';
35location = [ issmtier() '/test/IsmipHomResults/ismip_mat/']; %ISSM->THIS LINE HAS BEEN CHANGED
36
37% The experiment we're interested in
38exp = 'c';
39
40% The file we're intersted in
41fileNames = {[exp '005'], [exp '010'], [exp '020'], ...
42 [exp '040'], [exp '080'], [exp '160']};
43
44% The desired vector for normalized x. Used for interpolation so every
45% data set has the same number of points.
46newX = linspace(0.0,1.0,250);
47newY = 1/4*ones(250,1)';
48
49% Will hold all the full stokes surface velocities
50fsVels = cell(length(fileNames), length(fullStokesMask(fullStokesMask == 1)));
51% Will hold all the non-full stokes surface velocities
52nfsVels = cell(length(fileNames), length(fullStokesMask(fullStokesMask == 0)));
53
54% Keeps track of the index we are currently on (this is necessary because
55% some submittors didn't do all experiments so we can't rely on the loop
56% counter to keep track of where we are at)
57fsIndex = 1;
58nfsIndex = 1;
59
60% Keeps track of the number of submittors for each domain length (this will
61% help us later on in allocating the correct size of data structures)
62fsSizes = zeros(1, length(fileNames));
63nfsSizes = zeros(1, length(fileNames));
64
65% Loop over all folders
66for i=1:length(dirs)
67
68 % Loop over all files
69 for j=1:length(fileNames)
70
71 % Create the full file path from the base path and current directory
72 fullFilePath = [location dirs(i) fileNames(j)];
73
74 % Open the current file for reading
75 load(cell2mat(fullFilePath));
76
77 % If that file exists
78 if (isnan(B(1,1))==0)
79
80 % Store the values
81 x = B(:,1);
82 y = B(:,2);
83 xvel = B(:,3);
84 yvel = B(:,4);
85 zvel = B(:,5);
86
87 % Make sure the data is normalized
88 x = x./max(x);
89
90 % Make sure the data is normalized
91 y = y./max(y);
92
93 x = inpaint_nans(x, 4);
94 y = inpaint_nans(y, 4);
95 xvel = inpaint_nans(xvel, 4);
96 yvel = inpaint_nans(yvel, 4);
97 zvel = inpaint_nans(zvel, 4);
98
99 % Calculates the magnitude of the surface velocity
100
101 surfVel = sqrt(xvel.^2 + yvel.^2);
102
103 % If the current data is from a full stokes
104 if (fullStokesMask(i) == 1)
105 %[i j fsIndex] %ISSM->THIS LINE HAS BEEN CHANGED
106 % Store the data in the full stokes structure
107 fsVels{j, fsIndex} = griddata(x, y, surfVel, newX, newY);
108 fsVels{j, fsIndex} = inpaint_nans(fsVels{j,fsIndex}, 4);
109 MaxVelfs(i,j)=max(fsVels{j,fsIndex});
110 MeanVelfs(i,j)=mean(fsVels{j,fsIndex});
111
112 % Keep track of the number of entries in the array
113 if (length(fsVels{j, fsIndex}) > 0)
114
115 % Increment the number who performed this experiment
116 fsSizes(j) = fsSizes(j) + 1;
117
118 end
119
120 % If we are on the last file we can increment the index
121 if (j == (length(fileNames)))
122
123 % Increment the full stokes index
124 fsIndex = fsIndex + 1;
125
126 end
127
128 % Else its non-full stokes
129 else
130 %[i j nfsIndex] %ISSM->THIS LINE HAS BEEN CHANGED
131 % Store the data in the non-full stokes structure
132 nfsVels{j, nfsIndex} = griddata(x, y, surfVel, newX, newY);
133 nfsVels{j, nfsIndex} = inpaint_nans(nfsVels{j, nfsIndex}, 4);
134 MaxVelnfs(i,j)=max(nfsVels{j,nfsIndex});
135 MeanVelnfs(i,j)=mean(nfsVels{j,nfsIndex});
136
137 % Keep track of the number of entries in the array
138 if (length(nfsVels{j, nfsIndex}) > 0)
139
140 % Increment the number who performed this experiment
141 nfsSizes(j) = nfsSizes(j) + 1;
142
143 end
144
145 % If we are on the last file we can increment the index
146 if (j == (length(fileNames)))
147
148 % Increment the non-full stokes index
149 nfsIndex = nfsIndex + 1;
150
151 end
152
153 end
154
155 % We are done with this file, we can close it
156% fclose('all');
157
158 end
159
160 end
161
162end
163
164%--------------------------------------------------------
165% THIS IS THE PROCESSING AND DISPLAY SECTION WHERE THE
166% MEAN AND STANDARD DEVIATION ARE CALCULATED AND PLOTTED
167%--------------------------------------------------------
168
169% The titles for the plots
170plotTitles = {'5km' '10km' '20km' '40km' '80km' '160km'};
171% The label for the x-axis
172xLabel = 'Normalized x';
173% The label for the y-axis
174yLabel = 'Velocity (m a^{-1})';
175
176% The font to use for the axis labels
177axisLabelFont = 'Arial'; %ISSM->THIS LINE HAS BEEN CHANGED
178% The font size to use for the axis labels
179axisLabelSize = 7;
180% The font weight to use for the axis labels
181axisFontWeight = 'normal';
182
183% The font size to use for tick mark labels
184axisTickLabelSize = 7;
185% The font weight to use for tick mark labels
186axisTickFontWeight = 'normal';
187
188% The font size to use for the title
189titleFontSize = 10;
190% The font weight to use for the title
191titleFontWeight = 'bold';
192
193% Loop over each domain length
194for i=1:length(fileNames)
195
196 % Allocate a matrix for full stokes surface velocities
197 fsCurDomainVels = zeros(250, fsSizes(i));
198 % Again we need a seperate index
199 fsIndex = 1;
200
201 % Allocate a matrix for non-full stokes surface velocities
202 nfsCurDomainVels = zeros(250, fsSizes(i));
203 % Again we need a seperate index
204 nfsIndex = 1;
205
206 % Loop over full stokes
207 for j=1:length(fullStokesMask(fullStokesMask == 1))
208
209 % If there are data at this entry
210 if (length(fsVels{i,j}) ~= 0)
211
212 % Add it to the matrix
213 fsCurDomainVels(:,fsIndex) = fsVels{i,j};
214
215 % Increment the index
216 fsIndex = fsIndex + 1;
217
218 end
219
220 end
221
222 % Loop over non-full stokes
223 for j=1:length(fullStokesMask(fullStokesMask == 0))
224
225 % If there are data at this entry
226 if (length(nfsVels{i,j}) ~= 0)
227
228 % Add it to the matrix
229 nfsCurDomainVels(:,nfsIndex) = nfsVels{i,j};
230
231 % Increment the index
232 nfsIndex = nfsIndex + 1;
233 end
234
235 end
236
237 % Calcuate the mean for each domain length (full stokes)
238 fsMeanVel = mean(fsCurDomainVels, 2)';
239 % Calculate the std deviation for each domain length (full stokes)
240 fsStdVel = std(fsCurDomainVels, 0, 2)';
241
242 % Calcuate the mean for each domain length (non-full stokes)
243 nfsMeanVel = mean(nfsCurDomainVels, 2)';
244 % Calculate the std deviation for each domain length (non-full stokes)
245 nfsStdVel = std(nfsCurDomainVels, 0, 2)';
246
247 % Tell MATLAB which subplot we are currently on
248 subplot(2, 3, i);
249
250 % The fill color (rgb) for full stokes
251 fsFillColor = [0.254 0.625 0.660];
252 % The fill color (rgb) for non-full stokes
253 nfsFillColor = [0.422 0.688 0.367];
254
255 % Plot full stokes
256% [fh1, msg1] = jbfill(newX, fsMeanVel+fsStdVel, fsMeanVel-fsStdVel, ...%ISSM->THIS LINE HAS BEEN CHANGED
257% fsFillColor, fsFillColor, 1, 0.5);%ISSM->THIS LINE HAS BEEN CHANGED
258%
259% % Plot non-full stokes
260% [fh2, msg2] = jbfill(newX, nfsMeanVel+nfsStdVel, nfsMeanVel-nfsStdVel, ...%ISSM->THIS LINE HAS BEEN CHANGED
261% nfsFillColor, nfsFillColor, 1, 0.35); %ISSM->THIS LINE HAS BEEN CHANGED
262 [fh1 fh2]=jbfill2(newX,fsMeanVel+fsStdVel,fsMeanVel-fsStdVel,nfsMeanVel+nfsStdVel,nfsMeanVel-nfsStdVel);
263
264 % Turn the grid on
265 grid on;
266
267 % Set title properties
268 th = title(plotTitles(i));
269 set(th, 'FontSize', titleFontSize);
270 set(th, 'FontWeight', titleFontWeight);
271
272 % Set x label properties
273 xlabel(xLabel);
274 xh = get(gca, 'xlabel');
275 set(xh, 'FontName', axisLabelFont);
276 set(xh, 'FontSize', axisLabelSize);
277 set(xh, 'FontWeight', axisFontWeight);
278
279 % Set y label properties
280 ylabel('Velocity (m a^{-1})');
281 yh = get(gca, 'ylabel');
282 set(yh, 'FontName', axisLabelFont);
283 set(yh, 'FontSize', axisLabelSize);
284 set(yh, 'FontWeight', axisFontWeight);
285
286 % Set tick mark properties
287 set(gca, 'FontSize', axisTickLabelSize);
288 set(gca, 'FontWeight', axisTickFontWeight);
289
290 % This turns the box around the axis on
291 set(gca, 'Box', 'on' );
292
293 % These lines plot the mean
294 hold on;
295 %plot(newX, fsMeanVel, 'k');%ISSM->THIS LINE HAS BEEN CHANGED
296 %set(findobj(gca,'Type','line','Color',[0 0 0]),'Color',fsFillColor,'LineWidth',2);
297 %plot(newX, nfsMeanVel, 'b');%ISSM->THIS LINE HAS BEEN CHANGED
298 %set(findobj(gca,'Type','line','Color',[0 0 1]),'Color',nfsFillColor,'LineWidth',2);
299
300end
301return %ISSM->THIS LINE HAS BEEN CHANGED
302
303% Add the legend to the final subplot (in upper left corner)
304legend('FS', 'NFS', 'FS Mean', 'NFS Mean', 'Location','West');
305
306set(gcf, 'paperpositionmode','manual','paperorientation', ...
307 'portrait','papertype','A4','paperunits', 'centimeters', ...
308 'paperposition',[1 4 21 13]);
309saveas(gcf, 'expc.eps', 'psc2');
310
311% Analysis of maximum velocities (F. Pattyn)
312% Full Stokes stored in MaxVelfs (else MaxVelnfs)
313% cols = L, rows = participants, 0 = no result
314
315for i=1:length(MaxVelfs)
316 for j=1:size(MaxVelfs,2)
317 if MaxVelfs(i,j)==0
318 MaxVelfs(i,j)=NaN;
319 end
320 end
321end
322for j=1:size(MaxVelfs,2)
323 MeanMaxfs(j)=mean(MaxVelfs(~isnan(MaxVelfs(:,j)),j));
324 StdDevfs(j)=std(MaxVelfs(~isnan(MaxVelfs(:,j)),j));
325 Numfs(j)=sum(~isnan(MaxVelfs(:,j)));
326end
327for i=1:length(MaxVelnfs)
328 for j=1:size(MaxVelnfs,2)
329 if MaxVelnfs(i,j)==0
330 MaxVelnfs(i,j)=NaN;
331 end
332 end
333end
334for j=1:size(MaxVelnfs,2)
335 MeanMaxnfs(j)=mean(MaxVelnfs(~isnan(MaxVelnfs(:,j)),j));
336 StdDevnfs(j)=std(MaxVelnfs(~isnan(MaxVelnfs(:,j)),j));
337 Numnfs(j)=sum(~isnan(MaxVelnfs(:,j)));
338end
339
340% print in format for LaTeX file
341fprintf('NFS & ');
342for j=1:size(MaxVelnfs,2)
343 fprintf('%.2f & %.2f & %d & ', MeanMaxnfs(j), StdDevnfs(j), Numnfs(j));
344end
345fprintf('\\\\ \n');
346fprintf('FS & ');
347for j=1:size(MaxVelfs,2)
348 fprintf('%.2f & %.2f & %d & ', MeanMaxfs(j), StdDevfs(j), Numfs(j));
349end
350fprintf('\\\\ \n');
351
352% Analysis of mean surface velocities (F. Pattyn)
353% Full Stokes stored in MaxVelfs (else MaxVelnfs)
354% cols = L, rows = participants, 0 = no result
355
356for i=1:length(MeanVelfs)
357 for j=1:size(MeanVelfs,2)
358 if MeanVelfs(i,j)==0
359 MeanVelfs(i,j)=NaN;
360 end
361 end
362end
363for j=1:size(MaxVelfs,2)
364 MeanMaxfs(j)=mean(MeanVelfs(~isnan(MeanVelfs(:,j)),j));
365 StdDevfs(j)=std(MeanVelfs(~isnan(MeanVelfs(:,j)),j));
366 Numfs(j)=sum(~isnan(MeanVelfs(:,j)));
367end
368for i=1:length(MeanVelnfs)
369 for j=1:size(MeanVelnfs,2)
370 if MeanVelnfs(i,j)==0
371 MeanVelnfs(i,j)=NaN;
372 end
373 end
374end
375for j=1:size(MeanVelnfs,2)
376 MeanMaxnfs(j)=mean(MeanVelnfs(~isnan(MeanVelnfs(:,j)),j));
377 StdDevnfs(j)=std(MeanVelnfs(~isnan(MeanVelnfs(:,j)),j));
378 Numnfs(j)=sum(~isnan(MeanVelnfs(:,j)));
379end
380
381% print in format for LaTeX file
382fprintf('NFS & ');
383for j=1:size(MaxVelnfs,2)
384 fprintf('%.2f & %.2f & %d & ', MeanMaxnfs(j), StdDevnfs(j), Numnfs(j));
385end
386fprintf('\\\\ \n');
387fprintf('FS & ');
388for j=1:size(MaxVelfs,2)
389 fprintf('%.2f & %.2f & %d & ', MeanMaxfs(j), StdDevfs(j), Numfs(j));
390end
391fprintf('\\\\ \n');
392
Note: See TracBrowser for help on using the repository browser.