% Installer: "nefis_install.m" % Created: 28-Feb-2002 16:17:31. function bund_driver % bund_driver -- Driver for "bund" bundles. % bund_driver (no arguments) contains Matlab commands % to inflate the instructions and files that are % encoded into the "bund_data" function of this package. % Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 14-Jun-2001 10:54:16. % Updated 03-Aug-2001 13:43:17. help(mfilename) BINARY_TAG = '?'; CR = char(13); LF = char(10); comp = upper(computer); if any(findstr(comp, 'PCWIN')) % Windows. NL = [CR LF]; elseif any(findstr(comp, 'MAC2')) % Macintosh. NL = CR; else % Unix. NL = LF; end c = zeros(1, 256); c(abs('0'):abs('9')) = 0:9; c(abs('a'):abs('f')) = 10:15; disp([' ']) disp([' ## This installer is ready to expand its contents,']) disp([' ## starting in the present directory: "' pwd '"']) disp([' ## To abort, execute an interruption now.']) disp([' ## Otherwise, to continue, press any key.']) disp([' ']) try pause catch disp([' ## Installation interrupted.']) disp([' ']) return end tic w = which(mfilename); fin = fopen(w, 'r'); if fin < 0, return, end found = ~~0; while ~found s = fgetl(fin); if isequal(s, -1) fclose(fin); return end s = strrep(s, LF, ''); % Not necessary? s = strrep(s, CR, ''); % Not necessary? if isequal(s, 'function bund_data') found = ~~1; end end fout = -1; done = ~~0; while ~done s = fgetl(fin); if isequal(s, -1) fclose(fin); return end if length(s) > 0 if s(1) ~= '%' f = findstr(s, 'bund_setdir'); if any(f) theDir = eval(strrep(s, 'bund_setdir', '')); status = mkdir(theDir); switch status case 1 disp([' ## Directory created: "' theDir '"']) case 2 disp([' ## Directory exists: "' theDir '"']) otherwise error([' ## Error while making new directory.']) end try cd(theDir) catch error([' ## Unable to go to directory: "' theDir '"']) end else try eval(s); catch error([' ## Unable to evaluate: "' s '"']) end end elseif length(s) > 1 & s(2) == BINARY_TAG hx = double(s(3:end)); % Assume hex data. bin = 16*c(hx(1:2:end)) + c(hx(2:2:end)); fwrite(fout, bin, 'uchar'); else fprintf(fout, '%s', s(2:end)); fprintf(fout, NL); end end end fclose(fin); disp([' ## Elapsed time: ' num2str(fix(10*toc)/10) ' s.']) function bund_data bund_setdir('nefis') disp(' ## Installing: "nefis_bundle.m" (text)') fout = fopen('nefis_bundle.m', 'w'); %function nefis_bundle % %% nefis_bundle -- Bundler for "nefis" toolbox. %% nefis_bundle (no argument) bundles the "nefis" %% toolbox. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 18:18:40. %% Updated 28-Feb-2002 16:13:05. % %at(mfilename) % %bund new nefis %bund setdir nefis %bund mfile nefis_bundle % %bund class nefis %bund class nfgroup %bund class nfelement %bund class nfitem % %bund mfile nf %bund mfile nef_demo %% bund binary trim-t31.dat %% bund binary trim-t31.def %bund mfile at %bund mfile arrowsafe %bund cd .. %bund close fclose(fout); bund_setdir('@nefis') disp(' ## Installing: "close.m" (text)') fout = fopen('close.m', 'w'); %function theResult = close(self) % %% nefis/close -- Close a "nefis" file. %% close(self) closes the NEFIS file associated with self, %% a "nefis" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 10:23:03. %% Updated 08-Feb-2002 10:23:03. % %if nargin < 1, help(mfilename), return, end % %try % result = []; %catch % result = self; %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "data.m" (text)') fout = fopen('data.m', 'w'); %function theResult = data(self, theData) % %% nefis/data -- Get/set "nefis" data. %% data(self) returns the data structure associated %% with self, a "nefis" object. %% data(self, theData) sets the data structure of %% self to theData. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 10:57:54. %% Updated 08-Feb-2002 10:57:54. % %if nargin < 1, help(mfilename), return, end % %if nargin < 2 % result = self.itsData; %else % result = self; % result.itsData = theData; %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "getvar.m" (text)') fout = fopen('getvar.m', 'w'); %function theResult = getvar(self, theGroupname, theVarname, varargin) % %% nefis/getvar -- Get a NEFIS variable. %% getvar(self, 'theGroupname', 'theVarname', ...) returns the data %% held by (case-sensitive) 'theGroupname' and 'theVarname', associated %% with self, a "nefis" object. Additional arguments are assumed to %% be Matlab array indices, starting with a one-dimensional %% index into a cell-array. (Note: it might make sense to construct %% an "nfgrp" group-object, then an "nfvar" object that is part %% of a particular group. Alternatively, we could use a syntax %% like "group/var" to get what we want.) % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 10:29:08. %% Updated 08-Feb-2002 10:29:08. % %if nargin < 1, help(mfilename), return, end % %% Get the whole variable. % %[result, success] = vs_get(self.itsData, theGroupname, theVarname); % %% Process the indices. % %if success & length(varargin) > 0 % switch class(result) % case 'cell' % Process 1-d cell indices. % while isa(result, 'cell') % result = result{varargin{1}}; % varargin(1) = []; % end % if length(varargin) > 0 % Process the remainder. % result = result(varargin{:}); % end % case 'double' % if length(varargin) > 0 % result = result(varargin{:}); % end % case 'char' % if length(varargin) > 0 % result = result(varargin{:}); % end % otherwise % end %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "groups.m" (text)') fout = fopen('groups.m', 'w'); %function theResult = groups(self) % %% nefis/groups -- Names of NEFIS groups. %% groups(self) returns a cell-array of the names %% of groups associated with self, a "nefis" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 13:44:00. %% Updated 08-Feb-2002 13:44:00. % %if nargin < 1, help(mfilename), return, end % %result = vs_disp(info(self)); % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "nefis.m" (text)') fout = fopen('nefis.m', 'w'); %function theResult = nefis(theFilename) % %% nefis/nefis -- Constructor for "nefis" class. %% nefis('theFilename') returns a "nefis" object that %% uses the given file. The result is empty if the %% file cannot be opened. %% %% Requires: "Delft3D Matlab Interface Toolbox". %% %% Example: %% %% nf = nefis('trim-t31.dat'); % Open the file. %% gp = nfgroup(nf, 'map-series'); % Get a group. %% u1 = nfelement(gp, 'U1'); % Get an element; %% sz = size(u1); % Get the size of the element. %% xx = u1{index}(indices); % Get the data. %% nf = close(nf); % Close the file. %% %% Utility methods: info, name, file, group, element. %% %% NEFIS Class Tree: %% %% NFITEM -- Base class. %% NEFIS %% NFGROUP %% NFELEMENT % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 10:13:13. %% Updated 19-Feb-2002 09:49:21. % %if nargout > 0, theResult = []; end % %% Check for Delft3D Matlab toolbox. % %itRequires = {'vs_use', 'vs_disp', 'vs_get'}; %allFound = ~~1; %for i = 1:length(itRequires) % if isempty(which(itRequires{i})) % disp([' ## Not found: "' itRequires{i} '"']) % allFound = ~~0; % end %end % %if ~allFound % disp([' ## Requires the Delft3D Matlab Interface Toolbox."']) % return %end % %if nargin < 1, help(mfilename), theFilename = '*'; end %if any(theFilename == '*') % [theFile, thePath] = uigetfile('*.dat', 'Select a NEFIS File'); % if ~any(theFile), return, end % if thePath(end) ~= filesep, thePath(end+1) = filesep; end % theFilename = [thePath theFile]; %end % %try % theNFStruct = vs_use(theFilename, 'quiet'); %catch % theNFStruct = []; % disp([' ## Unable to open NEFIS file: "' theFilename '"']) %end % %if isempty(theNFStruct) % self = []; %else % theStruct.ignore = []; % self = class(theStruct, 'nefis', nfitem(theNFStruct)); %end % %if nargout > 0 % theResult = self; %else % assignin('caller', 'ans', self) %end fclose(fout); disp(' ## Installing: "numel.m" (text)') fout = fopen('numel.m', 'w'); %function theResult = numel(varargin) % %% class/numel -- Overloaded NUMEL. %% numel(varargin) is called by Matlab 6.1+ during SUBSREF %% and SUBSASGN operations to figure out how many output %% and input arguments to expect, respectively. We %% believe the answer should always be 1, in keeping %% with the way we have traditionally programmed. % %% Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 30-Jul-2001 15:45:20. %% Updated 30-Jul-2001 15:45:20. % %theResult = numel_default(varargin{:}); fclose(fout); cd ('..') bund_setdir('@nfgroup') disp(' ## Installing: "elements.m" (text)') fout = fopen('elements.m', 'w'); %function theResult = elements(self) % %% nfgrp/elements -- Names of NEFIS elements. %% elements(self) returns the names of the elements %% associated with self, an "nfgrp" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 13:49:37. %% Updated 08-Feb-2002 13:49:37. % %if nargin < 1, help(mfilename), return, end % %result = vs_disp(info(self), name(self)); % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "nfgroup.m" (text)') fout = fopen('nfgroup.m', 'w'); %function theResult = nfgroup(theNefis, theGroupname) % %% nfgrp/nfgroup -- Constructor for "nfgroup" class. %% nfgroup(theParent, 'theGroupname') returns an "nfgroup" %% object that represents the given NEFIS group. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 13:39:28. %% Updated 08-Feb-2002 13:39:28. % %if nargin < 1, help(mfilename), return, end %if nargin < 2, theGroupname = ''; end % %theStruct.ignore = []; % %self = class(theStruct, 'nfgroup', nfitem(info(theNefis), theGroupname)); % %if nargout > 0 % theResult = self; %else % assignin('caller', 'ans', self) %end fclose(fout); disp(' ## Installing: "numel.m" (text)') fout = fopen('numel.m', 'w'); %function theResult = numel(varargin) % %% class/numel -- Overloaded NUMEL. %% numel(varargin) is called by Matlab 6.1+ during SUBSREF %% and SUBSASGN operations to figure out how many output %% and input arguments to expect, respectively. We %% believe the answer should always be 1, in keeping %% with the way we have traditionally programmed. % %% Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 30-Jul-2001 15:45:20. %% Updated 30-Jul-2001 15:45:20. % %theResult = numel_default(varargin{:}); fclose(fout); cd ('..') bund_setdir('@nfelement') disp(' ## Installing: "data.m" (text)') fout = fopen('data.m', 'w'); %function theResult = data(self) % %% nfelement/data -- Get data from a NEFIS element. %% data(self) returns the data associated with self, %% an "nfelement" object. On error, the empty matrix %% is returned. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 11:24:21. %% Updated 08-Feb-2002 11:24:21. % %if nargin < 1, help(mfilename), return, end % %[x, okay] = vs_get(info(self), group(self), element(self)); %if ~okay, x = []; end % %if nargout > 0 % theResult = x; %else % assignin('caller', 'ans', x) %end fclose(fout); disp(' ## Installing: "end.m" (text)') fout = fopen('end.m', 'w'); %function theResult = end(self, theIndex) % %% nfelement/end -- Process END as an index of "nfelement". %% end(self, theIndex) returns the maximum length of the %% data associated with self, an "nfelement" object, %% along the given index. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Feb-2002 16:39:16. %% Updated 13-Feb-2002 16:39:16. % %if nargin < 1, help(mfilename), return, end % %theSize = size(self); %result = abs(theSize(k)); % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "length.m" (text)') fout = fopen('length.m', 'w'); %function theResult = length(self) % %% nfelement/length -- Length of "nfelement" data. %% length(self) returns the length of the data associated %% with self, an "nfelement". The result is the length %% of the cell-array containing the actual values. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Feb-2002 16:50:17. %% Updated 13-Feb-2002 16:50:17. % %theSize = size(self); % %result = max(abs(theSize(theSize < 0))); % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "nfelement.m" (text)') fout = fopen('nfelement.m', 'w'); %function theResult = nfelement(theGroup, theElementname) % %% nfelement/nfelement -- Constructor for NEFIS "nfelement" class. %% nfelement(theGroup, 'theElementname') constructs an "nfelement" %% object for theGroup, an "nfgroup" object, and theElementname. %% The "nfelement" data can be accessed with conventional Matlab %% subscripting. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:50:52. %% Updated 08-Feb-2002 14:50:52. % %if nargin < 1, help(mfilename), return, end %if nargin < 2, theElementname = ''; end % %theStruct.ignore = []; % %self = class(theStruct, 'nfelement', ... % nfitem(theGroup, theGroup, theElementname)); % %if nargout > 0 % theResult = self; %else % assignin('caller', 'ans', self) %end fclose(fout); disp(' ## Installing: "numel.m" (text)') fout = fopen('numel.m', 'w'); %function theResult = numel(varargin) % %% class/numel -- Overloaded NUMEL. %% numel(varargin) is called by Matlab 6.1+ during SUBSREF %% and SUBSASGN operations to figure out how many output %% and input arguments to expect, respectively. We %% believe the answer should always be 1, in keeping %% with the way we have traditionally programmed. % %% Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 30-Jul-2001 15:45:20. %% Updated 30-Jul-2001 15:45:20. % %theResult = numel_default(varargin{:}); fclose(fout); disp(' ## Installing: "size.m" (text)') fout = fopen('size.m', 'w'); %function theResult = size(self) % %% nfelement/size -- Size of a NEFIS element. %% size(self) returns the size of the data %% associated with self, an "nfelement" object. %% The negative values refer to the cell-size %% of the group, whereas the positive values %% refer to the NEFIS data element itself. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 11:52:56. %% Updated 08-Feb-2002 11:52:56. % %if nargin < 1, help(mfilename), return, end % %result = []; % %d = info(self); % %x = d.ElmDef; %for i = 1:length(x) % if isequal(name(self), x(i).Name) % result = x(i).Size; % break % end %end % %x = d.GrpDat; %for i = 1:length(x) % if isequal(group(self), x(i).Name) % result = [-x(i).SizeDim result]; % break % end %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "subsref.m" (text)') fout = fopen('subsref.m', 'w'); %function theResult = subsref(self, theStruct) % %% nfelement/subsref -- Get values from NEFIS element. %% subsref(self, theStruct) processes right-side subscripting %% on behalf of self, a "nfelement" object. All subscripts must %% be provided. The solitary colon-operator ":" may be used %% to indicate all the elements in the corresponding dimension. %% %% Also see: nfelement/size. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 11:12:58. %% Updated 08-Feb-2002 11:12:58. % %if nargin < 1, help(mfilename), return, end % %theSize = size(self); % %theGroupIndex = {}; %theElementIndex = {}; % %for k = 1:length(theStruct) % switch theStruct(k).type % case '{}' % theGroupIndex = theStruct(k).subs; % case '()' % theElementIndex = theStruct(k).subs; % end %end % %if ~iscell(theGroupIndex), theGroupIndex = {theGroupIndex}; end %if ~iscell(theElementIndex), theElementIndex = {theElementIndex}; end % %i = 0; %for k = 1:length(theGroupIndex) % i = i+1; % if isequal(theGroupIndex{k}, ':') % theGroupIndex{k} = 1:abs(theSize(i)); % end %end %for k = 1:length(theElementIndex) % i = i+1; % if isequal(theElementIndex{k}, ':') % theElementIndex{k} = 1:abs(theSize(i)); % end %end % %v = {info(self), group(self)}; %if ~isempty(theGroupIndex) % v = [v {theGroupIndex}]; %end %v = [v {element(self)}]; %if ~isempty(theElementIndex) % v = [v {theElementIndex}]; %end % %x = vs_get(v{:}, 'quiet'); % %if nargout > 0 % theResult = x; %else % assignin('caller', 'ans', x) %end fclose(fout); cd ('..') bund_setdir('@nfitem') disp(' ## Installing: "disp.m" (text)') fout = fopen('disp.m', 'w'); %function theResult = disp(self) % %% nfitem/disp -- Display a NEFIS item. %% disp(self) displays or returns information %% about self, an "nfitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:10:26. %% Updated 08-Feb-2002 14:10:26. % %s.File = self.itsFilename; %s.Group = self.itsGroupname; %s.Element = self.itsElementname; % %if nargout > 0 % theResult = s; %else % disp(' ') % disp(s) %end fclose(fout); disp(' ## Installing: "display.m" (text)') fout = fopen('display.m', 'w'); %function theResult = display(self) % %% nfitem/display -- Display an "nfitem" object. %% display(self) displays or returns information %% about self, an "ncitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 15:28:05. %% Updated 08-Feb-2002 15:28:05. % %if nargin < 1, help(mfilename), return, end % %s = [inputname(1) ' =']; %t = disp(self); % %if nargout > 0 % theResult = [s t]; %else % disp(' ') % disp(s) % disp(t) %end fclose(fout); disp(' ## Installing: "element.m" (text)') fout = fopen('element.m', 'w'); %function theResult = element(self) % %% nfitem/element -- Element-name of an NEFIS item. %% element(self) returns the element-name associated %% with self, an "nfitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:12:13. %% Updated 08-Feb-2002 14:12:13. % %if nargin < 1, help(mfilename), return, end % %result = self.itsElementname; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "file.m" (text)') fout = fopen('file.m', 'w'); %function theResult = file(self) % %% nfitem/file -- Filename of an NEFIS item. %% file(self) returns the filename associated %% with self, an "nfitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:12:13. %% Updated 08-Feb-2002 14:12:13. % %if nargin < 1, help(mfilename), return, end % %result = self.itsFilename; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "group.m" (text)') fout = fopen('group.m', 'w'); %function theResult = group(self) % %% nfitem/group -- Group-name of an NEFIS item. %% group(self) returns the group-name associated %% with self, an "nfitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:12:13. %% Updated 08-Feb-2002 14:12:13. % %if nargin < 1, help(mfilename), return, end % %result = self.itsGroupname; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "info.m" (text)') fout = fopen('info.m', 'w'); %function theResult = info(self) % %% nfitem/info -- NEFIS structure. %% info(self) returns the NEFIS data-structurre %% associated with self, an "nfitem" object. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:12:13. %% Updated 08-Feb-2002 14:12:13. % %if nargin < 1, help(mfilename), return, end % %result = self.itsNefisInfo; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "name.m" (text)') fout = fopen('name.m', 'w'); %function theResult = name(self) % %% nfitem/name -- Name of a NEFIS item. %% name(self) returns the name associated with self, %% an "nfitem" object. This will be a file-name, %% group-name, or element-name, depending on context. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:25:02. %% Updated 08-Feb-2002 14:25:02. % %if nargin < 1, help(mfilename), return, end % %result = element(self); %if isempty(result), result = group(self); end %if isempty(result), result = file(self); end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "nfitem.m" (text)') fout = fopen('nfitem.m', 'w'); %function theResult = nfitem(theNefisInfo, theGroupname, theElementname) % %% nfitem/nfitem -- Base class for NEFIS Toolbox. %% nfitem(theNefisInfo, 'theGroupname', 'theElementname') %% constructs a base-object for NEFIS entities, from %% the given NEFIS info-structure, group-name (if any), %% and element-name (if any). % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Feb-2002 14:01:01. %% Updated 08-Feb-2002 14:01:01. % %if nargin < 1, help(mfilename), return, end % %theStruct.itsNefisInfo = []; %theStruct.itsFilename = []; %theStruct.itsGroupname = []; %theStruct.itsElementname = []; % %self = class(theStruct, 'nfitem'); % %self.itsFilename = ''; %self.itsGroupname = ''; %self.itsElementname = ''; % %if nargin > 0 % if isa(theNefisInfo, 'nfitem') % theNefisInfo = info(theNefisInfo); % end % self.itsNefisInfo = theNefisInfo; %end % %if nargin > 1 % if isa(theGroupname, 'nfitem') % theGroupname = group(theGroupname); % end % self.itsGroupname = theGroupname; %end % %if nargin > 2 % if isa(theElementname, 'nfitem') % theElementname = element(theElementname); % end % self.itsElementname = theElementname; %end % %if ~isempty(theNefisInfo) % theInfo = info(self); % self.itsFilename = theInfo.FileName; %else % self.itsFilename = ''; %end % %if nargout > 0 % theResult = self; %else % assignin('caller', 'ans', self) %end fclose(fout); cd ('..') disp(' ## Installing: "nf.m" (text)') fout = fopen('nf.m', 'w'); %function nf % %% nf -- Switch to NEFIS Toolbox. %% nf (no argument) switches to the NEFIS Toolbox area. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 19-Feb-2002 10:12:20. %% Updated 19-Feb-2002 10:12:20. % %at(mfilename) fclose(fout); disp(' ## Installing: "nef_demo.m" (text)') fout = fopen('nef_demo.m', 'w'); %function nef_demo(theFilename, theSlice) % %% nef_demo -- Simple animation of NEFIS data. %% nef_demo('theFilename', theSlice) animates some NEFIS data. %% Defaults: 'trim-t31.dat' and 51. % %% Copyright (C) 2002 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 13-Feb-2002 16:01:21. %% Updated 28-Feb-2002 15:58:19. % %figure_name = 'NEF Demo'; % %% Default arguments. % %if nargin < 1, theFilename = 'trim-t31.dat'; end %if nargin < 2, theSlice = 51; end % %% Open the NEFIS file. %% To see its group names, use "groups(aNEFIS)". % %nf = nefis(theFilename); %if isempty(nf), return, end % %% Get groups associated with the NEFIS file. %% To see element names, use "elements(anNFGroup)". % %se = nfgroup(nf, 'map-series'); %co = nfgroup(nf, 'map-const'); % %% Get elements associated with the groups. %% These behave as regular Matlab variables. % %u = nfelement(se, 'U1'); %v = nfelement(se, 'V1'); %w = nfelement(se, 'WPHY'); % %xz = nfelement(co, 'XZ'); %yz = nfelement(co, 'YZ'); % %depth = nfelement(co, 'DP0'); %thick = nfelement(co, 'THICK'); % %% Preliminary calculations. % %sigma = cumsum(thick{1}(:)); % %d = depth{1}(:, theSlice); %f = find(d >= 0); % %z = sigma * d.'; %z(z < 0) = 0; % %x = xz{1}(:, theSlice); % Along strike? %x = repmat(x.', [length(sigma) 1]); % %y = yz{1}(:, theSlice); % Across dip? %y_bottom = y; %y = repmat(y.', [length(sigma) 1]); % %sz = size(u); %[xx, zz] = meshgrid(1:sz(2), 1:sz(4)); % %% Loop: 25 time-steps: dimensions = [{25}, 21, 101, 13]. % %for k = 1:min(length(u), inf) % uu = u{k}(1:end, 51, 1:end); % Get data via Matlab indexing. % vv = v{k}(1:end, 51, 1:end); % ww = w{k}(1:end, theSlice, 1:end); % uu = squeeze(uu); % Eliminate singleton dimensions. % vv = squeeze(vv); % ww = squeeze(ww); % uu = uu.'; % Re-orient. % vv = vv.'; % ww = ww.'; % hold off % Start plotting. % contour(y, z, vv) % hold on % plot(y_bottom(f), d(f), 'Color', 'k', 'LineWidth', 3) % x0 = y; % Prepare for ARROWSAFE. % y0 = z; % z0 = uu + sqrt(-1)*ww; % No vertical exageration. % len = abs(z0); % len = len ./ max(len(:)); % ang = angle(z0) * 180 / pi; % head = 0.1; % arrowsafe(x0, y0, len, ang, head*1); % hold off % End of plotting. % set(gcf, 'Name', [figure_name ': Step ' int2str(k)]) % set(gca, 'XDir', 'reverse', 'YDir', 'reverse') % xlabel('Distance (m)') % ylabel('Depth (m)') % figure(gcf) % drawnow %end % %close(nf) fclose(fout); disp(' ## Installing: "at.m" (text)') fout = fopen('at.m', 'w'); %function theResult = at(theFile) % %% at -- Switch to the folder of a given file. %% at('theFunction') switches to the folder %% of 'theFunction', as determined by the %% "which" function. % %% Copyright (C) 2000 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Feb-2000 22:21:09. %% Updated 30-May-2001 07:24:40. % %if nargout > 0, theResult = []; end % %if nargin < 1, help(mfilename), return, end % %w = which(theFile); % %if isempty(w) % disp([' ## No such file: ' theFile]) % return %elseif isequal(w, 'built-in') % disp([' ## ' theFile ' is built-in. Try "at ' theFile '.m".']) % return %end % %[thePath, theName, theExtension, theVersion] = fileparts(w); % %if any(thePath), cd(thePath), end % %if nargout > 0 % theResult = pwd; %else % disp([' ## ' pwd]) %end fclose(fout); disp(' ## Installing: "arrowsafe.m" (text)') fout = fopen('arrowsafe.m', 'w'); %function [x, y] = arrowsafe(x0, y0, theLength, theAngle, theHeadSize) % %% arrowsafe -- Intelligent, oriented arrows. %% arrowsafe('demo') demonstrates itself with arrows centered %% on the origin, each one-unit long. %% arrowsafe(N) demonstrates itself with N arrows. %% arrowsafe(x0, y0, theLength, theAngle, theHeadSize) draws %% arrows that start at (x0, y0), with theLength (in y-axis units), %% theAngle (degrees, counter-clockwise from +x), and theHeadSize %% (in y-axis units). The variables should be the same size, but %% any can be a scalar, just so long as the x0 and/or y0 array is %% the full size. The "ResizeFcn" of the figure is set to update %% the arrows automatically. The "Tag" is the mfilename. %% h = arrowsafe(...) draws the arrows and returns the handle. %% [x, y] = arrowsafe(...) returns the (x, y) data for the %% arrows, one column per arrow, but does not draw them. %% arrowsafe (no argument) redraws existing arrows. This is %% useful whenever the window is resized or the x or y limits %% change. (Recall that printing causes the "ResizeFcn" to %% be called twice.) %% %% Note: this routine leaves the axes in "manual" mode. Use %% "axis auto" to revert to automatic axis limits. % %% Copyright (C) 2000 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 12-Jan-2000 14:22:59. %% Updated 20-Feb-2002 16:22:49. % %RCF = 180 / pi; % %% Resize. % %if nargin < 1 % oldGCA = gca; % h = findobj(gcf, 'Type', 'line', 'Tag', mfilename); % for i = 1:length(h) % p = get(h(i), 'Parent'); % axes(p) % u = get(h(i), 'UserData'); % [xx, yy] = feval(mfilename, u(:, 1), u(:, 2), ... % u(:, 3), u(:, 4), u(:, 5)); % set(h(i), 'XData', xx(:), 'YData', yy(:)); % end % axes(oldGCA) % return %end % %% Demonstration. % %if nargin == 1 % if isequal(x0, 'demo') % help(mfilename) % x0 = 16; % elseif ischar(x0) % x0 = eval(x0); % end % theName = [mfilename ' demo']; % f = findobj('Type', 'figure', 'Name', theName); % if ~any(f) % f = figure('Name', theName); % end % figure(max(f)) % delete(get(f, 'Children')) % n = max(1, round(x0)); % offset = 0; % x0 = zeros(1, n) + offset; % ang = linspace(0, 360, length(x0)+1); % ang(end) = []; % h = feval(mfilename, x0, 0, 1, ang); % set(gca, 'Xlim', [-n n], 'YLim', [-2 2]) % feval(mfilename) % set(gcf, 'WindowButtonDownFcn', ... % ['if zoomsafe(''down''), ' mfilename ', end']) % if nargout > 0, x = h; end % return %end % %% Initialize. % %if nargin > 1 % if nargout == 2, x = []; y = []; end % if length(x0) == 1 % x0 = x0 * ones(size(y0)); % elseif length(y0) == 1 % y0 = y0 * ones(size(x0)); % end % x0 = reshape(x0, [1 prod(size(x0))]); % y0 = reshape(y0, size(x0)); % if nargin < 3, theLength = 1; end % if nargin < 4, theAngle = 0; end % if nargin < 5, theHeadSize = 0.1 .* theLength; end % if length(theLength) == 1 % theLength = theLength * ones(size(x0)); % end % if length(theAngle) == 1 % theAngle = theAngle * ones(size(x0)); % end % if length(theHeadSize) == 1 % theHeadSize = theHeadSize * ones(size(x0)); % end % % theLength = reshape(theLength, size(x0)); % theAngle = reshape(theAngle, size(x0)); % theHeadSize = reshape(theHeadSize, size(x0)); % % axes(gca) % oldUnits = get(gca, 'Units'); % set(gca, 'Units', 'pixels') % thePosition = get(gca, 'Position'); % set(gca, 'Units', oldUnits) % theWidth = thePosition(3); % pixels. % theHeight = thePosition(4); % pixels. % % axis('manual') % dx = diff(get(gca, 'XLim')); % dy = diff(get(gca, 'YLim')); % dydx = dy / dx; % Not used. % dxdp = dx / theWidth; % sci/pixel. % dydp = dy / theHeight; % sci/pixel. % scale = dxdp / dydp; %% <== Scale-factor. % % xa = [-10; -20; 0; -20; -10]/20; % Arrowhead. % ya = [0; 10; 0; -10; 0]/20; % % m = length(xa); % n = prod(size(x0)); % repeats = [m 1]; % % ang = repmat(theAngle, repeats); % len = repmat(theLength, repeats); % head = repmat(theHeadSize, repeats); % % xa = repmat(xa, [1 n]); % ya = repmat(ya, [1 n]); % % xa = xa .* head; % ya = ya .* head; % % xa = xa + len; % % za = xa + sqrt(-1) * ya; % % za = [zeros(1, n); za]; % % ang = repmat(theAngle, [size(za, 1) 1]); % len = repmat(theLength, [size(za, 1) 1]); % head = repmat(theHeadSize, [size(za, 1) 1]); % xx0 = repmat(x0, [size(za, 1) 1]); % yy0 = repmat(y0, [size(za, 1) 1]); % % za = exp(sqrt(-1) * ang / RCF) .* za; % xx = real(za); % yy = imag(za); % % nans = zeros(1, n) + NaN; % % xx = [xx; nans]; % yy = [yy; nans]; % % zz = xx + sqrt(-1) .* yy; % % xx0 = repmat(x0, [size(zz, 1) 1]); % yy0 = repmat(y0, [size(zz, 1) 1]); % % xx = xx0 + real(zz) * scale; % <== Scaling. % yy = yy0 + imag(zz); % % parameters = [x0(:) y0(:) theLength(:) theAngle(:) theHeadSize(:)]; % % if nargout < 2 % h = line(xx(:), yy(:), ... % 'Tag', mfilename, ... % 'UserData', parameters); % if nargout > 1, x = h; end % elseif nargout == 2 % x = xx; % y = yy; % end % set(gcf, 'ResizeFcn', mfilename) % % if nargout == 1, x = h; end %end fclose(fout); cd ('..')