📄 actoolboxfrontend.m
字号:
case 'PltModeLocations',
PlotModes([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltModeShapes',
PlotModeShapes([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltEnvironment',
PlotEnvironment(Def.Environment);
State = 'PlotMenu';
case 'ViewFiles',
ViewOpt = menu('File view options', ...
'View log (.prn) file', ...
'View environment (.env) file', ...
'Main menu');
switch ViewOpt
case 1,
State = 'ViewPrn';
case 2,
State = 'ViewEnv';
case 3,
State = 'MainMenu';
end
case 'ViewPrn',
lViewFile([DirInfo.MainWork Def.SubDir], '*.prn');
State = 'ViewFiles';
case 'ViewEnv',
lViewFile([DirInfo.MainWork Def.SubDir], '*.env');
State = 'ViewFiles';
end %switch State
end %while ~Done
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Def = lLoadDefaultParams(DirInfo, DefFName)
Def = [];
Def.Title = 'Default run parameters'; %Title for run
Def.Freq = [10 20 50 100 200 500]; %Frequency(s) (may be an array definition) (Hz)
Def.Zs = 10; %Source depth (m)
Def.Zr = [5:5:150]; %Receiver depth (may be an array definition) (m)
Def.RMin = 100; %Minimum range (m)
Def.RMax = 1000; %Maximum range (m)
Def.NRange = 200; %Number of range steps
Def.SubDir = '';
Def.FPrefix = 'Test';
Def.ManualEnvEdit = 0;
Def.Environment = AcEnvironment('Default', DirInfo);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Def = lOpenRunDef(DirInfo)
Here = pwd;
Status = 1;
if ~exist(DirInfo.RunDef, 'dir')
Status = LibMakeDirectory(DirInfo.RunDef);
if ~Status
uiwait(warndlg(['Couldn''t make directory ' DirInfo.RunDef]));
end
end
if Status
cd(DirInfo.RunDef);
[File, Path] = uigetfile('*.mat', 'Run definition file');
cd(Here);
Def = [];
if File ~= 0
load([Path File]); %loads Def structure
if ~isfield(Def, 'SubDir')
Def.SubDir = '';
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function lSaveRunDef(DirInfo, Def)
Here = pwd;
Status = 1;
if ~exist(DirInfo.RunDef, 'dir')
Status = LibMakeDirectory(DirInfo.RunDef);
end
if ~Status
uiwait(warndlg(['Couldn''t make directory: ' DirInfo.RunDef ', run definition not saved']));
else
cd(DirInfo.RunDef);
[File, Path] = uiputfile('*.mat', 'Environment definition file');
cd(Here);
if File ~= 0
save([Path File], 'Def'); %saves Def structure
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Def = lRunPropagationCode(Def, DefFName)
%Make sure the directory information is up to date
DirInfo = GetAcDirectoryInfo;
Def.Environment = SetDirInfo(Def.Environment, DirInfo);
ExtraParams = [];
Opt = menu('Choose code to run:', ...
'Kraken', ...
'KrakenC', ...
'Scooter', ...
'Bellhop',...
'Reflection coefft calc (Bounce)', ...
'Greens function calc (Scooter)', ...
'Main menu' ...
);
switch Opt
case 1,
RunID = 'Kraken';
case 2,
RunID = 'Krakenc';
case 3,
RunID = 'Scooter';
case 4,
RunID = 'Bellhop';
case 5,
RunID = 'Bounce';
case 6,
RunID = 'GreensFn';
case 7,
return;
end
FreqVec = Def.Freq;
Status = 1;
switch RunID
case 'Krakenc',
[Status, ExtraParams] = lSetKrakencParams(Def, RunID);
case 'Bellhop',
[Status, ExtraParams] = lSetBellhopParams(Def, RunID);
end
if Status
Ans = inputdlg({'File prefix'}, '', 1, {Def.FPrefix});
if isempty(Ans)
Status = 0;
else
Def.FPrefix = Ans{1};
end
end
if Status
if Def.NRange <= 1
DeltaR = 0;
else
DeltaR = (Def.RMax - Def.RMin) / (Def.NRange - 1);
end
ThisDir = [DirInfo.MainWork Def.SubDir];
if ~exist(ThisDir, 'dir');
DirStatus = LibMakeDirectory(ThisDir);
if ~DirStatus
uiwait(warndlg(['Couldn''t make directory: ' ThisDir]));
Status = 0;
end
end
%For each frequency ...
for IFile = 1:length(FreqVec)
FBase = [Def.FPrefix '_' num2str(FreqVec(IFile))];
BaseName = [DirInfo.MainWork Def.SubDir FBase]; %Includes path
%Run the propagation model
[Status, ErrStr] = RunPropgnCode(Def.Environment, FreqVec(IFile), Def.RMin, Def.RMax, DeltaR, Def.Zr, Def.Zs, ...
BaseName, 0, RunID, Def.Title, Def.ManualEnvEdit, ExtraParams);
if ~Status
h = warndlg(ErrStr);
uiwait(h);
end
end %for IFile = ....
end %if Status
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Status, BellhopParams] = lSetBellhopParams(Def, RunID)
persistent BathyPath;
KnownRunTypes = {'R', 'A', 'C', 'I', 'S'};
KnownBeamTypes = {'B', 'G'};
%Warn user if any of these combinations of run and beam types are specified
BadCombinations = {'AS', 'aS', 'IS', 'SS'};
SuggestedBeamType = {'G', 'G', 'G', 'G'};
DirInfo = GetAcDirectoryInfo;
%Read in parameters specifically required by Bellhop
BellhopDefFName = 'BellhopDefaultParams.mat';
GotFields = 0;
if exist(BellhopDefFName, 'file')
load(BellhopDefFName);
if length(fieldnames(BellhopParams)) == 7
GotFields = 1;
end
end
if ~GotFields
BellhopParams = [];
%Run type: R = ray, E = eigenray, A = amplitude-delay, C = coherent TL, I = incoherent TL, S = semicoherent TL
BellhopParams.RunType = 'R';
BellhopParams.NBeams = 50; %Number of beams
BellhopParams.StartAngle = -80; %Starting angle (degrees)
BellhopParams.EndAngle = 80; %Ending angle (degrees)
BellhopParams.StepSize = 0.0; %Step size along ray for raytrace (wavelengths)
BellhopParams.UseBathyFile = 0; %1 to use bathymetry file, 0 for constant depth from environment info
BellhopParams.BathyFName = '';
end
Prompt = {...
'Run type: R = ray, C = coherent TL, I = incoherent TL, S = semicoherent TL, A = amplitude-delay', ...
'Beam type: B = Gaussian bundles, G = geometric', ...
'Number of beams', ...
'Launch angle of 1st ray (degrees from horizontal, -ve towards surface)', ...
'Launch angle of last ray (degrees from horizontal, -ve towards surface)', ...
'Step size along ray for raytrace (wavelengths, 0 to let Bellhop choose)', ...
'Use bathymetry file (number of ranges then range (km) depth (m) pairs) (y/n)'};
Done = 0;
while ~Done
if BellhopParams.UseBathyFile
BathyStr = 'y';
else
BathyStr = 'n';
end
Opt1 = BellhopParams.RunType(1);
if length(BellhopParams.RunType) >= 2
Opt2 = BellhopParams.RunType(2);
else
Opt2 = '';
end
DefAns = {Opt1, Opt2, num2str(BellhopParams.NBeams), num2str(BellhopParams.StartAngle), ...
num2str(BellhopParams.EndAngle), num2str(BellhopParams.StepSize), BathyStr};
Ans = inputdlg(Prompt,'Bellhop specific parameters', 1, DefAns);
if isempty(Ans)
Status = 0;
Done = 1;
else
Status = 1;
BellhopParams.RunType = [Ans{1} Ans{2}];
BellhopParams.NBeams = str2num(Ans{3});
BellhopParams.StartAngle = str2num(Ans{4});
BellhopParams.EndAngle = str2num(Ans{5});
BellhopParams.StepSize = str2num(Ans{6});
BellhopParams.UseBathyFile = strcmpi(Ans{7}, 'y');
if BellhopParams.UseBathyFile
Here = pwd;
if isempty(BathyPath)
BathyPath = [DirInfo.MainWork Def.SubDir];
end
if ~exist(BathyPath, 'dir');
LibMakeDirectory(BathyPath);
end
cd(BathyPath);
[File Path] = uigetfile('*.bty', 'Bathymetry data file');
cd(Here);
if File ~= 0
BathyPath = Path;
BellhopParams.BathyFName = [Path File];
end
end
save(BellhopDefFName, 'BellhopParams');
end
%Check the parameters are OK
FoundErr = 0;
RT = BellhopParams.RunType;
IType = find(strcmp(RT(1), KnownRunTypes));
if isempty(IType)
Msg = ['Unknown run type: ' RT(1)];
FoundErr = 1;
end
if ~FoundErr
IType = find(strcmp(RT(2), KnownBeamTypes));
if isempty(IType)
Msg = ['Unknown beam type: ' RT(2)];
FoundErr = 1;
end
end
if ~FoundErr
IBad = find(strcmp(BellhopParams.RunType, BadCombinations));
if ~isempty(IBad)
Msg = {['Bellhop does not currently implement run type: ' RT(1) ' with beam type: ' RT(2)], ...
['Try beam type: ' SuggestedBeamType{IBad(1)} ' instead']};
FoundErr = 1;
end
end
if FoundErr
uiwait(warndlg(Msg));
switch(menu('', 'Modify', 'Continue anyway'));
case 2,
Done = 1;
end
else
Done = 1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Status, ExtraParams] = lSetKrakencParams(Def, RunID)
Ans = inputdlg({'Use exhaustive mode search (slow, but recommended for elastic problems - may give warnings) (y/n)'}, '', 1, {'y'});
if isempty(Ans)
Status = 0;
ExtraParams.ExhaustiveSearch = 1;
else
Status = 1;
ExtraParams.ExhaustiveSearch = strcmpi(Ans{1}, 'y');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function NewDir = lViewFile(DefDir, Mask);
Here = pwd;
cd(DefDir);
[File, Path] = uigetfile(Mask, 'File to view');
cd(Here);
if File ~= 0
NewDir = Path;
CmdStr = ['!notepad ' Path File];
eval(CmdStr);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Def = lReadEnvFile(DirInfo, Def);
ThisDir = DirInfo.MainWork;
Here = pwd;
Status = 1;
if ~exist(ThisDir, 'dir')
Status = LibMakeDirectory(ThisDir);
end
if Status
cd(ThisDir);
end
[File, Path] = uigetfile('*.env', 'Environment file to load');
cd(Here);
if File ~= 0
[EnvObj, RunInfo] = LoadFromEnvFile(Def.Environment, [Path File]);
if ~isempty(RunInfo)
Def.Title = GetName(EnvObj);
Def.Freq = RunInfo.Freq;
Def.Environment = EnvObj;
Def.Zs = RunInfo.Zs;
Def.Zr = RunInfo.Zr;
if ~isempty(RunInfo.RMin)
Def.RMin = RunInfo.RMin;
Def.RMax = RunInfo.RMax;
Def.NRange = RunInfo.NRange;
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -