function [vDate, vWVS, vWRS, vWG3] = readwind(strPath, strInFile);
% function [vDate, vWVS, vWRS, vWG3] = readwind(strPath, strInFile, nCols);
%
% Reads raw data with time series of wind information for periods with significant 
% storms in the Belgiam coast.
% The data has been prepared for the MICORE project: www.micore.eu
% Raw data is in ASCII files and this function is called by another
% functions to convert these raw data files into netCDF format.
%
% #INPUTS:  -strPath: string with the directory path where the raw data is
%            saved. Relative paths are allowed, e.g. '../raw/19931115/'.
%            Include the / sign at the end of the string.
%           -strInFile: string with the name of the input ASCII file.
%            Usually it is a file with 4 columns (date, WVS, WRS and WG3)
%            but some files have only 3 columns (date, WVS and WRS) and some
%            other files have 6 columns (the last two columns are with dummy
%            data).
%           -nCols: total number of columns in the file, taking into
%            account the first column with the date.
%
% #OUTPUTS: -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
%
% #REMARKS: The format of the raw data ASCII file is:
%           - Lines of comments starting with % sign
%           - 1st column date: YYYYMMDD.HHmmSS
%           - Rest of the columns: data. Nodata values are -999.00
%

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

% Read water levels file from IMDC data
path = fullfile(strPath, strInFile);
% if (nCols == 3)
%     data = load(path);
%     values = [data(:,1) data(:,2) data(:,3) -999*ones(size(data,1),1)];
% elseif (nCols == 4)
%     data = load(path);
%     values = [data(:,1) data(:,2) data(:,3) data(:,4)];
% else
%     data = load(path);
%     values = [data(:,1) data(:,2) data(:,3) data(:,4)];
% end

NumLines = 1;
strDelimiter = '/:|';
[B(:,1) B(:,2) B(:,3) B(:,4) B(:,5) vWVS vWRS vWG3] = textread(path, ...
    '%d %d %d %d %d %f %f %f', 'headerlines', NumLines, 'delimiter',strDelimiter);
vDate = datenum(B(:,3), B(:,2), B(:,1), B(:,4), B(:,5), 0);
