% Convert waterbase data for vlugtenburg analyse
% Run oetsettings.m first
clear all

% check if you have ran oetsettings.m
if exist ('setProperty.m') ~= 2
    error ('DUDE...  run OETsettings first man!')
end


Var=1
if Var==1
filename='id22-EURPFM-200904010000-201312312359 (2).txt' 
% this file can be downloaded from waterbase via the following link
% http://live.waterbase.nl/wboutput.cfm?loc=EURPFM&wbwns=22%7CSignificante+golfhoogte+uit+energiespectrum+van+30-500+mhz+in+cm+in+oppervlaktewater&byear=2009&bmonth=04&bday=01&eyear=2013&emonth=12&eday=31&output=Tekst&whichform=2

% Convert txt file to structure
DAT = rws_waterbase_read_edit(filename)

% save in handy matrix
Hs=[DAT.data.datenum DAT.data.waarde];
Hs_text='Hs @ Europlatform. (column 1 = Matlab time, column 2 = Hs in cm)';
cd ..
save ('EURHs.mat','Hs','Hs_text')

disp('EURHS.mat created')

%plot wave timeseries
figure
plot(DAT.data.datenum,DAT.data.waarde);
datetick('x')
title({ DAT.data.location ; DAT.data.waarnemingssoort})


cd Rawdata
end

if Var==2
filename='id24-EURPFM-200904010000-201312312359 (2).txt' 
% this file can be downloaded from waterbase via the following link
% http://live.waterbase.nl/wboutput.cfm?loc=EURPFM&wbwns=24%7CGem.+golfperiode+uit+spectrale+momenten+m0%2Bm2+van+30-500+mhz+in+s+in+oppervlaktewater&byear=2009&bmonth=04&bday=01&eyear=2013&emonth=12&eday=31&output=Tekst&whichform=2
% Convert txt file to structure
DAT = rws_waterbase_read_edit(filename)

% save in handy matrix
T=[DAT.data.datenum DAT.data.waarde];
T_text='T @ Europlatform. (column 1 = Matlab time, column 2 = T in s)';
cd ..
save ('EURT.mat','T','T_text')

disp('EURT.mat created')

%plot wave timeseries
figure
plot(DAT.data.datenum,DAT.data.waarde);
datetick('x')
title({ DAT.data.location ; DAT.data.waarnemingssoort})


% angle
cd Rawdata
end

if Var==3
filename='id23-EURPFM-200904010000-201312312359 (2).txt' 
% this file can be downloaded from waterbase via the following link
% http://live.waterbase.nl/wboutput.cfm?loc=EURPFM&wbwns=23%7CAverage+direction+of+wave+direction+spectra+30-500+mhz+%28with+respect+to+kaartnrdn%29+in+graad+with+respect+to+map+north+in+surface+water&byear=2009&bmonth=04&bday=01&eyear=2013&emonth=12&eday=31&output=Tekst&whichform=2% Convert txt file to structure
DAT = rws_waterbase_read_edit(filename)

% save in handy matrix
Dir=[DAT.data.datenum DAT.data.waarde];
Dir_text='Dir @ Europlatform. (column 1 = Matlab time, column 2 = Dir in deg N)';
cd ..
save ('EURdir.mat','Dir','Dir_text')

disp('EURDir.mat created')

%plot wave timeseries
figure
plot(DAT.data.datenum,DAT.data.waarde);
datetick('x')
title({ DAT.data.location ; DAT.data.waarnemingssoort})

end
