-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretreat_rate_sets_results.m
80 lines (51 loc) · 3.07 KB
/
retreat_rate_sets_results.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%find the median retreat rates for the BRIE experiments
clc; close all; clear
%%
resultsPath = 'C:\Users\ddileonardo\The Water Institute of the Gulf\TO71 - Barrier Island Modeling - General\BRIE_Tests\SLR';
fdir = dir([resultsPath '\*.mat']);
%% Rates for every SLR condition plotted as grid of subplots
figure('position',[-1200 -75 1137 800],'color','w') %single external monitor to the left of laptop
for n = 7%1:length(fdir)
load([resultsPath '\' fdir(n).name]);
paramSets = fieldnames(output); %fieldnames of each parameter set
xt_rate_median = NaN*ones(length(output.(paramSets{1}).dx_tdt(1,:)),length(paramSets));
xt_rate_mean = NaN*ones(length(output.(paramSets{1}).dx_tdt(1,:)),length(paramSets));
xs_rate_median = NaN*ones(length(output.(paramSets{1}).dx_tdt(1,:)),length(paramSets));
xs_rate_mean = NaN*ones(length(output.(paramSets{1}).dx_tdt(1,:)),length(paramSets));
for jj = 1:length(paramSets)
for ii = 1:length(output.(paramSets{1}).dx_tdt(1,:))
if length(output.(paramSets{jj}).dx_tdt(1,:)) == ii %if ii is the last timestep
%continue
elseif sum(output.(paramSets{jj}).dx_tdt(:,ii+1)) == 0 %if all the rates are zero at the next time step
%the barrier has drowned, break the loop
break
end
xt_rate_median(ii,jj) = double(median(output.(paramSets{jj}).dx_tdt(output.(paramSets{jj}).dx_tdt(:,ii)>0,ii)));
xt_rate_mean(ii,jj) = mean(double(output.(paramSets{jj}).dx_tdt(output.(paramSets{jj}).dx_tdt(:,ii)>0,ii)));
xs_rate_median(ii,jj) = double(median(output.(paramSets{jj}).dx_sdt(output.(paramSets{jj}).dx_sdt(:,ii)>0,ii)));
xs_rate_mean(ii,jj) = mean(double(output.(paramSets{jj}).dx_sdt(output.(paramSets{jj}).dx_sdt(:,ii)>0,ii)));
end
%subplot(1,length(paramSets),jj)
subplot(3,3,jj)
plot(xt_rate_median(:,jj),'b.')
hold
plot(xs_rate_median(:,jj),'ro')
grid on
%plot(xt_rate_mean,'co')
%plot(xs_rate_mean,'mo')
plot([10 10],[0 10],'k')
xlabel('Timestep (5 yr intervals)')
ylabel('Retreat Rate (m/yr)')
set(gca,'ylim',[0 15])
if jj == 1
legend('shoreface toe','shoreline','location','northwest')
end
title(['SLR: ' num2str(paramValues(1,jj)*1000) 'mmyr^-^1 H: ' num2str(paramValues(3,jj)) 'm T: ' num2str(paramValues(4,jj)) 's Hb,crit:' num2str(paramValues(5,jj)) 'm'])
end
pause
img = getframe(gcf);
%imwrite(img.cdata, [resultsPath '\Retreat_Rates_' fdir(n).name(1:end-4), '.png']);
%print(gcf, '-dpng','-r150',[resultsPath '\Retreat_Rates_' fdir(n).name(1:end-3) 'png'])
clf
%save([resultsPath '\' fdir(n).name],'b_struct','output','param','paramSets','paramValues','xs_rate_mean','xs_rate_median','xt_rate_mean','xt_rate_median')
end