% Plot stacked channel-floodplain characteristics

clear

%% INPUTS

dir_root = '/Users/Colin/Documents/MATLAB/DFlow/influences_chap2/data/';

% Areas
load(strcat(dir_root,'total_area.mat'));
load(strcat(dir_root,'fp_area.mat'));
load(strcat(dir_root,'ch_area.mat'));
a = 0;
for i = 4:4:108
    a = a + 1;
    total_area_1000m(a,1) = sum(total_area(i-3:i,1));
    ch_area_1000m(a,1) = sum(ch_area(i-3:i,1));
    fp_area_1000m(a,1) = sum(fp_area(i-3:i,1));
end

% Inundated Area
load(strcat(dir_root,'f30cms_areas.mat'));
load(strcat(dir_root,'f150cms_areas.mat'));

% Roughness
load(strcat(dir_root,'fp_roughness_1000m.mat'));
load(strcat(dir_root,'bank_roughness_1000m.mat'));

% QAR
load(strcat(dir_root,'dist_qar_rate1000m.mat'));
qar1000m_s180 = 1 - cumsum(dist_qar_rate1000m(:,1));
qar1000m_s300 = 1 - cumsum(dist_qar_rate1000m(:,2));

% Topographic Elevation
load(strcat(dir_root,'bank_elevation_1000m.mat'));
load(strcat(dir_root,'ch_elevation_1000m.mat'));
load(strcat(dir_root,'fp_elevation_1000m.mat'));
bank_ch_z = bank_elevation_1000m(1:27,1) - ch_elevation_1000m(1:27,1);
fp_ch_z = fp_elevation_1000m(1:27,1) - ch_elevation_1000m(1:27,1);

% Water Surface Elevation
load(strcat(dir_root,'WSE_minus_bank.mat'));
load(strcat(dir_root,'WSE_minus_fp.mat'));

% Slope
load(strcat(dir_root,'slope_1000m.mat'));

%% Stats

ch_area_percent = ch_area_1000m ./ total_area_1000m;
mean_ch_area_percent = mean(ch_area_percent);

%% Plots

f1 = figure(1);
f1.Units = 'inches';
%h.Position = [1 1 11 15];
f1.PaperSize = [8.5 11];
set(f1,'color','white');
fsize = 14;

xs_dist = 1:27;
num_sp = 8;

subplot(num_sp,1,1)
plot(xs_dist,qar1000m_s180,'k-');
hold on
plot(xs_dist,qar1000m_s300,'k--');
xlim([0 28])
ylim([.75 1])
ylabel('QAR');
set(gca,'fontsize',fsize);
% legend('Moderate','Major','Location','east');
% legend('boxoff');

subplot(num_sp,1,2)
plot(xs_dist,dist_qar_rate1000m(:,1),'k-');
hold on
plot(xs_dist,dist_qar_rate1000m(:,2),'k--');
xlim([0 28])
ylabel('\DeltaQAR');
set(gca,'fontsize',fsize);
% legend('Moderate','Major','Location','east');
% legend('boxoff');

subplot(num_sp,1,3)
plot(xs_dist,total_area_1000m/1000000,'k-');
hold on
plot(xs_dist,fp_area_1000m/1000000,'k--');
%plot(xs_dist,ch_area_1000m/1000000,'k-.');
xlim([0 28])
ylabel({'Area'; '(km^2)'});
set(gca,'fontsize',fsize);
% legend('TA','FPA','CA','Location','east');
% legend('boxoff');

subplot(num_sp,1,4)
plot(xs_dist,fp_roughness_1000m(1:27,1),'k-');
hold on
plot(xs_dist,bank_roughness_1000m(1:27,1),'k--');
xlim([0 28])
ylabel('n-value');
set(gca,'fontsize',fsize);

subplot(num_sp,1,5)
plot(xs_dist,fp_ch_z(1:27,1),'k-');
hold on
plot(xs_dist,bank_ch_z(1:27,1),'k--');
xlim([0 28])
ylabel({'Static';'Elevation'; '(m)'});
set(gca,'fontsize',fsize);

subplot(num_sp,1,6)
plot(xs_dist,WSE_minus_fp(1:27,1),'k-');
hold on
plot(xs_dist,WSE_minus_bank(1:27,2),'k--');
xlim([0 28])
ylabel({'Flow'; 'Dependent';'Elevation'; '(m)'});
set(gca,'fontsize',fsize);

subplot(num_sp,1,7)
plot(xs_dist,WSE_minus_fp(1:27,2),'k-');
hold on
plot(xs_dist,WSE_minus_bank(1:27,2),'k--');
xlim([0 28])
ylabel({'Flow'; 'Dependent';'Elevation'; '(m)'});
set(gca,'fontsize',fsize);

subplot(num_sp,1,8)
plot(xs_dist,f30cms_areas(:,3),'k-');
hold on
plot(xs_dist,f150cms_areas(:,3),'k--');
xlim([0 28])
xlabel('Distance downstream (km)')
ylabel('RIATA')
set(gca,'fontsize',fsize);

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