%% Read and process results from long term DUNEX Run addpath(genpath('matlab/applications/delft3d_matlab'),'-begin') addpath(genpath('D:/DUNEX_RT/Operation/Hindcast'),'-begin') %% Model Results 9 %trihPath = 'D:\DUNEX_RT\Operation\Hindcast\Setup\trih-dunx22.dat'; trihPath = 'D:\Alexander\Setup8_NoWaves\trih-dunx22.dat'; % trihPath = 'D:\Alexander\Setup8_NoWind_NoWaves\trih-dunx22.dat'; % trihPath = '\\tsclient\F\DUNEX_RT\trih-dunx22.dat'; runSteps = 1:8785; % Read in model data modelHistNamesB = qpread(qpfopen(trihPath),1,'water level','stations'); modelHistWLB = qpread(qpfopen(trihPath),1,'water level','griddata',runSteps,[98:129 6 7 8 9]); modelHistVelB = qpread(qpfopen(trihPath),1,'depth averaged velocity','griddata',runSteps,[98:129 6 7 8 9]); modelHistWaveHeightB = qpread(qpfopen(trihPath),1,'significant wave height','griddata',runSteps,[98:129 6 7 8 9]); modelHistWavePerB = qpread(qpfopen(trihPath),1,'peak wave period','griddata',runSteps,[98:129 6 7 8 9]); modelHistWaveDirB = qpread(qpfopen(trihPath),1,'wave direction','griddata',runSteps,[98:129 6 7 8 9]); modelHistWindSpeedB = qpread(qpfopen(trihPath),1,'wind speed','griddata',runSteps,[98:129 6 7 8 9]); modelHistWindDirB = qpread(qpfopen(trihPath),1,'wind direction','griddata',runSteps,[98:129 6 7 8 9]); %% Model Results trihPath = 'D:\Alexander\Setup8\trih-dunx22.def'; % trihPath = 'D:\Alexander\Setup8_NoWind_NoWaves\trih-dunx22.dat'; % trihPath = 'D:\Alexander\Setup8_NoWind\trih-dunx22.dat'; runSteps = 1:8785; % Read in model data modelHistNames = qpread(qpfopen(trihPath),1,'water level','stations'); modelHistWL = qpread(qpfopen(trihPath),1,'water level','griddata',runSteps,[98:129 6 7 8 9]); modelHistVel = qpread(qpfopen(trihPath),1,'depth averaged velocity','griddata',runSteps,[98:129 6 7 8 9]); modelHistWaveHeight = qpread(qpfopen(trihPath),1,'significant wave height','griddata',runSteps,[98:129 6 7 8 9]); modelHistWavePer = qpread(qpfopen(trihPath),1,'peak wave period','griddata',runSteps,[98:129 6 7 8 9]); modelHistWaveDir = qpread(qpfopen(trihPath),1,'wave direction','griddata',runSteps,[98:129 6 7 8 9]); modelHistWindSpeed = qpread(qpfopen(trihPath),1,'wind speed','griddata',runSteps,[98:129 6 7 8 9]); modelHistWindDir = qpread(qpfopen(trihPath),1,'wind direction','griddata',runSteps,[98:129 6 7 8 9]); %% WL QA/AC axisLimits=[datetime(2020,07,20) datetime(2020,10,01,00,00,00)]; dateStart = axisLimits(1); dateEnd = axisLimits(2); delfTime = axisLimits(1):minutes(10):axisLimits(2); %% Read in WL stations{6} = 8651370; %Dck stations{7} = 8652587; %Oregon Inlet stations{8} = 8654467; %Hatteras stations{9} = 8656483; %Beau for Stat=[6 7 8 9] for Month = 1:3 if Month==1 dateStartM=dateStart +((Month-1).*days(31)); dateEndM=dateStart +((Month).*days(31)); else dateStartM=dateEndM + days(1); dateEndM=dateStart +((Month).*days(31)); end url = ['https://tidesandcurrents.noaa.gov/api/datagetter?product=water_level&application=NOS.COOPS.TAC.WL&'... 'begin_date=' datestr(dateStartM,'yyyymmdd') '&end_date=' datestr(dateEndM,'yyyymmdd') '&datum=NAVD' '&station=' num2str(stations{Stat})... '&time_zone=GMT&units=metric&format=csv']; wlIN = webread(url); if Month==1 measuredWL_D = datenum(wlIN.DateTime); measuredWL_W = wlIN.WaterLevel; else measuredWL_D = vertcat(measuredWL_D,datenum(wlIN.DateTime)); measuredWL_W = vertcat(measuredWL_W,wlIN.WaterLevel); end clear windIN wlIN end switch Stat case 6 tideOutN = interp1(measuredWL_D,... measuredWL_W,... datenum(axisLimits(1):minutes(10):axisLimits(2))); case 7 tideOutOI = interp1(measuredWL_D,... measuredWL_W,... datenum(axisLimits(1):minutes(10):axisLimits(2))); case 8 tideOutHat = interp1(measuredWL_D,... measuredWL_W,... datenum(axisLimits(1):minutes(10):axisLimits(2))); case 9 tideOutS = interp1(measuredWL_D,... measuredWL_W,... datenum(axisLimits(1):minutes(10):axisLimits(2))); end end %% Read in merged WL MergedWL_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_WL.csv'); MergedHs_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_SigWave.csv'); MergedDir_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_Dir.csv'); MergedPer_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_Period.csv'); MergedVelX_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_VelX.csv'); MergedVelY_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_VelY.csv'); MergedWindD_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_WindDir.csv'); MergedWindS_Table = readtable('D:\Alexander\MATLAB\DunexBounds\Dunex_RT_WindSpeed.csv'); %% Hs QA/QC % Read in NDBC StatCount=1; for Station = [44095] buoyIn{StatCount} = readtable(... ['D:\DUNEX_RT\Operation\Hindcast\Buoy\'... num2str(Station) 'h2020.txt']); buoyOut{StatCount} = struct; buoyOut{StatCount}.WVHT = buoyIn{StatCount}.WVHT; buoyOut{StatCount}.DateTime = datetime(buoyIn{StatCount}.x_YY,... buoyIn{StatCount}.MM,buoyIn{StatCount}.DD,buoyIn{StatCount}.hh,... buoyIn{StatCount}.mm,0); buoyOut{StatCount}.DateTime(buoyOut{StatCount}.WVHT==99) = []; buoyOut{StatCount}.WVHT(buoyOut{StatCount}.WVHT==99) = []; StatCount=StatCount+1; end %% Create FrankenTimeline Dunex_RT_WL = MergedWL_Table; Dunex_RT_SigWave = MergedHs_Table; Dunex_RT_Dir = MergedDir_Table; Dunex_RT_Period = MergedPer_Table; Dunex_RT_VelX = MergedVelX_Table; Dunex_RT_VelY = MergedVelY_Table; Dunex_RT_WindDir = MergedWindD_Table; Dunex_RT_WindSpeed = MergedWindS_Table; for i = 1:32 modelWL_Inter(:, i) = interp1(modelHistWL.Time,... modelHistWL.Val(:,i), datenum(MergedWL_Table.DateTime)); modelHs_Inter(:, i) = interp1(modelHistWaveHeight.Time,... modelHistWaveHeight.Val(:,i), datenum(MergedHs_Table.DateTime)); modelDir_Inter(:, i) = interp1(modelHistWaveDir.Time,... modelHistWaveDir.Val(:,i), datenum(MergedDir_Table.DateTime)); modelPer_Inter(:, i) = interp1(modelHistWavePer.Time,... modelHistWavePer.Val(:,i), datenum(MergedPer_Table.DateTime)); modelVelX_Inter(:, i) = interp1(modelHistVel.Time,... modelHistVel.XComp(:,i), datenum(MergedVelX_Table.DateTime)); modelVelY_Inter(:, i) = interp1(modelHistVel.Time,... modelHistVel.YComp(:,i), datenum(MergedVelY_Table.DateTime)); modelWindD_Inter(:, i) = interp1(modelHistWindDir.Time,... modelHistWindDir.Val(:,i), datenum(MergedWindD_Table.DateTime)); modelWindS_Inter(:, i) = interp1(modelHistWindSpeed.Time,... modelHistWindSpeed.Val(:,i), datenum(MergedWindS_Table.DateTime)); Dunex_RT_WL{isnan(Dunex_RT_WL{:,i}), i} =... modelWL_Inter(isnan(Dunex_RT_WL{:,i}), i); Dunex_RT_SigWave{isnan(Dunex_RT_SigWave{:,i}), i} =... modelHs_Inter(isnan(Dunex_RT_SigWave{:,i}), i); Dunex_RT_Dir{isnan(Dunex_RT_Dir{:,i}), i} =... modelDir_Inter(isnan(Dunex_RT_Dir{:,i}), i); Dunex_RT_Period{isnan(Dunex_RT_Period{:,i}), i} =... modelPer_Inter(isnan(Dunex_RT_Period{:,i}), i); Dunex_RT_VelX{isnan(Dunex_RT_VelX{:,i}), i} =... modelVelX_Inter(isnan(Dunex_RT_VelX{:,i}), i); Dunex_RT_VelY{isnan(Dunex_RT_VelY{:,i}), i} =... modelVelY_Inter(isnan(Dunex_RT_VelY{:,i}), i); Dunex_RT_WindDir{isnan(Dunex_RT_WindDir{:,i}), i} =... modelWindD_Inter(isnan(Dunex_RT_WindDir{:,i}), i); Dunex_RT_WindSpeed{isnan(Dunex_RT_WindSpeed{:,i}), i} =... modelWindS_Inter(isnan(Dunex_RT_WindSpeed{:,i}), i); end %% Plot WL Hat wlValF = figure subplot(2,1,1) title('Hatteras Coast Guard') hold on plot(modelHistWL.Time, modelHistWL.Val(:,35),'-r') % plot(modelHistWLB.Time, modelHistWLB.Val(:,35),'-b') plot(datenum(axisLimits(1):minutes(10):axisLimits(2)), tideOutHat, '-k') % plot(datenum(MergedWL_Table.DateTime),MergedWL_Table.x106_DUNEX_9,'-b') % plot(datenum(Dunex_RT_WL.DateTime),Dunex_RT_WL.x106_DUNEX_9,'-m') legend('Large-scale Model','Observations','Orientation','horizontal','Location','south') ylabel('Water Level [m]') ax=gca; ax.XLim = datenum([datetime(2020,08,01,00,00,00) datetime(2020,10,01,00,00,00)]); ax.YLim = [-0.5 0.75]; datetick('x','keeplimits') % figure subplot(2,1,2) title('Oregon Inlet Marina') hold on plot(modelHistWL.Time, modelHistWL.Val(:,34),'-r') % plot(modelHistWLB.Time, modelHistWLB.Val(:,34),'-b') % plot(datenum(axisLimits(1):minutes(10):axisLimits(2)), tideOutS, '-k') plot(datenum(axisLimits(1):minutes(10):axisLimits(2)), tideOutOI, '-k') % plot(datenum(MergedWL_Table.DateTime),MergedWL_Table.x106_DUNEX_9,'-b') % plot(datenum(Dunex_RT_WL.DateTime),Dunex_RT_WL.x106_DUNEX_9,'-m') legend('Large-scale Model','Observations','Orientation','horizontal','Location','south') ylabel('Water Level [m]') ax=gca; ax.XLim = datenum([datetime(2020,08,01,00,00,00) datetime(2020,10,01,00,00,00)]); ax.YLim = [-0.5 1]; datetick('x','keeplimits') wlValF.Units='inches'; wlValF.PaperOrientation='portrait'; wlValF.Position=[0 0 8 4]; exportgraphics(wlValF, 'D:\Alexander\LargeScaleWL_Val.png', 'Resolution', 300) %% Plot Hs figure hold on plot(modelHistWaveHeight.Time, modelHistWaveHeight.Val(:,34),'-r') % plot(datenum(axisLimits(1):minutes(10):axisLimits(2)), tideOutS, '-k') plot(datenum(buoyOut{3}.DateTime), buoyOut{3}.WVHT, '-k') % plot(datenum(MergedHs_Table.DateTime),MergedHs_Table.x129_DUNEX_32,'-b') plot(datenum(MergedHs_Table.DateTime),MergedHs_Table.x106_DUNEX_3,'-b') plot(datenum(Dunex_RT_SigWave.DateTime),Dunex_RT_SigWave.x106_DUNEX_3,'-m') datetick('x','keeplimits') %% Save writetable(Dunex_RT_WL, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_WL_RevB.csv') writetable(Dunex_RT_SigWave, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_SigWave_RevB.csv') writetable(Dunex_RT_Dir, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_Dir_RevB.csv') writetable(Dunex_RT_Period, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_Period_RevB.csv') writetable(Dunex_RT_VelX, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_VelX_RevB.csv') writetable(Dunex_RT_VelY, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_VelY_RevB.csv') writetable(Dunex_RT_WindDir, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_WindDir_RevB.csv') writetable(Dunex_RT_WindSpeed, 'D:\Alexander\MATLAB\DunexBoundsB\Dunex_RT_WindSpeed_RevB.csv') %% Save Raw Model varNames = {'WL', 'SigWave', 'Dir', 'Period', 'VelX', 'VelY', 'WindDir', 'WindSpeed'}; for v = 1:8%[1 5 6 7 8] clear table_Raw switch v case 1 table_Raw = array2table(modelHistWL.Val); case 2 table_Raw = array2table(modelHistWaveHeight.Val); case 3 table_Raw = array2table(modelHistWaveDir.Val); case 4 table_Raw = array2table(modelHistWavePer.Val); case 5 table_Raw = array2table(modelHistVel.XComp); case 6 table_Raw = array2table(modelHistVel.YComp); case 7 table_Raw = array2table(modelHistWindSpeed.Val); case 8 table_Raw = array2table(modelHistWindDir.Val); end table_Raw.Properties.VariableNames = modelHistNames([98:129 6 7 8 9]); table_Raw.DateTime = datetime(datevec(modelHistWL.Time)); writetable(table_Raw, ['D:\Alexander\MATLAB\DUNEX_NoWind\Dunex_RT_NoWind'... varNames{v} '.csv']) end