You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.6 KiB
Matlab
120 lines
3.6 KiB
Matlab
7 years ago
|
% Written by Joshua Simmons 11/02/2015 and updated 17/11/2017
|
||
|
% to convert from fielddata storage struct to SBEACH toolbox.
|
||
|
|
||
|
clear
|
||
|
clc
|
||
|
|
||
|
%% Settings
|
||
|
%profiledata locations
|
||
|
basedatapath = '.\example\input_data\';
|
||
|
setupoutputpath = '.\temp\';
|
||
|
infooutpath = '.\example\setup_info\';
|
||
|
|
||
|
sbeachexepath = '.\sbeach_exe\final_exe\SBEACH.exe';
|
||
|
|
||
|
%meta
|
||
|
site = 'narrabeen';
|
||
|
stormid = '2015';
|
||
|
|
||
|
%write file to
|
||
|
writetofile = 1; %boolean 1 = write to file, 0 = just SBEACHout.
|
||
|
|
||
|
% other parameters;
|
||
|
sbts = 2; %time step length minutes
|
||
|
%% Code - format the data
|
||
|
%load profile data - account for different data names - lin/poly
|
||
|
pfdata = load([basedatapath 'morphology\processed\morphology_' site '_' stormid '.mat']);
|
||
|
fns1 = fieldnames(pfdata);
|
||
|
pfdata = pfdata.(fns1{1});
|
||
|
|
||
|
%load wavedata
|
||
|
wavedata = load([basedatapath 'fielddata\wave\processed\wavedata_' site '_' stormid '.mat']);
|
||
|
fns2 = fieldnames(wavedata);
|
||
|
wavedata = wavedata.(fns2{1});
|
||
|
|
||
|
%load tidedata
|
||
|
tidedata = load([basedatapath 'fielddata\tide\processed\tidedata_' site '_' stormid '.mat']);
|
||
|
fns3 = fieldnames(tidedata);
|
||
|
tidedata = tidedata.(fns3{1});
|
||
|
|
||
|
% load the profileinfo file
|
||
|
profileinfo = load([infooutpath 'profileinfo_' site '.mat']);
|
||
|
fns2 = fieldnames(profileinfo);
|
||
|
profileinfo = profileinfo.(fns2{1});
|
||
|
|
||
|
%check for dimension match
|
||
|
if length(pfdata.data) ~= length(wavedata.ns.data)
|
||
|
error('Wave data information does not match the morphology data')
|
||
|
end
|
||
|
|
||
|
%get the depth contour
|
||
|
sbdepth = wavedata.ns.contour(1:2);
|
||
|
|
||
|
pathrun = cell(length(pfdata.data),1);
|
||
|
|
||
|
%do the modelling
|
||
|
fprintf('Setting up %d SBEACH models...', length(pfdata.data))
|
||
|
for ii = 1:length(pfdata.data)
|
||
|
if ~isnan(pfdata.data(ii).initial.x)
|
||
|
fprintf('%d..',ii)
|
||
|
pfid = ['PF' num2str(ii)];
|
||
|
|
||
|
%get profile info
|
||
|
pfx = pfdata.data(ii).initial.x;
|
||
|
pfz = pfdata.data(ii).initial.z;
|
||
|
|
||
|
%angle of pf from true north
|
||
|
pfangle = profileinfo.data(ii).TN; %angle from true north
|
||
|
|
||
|
outpath = [setupoutputpath 'sb_' pfid '\'];
|
||
|
% outpath = [setupoutputpath 'sb_' site '_' stormid '_' pfid '\'];
|
||
|
|
||
|
sb_model = fsbeach_setupmodel(...
|
||
|
'bathy', { 'x', pfx, 'z', pfz}, ...
|
||
|
'waves', { 'time', wavedata.ns.data(ii).datenums, 'Hsig', wavedata.ns.data(ii).Hsig, 'Tp1', wavedata.ns.data(ii).Tp1, ...
|
||
|
'ang', wavedata.ns.data(ii).Wdir, 'pfang', pfangle}, ...
|
||
|
'tide', { 'time', tidedata.time,'elev', tidedata.tide}, ...
|
||
|
'settings', { 'DT', sbts, 'K', 2.5e-6, 'BMAX', 28.5, 'D50', 0.455 ...
|
||
|
}, ...
|
||
|
'path', outpath, ...
|
||
|
'name', ['sb_' pfid] ...
|
||
|
);
|
||
|
|
||
|
% variable grid can be specified in settings with e.g.:
|
||
|
% 'NGRID', 3, 'DXV', [1 5 10], 'NDXV', [115 30 28]
|
||
|
|
||
|
% hard bottom can be specified in bathy with e.g.:
|
||
|
% 'hbz', pfz-1
|
||
|
|
||
|
measured(ii).x = pfdata.data(ii).measured.x;
|
||
|
measured(ii).z = pfdata.data(ii).measured.z;
|
||
|
|
||
|
pathrun{ii} = sb_model.path;
|
||
|
end
|
||
|
end
|
||
|
|
||
|
fprintf('\n')
|
||
|
fprintf('Running %d SBEACH models...', length(pathrun))
|
||
|
%now run sbeach EXE on the files setup
|
||
|
for ii = 1:length(pathrun)
|
||
|
fprintf('%d..',ii)
|
||
|
[fail, cmdout] = fsbeach_runmodel(pathrun{ii},sbeachexepath);
|
||
|
if fail
|
||
|
error(cmdout);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
fprintf('\n')
|
||
|
fprintf('Collecting SBEACH results...\n')
|
||
|
%now collect the sbeach results
|
||
|
sbout = fsbeach_collectresults(pathrun);
|
||
|
|
||
|
fprintf('Getting measured data...\n')
|
||
|
%attached the measured data
|
||
|
sbout.measured = measured;
|
||
|
|
||
|
fprintf('Processing SBEACH results...\n')
|
||
|
%evaulate results
|
||
|
sbout = fsbeach_processresults(sbout);
|
||
|
|
||
|
fprintf('Done!\n')
|