% Plot 27 km flood waves for all alternatives

clear

% Load upstream flood waves
fpath_upstream = ...
    ['/Users/Colin/Documents/MATLAB/DFlow/roughness_investigation/'...
    'floods/'];
s180name = 's180peak.csv';
s300name = 's300peak.csv';

upstream(1,1) = {csvread(strcat(fpath_upstream,s180name))};
upstream(1,2) = {csvread(strcat(fpath_upstream,s300name))};

% Load QAR files

folder = '/Users/Colin/Documents/MATLAB/DFlow/influences_chap2/QAR_cells/';
files = dir([folder '*.mat']);

for i=1:length(files)
   load([folder files(i).name]);
end

% Extract XS flow at each time step
t = xs_chdown_cell{1,2} / 3600;
bank_down_s180 = xs_bankdown_cell{1,7};
bank_down_s300 = xs_bankdown_cell{2,7};
bank_up_s180 = xs_bankup_cell{1,7};
bank_up_s300 = xs_bankup_cell{2,7};
ch_down_s180 = xs_chdown_cell{1,7};
ch_down_s300 = xs_chdown_cell{2,7};
ch_up_s180 = xs_chup_cell{1,7};
ch_up_s300 = xs_chup_cell{2,7};
fp040_s180 = xs_fp040_cell{1,7};
fp040_s300 = xs_fp040_cell{2,7};
fp060_s180 = xs_fp060_cell{1,7};
fp060_s300 = xs_fp060_cell{2,7};
fp080_s180 = xs_fp080_cell{1,7};
fp080_s300 = xs_fp080_cell{2,7};
fp100_s180 = xs_fp100_cell{1,7};
fp100_s300 = xs_fp100_cell{2,7};
bank040_s180 = xs_bank040_cell{1,7};
bank040_s300 = xs_bank040_cell{2,7};
bank080_s180 = xs_bank080_cell{1,7};
bank080_s300 = xs_bank080_cell{2,7};
bank100_s180 = xs_bank100_cell{1,7};
bank100_s300 = xs_bank100_cell{2,7};

%% Plot

% Convert upstream cells to time and flow
up_s180 = upstream{1,1};
up_s300 = upstream{1,2};

% Set constants and plot size
xs_dist = 27; % km
xs_plot = xs_dist * 4;
f1 = figure(1);
f1.Units = 'inches';
f1.PaperSize = [8.5 6];
set(f1,'color','white');
legend11 = {'Upstream','Baseline','CD','CU','BU','BU'};
legend12 = {'Upstream','Baseline','F04','F08','F10',...
    'B04','B08','B10'};

%Plot - subplots by topography and roughness
subplot(2,2,1);
plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
hold on
plot(t,fp060_s180(:,xs_plot),'k');
plot(t,ch_down_s180(:,xs_plot),'--');
plot(t,ch_up_s180(:,xs_plot),'--');
ax = gca;
ax.ColorOrderIndex = 1;
plot(t,bank_down_s180(:,xs_plot));
plot(t,bank_up_s180(:,xs_plot));
xlim([0 40]);
ylim([20 190]);
yticks([50 100 150]);
set(gca,'Fontsize',14);
ylabel('Discharge (m^3s^{-1})')
legend(legend11,'Location','northeast');
% legend('boxoff');

subplot(2,2,2);
plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
hold on
plot(t,fp060_s180(:,xs_plot),'k');
ax = gca;
ax.ColorOrderIndex = 3;
plot(t,fp040_s180(:,xs_plot),'--');
plot(t,fp080_s180(:,xs_plot),'--');
plot(t,fp100_s180(:,xs_plot),'--');
ax = gca;
ax.ColorOrderIndex = 3;
plot(t,bank040_s180(:,xs_plot));
plot(t,bank080_s180(:,xs_plot));
plot(t,bank100_s180(:,xs_plot));
xlim([0 40]);
ylim([20 190]);
yticks([50 100 150]);
set(gca,'Fontsize',14);
legend(legend12,'Location','northeast');
% legend('boxoff');

subplot(2,2,3);
plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
hold on
plot(t,fp060_s300(:,xs_plot),'k');
plot(t,ch_down_s300(:,xs_plot),'--');
plot(t,ch_up_s300(:,xs_plot),'--');
ax = gca;
ax.ColorOrderIndex = 1;
plot(t,bank_down_s300(:,xs_plot));
plot(t,bank_up_s300(:,xs_plot));
xlim([0 40]);
ylim([140 310]);
yticks([150 200 250 300]);
set(gca,'Fontsize',14);
ylabel('Discharge (m^3s^{-1})')
xlabel('Time (hrs)')
% legend(legend11,'Location','northeast');
% legend('boxoff');

subplot(2,2,4);
plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
hold on
plot(t,fp060_s300(:,xs_plot),'k');
ax = gca;
ax.ColorOrderIndex = 3;
plot(t,fp040_s300(:,xs_plot),'--');
plot(t,fp080_s300(:,xs_plot),'--');
plot(t,fp100_s300(:,xs_plot),'--');
ax = gca;
ax.ColorOrderIndex = 3;
plot(t,bank040_s300(:,xs_plot));
plot(t,bank080_s300(:,xs_plot));
plot(t,bank100_s300(:,xs_plot));
xlim([0 40]);
ylim([140 310]);
yticks([150 200 250 300]);
set(gca,'Fontsize',14);
xlabel('Time (hrs)')
% legend(legend12,'Location','northeast');
% legend('boxoff');

print('-fillpage',['/Users/Colin/Documents/MATLAB/DFlow/'...
    'influences_chap2/figures/Q27km_topo_rough_legend'],'-dpdf');

% Plot - subplots by floodplain and bank
% f2 = figure(2);
% f2.Units = 'inches';
% f2.PaperSize = [8.5 6];
% set(f2,'color','white');
% 
% subplot(2,2,1);
% plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
% hold on
% plot(t,fp060_s180(:,xs_plot),'k');
% plot(t,ch_down_s180(:,xs_plot));
% plot(t,ch_up_s180(:,xs_plot));
% plot(t,fp040_s180(:,xs_plot));
% plot(t,fp080_s180(:,xs_plot));
% plot(t,fp100_s180(:,xs_plot));
% xlim([0 40]);
% ylim([20 190]);
% yticks([50 100 150]);
% set(gca,'Fontsize',14);
% ylabel('Discharge (m^3/s)')
% 
% subplot(2,2,2);
% plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
% hold on
% plot(t,fp060_s180(:,xs_plot),'k');
% plot(t,bank_down_s180(:,xs_plot));
% plot(t,bank_up_s180(:,xs_plot));
% plot(t,bank040_s180(:,xs_plot));
% plot(t,bank080_s180(:,xs_plot));
% plot(t,bank100_s180(:,xs_plot));
% xlim([0 40]);
% ylim([20 190]);
% yticks([50 100 150]);
% set(gca,'Fontsize',14);
% 
% subplot(2,2,3);
% plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
% hold on
% plot(t,fp060_s300(:,xs_plot),'k');
% plot(t,ch_down_s300(:,xs_plot));
% plot(t,ch_up_s300(:,xs_plot));
% plot(t,fp040_s300(:,xs_plot));
% plot(t,fp080_s300(:,xs_plot));
% plot(t,fp100_s300(:,xs_plot));
% xlim([0 40]);
% ylim([140 310]);
% yticks([150 200 250 300]);
% set(gca,'Fontsize',14);
% ylabel('Discharge (m^3/s)')
% xlabel('Time (hr)')
% 
% subplot(2,2,4);
% plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
% hold on
% plot(t,fp060_s300(:,xs_plot),'k');
% plot(t,bank_down_s300(:,xs_plot));
% plot(t,bank_up_s300(:,xs_plot));
% ax = gca;
% ax.ColorOrderIndex = 3;
% plot(t,bank040_s300(:,xs_plot));
% plot(t,bank080_s300(:,xs_plot));
% plot(t,bank100_s300(:,xs_plot));
% xlim([0 40]);
% ylim([140 310]);
% yticks([150 200 250 300]);
% set(gca,'Fontsize',14);
% xlabel('Time (hr)')
% 
% print('-fillpage',['/Users/Colin/Documents/MATLAB/DFlow/'...
%     'influences_chap2/figures/Q27km_fp_bank'],'-dpdf');

% Plot - subplots by floodplain and bank with legend
% f2 = figure(2);
% f2.Units = 'inches';
% f2.PaperSize = [8.5 6];
% set(f2,'color','white');
% % legend11 = {'Upstream','Baseline','C_{Dn}','C_{Up}','B_{Dn}','B_{Up}'};
% % legend12 = {'Upstream','Baseline','F_{0.04}','F_{0.08}','F_{0.10}',...
% %     'B_{0.04}','B_{0.08}','B_{0.10}'};
% legend21 = {'Upstream','Baseline','CD','CU',...
%     'F04','F08','F10'};
% legend22 = {'Upstream','Baseline','BD','BU',...
%     'B04','B08','B10'};
% 
% subplot(2,2,1);
% plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
% hold on
% plot(t,fp060_s180(:,xs_plot),'k');
% plot(t,ch_down_s180(:,xs_plot));
% plot(t,ch_up_s180(:,xs_plot));
% plot(t,fp040_s180(:,xs_plot));
% plot(t,fp080_s180(:,xs_plot));
% plot(t,fp100_s180(:,xs_plot));
% xlim([0 40]);
% ylim([20 190]);
% yticks([50 100 150]);
% set(gca,'Fontsize',14);
% ylabel('Discharge (m^3/s)')
% legend(legend21);
% 
% subplot(2,2,2);
% plot(up_s180(:,1)/60,up_s180(:,2),'k-.');
% hold on
% plot(t,fp060_s180(:,xs_plot),'k');
% plot(t,bank_down_s180(:,xs_plot));
% plot(t,bank_up_s180(:,xs_plot));
% plot(t,bank040_s180(:,xs_plot));
% plot(t,bank080_s180(:,xs_plot));
% plot(t,bank100_s180(:,xs_plot));
% xlim([0 40]);
% ylim([20 190]);
% yticks([50 100 150]);
% set(gca,'Fontsize',14);
% legend(legend22);
% 
% subplot(2,2,3);
% plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
% hold on
% plot(t,fp060_s300(:,xs_plot),'k');
% plot(t,ch_down_s300(:,xs_plot));
% plot(t,ch_up_s300(:,xs_plot));
% plot(t,fp040_s300(:,xs_plot));
% plot(t,fp080_s300(:,xs_plot));
% plot(t,fp100_s300(:,xs_plot));
% xlim([0 40]);
% ylim([140 310]);
% yticks([150 200 250 300]);
% set(gca,'Fontsize',14);
% ylabel('Discharge (m^3/s)')
% xlabel('Time (hr)')
% legend(legend21);
% 
% subplot(2,2,4);
% plot(up_s300(:,1)/60,up_s300(:,2),'k-.');
% hold on
% plot(t,fp060_s300(:,xs_plot),'k');
% plot(t,bank_down_s300(:,xs_plot));
% plot(t,bank_up_s300(:,xs_plot));
% ax = gca;
% ax.ColorOrderIndex = 3;
% plot(t,bank040_s300(:,xs_plot));
% plot(t,bank080_s300(:,xs_plot));
% plot(t,bank100_s300(:,xs_plot));
% xlim([0 40]);
% ylim([140 310]);
% yticks([150 200 250 300]);
% set(gca,'Fontsize',14);
% xlabel('Time (hr)')
% legend(legend22);
% 
% print('-fillpage',['/Users/Colin/Documents/MATLAB/DFlow/'...
%     'influences_chap2/figures/Q27km_fp_bank_legend'],'-dpdf');