% Plot upstream hydrograph and 18 km hydrographs for every flood wave
% his_extract_chap1.m must have been run

%% Load upstream data

fpath_upstream = ...
    ['/Users/Colin/Documents/MATLAB/DFlow/roughness_investigation/'...
    'floods/'];
s180name = 's180peak.csv';
s300name = 's300peak.csv';
m180name = 'm180peak.csv';
m300name = 'm300peak.csv';
l180name = 'l180peak.csv';
l300name = 'l300peak.csv';

upstream(1,1) = {csvread(strcat(fpath_upstream,s180name))};
upstream(1,2) = {csvread(strcat(fpath_upstream,s300name))};
upstream(1,3) = {csvread(strcat(fpath_upstream,m180name))};
upstream(1,4) = {csvread(strcat(fpath_upstream,m300name))};
upstream(1,5) = {csvread(strcat(fpath_upstream,l180name))};
upstream(1,6) = {csvread(strcat(fpath_upstream,l300name))};

%% Plot

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

hist_2010_km18ratio = zeros(6,1);
xs_id = 18 * 4;

for i=1:folder_num
    Qwave_2010 = xs_2010_cell{i,4};
    Qwave_hist = xs_hist_cell{i,4};
    Qwave_2010lidar = xs_2010lidar_cell{i,4};
    Qwave_prelidar = xs_prelidar_cell{i,4};
    Qtime_2010 = xs_2010_cell{i,2};
    Qtime_hist = xs_hist_cell{i,2};
    Qtime_2010lidar = xs_2010lidar_cell{i,2};
    Qtime_prelidar = xs_prelidar_cell{i,2};
    
    upstream_tQ = upstream{1,i};
    
    subplot(3,2,i)
    plot(upstream_tQ(:,1)/60,upstream_tQ(:,2),'k-');
    hold on
    plot(Qtime_hist/3600,Qwave_hist(:,xs_id));
    plot(Qtime_2010/3600,Qwave_2010(:,xs_id),'--');
    plot(Qtime_prelidar/3600,Qwave_prelidar(:,xs_id),'-.');
    plot(Qtime_2010lidar/3600,Qwave_2010lidar(:,xs_id),':');
%     if mod(i,2) == 0
%         ylim([0.85 1])
%     else
%         ylim([0.7 1])
%     end
    
    if i == 1 || i == 3 || i == 5
        ylim([0 200])
        yticks([0 50 100 150 200])
    elseif i == 2 || i == 4 || i == 6
        ylim([120 320])
    end
    
    if i == 5 || i == 6
        xlim([0 95]);
        xlabel('Time (hr)');
    elseif i == 3
        xlim([0 95]);
        ylabel('Discharge (m^3s^{-1})');
    elseif i == 4
        xlim([0 95])
    elseif i == 2
        xlim([0 95])
        legend('Upstream','HC','CC','PL','CL','Location','east');
    elseif i == 1
        xlim([0 95])
    end
    set(gca,'FontSize',fsize);
    
    hist_2010_km18ratio(i,1) =...
        (1- Qwave_hist(72,1)) / (1 - Qwave_2010(72,1));
    
end

% print('-bestfit',['/Users/Colin/Documents/MATLAB/DFlow/'...
%     'attenuation_chap1/figures/upstream_18km_hydros_11x6'],'-dpdf');
