function bOK = bathy2netcdf(strPath, strOutFileNetCFD, mData);
% function bOK = bathy2netcdf(strPath, strOutFileNetCFD, mData);
%
% Converts ASCII files with bahtymetric data to netcdf files.
% The ASCII files with raw data format contains bathymetry for the baseline measurements at
% Mariakerke, the Belgiam coast.
% The data has been prepared for the MICORE project: www.micore.eu
%
% #INPUTS:  -strOutPath: string with the dictory path where the output file
%            will be saved. Relative paths are allowed, e.g. '../raw/19931115/'.
%           -strOutFile: string with the name of the output file in format
%            netCDF
%
% #OUTPUTS: -bOK: Boolean with the result of the conversion from ASCII to netCDF
%
% #REMARKS: * This function calls functions from the OpenEarth Matlab
%             library
%

% International Marine and Dredging Consultants, IMDC
% www.imdc.be
% Antwerp, Belgium
%
% Written by: Fernando Toro, Piet Haerens
%             fto@imdc.be
% Date: 02 November 2009
% Modified: FTO April 2011
% Date:

% Read raw data input file
vx = mData(:,1);
vy = mData(:,2);
vz = mData(:,3);

% Create output netCDF file
strPathOut = fullfile(strPath, strOutFileNetCFD);
nc_create_empty(strPathOut);
nc_add_dimension(strPathOut, 'points', length(vx));
xVariable = struct(...
    'Name', 'x', ...
    'Nctype', 'double', ...
    'Dimension', {{'points'}}, ...
    'Attribute', struct('Name', {'unit','standard_name'}, 'Value', {'meters','projection_x_coordinate'}) ...
    );
nc_addvar(strPathOut, xVariable);
yVariable = struct(...
    'Name', 'y', ...
    'Nctype', 'double', ...
    'Dimension', {{'points'}}, ...
    'Attribute', struct('Name', {'unit','standard_name'}, 'Value', {'meters','projection_y_coordinate'}) ...
    );
nc_addvar(strPathOut, yVariable);
zVariable = struct(...
    'Name', 'z', ...
    'Nctype', 'double', ...
    'Dimension', {{'points'}}, ...
    'Attribute', struct('Name', {'unit','standard_name','positive'}, 'Value', {'meters','sea_surface_elevation','up'}) ...
    );
nc_addvar(strPathOut, zVariable);

nc_varput(strPathOut, 'x', vx);
nc_varput(strPathOut, 'y', vy);
nc_varput(strPathOut, 'z', vz);
nc_dump(strPathOut);
bOK = 1;
