%Plot time-series from buoys over lake Michigan
%Last updated: 11/13/2016
clear all; close all; clc;
addpath('C:\Program Files\MATLAB\R2016a\work');

%--------------------------------------------------------------------------
ROOT_DIR = 'D:\Backup\Dropbox\Works_Ongoing\Papers\01-PRIORITY\Papers_OpticalTurbulence\Work_Ducting_GrandHaven\';
DATA_DIR = [ROOT_DIR 'DATA\Buoy\'];
FIG_DIR  = [ROOT_DIR 'Figures\'];

[h1,D1]  = hdrload([DATA_DIR '45007.txt']); 
%#YY  MM DD hh mm WDIR WSPD GST  WVHT   DPD   APD MWD   PRES  ATMP  WTMP  DEWP  VIS  TIDE
%#yr  mo dy hr mn degT m/s  m/s     m   sec   sec degT   hPa  degC  degC  degC   mi    ft
%Size: 5828 x 18

[h2,D2]  = hdrload([DATA_DIR 'HLNM4.txt']); 
%#YY  MM DD hh mm WDIR WSPD GST  WVHT   DPD   APD MWD   PRES  ATMP  WTMP  DEWP  VIS  TIDE
%#yr  mo dy hr mn degT m/s  m/s     m   sec   sec degT   hPa  degC  degC  degC   mi    ft
%Size: 87413 x 18

[h3,D3]  = hdrload([DATA_DIR 'MKGM4.txt']); 
%#YY  MM DD hh mm WDIR WSPD GST  WVHT   DPD   APD MWD   PRES  ATMP  WTMP  DEWP  VIS  TIDE
%#yr  mo dy hr mn degT m/s  m/s     m   sec   sec degT   hPa  degC  degC  degC   mi    ft
%Size: 8349 x 18

[h4,D4]  = hdrload([DATA_DIR 'MLWW3.txt']); 
%#YY  MM DD hh mm WDIR WSPD GST  WVHT   DPD   APD MWD   PRES  ATMP  WTMP  DEWP  VIS  TIDE
%#yr  mo dy hr mn degT m/s  m/s     m   sec   sec degT   hPa  degC  degC  degC   mi    ft
%Size: 7604 x 18
%--------------------------------------------------------------------------

%--------------------------------------------------------------------------
%Day/Month of interest: May 11, 2012
I1 = find(D1(:,1) == 2012 & D1(:,2) == 5 & D1(:,3) == 11); 
T1 = datenum(D1(I1,1),D1(I1,2),D1(I1,3),D1(I1,4),D1(I1,5),0*D1(I1,5)); 
ATMP1 = D1(I1,14); WTMP1 = D1(I1,15); M1 = D1(I1,7);
III = find(ATMP1 == 999); ATMP1(III) = NaN; clear III;
III = find(WTMP1 == 999); WTMP1(III) = NaN; clear III;

I2 = find(D2(:,1) == 2012 & D2(:,2) == 5 & D2(:,3) == 11); 
T2 = datenum(D2(I2,1),D2(I2,2),D2(I2,3),D2(I2,4),D2(I2,5),0*D2(I2,5)); 
ATMP2 = D2(I2,14); WTMP2 = D2(I2,15); M2 = D2(I2,7);
III = find(ATMP2 == 999); ATMP2(III) = NaN; clear III;
III = find(WTMP2 == 999); WTMP2(III) = NaN; clear III;

I3 = find(D3(:,1) == 2012 & D3(:,2) == 5 & D3(:,3) == 11); 
T3 = datenum(D3(I3,1),D3(I3,2),D3(I3,3),D3(I3,4),D3(I3,5),0*D3(I3,5)); 
ATMP3 = D3(I3,14); WTMP3 = D3(I3,15); M3 = D3(I3,7);
III = find(ATMP3 == 999); ATMP3(III) = NaN; clear III;
III = find(WTMP3 == 999); WTMP3(III) = NaN; clear III;

I4 = find(D4(:,1) == 2012 & D4(:,2) == 5 & D4(:,3) == 11); 
T4 = datenum(D4(I4,1),D4(I4,2),D4(I4,3),D4(I4,4),D4(I4,5),0*D4(I4,5)); 
ATMP4 = D4(I4,14); WTMP4 = D4(I4,15); M4 = D4(I4,7);
III = find(ATMP4 == 999); ATMP4(III) = NaN; clear III;
III = find(WTMP4 == 999); WTMP4(III) = NaN; clear III;

Tini = datenum(2012,5,11,0,0,0); 

figure(1); 
plot(24*(T1-Tini),WTMP1+273.16,'o-k'); hold on;
plot(24*(T1-Tini),ATMP1+273.16,'o-r','MarkerFaceColor','r');
plot(24*(T2-Tini),ATMP2+273.16,'+-b','MarkerFaceColor','b');
plot(24*(T3-Tini),ATMP3+273.16,'p-m','MarkerFaceColor','m');
plot(24*(T4-Tini),ATMP4+273.16,'s-g','MarkerFaceColor','g');
hold off;
xlabel('Time (UTC)','FontSize',18);
ylabel('Temperature (K)','FontSize',18);
set(gca,'XLim',[0 12],'YLim',[280 290],'FontSize',18);
legend('45007 (Water)','45007 (Air)','HLNM4 (Air)','MKGM4 (Air)','MLWW3 (Air)');
LG = legend('Orientation','Horizontal','Location','North');
set(LG,'FontSize',9)
legend boxoff;
d = daspect; daspect([0.33*d(1) d(2) d(3)]);
print([FIG_DIR 'Buoy_Temp.eps'],'-depsc');

figure(1); 
plot(24*(T1-Tini),M1,'o-r','MarkerFaceColor','r'); hold on;
plot(24*(T2-Tini),M2,'+-b','MarkerFaceColor','b');
plot(24*(T3-Tini),M3,'p-m','MarkerFaceColor','m');
plot(24*(T4-Tini),M4,'s-g','MarkerFaceColor','g');
hold off;
xlabel('Time (UTC)','FontSize',18);
ylabel('Wind Speed (m s^{-1})','FontSize',18);
set(gca,'XLim',[0 12],'YLim',[0 10],'FontSize',18);
legend('45007','HLNM4','MKGM4','MLWW3');
LG = legend('Orientation','Horizontal','Location','North');
set(LG,'FontSize',9)
legend boxoff;
d = daspect; daspect([0.33*d(1) d(2) d(3)]);
print([FIG_DIR 'Buoy_Wind.eps'],'-depsc');
%--------------------------------------------------------------------------
