% Installer: "dods_install.m" % Created: 01-May-2003 12:01:54. 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 06-Feb-2003 14:36:58. help(mfilename) v = version; isVersion6 = (v(1) == '6'); BINARY_TAG = '?'; CR = char(13); LF = char(10); comp = upper(computer); if any(findstr(comp, 'PCWIN')) % Windows. NL = [CR LF]; elseif any(findstr(comp, 'MAC')) % 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 % eval('pause', 'disp(''Installation interrupted.''), return') 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 s = strrep(s, LF, ''); % Not necessary? s = strrep(s, CR, ''); % Not necessary? if length(s) > 0 if s(1) ~= '%' f = findstr(s, 'bund_setdir'); if any(f) theDir = eval(strrep(s, 'bund_setdir', '')); [status, msg] = mkdir(theDir); switch status case 1 if isVersion6 & any(msg) disp([' ## Directory exists: "' theDir '"']) else disp([' ## Directory created: "' theDir '"']) end 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 % eval('cd(theDir)', ... % 'disp(theDir), error('' ## Unable to go to directory.'')') else % try % eval(s); % catch % error([' ## Unable to evaluate: "' s '"']) % end eval(s, ... 'disp(s), error(''Unable to evaluate statement.'')') 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('dods') bund_setdir('@dods') disp(' ## Installing: "att.m" (text)') fout = fopen('att.m', 'w'); %function theResult = att(self) % %% dods/att -- List of "ddatt" attributes. %% att(self) returns the list of "ddatt" objects %% associated with self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 15:04:09. %% Updated 11-Apr-2003 15:04:09. % %result = []; % %theCatalog = value(self); % %a = theCatalog.att; %result = cell(size(a)); %for i = 1:length(a) % result{i} = ddatt(self, a(i).name); %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "das.m" (text)') fout = fopen('das.m', 'w'); %function theResult = das(self) % %% dods/das -- Data Attribute Structure of a DODS object. %% das(self) returns the DAS of the DODS file %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 02-Apr-2003 15:50:01. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.das'; % %theURL = [self.itsURL theSuffix]; % %oldPWD = pwd; %cd(tempdir) %filename = [tempdir tmpname(theSuffix)]; %cd(oldPWD) % %status = wget(theURL, filename); % %fp = fopen(filename, 'r'); % %s = char(fread(fp)).'; % %fclose(fp); % %delete(filename) % %if nargout > 0 % theResult = s; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "dds.m" (text)') fout = fopen('dds.m', 'w'); %function theResult = dds(self) % %% dods/dds -- DODS Dataset Descriptor Structure. %% dds(self) returns the DDS of the DODS file %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 02-Apr-2003 15:50:01. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.dds'; % %theURL = [self.itsURL theSuffix]; % %oldPWD = pwd; %cd(tempdir) %filename = [tempdir tmpname(theSuffix)]; %cd(oldPWD) % %status = wget(theURL, filename); % %fp = fopen(filename, 'r'); % %s = char(fread(fp)).'; % %fclose(fp); % %delete(filename) % %if nargout > 0 % theResult = s; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "disp.m" (text)') fout = fopen('disp.m', 'w'); %function disp(self) % %% dods/disp -- Display a DODS object. %% disp(self) displays the DODS entity %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 15:03:31. %% Updated 02-Apr-2003 15:03:31. % %if nargin < 1, help(mfilename), return, end % %disp(' ') %disp(struct(self)) fclose(fout); disp(' ## Installing: "display.m" (text)') fout = fopen('display.m', 'w'); %function display(self) % %% dods/display -- Display a DODS object. %% display(self) displays the DODS entity %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 15:03:31. %% Updated 02-Apr-2003 15:03:31. % %if nargin < 1, help(mfilename), return, end % %disp(' ') %disp([inputname(1) ' =']) %disp(self) fclose(fout); disp(' ## Installing: "dods.m" (text)') fout = fopen('dods.m', 'w'); %function self = dods(theURL) % %% dods/dods -- DODS Constructor. %% dods('theURL') constructs a DODS object, given %% 'theURL' ("http" protocol is assumed). DODS %% is the "Distributed Oceanographic Data System". %% The URL defaults to the example given in the %% DODS "Quick Start Guide". %% %% Syntax: %% %% dods_demo Demonstrations. %% %% dd = dods('a_File_URL') Open a DODS object. %% %% html(dd) Invoke DODS browser interface. %% info(dd) Display file info in browser. %% help(dd) Display DODS help in browser. %% %% x = dd{'var'}(ind1, ind2, ...) Get DODS variable data. %% %% The variable name is 'var'. %% The indices are base-1, as in Matlab, not base-0, %% as in the C-Language. %% %% ---------- DODS Toolbox Syntax ---------- %% %% In the following, dd represents a DODS file; %% d is a DODS dimension; v is a DODS variable; %% and a is a DODS attribute. Navigation through %% a DODS file proceeds by name, not index. The %% syntax is similar to that of the NetCDF Toolbox. %% %% d = dd('aDimname') % Dimension. %% length = d(1) or d(:) % Dimension length. %% %% a = dd.anAttname; % Global attribute. %% value = a(:) or a(indices) % Attribute data. %% %% v = dd{'aVarname'} % Variable. %% value = v(indices, ...) % Variable data. %% %% a = dd{'aVarname'}.anAttname % Variable attribute. %% a = v.anAttname % Variable attribute. %% value = a(:) or a(indices) % Attribute data. %% %% dims = dim(dd) % List of dimension objects. %% vars = var(dd) % Variables. %% atts = att(dd) % Global attributes. %% %% atts = var(v) % List of variable attribute objects. %% %% names = ddnames(anyList of dods-related objects) %% %% itsName = name(aDDItem) %% itsDatatype = datatype(aDDItem) %% %% itsSize = size(aDDItem) % Matlab-friendly size. %% itsDDSize = ddsize(aDDItem) % DODS-friendly size. %% %% itsValue = value(aDDItem) % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:32:42. %% Updated 25-Apr-2003 15:38:31. % %if nargin < 1 % help(mfilename) % theURL = ... % ['http://www.cdc.noaa.gov/cgi-bin/nph-nc/' ... % 'Datasets/reynolds_sst/sst.mnmean.nc'] %end % %theStruct.itsDate = []; %theStruct.itsURL = []; %theStruct.itsDDS = []; %theStruct.itsDAS = []; %theStruct.itsVER = []; %theStruct.itsCAT = []; % Catalog. % %if ~any(findstr(theURL, 'http://')) % theURL = ['http://' theURL]; %end % %theItem = dditem([], theURL, [], [], []); % %self = class(theStruct, 'dods', theItem); % %self.itsDate = datestr(now); %self.itsURL = theURL; %self.itsVER = ver(self); %if isempty(self.itsVER) % disp([' ## Unable to connect to DODS URL:']) % disp([' ## ' theURL]) %else % self.itsDDS = dds(self); % self.itsDAS = das(self); %end % %if ~isempty(self.itsDDS) % self.itsDDS = parse_dds(self.itsDDS); % if ~isempty(self.itsDAS) % self.itsDAS = parse_das(self.itsDAS); % self.itsCAT = dods2struct(self); % end %end % %self = value(self, self.itsCAT); fclose(fout); disp(' ## Installing: "help.m" (text)') fout = fopen('help.m', 'w'); %function theResult = help(self) % %% dods/help -- Help for a DODS object. %% help(self) returns "help" for the DODS object %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 04-Apr-2003 09:40:06. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.help'; % %theURL = [self.itsURL theSuffix]; % %oldPWD = pwd; %cd(tempdir) %filename = [tempdir tmpname(theSuffix)]; %cd(oldPWD) % %status = web(theURL); % %if nargout > 0 % theResult = status; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "html.m" (text)') fout = fopen('html.m', 'w'); %function theResult = html(self) % %% dods/html -- Data Access Form for a DODS object. %% html(self) displays the "Data Access Form" of the %% DODS file represented by self, a "dods" object. %% The form is shown in the Matlab web-browser. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 02-Apr-2003 14:43:57. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.html'; % %theURL = [self.itsURL theSuffix]; % %status = web(theURL); % %if nargout > 0 % theResult = status; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "info.m" (text)') fout = fopen('info.m', 'w'); %function theResult = info(self) % %% dods/info -- Dataset Information of a DODS object. %% info(self) displays the "Dataset Information" of %% the DODS file represented by self, a "dods" object. %% The information is shown in the Matlab browser. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 02-Apr-2003 14:43:57. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.info'; % %theURL = [self.itsURL theSuffix]; % %status = web(theURL); % %if nargout > 0 % theResult = status; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "numel.m" (text)') fout = fopen('numel.m', 'w'); %function theResult = numel(varargin) % %% dods/numel -- Generic NUMEL. %% numel(...) returns 1 always. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 15:31:40. %% Updated 02-Apr-2003 15:31:40. % %if nargin < 1, help(mfilename), return, end % %theResult = 1; fclose(fout); disp(' ## Installing: "subsref.m" (text)') fout = fopen('subsref.m', 'w'); %function theResult = subsref(self, theStruct) % %% dods/subsref -- Process right-side subscripting. %% subsref(self, theStruct) processes subscripting %% on the right-hand side of an expression, on behalf %% of self, a "dods" object. %% %% self('aDimname') %% self.anAttname(...) %% self{'aVarname'}(...) %% self{'aVarname'}.anAttname(...) % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 15:08:23. %% Updated 09-Apr-2003 15:20:45. % %if nargin < 2, help(mfilename), return, end %if nargout > 0, theResult = []; end % %for i = 1:length(theStruct) % if ~iscell(theStruct(i).subs) % theStruct(i).subs = {theStruct(i).subs}; % end %end % %theType = theStruct(1).type; %theSubs = theStruct(1).subs; % %switch theType % case '.' % Global attribute. % theAttname = theSubs{1}; % result = ddatt(self, theAttname); % theStruct(1) = []; % if ~isempty(theStruct) % result = subsref(result, theStruct); % end % case '()' % Dimension. % theDimname = theSubs{1}; % result = dddim(self, theDimname); % case '{}' % Variable. % theVarname = theSubs{1}; % result = ddvar(self, theVarname); % theStruct(1) = []; % if ~isempty(theStruct) % result = subsref(result, theStruct); % end % otherwise % error([' ## Illegal subscripting type: ' theType]) %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "var.m" (text)') fout = fopen('var.m', 'w'); %function theResult = var(self) % %% dods/var -- List of "ddvar" variables. %% var(self) returns the list of "ddvar" objects %% associated with self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 15:04:09. %% Updated 11-Apr-2003 15:04:09. % %result = []; % %theCatalog = value(self); % %v = theCatalog.var; %result = cell(size(v)); %for i = 1:length(v) % result{i} = ddvar(self, v(i).name); %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "ver.m" (text)') fout = fopen('ver.m', 'w'); %function theResult = ver(self) % %% dods/ver -- Version of a DODS object. %% ver(self) returns the version of the DODS server %% represented by self, a "dods" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Apr-2003 17:36:00. %% Updated 04-Apr-2003 09:40:06. % %if nargin < 1, help(mfilename), return, end % %theSuffix = '.ver'; % %theURL = [self.itsURL theSuffix]; % %oldPWD = pwd; %cd(tempdir) %filename = [tempdir tmpname(theSuffix)]; %cd(oldPWD) % %status = wget(theURL, filename); % %fp = fopen(filename, 'r'); % %s = char(fread(fp)).'; % %fclose(fp); % %delete(filename) % %if nargout > 0 % theResult = s; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'dods') fclose(fout); cd ('..') bund_setdir('@dditem') disp(' ## Installing: "datatype.m" (text)') fout = fopen('datatype.m', 'w'); %function theResult = datatype(self) % %% dditem/datatype -- Datatype of a DODS item. %% datatype(self) returns the datatype of the %% DODS item represented by self, a "dditem" %% object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:04:32. %% Updated 10-Apr-2003 15:04:32. % %result = self.itsDatatype; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "dditem.m" (text)') fout = fopen('dditem.m', 'w'); %function self = dditem(theParent, theName, ... % theDatatype, theSize, theValue) % %% dditem/dditem -- Constructor for DODS base object. %% dditem(theParent, theName, theDatatype, theSize, theValue) %% constructs a "dditem" object with the given parent, name, %% datatype, size, and value. The parameters adhere to %% DODS conventions, not Matlab. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 11:01:38. %% Updated 11-Apr-2003 11:52:46. % %theStruct.itsParent = []; %theStruct.itsName = []; %theStruct.itsDatatype = []; %theStruct.itsSize = []; %theStruct.itsValue = []; % %self = class(theStruct, 'dditem'); % %if nargin > 0, self.itsParent = theParent; end %if nargin > 1, self.itsName = theName; end %if nargin > 2, self.itsDatatype = theDatatype; end %if nargin > 3, self.itsSize = theSize; end %if nargin > 4, self.itsValue = theValue; end fclose(fout); disp(' ## Installing: "ddsize.m" (text)') fout = fopen('ddsize.m', 'w'); %function theResult = ddsize(self) % %% dditem/ddsize -- DODS-friendly size. %% ddsize(self) returns the DODS-friendly size %% of the item represented by self, a "dditem" %% object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 10:03:44. %% Updated 11-Apr-2003 10:03:44. % %result = self.itsSize; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "disp.m" (text)') fout = fopen('disp.m', 'w'); %function disp(self) % %% dditem/disp -- Display a DODS item. %% disp(self) displays the properties of the %% DODS item associated with self, a "dditem" %% object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 13:24:02. %% Updated 11-Apr-2003 13:24:02. % %s.name = name(self); %s.datatype = datatype(self); %s.ddsize = ddsize(self); %s.value = value(self); % %disp(s) fclose(fout); disp(' ## Installing: "display.m" (text)') fout = fopen('display.m', 'w'); %function display(self) % %% dditem/display -- Display a DODS item. %% display(self) displays the properties %% of the DODS item associated with self, %% a "dditem" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 13:25:26. %% Updated 11-Apr-2003 13:25:26. % %disp(' ') %disp([inputname(1) ' =']) % %disp(' ') %disp(self) fclose(fout); disp(' ## Installing: "message.m" (text)') fout = fopen('message.m', 'w'); %function message(self, theMessage) % %% dditem/message -- Post a message. %% message(self) posts the given message on %% behalf of self, a "dditem" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 16:11:07. %% Updated 11-Apr-2003 16:11:07. % %if nargin < 2 % theMessage = '(No message was specified.)'; %end % %disp(' ') %disp([' ## From the "' class(self) '" object named: "' name(self) '"']) %disp([' ## Message: ' theMessage]) %disp(' ') fclose(fout); disp(' ## Installing: "name.m" (text)') fout = fopen('name.m', 'w'); %function theResult = name(self) % %% dditem/name -- Name of a DODS item. %% name(self) returns the name of the DODS item %% represented by self, a "dditem" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:04:32. %% Updated 10-Apr-2003 15:04:32. % %result = self.itsName; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "parent.m" (text)') fout = fopen('parent.m', 'w'); %function theResult = parent(self) % %% dditem/parent -- Parent of a DODS item. %% parent(self) returns the parent of the DODS item %% represented by self, a "dditem" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:04:32. %% Updated 10-Apr-2003 15:04:32. % %result = self.itsParent; % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "size.m" (text)') fout = fopen('size.m', 'w'); %function theResult = size(self) % %% dditem/size -- Size of a DODS item. %% dditem(self) returns the Matlab-friendly size %% of the DODS item represented by self, a "dditem" %% object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 14:58:54. %% Updated 10-Apr-2003 14:58:54. % %result = self.itsSize; % %while length(result) < 2 % result = [result 1]; %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "value.m" (text)') fout = fopen('value.m', 'w'); %function theResult = value(self, theNewValue) % %% dditem/value -- Get/set value in a DODS item. %% value(self) returns the current value of the %% item represented by self, a "dditem" object. %% value(self, theNewValue) sets the value of %% self to the given value. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 16:57:56. %% Updated 10-Apr-2003 16:57:56. % %if nargin < 2 % result = self.itsValue; %else % result = self; % result.itsValue = theNewValue; %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'dditem') fclose(fout); disp(' ## Installing: "wget.status" (binary)') fout = fopen('wget.status', 'w'); %?2d2d31373a30303a34362d2d2020687474703a2f2f7777772e %?6364632e6e6f61612e676f762f6367692d62696e2f6e70682d %?6e632f44617461736574732f7265796e6f6c64735f7373742f %?7373742e6d6e6d65616e2e6e632e6461730a20202020202020 %?202020203d3e20602f746d702f746d70373632303936383333 %?302e646173270a5265736f6c76696e67207777772e6364632e %?6e6f61612e676f762e2e2e20646f6e652e0a436f6e6e656374 %?696e6720746f207777772e6364632e6e6f61612e676f765b31 %?34302e3137322e3135362e38315d3a38302e2e2e20636f6e6e %?65637465642e0a4854545020726571756573742073656e742c %?206177616974696e6720726573706f6e73652e2e2e20323030 %?204f4b0a4c656e6774683a20756e737065636966696564205b %?746578742f706c61696e5d0a0a20202020304b202e20202020 %?20202020202020202020202020202020202020202020202020 %?20202020202020202020202020202020202020202020202020 %?202020312e3734204d422f730a0a31373a30303a3437202831 %?2e3734204d422f7329202d20602f746d702f746d7037363230 %?3936383333302e64617327207361766564205b313832355d0a %?0a fclose(fout); cd ('..') bund_setdir('@dddim') disp(' ## Installing: "dddim.m" (text)') fout = fopen('dddim.m', 'w'); %function self = dddim(theDODS, theName, theLength) % %% dddim/dddim -- Constructor for DODS dimension object. %% dddim(theDODS, 'theName', theLength) constructs %% a DODS dimension object with the given DODS parent, %% name, and length. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 11:01:38. %% Updated 10-Apr-2003 11:01:38. % %if nargin < 1, theDODS = []; end %if nargin < 2, theName = []; end %if nargin < 3, theLength = []; end % %if ~isempty(theDODS) % theCatalog = value(theDODS); % d = theCatalog.dim; % for i = 1:length(d) % if isequal(theName, d(i).name) % theLength = d(i).length; % break % end % end %end % %if any(theLength) % theSize = 1; %else % theSize = []; %end % %theStruct.ignore = []; % %self = class(theStruct, 'dddim', ... % dditem(theDODS, theName, 'long', theSize, theLength)); fclose(fout); disp(' ## Installing: "subsref.m" (text)') fout = fopen('subsref.m', 'w'); %function theResult = subsref(self, theStruct) % %% dddim/subsref -- Process right-side subscripting. %% subsref(self, theStruct) processes right-side %% subscripting on behalf of self, a "dddim" %% object. %% %% self(1) -- Return the dimension length. %% self(:) --Same as above. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 13:43:48. %% Updated 11-Apr-2003 13:43:48. % %for i = 1:length(theStruct) % if ~iscell(theStruct(i).subs) % theStruct(i).subs = {theStruct(i).subs}; % end %end % %theType = theStruct(1).type; %theSubs = theStruct(1).subs; % %if length(theSubs) == 1 % if isequal(theSubs{1}, ':') % theStruct(1).subs{1} = 1; % end %end % %result = subsref(value(self), theStruct); % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'dddim') fclose(fout); cd ('..') bund_setdir('@ddvar') disp(' ## Installing: "att.m" (text)') fout = fopen('att.m', 'w'); %function theResult = att(self) % %% ddvar/att -- List of "ddatt" attributes. %% att(self) returns the list of "ddatt" objects %% associated with self, a "ddvar" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 15:04:09. %% Updated 11-Apr-2003 15:04:09. % %result = []; % %theVarname = name(self); % %theCatalog = value(parent(self)); % %v = theCatalog.var; %for j = 1:length(v) % if isequal(theVarname, v(j).name) % a = v(j).att; % result = cell(size(a)); % for i = 1:length(a) % result{i} = ddatt(self, a(i).name); % end % end %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "ddvar.m" (text)') fout = fopen('ddvar.m', 'w'); %function self = ddvar(theParent, theName, ... % theDatatype, theSize, theValue) % %% ddvar/ddvar -- Constructor for DODS variable object. %% ddvar(theParent, 'theName', 'theDatatype', theSize) %% constructs a DODS variable object from the given %% parent, name, datatype, size, and value (if any). % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:32:49. %% Updated 11-Apr-2003 09:58:54. % %if nargin < 1, theParent = []; end %if nargin < 2, theName = []; end %if nargin < 3, theDatatype = []; end %if nargin < 4, theSize = []; end %if nargin < 5, theValue = []; end % %if nargin < 3 % c = value(theParent); % v = c.var; % for j = 1:length(v) % if isequal(theName, v(j).name) % theDatatype = v(j).type; % d = v(j).dim; % theSize = zeros([1 length(d)]); % for i = 1:length(d) % theSize(i) = d(i).length; % end % end % end %end % %theStruct.ignore = []; % %self = class(theStruct, 'ddvar', ... % dditem(theParent, theName, ... % theDatatype, theSize, theValue)); fclose(fout); disp(' ## Installing: "subsref.m" (text)') fout = fopen('subsref.m', 'w'); %function theResult = subsref(self, theStruct) % %% ddvar/subsref -- Process right-side subscripting. %% subsref(self, theStruct) processes right-side %% subscripting on behalf of self, a "ddvar" %% object. For a single colon-index, the full %% value of the variable is returned, in its %% original orientation. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 12:46:44. %% Updated 11-Apr-2003 12:46:44. % %result = []; % %for i = 1:length(theStruct) % if ~iscell(theStruct(1).subs) % theStruct(i).subs = {theStruct(i).subs}; % end %end % %theType = theStruct(1).type; %theSubs = theStruct(1).subs; % %switch theType % case '()' % theSize = ddsize(self); % if length(theSubs) == 1 % for i = 1:length(theSubs) % if isequal(theSubs{i}, ':') % theSubs{i} = 1:theSize(i); % end % end % end % otherwise %end % %switch theType % case '()' % result = ddquery(self, theSubs{:}); % case '.' % theAttname = theSubs{1}; % result = ddatt(self, theAttname); % theStruct(1) = []; % if ~isempty(theStruct) % result = subsref(result, theStruct); % end % otherwise % dderror(['Unknown subscript type: ' theType]) %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'ddvar') fclose(fout); cd ('..') bund_setdir('@ddatt') disp(' ## Installing: "ddatt.m" (text)') fout = fopen('ddatt.m', 'w'); %function self = ddatt(theParent, theName, theDatatype, theValue) % %% ddatt/ddatt -- Constructor for DODS attribute object. %% ddatt(theParent, 'theName', 'theDatatype', theValue) %% constructs a DODS attribute object with the given %% parent, name, datatype, and value. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:16:43. %% Updated 10-Apr-2003 16:46:08. % %if nargin < 1, theParent = []; end %if nargin < 2, theName = []; end %if nargin < 3, theDatatype = []; end %if nargin < 4, theValue = []; end % %theStruct.ignore = []; % %if ~isempty(theParent) & ~isempty(theName) % switch class(theParent) % case 'dods' % theVarname = []; % theDODS = theParent; % case 'ddvar' % theVarname = name(theParent); % theDODS = parent(theParent); % otherwise % dderror('Illegal parent class.') % end % % theCatalog = value(theDODS); % % if isempty(theVarname) % a = theCatalog.att; % for i = 1:length(a) % if isequal(theName, a(i).name) % theValue = a(i).value; % theDatatype = a(i).type; % theSize = length(theValue); % break % end % end % else % done = 0; % v = theCatalog.var; % for j = 1:length(v) % if isequal(theVarname, v(j).name) % a = v(j).att; % for i = 1:length(a) % if isequal(theName, a(i).name) % theValue = a(i).value; % theDatatype = a(i).type; % theSize = length(theValue); % done = 1; % break % end % end % end % if done, break, end % end % end %end % %self = class(theStruct, 'ddatt', ... % dditem(theParent, theName, ... % theDatatype, theSize, theValue)); fclose(fout); disp(' ## Installing: "displ.m" (text)') fout = fopen('displ.m', 'w'); %function disp(self) % %% ddatt/disp -- DISP of a DODS attribute. %% disp(self) displays the DODS attribute %% associated with self, a "ddatt" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:22:24. %% Updated 10-Apr-2003 15:22:24. % %disp(' ') %disp(parent(self)) %disp(struct(self)) fclose(fout); disp(' ## Installing: "display.m" (text)') fout = fopen('display.m', 'w'); %function display(self) % %% ddatt/display -- DISPLAY a DODS attribute. %% display(self) displays the DODS attribute %% associated with self, a "ddatt" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:23:18. %% Updated 10-Apr-2003 15:23:18. % %disp(' ') %disp([inputname(1) ' =']) % %disp(self) fclose(fout); disp(' ## Installing: "subsref.m" (text)') fout = fopen('subsref.m', 'w'); %function theResult = subsref(self, theStruct) % %% ddatt/subsref -- Process right-side subscripting. %% subsref(self, theStruct) processes right-side %% subscripting to the DODS attribute associated %% with self, a "ddatt" object. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 13:28:13. %% Updated 11-Apr-2003 13:28:13. % %for i = 1:length(theStruct) % if ~iscell(theStruct(i).subs) % theStruct(i).subs = {theStruct(i).subs}; % end %end % %theType = theStruct(1).type; %theSubs = theStruct(1).subs; % %% If colon-notation, prepare to return %% the attribute orientation intact. % %if length(theSubs) == 1 % switch theSubs{1} % case ':' % len = prod(size(self)); % theStruct(1).subs{1} = 1:len; % otherwise % end %end % %% Process the reference. % %result = subsref(value(self), theStruct); % %% Return. % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'ddatt') fclose(fout); cd ('..') bund_setdir('@ddquery') disp(' ## Installing: "ddquery.m" (text)') fout = fopen('ddquery.m', 'w'); %function theResult = ddquery(theVariable, varargin) % %% ddquery/ddquery -- Make a DODS ".asc" data query. %% ddquery(theVariable, theIndices) launches a query %% to the given DODS variable with the given array %% indices (a cell array). The response is parsed %% and returned as a Matlab array of intended size, %% or [] if the query is unsuccessful. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 10-Apr-2003 15:52:02. %% Updated 29-Apr-2003 13:45:04. % %result = []; % %theStruct.ignore = []; %self = class(theStruct, 'ddquery'); % %theVarname = name(theVariable); %theSize = size(theVariable); %theURL = name(parent(theVariable)); % %% Translate any colon (':') notation to %% the length of that particular dimension. % %theIndices = varargin; %for i = 1:length(theIndices) % if isequal(theIndices{i}, ':') % theIndices{i} = 1:theSize(i); % end %end % %theExpectedSize = zeros(1, length(theIndices)); %for i = 1:length(theExpectedSize) % theExpectedSize(i) = length(theIndices{i}); %end % %theURL = [theURL '.asc?' theVarname]; % %for i = 1:length(theIndices) % k = theIndices{i} - 1; % Zero-base indices. % k1 = k(1); % dk = 1; % if length(k) > 1 % dk = diff(k); % dk = dk(1); % end % kn = k(end); % theURL = [theURL ... % '[' int2str(k1) ':' int2str(dk) ':' int2str(kn) ']']; %end % %oldPWD = pwd; % %try % cd(tempdir) % theTempfile = [tempdir tmpname('.tmp')]; % % try % [thePath, theStatus] = urlwrite(theURL, theTempfile); % catch % disp(' ## Error during URLWRITE; trying WGET.') % theStatus = wget(theURL, theTempfile); % end % % result = loadasc(theTempfile, theVarname, theExpectedSize); % % delete(theTempfile) %end % %cd(oldPWD) % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end % %% ---------- loadasc() ---------- % % %function theResult = loadasc(theFilename, theVariable, theSize) % %% loadasc -- Load DODS ".asc" reply. %% loadasc('theFilename', theVariable, theSize) loads the %% variable data from the given ascii file, assuming the %% format of a DODS ".asc" reply. The result is an array %% of theSize, to be determined by the caller. Vectors %% are oriented column-wise. Note that Matlab may %% eliminate trailing singleton dimensions. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 17:01:39. %% Updated 07-Apr-2003 16:03:20. % %END_OF_FILE = -1; % %if nargin < 2, help(mfilename), return, end % %theResult = []; % %theMatlabSize = theSize; % %while length(theMatlabSize) < 2 % theMatlabSize = [theMatlabSize 1]; %end % %% Use reversed dimensions, since DODS replies %% are C-like (rightmost index varies fastest), %% whereas Matlab indexing is Fortran-like %% (leftmost index varies fastest). % %fp = fopen(theFilename, 'r'); %if fp < 0 % disp([' ## Unable to open DODS reply-file.']) % return %end % %s = fgetl(fp); %if length(s) > 6 & isequal(s(1:7), 'Dataset') % theResult = zeros(fliplr(theMatlabSize)); % s = fgetl(fp); % f = find(s == ','); % theName = s(1:f(1)-1); % flag = isequal(theName, theVariable); % k = 0; % One-dimensional index for result. % while (1) % Iterate until end-of-file. % if ~flag, s = fgetl(fp); end % flag = 0; % if s == END_OF_FILE, break, end % i = 0; % while s(i+1) ~= ',', i = i+1; end % Find first comma. % x = eval(['[' s(i+1:end) ']']); % Comma-separated list. % theResult(k+1:k+length(x)) = x; % k = k + length(x); % end % fclose(fp); % theResult = permute(theResult, [length(theMatlabSize):-1:1]); %else % fclose(fp); % disp([' ## Sought ' int2str(prod(theSize)) ' value(s).']) % disp([' ## None returned.']) %end fclose(fout); disp(' ## Installing: "version.m" (text)') fout = fopen('version.m', 'w'); %function version(self) % %% Version of 01-May-2003 12:01:54. % %helpdlg(help(mfilename), 'ddquery') fclose(fout); cd ('..') disp(' ## Installing: "at.m" (text)') fout = fopen('at.m', 'w'); %function theResult = at(theFile, theOffset) % %% at -- Switch to the folder of a given file. %% at('theFunction') switches to the folder of %% 'theFunction', as determined by the "which" %% function. %% at('theFunction', theOffset) performs as above, %% then marches into higher directories by the %% amount of theOffset, which must be a negative %% integer. % %% 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 22-Apr-2003 09:19:37. % %if nargout > 0, theResult = []; end % %if nargin < 1, help(mfilename), return, end %if nargin < 2, theOffset = 0; end %if ischar(theOffset), theOffset = eval(theOffset); end % %w = which(theFile); % %if isempty(w) % w = which([theFile '/' theFile]); % if isempty(w) % disp([' ## No such file: ' theFile]) % return % end %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) % if theOffset < 0 % for i = 1:fix(abs(theOffset)) % cd .. % end % end %end % %if nargout > 0 % theResult = pwd; %else % disp([' ## ' pwd]) %end fclose(fout); disp(' ## Installing: "dderror.m" (text)') fout = fopen('dderror.m', 'w'); %function dderror(theMessage) % %% dderror -- Post a DODS error message. %% dderror('theMessage') posts a DODS error message. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 12:01:10. %% Updated 11-Apr-2003 12:01:10. % %if nargin < 1 % theMessage = ['An unspecified DODS error has occurred.']; %end % %disp(' ') %error([' ## dderror: ' theMessage]) fclose(fout); disp(' ## Installing: "ddnames.m" (text)') fout = fopen('ddnames.m', 'w'); %function theResult = ddnames(theDDList) % %% ddnames -- Names of a list of DODS objects. %% ddnames(theDDList) returns a list of the %% names of the items in theDDList. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 15:16:57. %% Updated 11-Apr-2003 15:16:57. % %result = cell(size(theDDList)); % %for i = 1:length(theDDList) % result{i} = name(theDDList{i}); %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) %end fclose(fout); disp(' ## Installing: "dods2struct.m" (text)') fout = fopen('dods2struct.m', 'w'); %function theResult = dods2struct(theDODS, theDDS, theDAS) % %% dods2struct -- Struct representing DODS. %% dods2struct(theDODS) returns a struct with %% fields "dim", "var", and "att", summarizing %% the structure of the DODS file or object. %% The sub-fields are: %% %% dim: name, length %% var: name, type, dim, att %% att: name, type, value %% dods2struct('theURL', theDDS, theDAS) is an %% alternative syntax. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 09-Apr-2003 11:25:30. %% Updated 09-Apr-2003 13:23:59. % %if nargout > 0, theResult = []; end % %if isa(theDODS, 'dods') % theURL = name(theDODS); % theDODS = struct(theDODS); % theDDS = theDODS.itsDDS; % theDAS = theDODS.itsDAS; %end % %var = theDDS; %att = theDAS; % %% Assemble the dimensions. % %dim = []; %dimname = {}; % %for j = 1:length(var) % for i = 1:length(var(j).dim) % if isempty(dim) % dim = var(j).dim(i); % dimname{1} = var(j).dim(i).name; % else % dim(end+1) = var(j).dim(i); % dimname{end+1} = var(j).dim(i).name; % end % end %end % %% Eliminate duplicate dimension names. % %[sorted, indices] = sort(dimname); %for i = length(sorted):-1:2 % if isequal(sorted{i}, sorted{i-1}) % indices(i) = 0; % end %end %indices(indices == 0) = []; %dim = dim(sort(indices)); % %% Assemble the attributes. % %for j = 1:length(var) % for i = 1:length(att) % if isequal(var(j).name, att(i).name) % for k = 1:length(att(i).att) % var(j).att(k) = att(i).att{k}; % end % end % end %end % %% Assemble the global attributes. % %gatt = []; % %for i = 1:length(att) % if isequal(att(i).name, 'NC_GLOBAL') % for k = 1:length(att(i).att) % if isempty(gatt) % gatt = att(i).att{k}; % else % gatt(k) = att(i).att{k}; % end % end % end %end % %% Assemble the result. % %s = []; %s.name = theURL; %s.dim = dim; %s.var = var; %s.att = gatt; % %% Return. % %if nargout > 0 % theResult = s; %else % assignin('caller', 'ans', s) %end fclose(fout); disp(' ## Installing: "dods_bundle.m" (text)') fout = fopen('dods_bundle.m', 'w'); %function dods_bundle % %% dods_bundle -- Bundle the DODS class. %% dods_bundle (no arguments) bundles the %% "dods" class and associated utilities. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 02-Apr-2003 17:26:41. %% Updated 01-May-2003 11:47:22. % %theMFiles = { % mfilename % 'dods_demo' % 'dods_demo1' % 'dods_demo2' % 'parse_dds' % 'parse_das' % 'dods2struct' % 'ddnames' % 'dderror' % 'wget' % 'labelsafe' % 'at' % 'tmpname' %}; % %theMFiles = sort(theMFiles); % %theClasses = { % 'dods' % 'dditem' % 'dddim' % 'ddvar' % 'ddatt' % 'ddquery' %}; % %for i = 1:length(theClasses) % newversion(theClasses{i}) %end % %theMessage = { % ' ' % ' ## -- DODS Toolbox for Matlab 6+ --' % ' ' % ' ## Add the "dods" directory to your Matlab path.' % ' ## Then, execute "dods_demo" at the Matlab prompt.' % ' ' % ' ## Note: If your Matlab lacks the URLWRITE function,' % ' ## this toolbox will attempt to use WGET. See' % ' ## "help wget" for instructions on obtaining the' % ' ## WGET utility.' % ' ' %}; % %theName = 'dods'; % %at(mfilename) % %newversion(theName) % %bund('new', theName) %bund('setdir', theName) % %bund('class', theClasses) %bund('mfile', theMFiles) %bund('disp', theMessage) % %bund cd .. % %bund close fclose(fout); disp(' ## Installing: "dods_demo.m" (text)') fout = fopen('dods_demo.m', 'w'); %function theResult = dods_demo(N) % %% dods_demo -- Simple demonstrations of DODS. %% dods_demo (no arguments) runs some DODS demonstrations. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 03-Apr-2003 11:14:02. %% Updated 03-Apr-2003 15:39:30. % %figure; % %dods_demo1 % %figure; % %dods_demo2 fclose(fout); disp(' ## Installing: "dods_demo1.m" (text)') fout = fopen('dods_demo1.m', 'w'); %function theResult = dods_demo1(N) % %% dods_demo1 -- Simple demonstration of DODS. %% dods_demo1(N) plots the N-th sea-surface temperature %% (sst) from the DODS example (N = 1..254, default = 1). %% The "dods" object is returned. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 03-Apr-2003 11:14:02. %% Updated 03-Apr-2003 15:39:30. % %RCF = 180/pi; % %if nargin < 1, N = 1; end %if ischar(N), N = eval(N); end % %N = min(max(1, N), 254); % %d = dods; % %if isempty(d), return, end % %lon = d{'lon'}(1:360); %lat = d{'lat'}(1:180); %lat = sin(lat/RCF); % %[lon, lat] = meshgrid(lon, lat); % %time = d{'time'}(N); % %disp(' ## Retrieving the SST data...') %tic %sst = d{'sst'}(1, 1:180, 1:360); %elapsed = toc; %elapsed = fix(toc*10)/10; %disp([' ## Retrieval time: ' num2str(elapsed) ' s.']) % %sst = sst * 0.009999999776; % Scale-factor from DAS. %sst = squeeze(sst); % %mask = d{'mask'}(1:180, 1:360); %sst(~mask) = NaN; % %surf(lon, lat, sst) % %shading flat % %xlabel Longitude %ylabel sin(Latitude) %zlabel Temperature % %t = name(d); %t(1:7) = ''; % %title(labelsafe(t)) % %set(gcf, 'Name', [num2str(time) ' Days Since Creation.']) % %view(2) %axis tight % %set(gca, 'Color', 'k') % %colorbar % %pos = get(gcf, 'Position'); %pos(3) = 2*pos(4); %set(gcf, 'Position', pos) % %figure(gcf) % %if nargout > 0 % theResult = d; %else % assignin('caller', 'ans', d) %end fclose(fout); disp(' ## Installing: "dods_demo2.m" (text)') fout = fopen('dods_demo2.m', 'w'); %function theResult = dods_demo2 % %% dods_demo2 -- DODS Demonstration. %% dods_demo2 (no argument) demonstrates some %% some temperature data from a DODS file. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 11-Apr-2003 15:38:01. %% Updated 11-Apr-2003 15:38:01. % %stellwagen = [ ... % 'http://stellwagen.er.usgs.gov/' ... % 'cgi-bin/nph-nc/data/time_series/fy2001/' %]; % %file = '3891-a_d0.nc'; % %theURL = [stellwagen file]; % %assignin('caller', 'theURL', theURL) % %d = dods(theURL); % %if isempty(d), return, end % %N = 3959; % %disp(' ## Retrieving time...') % %tic % %t = d{'time'}(1:N); % days. %t2 = d{'time2'}(1:N); % msec. % %time = t + t2/(24*60*60*1000); %time = time - time(1); % %disp(' ## Retrieving T_20...') % %T_20 = d{'T_20'}(1:N, 1, 1, 1); % %elapsed = toc; %elapsed = fix(toc*10)/10; %disp([' ## Retrieval time: ' num2str(elapsed) ' s.']) % %plot(time, T_20) % %xlab = [d{'time'}.units(:)]; %f = find(xlab~= ' '); %if any(f) % xlab = xlab(f(1):f(end)); %end % %ylab = [d{'T_20'}.long_name(:)]; %f = find(ylab~= ' '); %if any(f) % ylab = ylab(f(1):f(end)); %end % %xlabel([xlab ' - ' int2str(t(1))]) %ylabel(ylab) %title(labelsafe(name(d))) % %figure(gcf) %set(gcf, 'Name', mfilename) % %if nargout > 0 % theResult = d; %else % assignin('caller', 'ans', d) %end fclose(fout); disp(' ## Installing: "labelsafe.m" (text)') fout = fopen('labelsafe.m', 'w'); %function theResult = LabelSafe(theLabel) % %% LabelSafe -- Safe label for axes. %% LabelSafe('theLabel') modifies 'theLabel' by %% "escaping" instances of '\', '_', and '\^', %% after removing all instances of char(0) and '\0'. %% Existing escapes remain intact. The result is %% suitable as a title or axis label on a graph. %% LabelSafe (no argument) demonstrates itself. % %% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 01-Aug-1997 14:37:55. %% Version of 17-Nov-1997 13:35:12. % %if nargin < 1 % help(mfilename) % label = '\0_hello\world^'; % result = labelsafe(label); % begets(mfilename, 1, label, result) % return %end % %result = theLabel; % %if ~isempty(result) % result = strrep(result, char(0), ''); % result = strrep(result, '\0', ''); % % result = strrep(result, '\\', char(1)); % result = strrep(result, '\_', char(2)); % result = strrep(result, '\^', char(3)); % % result = strrep(result, '\', '\\'); % result = strrep(result, '_', '\_'); % result = strrep(result, '^', '\^'); % % result = strrep(result, char(1), '\\'); % result = strrep(result, char(2), '\_'); % result = strrep(result, char(3), '\^'); %end % %if ~isempty(result) % f = find(result ~= ' '); % if any(f) % result = result(f(1):f(length(f))); % end %end % %if nargout > 0 % theResult = result; % else % disp(result) %end fclose(fout); disp(' ## Installing: "parse_das.m" (text)') fout = fopen('parse_das.m', 'w'); %function theResult = parse_das(theDAS) % %% parse_das -- Parse a DODS Data Attribute Structure. %% parse_das(theDAS) parses the given DODS DAS. The %% variables are returned as an array of struct, with %% fields "name" and "att". The attributes themselves %% are a cell-array of struct, with fields "name", %% "type", and "value". %% %% v(i).name % Name of i-th variable. %% v(i).att(j).name % Name of j-th att of i-th var. %% v(i).att(j).type % Type of j-th att of i-th var. %% v(i).att(j).value % Value of j-th att of i-th var. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Apr-2003 10:17:36. %% Updated 09-Apr-2003 14:47:57. % %if nargin < 1, help(mfilename), return, end % %if isa(theDAS, 'dods') % theDAS = theDAS.das; %end % %theResult = parse(theDAS); % %% ---------- parse() ---------- % % %function theResult = parse(s) % %% Isolate the semi-colon punctuation. % %s = strrep(s, [';' char(10)], [' ; ' char(10)]); % %% Prime the lexical-analyzer. % %lexan(s) % %% Process variables until done. % %v = []; % Variables are accumulated here. %while (1) % tok = lexan; % if isempty(tok), break, end % switch tok % case 'Attributes' % match('{') % while ~isequal(lookahead, '}') % if length(v) < 1 % v = variable; % else % v(end+1) = variable; % end % end % match('}') % otherwise % hello % illegal(tok) % end %end % %theResult = v; % %% ---------- variable() ---------- % % %function theResult = variable % %a.name = []; % Predefine this structure. %a.type = []; %a.value = []; % %v.name = lexan; %v.att = {}; %match('{') % %while ~isequal(lookahead, '}') % a.type = lexan; % a.name = lexan; % a.value = lexan; % if a.value(1) == '"' % a.value = a.value(2:end-1); % else % a.value = eval(['[' a.value ']']); % end % v.att{end+1} = a; % match(';') %end %match('}') % %if nargout > 0 % theResult = v; %end % %% ---------- lexan() ---------- % % %function [theToken, theRemainder] = lexan(theString) % %persistent THE_REMAINDER % %if nargin > 0 % THE_REMAINDER = theString; %else % r = THE_REMAINDER; % [theToken, THE_REMAINDER] = strtok(THE_REMAINDER); % if length(theToken) > 0 % if theToken(1) == '"' | theToken(end) == ',' % i = 1; % while r(i+1) ~= ';' % i = i+1; % end % theToken = r(1:i); % while theToken(1) == ' ' % theToken(1) = ''; % end % f = find(theToken == '"'); % if theToken(1) == '"' & length(f) > 1 % theToken = theToken(f(1):f(end)); % end % r(1:i) = []; % THE_REMAINDER = r; % end % end % if nargout > 1, theRemainder = THE_REMAINDER; end %end % %% ---------- lookahead() ---------- % % %function theNextToken = lookahead % %[theNextToken, theRemainder] = lexan; %lexan([theNextToken ' ' theRemainder]) % %% ---------- match() ---------- % % %function match(theToken) % %s = lexan; %if ~isequal(theToken, s) % error([' ## Bad match: ' theToken ' ~= ' s]) %end % %% ---------- illegal() ---------- % % %function illegal(theToken) % %disp([' ## Illegal token: ' theToken]) %error(' ## Aborting.') fclose(fout); disp(' ## Installing: "parse_dds.m" (text)') fout = fopen('parse_dds.m', 'w'); %function theResult = parse_dds(theDDS) % %% parse_dds -- Parse a DODS Dataset Descriptor Structure. %% parse_dds(theDDS) parses the given DODS DDS. The %% variables are returned as an array of struct, with %% fields "name", "type", and "dim". The dimensions %% themselves are a cell-array of struct, with fields %% "name" and "length". %% %% v(i).name % Name of i-th variable. %% v(i).type % Type of i-th variable. %% v(i).dim(j).name % Name of j-th dim of i-th var. %% v(i).dim(j).length % Length of j-th dim of i-th var. % %% Copyright (C) 2003 Dr. Charles R. Denham, ZYDECO. %% All Rights Reserved. %% Disclosure without explicit written consent from the %% copyright owner does not constitute publication. % %% Version of 08-Apr-2003 10:17:36. %% Updated 09-Apr-2003 13:20:25. % %if nargin < 1, help(mfilename), return, end % %if isa(theDDS, 'dods') % theDDS = theDDS.dds; %end % %theResult = parse(theDDS); % %[names, indices] = sort({theResult.name}); %for i = length(names):-1:2 % if isequal(names{i}, names{i-1}) % indices(i) = 0; % end %end %indices(indices == 0) = []; %indices = sort(indices); %theResult = theResult(indices); % %% ---------- parse() ---------- % % %function theResult = parse(s) % %% Separate the punctuation tokens. % %s = strrep(s, '[', ' [ '); %s = strrep(s, ']', ' ] '); %s = strrep(s, ';', ' ; '); % %% Prime the lexical-analyzer. % %lexan(s) % %% Process datasets until done. % %v = []; % Variables are accumulated here. %while (1) % tok = lexan; % if isempty(tok), break, end % switch tok % case 'Dataset' % match('{') % while ~isequal(lookahead, '}') % v = [v variable]; % end % match('}') % theDatasetname = lexan; % match(';') % otherwise % hello % illegal(tok) % end %end % %theResult = v; % %% ---------- variable() ---------- % % %function theResult = variable % %v = []; % Variables are accumulated here. % %tok = lexan; % %switch tok % case 'Grid' % match('{') % match('ARRAY:') % v = variable; % match('MAPS:') % while ~isequal(lookahead, '}') % v(end+1) = variable; % end % match('}') % theGridname = lexan; % match(';') % otherwise % theType = tok; % theVarname = lexan; % v.name = theVarname; % v.type = theType; % % v.dim = {}; % v.dim = []; % while isequal(lookahead, '[') % match('[') % d = dimension; % % v.dim{end+1} = d; % if isempty(v.dim) % v.dim.name = d.name; % v.dim.length = d.length; % else % v.dim(end+1).name = d.name; % v.dim(end).length = d.length; % end % match(']') % end % match(';') %end % %if nargout > 0 % theResult = v; %end % %% ---------- dimension() ---------- % % %function theResult = dimension % %theDimname = lexan; %match('=') %theLength = lexan; % %d.name = theDimname; %d.length = eval(theLength); % %if nargout > 0 % theResult = d; %end % %% ---------- lexan() ---------- % % %function [theToken, theRemainder] = lexan(theString) % %persistent THE_REMAINDER % %if nargin > 0 % THE_REMAINDER = theString; %else % [theToken, THE_REMAINDER] = strtok(THE_REMAINDER); % if nargout > 1, theRemainder = THE_REMAINDER; end %end % %% ---------- lookahead() ---------- % % %function theNextToken = lookahead % %[theNextToken, theRemainder] = lexan; %lexan([theNextToken ' ' theRemainder]) % %% ---------- match() ---------- % % %function match(theToken) % %s = lexan; %if ~isequal(theToken, s) % error([' ## Bad match: ' theToken ' ~= ' s]) %end % %% ---------- illegal() ---------- % % %function illegal(theToken) % %disp([' ## Illegal token: ' theToken]) %error(' ## Aborting.') fclose(fout); disp(' ## Installing: "tmpname.m" (text)') fout = fopen('tmpname.m', 'w'); %function theResult = tmpname(extension) % %% tmpname -- File name suitable for temporary use. %% tmpname('extension') returns a non-existent filename with %% the given extension (default = none), suitable for use %% in the current directory. %% %% Also see: TEMPNAME, TEMPDIR. % %% 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 02-Apr-2002 14:50:26. %% Updated 02-Apr-2002 14:50:26. % %TMP_PREFIX = 'tmp'; % %if nargin < 1, extension = ''; end % %while (1) % number = int2str(rand(1, 1)*10^10); % while length(number) < 10 % number = ['0' number]; % end % result = [TMP_PREFIX number extension]; % fp = fopen(result, 'r'); % if fp < 0, break, end % fclose(fp); %end % %if nargout > 0 % theResult = result; %else % assignin('caller', 'ans', result) % disp(result) %end fclose(fout); disp(' ## Installing: "wget.m" (text)') fout = fopen('wget.m', 'w'); %function theResult = wget(theURL, theFilename) % %% wget -- Use Unix or PC "wget" to retrieve a URL. %% wget('theURL', 'theFilename') calls the "wget" %% utility to get 'theURL' and save it to 'theFilename'. %% If successful, TRUE (logical non-zero) is returned; %% otherwise, FALSE (logical 0). The message returned %% by "wget" is written to "wget.status". %% %% To obtain the "wget" utility: %% %% MacOSX: "fink install wgetssl" %% Unix: "http://wget.sunsite.dk" %% PCWIN: Follow link at Unix site to obtain %% zipped binaries of "wget" and "ssl". % %% 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 07-Feb-2000 16:22:07. %% Updated 03-Apr-2003 09:59:05. % %persistent WGET_PROGRAM % %if nargout > 0, theResult = []; end % %if nargin < 1 % help(mfilename) % return %end % %result = ~~0; % %% Get the path to the "wget" program. % %% theProgram = '/usr/local/bin/wget'; % Typical Unix. %% theProgram = '/sw/bin/wget'; % MacOSX Fink bin area. % %if isempty(WGET_PROGRAM) % [status, result] = system('which wget'); % if ~status % result(result < char(32)) = ''; % WGET_PROGRAM = result; % else % error(' ## Unable to locate the "wget" program.') % return % end %end % %theProgram = WGET_PROGRAM; % %if isunix & (exist(theProgram) == 2) % theCommand = ['!' theProgram ' ' ... % '--output-document="' theFilename '" ' ... % '--output-file="' mfilename '.status" ' ... % '"' theURL '"']; % eval(theCommand) % fp = fopen('wget.status', 'r'); % if fp >= 0 % s = char(fread(fp)).'; % fclose(fp); % result = ~any(findstr(s, 'ERROR')); % "crusty" status. % end %else % disp([' ## "' mfilename '" requires Unix and "' theProgram '".']) %end % %if nargout > 0, theResult = result; end fclose(fout); disp(' ') disp(' ## -- DODS Toolbox for Matlab 6+ --') disp(' ') disp(' ## Add the "dods" directory to your Matlab path.') disp(' ## Then, execute "dods_demo" at the Matlab prompt.') disp(' ') disp(' ## Note: If your Matlab lacks the URLWRITE function,') disp(' ## this toolbox will attempt to use WGET. See') disp(' ## "help wget" for instructions on obtaining the') disp(' ## WGET utility.') disp(' ') cd ('..')