start_Katrina = datenum(2005,8,23,0,0,0)
end_Katrina = datenum(2005,8,31,0,0,0);

%% shallow water = buoy 42007
shallow_water = load('42007.mat');
shallow_Time = shallow_water.D.stdmet.time;
shallow_waveheights = shallow_water.D.stdmet.wave_height;
buolian_Time = shallow_Time>start_Katrina & shallow_Time<end_Katrina;
shallow_water_waveheights_Katrina = shallow_waveheights(buolian_Time);
shallow_water_time_Katrina = shallow_Time(buolian_Time);
plot(shallow_water_time_Katrina,shallow_water_waveheights_Katrina,'r');

%% deep water = buoy 42007
deep_water = load('42040.mat')
deep_water_waveheight = deep_water.D.stdmet.wave_height;
deep_water_Time = deep_water.D.stdmet.time;
buolian_Time = deep_water_Time>start_Katrina & deep_water_Time<end_Katrina;
deep_water_waveheights_Katrina = deep_water_waveheight(buolian_Time);
deep_water_time_Katrina = deep_water_Time(buolian_Time);
plot(deep_water_time_Katrina,deep_water_waveheights_Katrina,'r');

% select the highest waves
[y x] = sort(deep_water_waveheights_Katrina);
x = deep_water_time_Katrina(x);
heighest_48Waves = y((end-47):end);
heighest_48WavesTime = x((end-47):end);
[x y] = sort(heighest_48WavesTime);
y  = heighest_48Waves(y);

figure();plot(x,y,'.r');
hold on;
plot(x((end-46):end),y((end-46):end),'.g');

% surge as input for Katrina as in input XBeach model
CorpsData = load(fullfile(fileparts(which(mfilename)),'..','Buoy','corpsData','corpsData.mat'));
surgeDates = CorpsData.C(1,1).dates;
surgeHeight = CorpsData.C(1,1).wl;

plot(surgeDates,surgeHeight,'.r')
hold on
plot(surgeDates(1:2:end),surgeHeight(1:2:end),'.g')


figure();plot(surgeHeight(1:2:end),y,'.k')



