function varargout = vaklodingen2jarkus_transect_netcdf(varargin)
%VAKLODINGEN2JARKUS_TRANSECT_NETCDF  One line description goes here.
%
%   More detailed description goes here.
%
%   Syntax:
%   varargout = vaklodingen2jarkus_transect_netcdf(varargin)
%
%   Input: For <keyword,value> pairs call vaklodingen2jarkus_transect_netcdf() without arguments.
%   varargin  =
%
%   Output:
%   varargout =
%
%   Example
%   vaklodingen2jarkus_transect_netcdf
%
%   See also

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2013 Deltares
%       Kees den Heijer
%
%       Kees.denHeijer@Deltares.nl
%
%       Deltares
%       P.O. Box 177
%       2600 MH 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: 21 Feb 2013
% Created with Matlab version: 7.13.0.564 (R2011b)

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

%%
OPT = struct(...
    'dataDir', '..');

outputfile      = ['jarkus_vaklodingen_' date '.nc'];

transectStruct = vaklodingen2jarkus_transectstruct(...
    'url', 'jarkus135_21-Feb-2013.nc',...
    'year', 1926:year(now),...
...    'id', 7000000:7000100,...
    'areacode', 7:9);

%% define a grid based on the transectStruct

disp('converting transects to grid');
grid = jarkus_transect2grid(transectStruct);% renamed from transect2grid 2009 june 19th
grid = jarkus_updategrid(grid, fullfile(OPT.dataDir, 'raw', 'info', 'raaien.txt'  ), ...
                               fullfile(OPT.dataDir, 'raw', 'info', 'TIDEINFO.txt')); % this file contains extra information

%% store grid and transects to a netcdf file
disp('Publish grid to NetCDF file');
jarkus_grid2netcdf(outputfile, grid);

%% extract a curvilinear grid definition from the transectStruct x grid H(time, transect, length) where
%  * time is the year, 
%  * transect is the transect and 
%  * lenght is the difference along the line starting from the measurement pole.
disp('Publish transects to a NetCDF file');
jarkus_transect2netcdf(outputfile, transectStruct);
