source: issm/trunk/test/IsmipHomResults/plotting_scripts/plot_exp_a.asv@ 7888

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

Added ISMIP results from Pattyn

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