% Hs comparisons, riegl and wave rider
clear
close all

dfl1 = '/Users/byronb/Raw_Data_Files.noindex/High_Wind_Flux_2013/Leeds Archive/STATS_10min_1D_all.mat';
load(dfl1); % to load waverider Hs stats
dfl2 = '/Users/byronb/Raw_Data_Files.noindex/High_Wind_Flux_2013/Leeds Archive/SPEC_10min_1D_all.mat';
load(dfl2); % to load waverider Hs stats
dfl3 = '/Users/byronb/Raw_Data_Files.noindex/HiWinGS_2013/Knorr/flux/Processed_v3/HiWinGS_2013_flux_10_v3_decorr.mat';
load(dfl3) % to import flux10 array
dfl4 = '/Users/byronb/Raw_Data_Files.noindex/HiWinGS_2013/Knorr/flux/Processed_v3/riegl_wave_data/HiWinGS_2013_WaveSpectra.mat';
load(dfl4) % to import Rgl_spectra array
dfl5 = '/Users/byronb/Raw_Data_Files.noindex/HiWinGS_2013/Knorr/flux/Processed_v3/riegl_wave_data/HiWinGS_2013_WaveStats_Hw.mat';
load(dfl5) % to import Rgl_1D_10min

Hs_WR = STATS.Hs;
jd_WR = STATS.doy;
jd_WR = floor(jd_WR*144)/144;
Tz_WR = STATS.Tz;
Sp_WR = NaN(2442,2160);
for ii = 1:2442
    if length(wSPEC1D(ii).S)==2160
        Sp_WR(ii,:) = wSPEC1D(ii).S';
    end;
end;
fwr = wSPEC1D(1).f';

jd_flux = flux10(:,1);
u10n = flux10(:,68);

jd_rgl = Rgl_1D_10min(:,1);
jd_rgl = round(jd_rgl*144)/144;
Hs_rgl = Rgl_1D_10min(:,4);
Hs_m0 = Rgl_1D_10min(:,5);
Hw_rgl = Rgl_1D_10min(:,20);
Tz_rgl = Rgl_1D_10min(:,6);
Sp_rgl = Rgl_spectra(:,158:235);
f_rgl = Rgl_spectra(1,2:79);

figure; plot(jd_rgl,Hs_rgl,'bo',jd_rgl,Hw_rgl,'go',jd_rgl,Hs_m0,'ko',jd_WR,Hs_WR,'ro'); grid;
xlabel('DOY, 2013'); xlim([258,302]); ylabel('Hs, m');
legend('Riegl Hs','Riegl Hw','Riegl Hs-SpecIntegral','WaveRider','location','northwest');
title('HiWinGS 1D Hs comparison');

% Spectra
% jd 286, hr 0, 
stjd = 286 + 0/24;
enjd = 286 + 1/24;
ww = find(jd_WR>=stjd & jd_WR<enjd);
rr = find(jd_rgl>=stjd & jd_rgl<enjd);
Swr = nanmean1(Sp_WR(ww,:),1);
[Swrb,fwrb] = logSmoothSpec_Nbins(Swr,fwr,78);
Srg = nanmean1(Sp_rgl(rr,:),1);

% plot spectrum
figure; loglog(f_rgl,Srg,'bo-',fwrb,Swrb,'ro-'); grid; xlim([0.01,10]);
xlabel('F (Hz)'); ylabel('Sw (m^2/Hz)'); legend('Riegl','WaveRider','location','northwest');
title(['HiWinGS 1D Wave Spectrum, ',sprintf('%03.3f',stjd),' to ',sprintf('%03.3f',enjd)]);

% jd 288, hr 0, 
stjd = 288 + 0/24;
enjd = 288 + 1/24;
ww = find(jd_WR>=stjd & jd_WR<enjd);
rr = find(jd_rgl>=stjd & jd_rgl<enjd);
Swr = nanmean1(Sp_WR(ww,:),1);
[Swrb,fwrb] = logSmoothSpec_Nbins(Swr,fwr,48);
Srg = nanmean1(Sp_rgl(rr,:),1);

% plot spectrum
figure; loglog(f_rgl,Srg,'bo-',fwrb,Swrb,'ro-'); grid; xlim([0.01,10]);
xlabel('F (Hz)'); ylabel('Sw (m^2/Hz)'); legend('Riegl','WaveRider','location','northwest');
title(['HiWinGS 1D Wave Spectrum, ',sprintf('%03.3f',stjd),' to ',sprintf('%03.3f',enjd)]);

% jd 299, hr 6, 
stjd = 299 + 6/24;
enjd = 299 + 7/24;
ww = find(jd_WR>=stjd & jd_WR<enjd);
rr = find(jd_rgl>=stjd & jd_rgl<enjd);
Swr = nanmean1(Sp_WR(ww,:),1);
[Swrb,fwrb] = logSmoothSpec_Nbins(Swr,fwr,48);
Srg = nanmean1(Sp_rgl(rr,:),1);

% plot spectrum
figure; loglog(f_rgl,Srg,'bo-',fwrb,Swrb,'ro-'); grid; xlim([0.01,10]);
xlabel('F (Hz)'); ylabel('Sw (m^2/Hz)'); legend('Riegl','WaveRider','location','northwest');
title(['HiWinGS 1D Wave Spectrum, ',sprintf('%03.3f',stjd),' to ',sprintf('%03.3f',enjd)]);
