📄 actoolboxfrontend.m
字号:
function AcToolboxFrontEnd()
% AcToolboxFrontEnd
% User friendly matlab front-end for Mike Porter's Acoustics Toolbox
%
% Author:
% Alec J Duncan,
% Centre for Marine Science and Technology,
% Curtin University of Technology,
% Kent Street, Bentley, Western Australia
% a.duncan@cmst.curtin.edu.au
%
% Provides a uniform user interface for running and plotting the results from the following programs:
% kraken (normal mode model)
% krakenc (complex normal mode model)
% scooter (fast-field model)
% bellhop (gaussian beam tracing)
% bounce (bottom reflection coefficient from geoacoustic model)
%
% This is especially handy for running models at multiple frequencies or for running different models on the same
% problem.
%
% The price for all this is, however, some loss of flexibility, as to keep the interface as simple as possible quite
% a lot of the parameters and options are hard-coded or computed by the program.
%
% This interface can only run kraken, krakenc and scooter for range independent problems.
% Bellhop can be run for range dependent bathymetry but not range dependent sound speed or bottom properties.
%
% The interface can only handle single source depths, but it can handle multiple receiver depths, multiple
% receiver ranges and multiple frequencies.
%
% If you get an obscure error message coming up in the command window check the appropriate .prn file for
% more meaningful error messages. Consult the OALIB ...\doc\*.hlp files for further information.
%
% The Acoustic Toolbox is available from:
% ftp://oalib.saic.com/pub/oalib/AcousticsToolbox/
%
% Code has been tested with the version of the Acoustics Toolbox contained in:
% atPII_f95.zip June 27th 2002
%
% Works with Matlab 5 and Matlab 6 although Matlab 6 has a bug which makes some of the GUI windows sometimes only partly visible.
% Switching back and forth between windows usually solves the problem.
%
%*****************************************************************************************************************************
% To use it:
% 1. download and unzip the Acoustics Toolbox (atPII_f95.zip, see above) into a convenient directory
% 2. Unzip the AcToolboxFrontEnd archive into an appropriate directory and either
% put this directory on your matlab path or cd to it from within matlab (don't put @AcEnvironment or @AcLayer on the path)
% 3. Use your matlab editor or another text editor to modify GetAcDirectoryInfo.m to specify the correct locations
% for the Acoustic Toolbox files and the working directories you want to use.
% 4. At the Matlab command prompt, type act (this calls AcToolboxFrontEnd.m)
% 5. Hopefully from here on the menus and prompts will make it straightforward.
%
% The program starts up with a default run definition which you can run the various propagation models on as is, or
% you can modify the run definition to suit your own problems. There are also a number of pre-defined run definitions that
% you can load, modify etc. - many of these are examples from "Computational ocean Acoustics" by Jensen, Kuperman,
% Porter and Schmidt. Page numbers refer to the Springer 2000 edition - AIP Press edition page numbers are slightly different.
%
% You specify a directory and file prefix for each run and the program appends the frequency and an extension to make
% the file name. Files with a number of different
% extensions are generated as follows:
% .env Environment file used when running the specified propagation program (all)
% .prn File used to log program output - check this if any errors occur (all)
% .shd Shade file, ie. acoustic transmission loss data (kraken, krakenc, scooter, and bellhop
% if told to compute transmission loss)
% .brc Bottom reflection coefficient file - this in the format that bellhop likes (bounce and bellhop)
% .ray Ray file (bellhop if told to compute rays or eigenrays)
% .arr Amplitude/delay information for each arrival (bellhop if told to compute arraivals information)
% .grn Depth dependent Greens function (Scooter)
% .mod Mode file (kraken, krakenc)
%
% Input dialog boxes can handle valid matlab expressions as well as numeric values. This is particularly useful
% for specifying a vector of values, for example:
% 30:5:200
% specifies the vector [30, 35, 40, ... , 200]
%
% Sound speed profiles can either be specified manually or read from an ascii text file.
% Each row of file has following fields:
% Depth Cp Density Cs Ap As
%
% where:
% Depth is depth below top of layer in metres
% Cp is compressional sound speed in m/s
% Density is density in kg/m^3
% Cs is shear sound speed in m/s
% Ap is compressional wave absorption in dB/wavelength
% As is shear wave absorption in dB/wavelength
%
% You don't have to specify all columns, any after the last specified will be set to defaults:
% Cp = 1500m/s, Density = 1024m/s, Cs, Ap, As = 0
%
% Bellhop can optionally be run with a bathymetry file for problems with bathynmetry dependent on range although the
% geoacoustic parameters and water column sound speed profile are treated as independent of range.
% The format of the bathymetry (.bty) file is as follows:
% N
% R(1) Zw(1)
% R(2) Zw(2)
% . .
% . .
% . .
% R(N) Zw(N)
%
% Where: N is the number of range - depth pairs
% R is the range in km
% Zw is the water depth in metres
%
% Note that in this case the water column sound speed profile in the environment definition must be specified down to
% the deepest depth in the bathymetry out to the maximum range specified for the run.
%
% I've put a lot of error trapping in the code, but there may still be conditions that aren't trapped. Please contact me
% at the above email address if you find any bugs or have any suggestions for improvements etc.
%
% **********************************************************************************************************
% Release notes:
% Changes incorporated in Version 1.1 (29 May 2002):
% - Added capability to read sound speed profiles from an ascii text file
%
% Changes incorporated in Version 1.2 (12th June 2002)
% - Fixed some bugs to do with default directories to make it easier to transfer run definitions
% between machines
% - Fixed a bug in Greens function reading code (ReadGreen.m) that caused initial block of data to be
% overwritten
% - Added act.m which simply calls actoolboxfrontend.m - for those who don't like typing!
% - Added additional error checking to prevent aborts on some types of directory creation errors
% and aborts when trying to read invalid shade files
% - Added support for additional Bellhop run options
% - Added automatic scanning of log (.prn) files for error and warning messages
% - Number of mesh points in environment file is now set to zero so that propagation code will pick
% a default value
% - Added option to allow manual editing of automatically generated environment files, .flp files etc.
% prior to the code being run
%
% Changes incorporated in Version 1.3 (13th June 2002)
% - Code now reads binary shade files instead of converting to ascii
% - Added option to force exhaustive mode search when running Krakenc
% - Fixed problem with directory paths containing blanks
%
% Changes incorporated in Version 1.4 (14th June 2002)
% - Improved method of specifying layers so they automatically stack
% - Directory for each run definition is now specified relative to main working directory
% - added option to plot environment parameters (still a bit untidy)
%
% Changes incorporated in Version 1.5 (27th June 2002)
% - Fixed bug in error screening code that caused problems when there are a large number of warnings in .prn file
% - Code now consistently keeps intermediate files (bottom reflection coefft, mode, greens function)
% - Added capability to plot mode locations in complex Kr plane
% - Added capability to plot mode shapes
% - Added capability to plot amplitude - delay information produced by bellhop with 'A' option
% - Added screening for run type and beam type combinations not suppoprted by bellhop
%
% Changes incorporated in Version 1.6 (1st July 2002) - first public release
% - Added capability to read a run definition from a kraken or bellhop environment file
% - Tidied up environment plotting
VersionStr = '1.6';
DirInfo = GetAcDirectoryInfo;
DefFName = 'AcToolboxFrontEnd.mat'; %Name of file for storing defaults
%Reset the environment to default values
Def = lLoadDefaultParams(DirInfo, DefFName);
Done = 0;
NRows = 1;
NCols = 1;
SubplNum = 1;
PltFreq = Def.Freq;
RangeLimits = [0 1000];
LineStyle = 'r:';
State = 'MainMenu';
while ~Done
switch State
case 'MainMenu'
Opt = ...
menu(['Acoustic Toolbox Front End, Version ' VersionStr], ...
'Open existing run definition', ...
'Read run definition from .env file', ...
'Edit run definition', ...
'Save run definition', ...
'Run propagation code', ...
'View log or environment files', ...
'Plot environment or results', ...
'Exit');
switch Opt
case 1,
State = 'OpenRunDef';
case 2,
State = 'ReadEnvFile';
case 3,
State = 'EditRunDef';
case 4,
State = 'SaveRunDef';
case 5,
State = 'RunModel';
case 6,
State = 'ViewFiles';
case 7,
State = 'PlotMenu';
case 8,
State = 'Exit';
end
case 'Exit',
Done = 1;
case 'OpenRunDef'
NewDef = lOpenRunDef(DirInfo);
if ~isempty(NewDef)
Def = NewDef;
if ~isfield(Def, 'FPrefix')
Def.FPrefix = 'Test';
end
if ~isfield(Def, 'ManualEnvEdit')
Def.ManualEnvEdit = 0;
end
end
State = 'MainMenu';
case 'ReadEnvFile'
Def = lReadEnvFile(DirInfo, Def);
State = 'MainMenu';
case 'EditRunDef'
%Mod the environment parameters
Prompt = {'Title', 'Frequency(s) (Hz)', 'Source depth (m)', 'Receiver depth(s) (m)', ...
'Minimum range (m)', 'Maximum range (m)', 'Number of range steps', ...
'Sub directory for output files', 'Allow manual edit of environment file (y/n)'};
DefAns = {Def.Title, num2str(Def.Freq), num2str(Def.Zs), num2str(Def.Zr), ...
num2str(Def.RMin), num2str(Def.RMax), num2str(Def.NRange), Def.SubDir, 'n'};
Ans = inputdlg(Prompt,'Propagation model parameters', 1, DefAns);
if ~isempty(Ans)
Def.Title = Ans{1};
Def.Freq = str2num(Ans{2});
Def.Zs = str2num(Ans{3});
Def.Zr = str2num(Ans{4});
Def.RMin = str2num(Ans{5});
Def.RMax = str2num(Ans{6});
Def.NRange = str2num(Ans{7});
Def.SubDir = Ans{8};
if ~isempty(Def.SubDir)
if Def.SubDir(end) ~= '\'
Def.SubDir = [Def.SubDir '\'];
end
end
Def.ManualEnvEdit = strcmpi(Ans{9}, 'y');
save(DefFName, 'Def'); %Save the new settings
end
Def.Environment = EditGUI(Def.Environment, 0);
State = 'MainMenu';
case 'LoadDefaultRunDef',
%Reset the environment to default values
Def = lLoadDefaultParams(DirInfo, DefFName);
State = 'MainMenu';
case 'SaveRunDef'
lSaveRunDef(DirInfo, Def);
State = 'MainMenu';
case 'RunModel',
%Run Kraken, KrakenC, Scooter, etc.
Def = lRunPropagationCode(Def, DefFName);
State = 'MainMenu';
case 'PlotMenu',
PlotOpt = menu('Plotting options:', ...
'TL vs range', ...
'TL vs range at multiple frequencies', ...
'TL vs range and depth', ...
'Bottom reflection coefficient', ...
'Rays', ...
'Amplitude-delay for each ray path', ...
'Greens function', ...
'Mode locations', ...
'Mode shapes', ...
'Environment', ...
'Bathymetry', ...
'Main Menu');
switch PlotOpt
case 1,
State = 'PltTLVRange';
case 2,
State = 'PltTLVRangeMultiFreq';
case 3,
State = 'PltField';
case 4,
State = 'PltRCoefft';
case 5,
State = 'PltRays';
case 6,
State = 'PltAmpDly';
case 7,
State = 'PltGreensFn';
case 8,
State = 'PltModeLocations';
case 9,
State = 'PltModeShapes';
case 10,
State = 'PltEnvironment';
case 11,
State = 'PltBathymetry';
case 12,
State = 'MainMenu';
end
case 'PltTLVRange',
PlotSlice([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltTLVRangeMultiFreq',
%Multiple depth slices
Ans = inputdlg({'Sub directory', 'File prefix', 'Vector of frequencies', 'Vector of figure numbers', ...
'Hold current plots (y/n)', 'Line style', 'Range limits for plot (m)', ...
'Number of subplot rows', 'Number of subplot columns', 'Subplot number for this plot', },...
'Files to be plotted:', 1, {Def.SubDir, Def.FPrefix, num2str(PltFreq), int2str(PltFreq), 'y', LineStyle, ...
num2str(RangeLimits), int2str(NRows), int2str(NCols), '1'});
if ~isempty(Ans)
PltDir = [DirInfo.MainWork Ans{1}];
if PltDir(end) ~= '\'
PltDir = [PltDir '\'];
end
FPrefix = Ans{2};
PltFreq = str2num(Ans{3});
FigVec = str2num(Ans{4});
HoldCurrent = strcmpi(Ans{5}, 'y');
LineStyle = Ans{6};
RangeLimits = str2num(Ans{7});
NRows = str2num(Ans{8});
NCols = str2num(Ans{9});
SubplNum = str2num(Ans{10});
Ans = inputdlg({'Plot phase as well as magnitude (y/n)'}, '', 1, {'n'});
if isempty(Ans)
Status = 0;
else
PltPhase = strcmpi(Ans{1}, 'y');
Status = 1;
RxDepth = [];
for IFreq = 1:length(PltFreq)
FBase = [FPrefix '_' num2str(PltFreq(IFreq))];
FigNum = FigVec(IFreq);
if Status
[PltDir, Status, RxDepth] = PlotSlice(PltDir, FBase, FigNum, NRows, NCols, SubplNum, HoldCurrent, ...
LineStyle, RangeLimits, PltPhase, RxDepth);
end
end
end
end
State = 'PlotMenu';
case 'PltField',
%Plot acoustic field
PlotShade([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltRCoefft',
PlotReflnCoefft([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltRays',
%Plot rays (only for bellhop output)
PlotRay([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltAmpDly',
%Plot rays (only for bellhop output)
PlotArrivals([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltBathymetry',
PlotBathymetry([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
case 'PltGreensFn',
PlotGreensFn([DirInfo.MainWork Def.SubDir]);
State = 'PlotMenu';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -