function ok = Westerschelde_batch(varargin)
%WESTERSCHELDE_BATCH  Whatever can be done in batch is in this m-file
%
%
%   All actions needed to create or extend the needed kml file and the
%   graphs to be used is in this script. The script can be adapted at any
%   moment and will have no static source. For that reason commenting is
%   used.
%   It is possible to direct resulting files to a specific directory with
%   the one an only parameter.
%
%   Syntax:
%   ok = Westerschelde_batch(varargin)
%
%   Input:
%   varargin = any key/value pair. This will vary. The possible pairs are
%              described in the source.
%              A fixed one:
%              'storein' : store the results in this directory, create when
%                          not available. Default it is the current
%                          directory.
%
%   Output:
%   ok       = 0 when failed, 1 when successfull
%
%   Example
%   See also 

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2010 Deltares
%       Lou Verhage
%
%       lou.verhage@deltares.nl	
%
%       Deltares
%       P.O. Box 177
%       2600MH Delft
%       Tel: +31 (0)88 335  8273
%       
%       Visiting adress:
%       Rotterdamseweg 185
%       2629 HD Delft
%       Tel: +31 (0)88 335  8276
%
%   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: 10 Sep 2010
% Created with Matlab version: 7.8.0.347 (R2009a)

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

%% initialize

ok = true;

OPT.storein = '';
if nargin > 0
    [OPT,Set,Default] = setproperty(OPT, varargin{:});
end

if ~isempty(OPT.storein)
    [s,mess,messid] = mkdir(OPT.storein);
end

% create the plots for the Macrocels

% definition of variables used in the key/value pairs for function
%                                                   Westerschelde_Volumes
% trenchtype   = 'ebb';
% selectionSet = {1};     % for the given selection gives one or a set for the selection
% volumes      = {'all'}; % possible combinations from: 
%                         % total, diep, ondiep, plaat, tussen
%                         % (all = all are selected)
% plotname     = 'tweede';% the name of the plot file, default png is used
% subtitle     = 'Ebgeul Macrocel 1'%

% a set of combinations, per combination
% {set,trenchtype,plotname,subtitle}
% % combinations = {{1,'ebb'  ,'Ebb-Macrocel-1'  ,'Ebgeul Macrocel 1'   ,'southeast'}...
% %                 {1,'flood','Flood-Macrocel-1','Vloedgeul Macrocel 1','southwest'}...
% %                 {2,'flood','Mesocel-2a'       ,'Mesocel 2'           ,'northeast'}...
% %                 {3,'ebb'  ,'Ebb-Macrocel-3'  ,'Ebgeul Macrocel 3'   ,'southwest'}...
% %                 {3,'flood','Flood-Macrocel-3','Vloedgeul Macrocel 3','southwest'}...
% %                 {4,'ebb'  ,'Ebb-Macrocel-4'  ,'Ebgeul Macrocel 4'   ,'northwest'}...
% %                 {4,'flood','Flood-Macrocel-4','Vloedgeul Macrocel 4','southwest'}...
% %                 {5,'ebb'  ,'Ebb-Macrocel-5'  ,'Ebgeul Macrocel 5'   ,'southwest'}...
% %                 {5,'flood','Flood-Macrocel-5','Vloedgeul Macrocel 5','northwest'}...
% %                 {6,'ebb'  ,'Ebb-Macrocel-6'  ,'Ebgeul Macrocel 6'   ,'southwest'}...
% %                 {6,'flood','Flood-Macrocel-6','Vloedgeul Macrocel 6','southwest'}...
% %                 {7,'ebb'  ,'Ebb-Macrocel-7'  ,'Ebgeul Macrocel 7'   ,'southwest'}...
% %                 {7,'flood','Flood-Macrocel-7','Vloedgeul Macrocel 7','southwest'}...
% %                };

combinations = {{1,'trenches'  ,'Macrocel-1'  ,'Macrocel 1'   ,'southwest'}...
                {2,'trenches'  ,'Mesocel-2'   ,'Mesocel 2'    ,'northwest'}...
                {3,'trenches'  ,'Macrocel-3a'  ,'Macrocel 3'   ,'southwest'}...
                {4,'trenches'  ,'Macrocel-4'  ,'Macrocel 4'   ,'northwest'}...
                {5,'trenches'  ,'Macrocel-5'  ,'Macrocel 5'   ,'southwest'}...
                {6,'trenches'  ,'Macrocel-6'  ,'Macrocel 6'   ,'southwest'}...
                {7,'trenches'  ,'Macrocel-7'  ,'Macrocel 7'   ,'southwest'}...
               };

%                 {[1,2,3,4,5,6,7],'trenches'  ,'Alle macrocellen'   ,'Alle macrocellen'    ,'southwest'}...

           
%                 {2,'trenches'  ,'Mesocel-2'   ,'Mesocel 2'    ,'northwest'}...
           
%                 {[10,600,601,4,6,9,500,5],'trenches'  ,'Macrocel-3'  ,'Macrocel 3'   ,'southwest'}...

%                 {3,'trenches'  ,'Macrocel-3'  ,'Macrocel 3'   ,'southwest'}...
           

volumes = {'all'};

for n = 2:2 %1 : length(combinations)
    % {selectionSet,trenchtype,plotname,subtitle}
    combi        = combinations(1,n);
    combi        = combi{1};
    selectionSet = combi{1};
    trenchtype   = combi{2};
    plotname     = combi{3};
    subtitle     = combi{4};
    legend       = combi{5};

    disp (sprintf('Combination %s out of %s',num2str(n),num2str(length(combinations))));
% %     ok=Westerschelde_Volumes('d:\Zandbalans\Ingrepen\zandbalans per rekenvak tm 2008_concept-leen-uitbreiding.xls',...
% %                              'selection','Macrocel',...
% %                              'set',selectionSet,...
% %                              'trenchtype',trenchtype,...
% %                              'volumes',volumes,...
% %                              'plotname',{plotname,'png'},...
% %                              'cd',OPT.storein,...
% %                              'x','Tijd',...
% %                              'y','volume t.o.v. 1955 (m^3)',...
% %                              'subtitle',subtitle,...
% %                              'legend',legend);
    ok=Westerschelde_Volumes('d:\Zandbalans\Ingrepen\zandbalans per rekenvak tm 2008_concept-leen-uitbreiding.xls',...
                             'selection','macrocel',...
                             'set',selectionSet,...
                             'trenchtype',trenchtype,...
                             'volumes',volumes,...
                             'plotname',{plotname,'png'},...
                             'cd',OPT.storein,...
                             'x','Tijd',...
                             'y','volume t.o.v. 1955 (m^3)',...
                             'subtitle',subtitle,...
                             'legend',legend);
end
