function h = tb_V1Fullpage(dims,zb,dirs)
%UNTITLED  Created a spatial overview of DeltaR & A at t = 90 min
%
%   Syntax:
%   h = tb_V1Fullpage(dims,zb)
%
%   Input:      XBeach structure with dimensions & initial and final 
%               bottom data
%   Output:     Spatial overview (h)%
%
%   Example
%   tb_V1Fullpage(dims,[xb.data(1,2).value(1,:,:); xb.data(1,2).value(end,:,:)]);
%
%   See also

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2011 <COMPANY>
%       Bram de Vries
%
%       <EMAIL>	
%
%       <ADDRESS>
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 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
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tool is part of <a href="http://OpenEarth.nl">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: 13 May 2011
% Created with Matlab version: 7.9.1.705 (R2009b) Service Pack 1

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

%% ===Settings=============================================================
OPT = struct(...
    'savedir',nan,...
    'width',22.8,...
    'height',12.2);


%% ===Load measurements of DeltaR* & A=====================================
DBDR = load(fullfile(dirs.data,'V1ARGUS_DELTAR_FULL.mat'));
DBDRWP = load(fullfile(dirs.data,'V1WHEELPROFILER_DELTAR.mat'));

yin = [2.53 4.03 4.78 5.03 5.28 8.66 12.03 15.78 19.53 19.78 20.03 20.78 22.28];
load(fullfile(dirs.data,'V1WHEELPROFILER_A.mat'));


%% ===Calculate DeltaR* & A from XBeach output=============================
%---Find y-indices of begin & end y-coordinate of structures---------------
yInd.D1 = [find(dims.y(:,1)==0) find(dims.y(:,1)==5.53)];
yInd.B1 = [find(dims.y(:,1)==8.53) find(dims.y(:,1)==8.78)];
yInd.B2 = [find(dims.y(:,1)==11.78) find(dims.y(:,1)==12.28)];
yInd.B3 = [find(dims.y(:,1)==15.28) find(dims.y(:,1)==16.28)];
yInd.D2 = [find(dims.y(:,1)==19.28) find(dims.y(:,1)==25.42)];

%---Calculate DeltaR* & A--------------------------------------------------
XBDR = tb_calc_DeltaR(dims,zb);
XBA = tb_calc_A(dims,zb);


%% ===Plot spatial overview================================================
h = figure; set(h,'units','centimeters'); set(h,'position',[0 0 OPT.width OPT.height]);

h(1) = subplot(2,1,1); set(h(1),'units','centimeters'); set(h(1),'position',[1.8 7.5 20.1 4.1]);
hold(h(1),'on'); box on; grid on;

    plot(dims.y(yInd.D1(1):yInd.D1(2),1),XBDR(end,yInd.D1(1):yInd.D1(2)),'r');
    plot(DBDR.Y.D1,DBDR.DeltaR(1,3).D1(:,end),'b');
    
    plot(dims.y(yInd.D2(1):yInd.D2(2),1),XBDR(end,yInd.D2(1):yInd.D2(2)),'r'); 
    plot(DBDR.Y.D2,DBDR.DeltaR(1,3).D2(:,end),'b');
    
    plot(dims.y(yInd.B1(1):yInd.B1(2),1), XBDR(end,yInd.B1(1):yInd.B1(2)),'r');
    plot(DBDR.Y.B1,DBDR.DeltaR(1,3).B1(:,end),'b');
    
    plot(dims.y(yInd.B2(1):yInd.B2(2),1),XBDR(end,yInd.B2(1):yInd.B2(2)),'r');
    plot(DBDR.Y.B2,DBDR.DeltaR(1,3).B2(:,end),'b');
    
    plot(dims.y(yInd.B3(1):yInd.B3(2),1),XBDR(end,yInd.B3(1):yInd.B3(2)),'r');
    plot(DBDR.Y.B3,DBDR.DeltaR(1,3).B3(:,end),'b');
    
    plot(yin,DBDRWP.DeltaR_WP(3,:),'k','Marker','o','LineStyle','none','MarkerFaceColor','k','MarkerSize',5);
    
xlim([0 26.42]); ylim([0 1.1]);
ylabel('$\Delta$R$^\textrm{*}$ [m]','Interpreter','latex');

% Structures
Faces = [1 2 3; 2 3 4; 5 6 7; 6 7 8; 9 10 11; 10 11 12; 13 14 15; 14 15 16; 17 18 19; 18 19 20];
Verts = [5.53 min(ylim); 5.53 max(ylim); 8.53 min(ylim); 8.53 max(ylim); ...
         8.78 min(ylim); 8.78 max(ylim); 11.78 min(ylim); 11.78 max(ylim); ...
         12.28 min(ylim); 12.28 max(ylim); 15.28 min(ylim); 15.28 max(ylim); ...
         16.28 min(ylim); 16.28 max(ylim); 19.28 min(ylim); 19.28 max(ylim); ...
         25.42 min(ylim); 25.42 max(ylim); 26.42 min(ylim); 26.42 max(ylim)];
    
p = patch('Faces',Faces,'Vertices',Verts,'FaceAlpha',0.4,'LineWidth',1,...
    'FaceColor',[0 0 0],'EdgeColor','none');

%Removed data
Faces = [1 2 3; 2 3 4; 5 6 7; 6 7 8; 9 10 11; 10 11 12; 13 14 15; 14 15 16; 17 18 19; 18 19 20; ...
    21 22 23; 22 23 24; 25 26 27; 26 27 28; 29 30 31; 30 31 32; 33 34 35; 34 35 36];
Verts = [0 min(ylim); 0 max(ylim); 2.24 min(ylim); 2.24 max(ylim); ...
         5.45 min(ylim); 5.45 max(ylim); 5.53 min(ylim); 5.53 max(ylim); ...
         8.53 min(ylim); 8.53 max(ylim); 8.58 min(ylim); 8.58 max(ylim); ...
         8.68 min(ylim); 8.68 max(ylim); 8.78 min(ylim); 8.78 max(ylim); ...
         11.78 min(ylim); 11.78 max(ylim); 11.83 min(ylim); 11.83 max(ylim); ...
         12.13 min(ylim); 12.13 max(ylim); 12.28 min(ylim); 12.28 max(ylim); ...
         15.28 min(ylim); 15.28 max(ylim); 15.33 min(ylim); 15.33 max(ylim); ...
         19.28 min(ylim); 19.28 max(ylim); 19.38 min(ylim); 19.38 max(ylim); ...
         24.18 min(ylim); 24.18 max(ylim); 25.42 min(ylim); 25.42 max(ylim)];
     
pr = patch('Faces',Faces,'Vertices',Verts,'FaceAlpha',0.4,'LineWidth',1,...
    'FaceColor',[0.7 0.7 0.7],'EdgeColor','none');

v1 = vline([5.53 8.53 8.78 11.78 12.28 15.28 16.28 19.28 25.42],'-k');

annotation(gcf,'textbox',[0.151 0.97 0.03 0.03],'String',{'D1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.301 0.97 0.03 0.03],'String',{'H1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.353 0.97 0.03 0.03],'String',{'B1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.404 0.97 0.03 0.03],'String',{'H2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.466 0.97 0.03 0.03],'String',{'B2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.521 0.97 0.03 0.03],'String',{'H3'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.591 0.97 0.03 0.03],'String',{'B3'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.658 0.97 0.03 0.03],'String',{'H4'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.815 0.97 0.03 0.03],'String',{'D2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.931 0.97 0.03 0.03],'String',{'R1'},'FitBoxToText','off','LineStyle','none','FontSize',8);

    
h(2) = subplot(2,1,2); set(h(2),'units','centimeters'); set(h(2),'position',[1.8 1.5 20.1 4.1]);
hold(h(2),'on'); box on; grid on;

    plot(dims.y(yInd.D1(1):yInd.D1(2),1),XBA(end,yInd.D1(1):yInd.D1(2)),'r');
    plot(dims.y(yInd.D2(1):yInd.D2(2),1),XBA(end,yInd.D2(1):yInd.D2(2)),'r');
    plot(dims.y(yInd.B1(1):yInd.B1(2),1),XBA(end,yInd.B1(1):yInd.B1(2)),'r');
    plot(dims.y(yInd.B2(1):yInd.B2(2),1),XBA(end,yInd.B2(1):yInd.B2(2)),'r');
    plot(dims.y(yInd.B3(1):yInd.B3(2),1),XBA(end,yInd.B3(1):yInd.B3(2)),'r');
    plot(yin,ADB(3,:),'k','Marker','o','LineStyle','none','MarkerFaceColor','k','MarkerSize',5);

xlim([0 26.42]); ylim([0 0.15]);
ylabel('A [m$^{3}$/m]','Interpreter','latex'); xlabel('y [m]');

% Structures
Faces = [1 2 3; 2 3 4; 5 6 7; 6 7 8; 9 10 11; 10 11 12; 13 14 15; 14 15 16; 17 18 19; 18 19 20];
Verts = [5.53 min(ylim); 5.53 max(ylim); 8.53 min(ylim); 8.53 max(ylim); ...
         8.78 min(ylim); 8.78 max(ylim); 11.78 min(ylim); 11.78 max(ylim); ...
         12.28 min(ylim); 12.28 max(ylim); 15.28 min(ylim); 15.28 max(ylim); ...
         16.28 min(ylim); 16.28 max(ylim); 19.28 min(ylim); 19.28 max(ylim); ...
         25.42 min(ylim); 25.42 max(ylim); 26.42 min(ylim); 26.42 max(ylim)];
    
p = patch('Faces',Faces,'Vertices',Verts,'FaceAlpha',0.4,'LineWidth',1,...
    'FaceColor',[0 0 0],'EdgeColor','none');

%Removed data
Faces = [1 2 3; 2 3 4; 5 6 7; 6 7 8; 9 10 11; 10 11 12; 13 14 15; 14 15 16; 17 18 19; 18 19 20; ...
    21 22 23; 22 23 24; 25 26 27; 26 27 28; 29 30 31; 30 31 32; 33 34 35; 34 35 36];
Verts = [0 min(ylim); 0 max(ylim); 2.24 min(ylim); 2.24 max(ylim); ...
         5.45 min(ylim); 5.45 max(ylim); 5.53 min(ylim); 5.53 max(ylim); ...
         8.53 min(ylim); 8.53 max(ylim); 8.58 min(ylim); 8.58 max(ylim); ...
         8.68 min(ylim); 8.68 max(ylim); 8.78 min(ylim); 8.78 max(ylim); ...
         11.78 min(ylim); 11.78 max(ylim); 11.83 min(ylim); 11.83 max(ylim); ...
         12.13 min(ylim); 12.13 max(ylim); 12.28 min(ylim); 12.28 max(ylim); ...
         15.28 min(ylim); 15.28 max(ylim); 15.33 min(ylim); 15.33 max(ylim); ...
         19.28 min(ylim); 19.28 max(ylim); 19.38 min(ylim); 19.38 max(ylim); ...
         24.18 min(ylim); 24.18 max(ylim); 25.42 min(ylim); 25.42 max(ylim)];
     
pr = patch('Faces',Faces,'Vertices',Verts,'FaceAlpha',0.4,'LineWidth',1,...
    'FaceColor',[0.7 0.7 0.7],'EdgeColor','none');

v1 = vline([5.53 8.53 8.78 11.78 12.28 15.28 16.28 19.28 25.42],'-k');

annotation(gcf,'textbox',[0.151 0.48 0.03 0.03],'String',{'D1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.301 0.48 0.03 0.03],'String',{'H1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.353 0.48 0.03 0.03],'String',{'B1'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.404 0.48 0.03 0.03],'String',{'H2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.466 0.48 0.03 0.03],'String',{'B2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.521 0.48 0.03 0.03],'String',{'H3'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.591 0.48 0.03 0.03],'String',{'B3'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.658 0.48 0.03 0.03],'String',{'H4'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.815 0.48 0.03 0.03],'String',{'D2'},'FitBoxToText','off','LineStyle','none','FontSize',8);
annotation(gcf,'textbox',[0.931 0.48 0.03 0.03],'String',{'R1'},'FitBoxToText','off','LineStyle','none','FontSize',8);

xb_write_plot(gcf,dirs.output,'V1SpatialOverview')