close all
clear all

paths.data=cd;
paths.figs=fullfile(cd,'Figures');

mkdir(paths.figs)

load(fullfile(paths.data,'run_summary.mat'));

% ic=make_icol_scheme;

addpath(genpath('E:\My software'));


ic(:,1)=[162 38 109]/255;
ic(:,2)=[0 96 255]/255;
ic(:,3)=[80 162 84]/255;
ic(:,4)=[192 119 38]/255;
ic(:,5)=[239 0 0]/255;
ic(:,6)=[0 0 0];
ic(:,7)=[0.5 0.3 1];
ic(:,8)=[0.7 0.7 .9];
ic(:,9)=[0.7 0.1 .7];



% pps={'Run1M_00';'Run1M_00_facua02';'Run1M_00_wetslope';'Run1M_both';'Run1M_longshore';'Run1M_longshore_Cz';'Run1M_longwaves';'Run1M_perpendicular';'Run1M_irregular'};
% 
% labs={'simple';'facua 0.2';'wetslope 0.2';'longshore+longwaves';'longshore on';'longshore on-Cz=0.5';'longwaves on';'perpendicular';'irregular'};

% Explanation:
% Default values are (Simple)
% facua=0.5
% wetslope=0.3
% Chezy=0.65
% waves with 300o degree
% lws=0
% left     = 1
% right    = 1

% Each run changes the parameter noted on the legend. 
% perpendicular is one run with default values and waves coming from 270
% irregular is one run with irregular grid of minimum grid spacing=0.5 m
% longshore on means:
% left     = 0
% right    = 0
% leftwave = 1
% rightwave= 1

% here i make comparison plots for some cases  and you can add yours if you
% want

cmps={[1 2 3];[1 4 5 6 8];[1 4 9];[1:length(runres)];[1 2 3 8 9];[1 4 7];[1 7]};
    
tits={'Effect of facua and wetslope';'Effect of longshore';'Effect of long waves and irregular grid';'All cases';'Effect of facua, wetslope, wave direction and irregular grid';'Effect of longwave stirring';'Praia de Faro-H_s=4 m, T_p=4 s'};

 
for it=1:length(tits)
    
    figure(it)

    pp=plot(field.xi,field.zi,'color','k');

    set(pp,'Linewidth',2)

    hold on

    pp=plot(field.xf,field.zf,'color',[0.5 0.5 0.5]);

    set(pp,'Linewidth',2)


    %         add formating
     xlabel('Cross-shore distance (m)');ylabel('Elevation (m)');%title(['wave condition ' num2str(ii) ' iter ' num2str(i) '/' num2str(nt)]);

    grid on 
    box on

    cl=cmps{it};
    
    
    leg2={'Initial','Final'};
    
    for it2=1:length(cl)
        
        itt=cl(it2);
        
        plot(runres(itt).x,runres(itt).final,'color',ic(:,it2))

        axis([1000 1600 -5 8])

        leg2{it2+2}=runres(itt).leg;

        
        
    end
    
    legend(leg2,2)

    title(tits{it})
    
    print('-dtiff','-r300',fullfile(paths.figs,['Case-' num2str(it)]))
    
    %             % set limits
    %         yl1=-6 ;
    %         yl2=8;
    % 
    %         xx=repres(i).x;
    %         nst=repres(i).z;
    %         
    %         
    %         inds=find(nst>yl1 & nst < yl2);
    % 
    %         xl1=min(xx(inds));
    %         xl2=max(xx(inds));
    %         axis([xl1 xl2 yl1 yl2])
    % 
    %         plot([xl1 xl2],[2 2],'k')
end


mkdir(fullfile(cd,'4Ap'))

figure(length(tits))
    print('-dpng','-r300',fullfile(cd,'4Ap',['Case-' num2str(it)]))
    saveas(gcf,fullfile(cd,'4Ap',['Case-' num2str(it) '.fig']))
