function bOK = wind2netcdf(strOutPath, strOutFile, vDate, vWVS, vWRS, vWG3);
% function bOK = wind2netcdf(strOutPath, strOutFile, vDate, vWVS, vWRS, vWG3);
%
% Converts ASCII files with wave time series data into netCDF
% format. The ASCII files with raw data format contains significant 
% storms in 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
%           -vDate: vector (n rowsx 1 col) with the dates in Serial Date Number Format 
%           -vWVS: vector (n rowsx 1 col) with the wind velocity magnitude
%                  in m/s
%           -vWRS: vector (n rowsx 1 col) with the wind direction in
%                  degrees
%           -vWG3: vector (n rowsx 1 col) with the maximum wind velocity in
%                  the last 10min that lasts at least 3 seconds at the height
%                  of the measurement equipment in m/s
%
% #OUTPUTS: -bOK: Boolean with the result of the conversion from ASCII to netCDF
%
% #REMARKS: % Nodata values are -999.00
%           * 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: July 2009
% Modified: April 2011
% Date:

% Create output netCDF file
strPathOut = fullfile(strOutPath, strOutFile);
nc_create_empty(strPathOut);
nc_add_dimension(strPathOut, 'time', length(vDate));

% Add variables
timeVariable = struct(...
    'Name', 'Time', ...
    'Nctype', 'double', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'days') ...
    );
nc_addvar(strPathOut, timeVariable);
vWVSVariable = struct(...
    'Name', 'WVS', ...
    'Nctype', 'float', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'metre/sec') ...
    );
nc_addvar(strPathOut, vWVSVariable);
vWRSVariable = struct(...
    'Name', 'WRS', ...
    'Nctype', 'float', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'deg') ...
    );
nc_addvar(strPathOut, vWRSVariable);
vWG3Variable = struct(...
    'Name', 'WG3', ...
    'Nctype', 'float', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'metre/sec') ...
    );
nc_addvar(strPathOut, vWG3Variable);

% Put variables
nc_varput(strPathOut, 'Time', vDate);
nc_varput(strPathOut, 'WVS', vWVS);
nc_varput(strPathOut, 'WRS', vWRS);
nc_varput(strPathOut, 'WG3', vWG3);
nc_dump(strPathOut);
bOK = 1;
