function varargout = dewa_plot_wave_angle_erosion(varargin)
%DEWA_PLOT_WAVE_ANGLE_EROSION  One line description goes here.
%
%   More detailed description goes here.
%
%   Syntax:
%   varargout = dewa_plot_wave_angle_erosion(varargin)
%
%   Input:
%   varargin  =
%
%   Output:
%   varargout =
%
%   Example
%   dewa_plot_wave_angle_erosion
%
%   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: 29 Aug 2012
% Created with Matlab version: 7.13.0.564 (R2011b)

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

%%
OPT = struct(...
    'xbeach', fullfile(fileparts(which(mfilename)), 'wave_angle_erosion_xbeach.mat'),...
    'durosta', fullfile(fileparts(which(mfilename)), '..', '..', 'heijer', 'matlab', 'durosta', 'durosta_wave_angle.mat') ...
    );

OPT = setproperty(OPT, varargin);

%%
load(OPT.xbeach)
load(OPT.durosta)

[wave_angle erosion] = deal(zeros(size(D)));
for i = 1:length(D)
    wave_angle(i) = D(i).Input.WaveAngle;
    erosion(i) = D(i).Output.Volumes.Data(2);
end

figure;
ph = plot(wave_angle, erosion, 'o',...
    'displayname', 'DurosTA');
hold on
ph(2) = errorbar(angles_mean, Ero_mean, Ero_std*2,...
    'color', 'r',...
    'marker', 'x',...
    'linestyle', 'none',...
    'displayname', 'XBeach');
legend(gca,...
    'location', 'east')
% % fit a cosine shape through the points
% a = nanmean((max(erosion) - erosion) ./ (1 - cosd(wave_angle)));
% m = max(erosion) - a;
% hold on; plot(min(wave_angle):max(wave_angle), m + a * cosd(min(wave_angle):max(wave_angle)))

xlabel('wave angle [deg] w.r.t. shore normal')
ylabel('erosion volume [m^3/m] above SSL')

%%
figureStyle(@styleThesis,...
    {'figure', 'Position', [1 1 15 9]});
tightenfigure
[fpath fname] = fileparts(which(mfilename));
figurepath = fullfile(fpath);
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']))

%%
if nargout > 0
    varargout = {ph};
end