function varargout = decc_plot_comparison(varargin)
%DECC_PLOT_COMPARISON  One line description goes here.
%
%   More detailed description goes here.
%
%   Syntax:
%   varargout = decc_plot_comparison(varargin)
%
%   Input:
%   varargin  =
%
%   Output:
%   varargout =
%
%   Example
%   decc_plot_comparison
%
%   See also

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2012 Delft University of Technology
%       Kees den Heijer
%
%       C.denHeijer@TUDelft.nl
%
%       Faculty of Civil Engineering and Geosciences
%       P.O. Box 5048
%       2600 GA Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation, either version 3 of the License, or
%   (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this library.  If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tool is part of <a href="http://www.OpenEarth.eu">OpenEarthTools</a>.
% OpenEarthTools is an online collaboration to share and manage data and
% programming tools in an open source, version controlled environment.
% Sign up to recieve regular updates of this function, and to contribute
% your own tools.

%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% Created: 20 Jan 2012
% Created with Matlab version: 7.7.0.471 (R2008b)

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

%% DUROS+
result = DUROS;
DUROS_A0 = result(2).Volumes.Erosion;
DUROSresult.radius = roundoff(1000 ./ (pi*(6:6:18)/180), -2);
DUROSresult.relErosion = (DUROS_A0 + [50 75 100]) / DUROS_A0 *100;

%% DUROSTA
%{
D = durosta_coastal_curvature('exefile', '');
id45 = cellfun(@(x) x.WaveAngle == 45, {D.Input})
DUROSTA_A45 = cellfun(@(x) x.Volumes.Data(2), {D(id45).Output})
id0 = cellfun(@(x) x.WaveAngle == 0, {D.Input})
DUROSTA_A = cellfun(@(x) x.Volumes.Data(2), {D(id0).Output})
DUROSTA_radius = cellfun(@(x) x.Params.RK, {D(id0).settings})
%}
DUROSTA_radius = [0 9500 4800 3200 2400 1900];
DUROSTA_A = [194.093 205.443 216.86 228.608 240.265 252.342];
DUROSTA_A45 = [157.274 158.082 158.927 159.595 160.369 161.082];
DUROSTAresult.radius = DUROSTA_radius(2:end);
DUROSTAresult.relErosion = DUROSTA_A(2:end) / DUROSTA_A(1) *100;
DUROSTAresult.relErosion45 = DUROSTA_A45(2:end) / DUROSTA_A(1) *100;

%% XBEACH
XBEACH_A0 = 162;
% run40
XBEACH_Aperp = [167.705 169.023 162.782 157.532 156.983];
XBEACH_A45 = [239.865 230.83 221.172 223.798 218.11];
XBEACH_Amax = [244.307 240.925 230.255 230.899 229.787];
XBEACH_Amean = [211.821 208.016 201.731 198.834 196.028];
XBEACH_Amin = [161.778 163.006 160.589 157.532 153.865];
XBEACH_radius = [1900 2400 3200 4800 9500];

XBEACHresult.radius = XBEACH_radius;
XBEACHresult.relErosion = XBEACH_Aperp / XBEACH_A0 *100;
XBEACHresult.relErosion45 = XBEACH_A45 / XBEACH_A0 *100;
XBEACHresult.relmeanErosion = XBEACH_Amean / XBEACH_A0 *100;
XBEACHresult.relmaxErosion = XBEACH_Amax / XBEACH_A0 *100;
XBEACHresult.relminErosion = XBEACH_Amin / XBEACH_A0 *100;

%% plot
figure
plot(XBEACHresult.radius, XBEACHresult.relErosion, 'xr')

hold on
plot(DUROSTAresult.radius, DUROSTAresult.relErosion, 'og')

plot(DUROSresult.radius, DUROSresult.relErosion, 'sb')
xlabel('Radius [m]')
ylabel('Relative Erosion w.r.t. straight coast [%]')
title('Shore normal waves')

set(gca, 'ylim', [80 160])

legend('XBeach', 'Durosta', 'Guideline',...
    'Location','NorthEastOutside')

figureStyle(@stylePresentation,...
    {'figure', 'Units', 'Points'});
[fpath fname] = fileparts(which(mfilename));
fname = sprintf('%s_%s', fname, strrep('at head', ' ', '_'));
figurepath = fullfile(fpath, '..', 'figures');
set(gcf, 'tag', '$HeadURL$ $Revision$')
print(gcf, '-depsc2', fullfile(figurepath, [fname '.eps']))
if ispc
    saveas(gcf, fullfile(figurepath, [fname '.emf']))
end
saveas(gcf, fullfile(figurepath, [fname '.fig']))

%% plot
figure
plot(XBEACHresult.radius, XBEACHresult.relErosion45, 'xr')

hold on
plot(DUROSTAresult.radius, DUROSTAresult.relErosion45, 'og')

plot(DUROSresult.radius, DUROSresult.relErosion, 'sb')
xlabel('Radius [m]')
ylabel('Relative Erosion w.r.t. straight coast [%]')
title('Oblique waves (45 \circ)')

set(gca, 'ylim', [80 160])

legend('XBeach', 'Durosta', 'Guideline',...
    'Location','NorthEastOutside')

figureStyle(@stylePresentation,...
    {'figure', 'Units', 'Points'});
[fpath fname] = fileparts(which(mfilename));
fname = sprintf('%s_%s', fname, strrep('at 45deg', ' ', '_'));
figurepath = fullfile(fpath, '..', 'figures');
set(gcf, 'tag', '$HeadURL$ $Revision$')
print(gcf, '-depsc2', fullfile(figurepath, [fname '.eps']))
if ispc
    saveas(gcf, fullfile(figurepath, [fname '.emf']))
end
saveas(gcf, fullfile(figurepath, [fname '.fig']))

%% plot
figure
offset = 20;
errorbar(XBEACHresult.radius-offset, XBEACHresult.relErosion,...
    XBEACHresult.relErosion - XBEACHresult.relminErosion,...
    XBEACHresult.relmaxErosion - XBEACHresult.relErosion, 'xr')

hold on
errorbar(DUROSTAresult.radius+offset, DUROSTAresult.relErosion,...
    DUROSTAresult.relErosion45 - DUROSTAresult.relErosion,...
    DUROSTAresult.relErosion - DUROSTAresult.relErosion, 'og')

% plot(DUROSTAresult.radius, DUROSTAresult.relErosion, 'og')

plot(DUROSresult.radius, DUROSresult.relErosion, 'sb')
xlabel('Radius [m]')
ylabel('Relative Erosion w.r.t. straight coast [%]')

legend('XBeach', 'Durosta', 'Guideline',...
    'Location','NorthEastOutside')

set(gca, 'ylim', [80 160])

figureStyle(@stylePresentation,...
    {'figure', 'Units', 'Points'});
[fpath fname] = fileparts(which(mfilename));
fname = sprintf('%s_%s', fname, strrep('along curve', ' ', '_'));
figurepath = fullfile(fpath, '..', 'figures');
set(gcf, 'tag', '$HeadURL$ $Revision$')
print(gcf, '-depsc2', fullfile(figurepath, [fname '.eps']))
if ispc
    saveas(gcf, fullfile(figurepath, [fname '.emf']))
end
saveas(gcf, fullfile(figurepath, [fname '.fig']))
