📄 netcdf_install.m
字号:
%% ncatt/datatype -- Numeric type of an ncatt object.%% datatype(self) returns the numeric type of self,%% an "ncatt" object.% %% 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 07-Aug-1997 09:42:59.%%if nargin < 1, help(mfilename), return, end%%result = '';%%theTypes = {'byte', 'char', 'short', 'long', 'float', 'double'};%%theNCid = ncid(self);%%if theNCid >= 0% theVarid = varid(self);% theAttname = name(self);% [theType, theLen, status] = ncmex('attinq', theNCid, theVarid, theAttname);% if status >= 0 & ~isstr(theType)% theType = theTypes{theType};% end%else% theType = self.itsAtttype;%end%%result = theType;%%if nargout > 0% theResult = result;%else% disp(result)%endfclose(fout);disp(' ## Installing: "delete.m" (text)')fout = fopen('delete.m', 'w');%function theResult = delete(varargin)%%% ncatt/delete -- Delete a NetCDF attribute.%% delete(self) deletes the NetCDF attribute associated%% with self, an "ncatt" object, and returns [] if%% successful. Otherwise, it returns self.%% delete(att1, att2, ...) deletes the given attributes%% and the results in a list.% %% 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 07-Aug-1997 15:43:32.%%if nargin < 1, help(mfilename), return, end%%% If not all arguments are "ncatt" objects,%% let the the "netcdf" parent inherit.%%if nargin > 1% all_ncatt = 1;% for i = 1:length(varargin)% switch ncclass(varargin{i})% case 'ncatt'% otherwise% all_ncatt = 0; break% end% end% if ~all_ncatt% self = varargin{1};% theParent = parent(parent(self));% result = delete(theParent, varargin{:});% if nargout > 0, theResult = result; end% return% end%end%%self = varargin;%status = zeros(size(varargin));%%for i = 1:length(varargin)% theAtt = varargin{i};% status(i) = ncmex('attdel', ncid(theAtt), varid(theAtt), name(theAtt));% if status(i) < 0% theParent = parent(parent(theAtt));% theParent = redef(theParent);% if ~isempty(theParent)% status(i) = ncmex('attdel', ncid(theAtt), varid(theAtt), name(theAtt));% end% end% if status(i) > 0, self{i} = []; end%end%%if length(varargin) == 1, self = self{1}; end%%if all(status >= 0)% result = [];% else% result = self;%end%%if nargout > 0% theResult = result;%endfclose(fout);disp(' ## Installing: "dim.m" (text)')fout = fopen('dim.m', 'w');%function theResult = dim(self)%%% ncatt/dim -- Dimensions associated with attributes of the same name.%% dim(self) returns a list of the ncdim objects that are%% associated with variables that have an attribute with the%% same name as self, an ncatt object.% %% 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 07-Aug-1997 15:43:32.%%if nargin < 1, help(mfilename), return, end%%if nargout > 0, theResult = []; end%%[ndims, nvars, ngatts, recdim, status] = ...% ncmex('inquire', ncid(self));%if status < 0, return, end%%result = cell(0, 0);%for i = 1:nvars% varid = i - 1;% [varname, vartype, varndims, vardims, varnatts, status] = ...% ncmex('varinq', ncid(self), varid);% if status >= 0% nc = ncitem('', ncid(self));% v = ncvar(varname, nc);% a = att(v);% for j = 1:length(a)% if strcmp(name(a{j}), name(self))% result = [result dim(v)];% break% end% end% end%end%%if nargout > 0% theResult = result;% else% for i = 1:length(result)% disp(name(result{i}))% end%endfclose(fout);disp(' ## Installing: "gt.m" (text)')fout = fopen('gt.m', 'w');%function theResult = gt(self, other)%%% gt -- Greater-than operator; redirection operator.%% gt(self, other) returns the arithmetic greater-than%% comparison of self with other, for self, an ncatt%% object, and other, an ncatt, double, or char.%% gt(self, other) redirects self, an ncatt object,%% into other, a netcdf or ncvar object.% %% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.%% All Rights Reserved.%% Disclosure without explicit written consent from the%% copyright owner does not constitute publication.%%if nargin < 1, help(mfilename), return, end%%result = [];%%switch class(other)% case {'netcdf', 'ncvar'}% result = copy(self, other);% case 'ncatt'% a = self(:);% b = other(:);% if isequal(size(a), size(b)) | length(b) == 1% result = (a > b);% end% case {'double', 'char'}% a = self(:);% b = other;% if isequal(size(a), size(b)) | length(b) == 1% result = (a > b);% end% otherwise% warning(' ## Incompatible arguments.')%end%%if nargout > 0, theResult = result; endfclose(fout);disp(' ## Installing: "isglobal.m" (text)')fout = fopen('isglobal.m', 'w');%function theResult = isglobal(self)%%% ncatt/isglobal -- Is this a global atttribute?%% isglobal(self) returns TRUE (1) if self, an%% ncatt object, represents a global attribute.% %% 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 15-May-1997 11:57:05.%%if nargin < 1, help(mfilename), return, end%%result = (varid(self) < 0);%%if nargout > 0% theResult = result;% else% disp(result)%endfclose(fout);disp(' ## Installing: "lt.m" (text)')fout = fopen('lt.m', 'w');%function theResult = lt(self, other)%%% ncatt/lt -- Redirection operator.%% lt(self, other) redirects the contents of other,%% an ncatt, double, or char object, into self,%% an ncatt object.% %% 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 07-Aug-1997 15:43:32.%%if nargin < 1, help(mfilename), return, end%%result = [];%%switch class(other)% case 'ncatt'% result = copy(other, self);% a = self(:);% b = other(:);% if isequal(size(a), size(b)) | length(b) == 1% result = (a > b);% end% case {'double', 'char'}% a = self(:);% b = other;% if isequal(size(a), size(b)) | length(b) == 1% result = (a > b);% end% otherwise% warning(' ## Incompatible arguments.')%end%%if nargout > 0, theResult = result; endfclose(fout);disp(' ## Installing: "ncatt.m" (text)')fout = fopen('ncatt.m', 'w');%function self = ncatt(theAttname, theAtttype, theAttvalue, theParent)%%% ncatt/ncatt -- Constructor for ncatt class.%% ncatt(theAttname, theAtttype, theAttvalue, theParent) allocates%% an ncatt object with theAttname, theAtttype, and theAttvalue in%% theParent, a netcdf or an ncvar object. The redirection syntax%% is theParent < ncatt(theAttname, theAtttype, theAttvalue).%% The result is assigned silently to 'ans" if no output%% argument is given.%% ncatt(theAttname, theAttvalue, theParent) uses the class of%% theAttvalue as theAtttype ('char' or 'double').%% ncatt(theAttname, theParent) returns an ncatt object corresponding%% to the attribute of theAttname in theParent.%% ncatt (no argument) returns a raw "ncatt" object.%%%% N.B. To put/get the conventional '_FillValue' attribute of a variable,%% use 'FillValue_'.% %% 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 07-Aug-1997 15:45:48.%% Revised 19-Mar-1998 09:37:02.%%if nargin < 1 & nargout < 1, help(mfilename), return, end%%% Basic structure.%%theStruct.itsAtttype = '';%theStruct.itsAttvalue = '';%%% Raw object.%%if nargin < 1 & nargout > 0% self = class(theStruct, 'ncatt', ncitem);% return%end%%if strcmp(theAttname, 'FillValue_'), theAttname = '_FillValue'; end%%if nargin == 2% theParent = theAtttype;% theNCid = ncid(theParent);% theVarid = varid(theParent);% theAttnum = 0;% [theAtttype, theAttlen, status] = ...% ncmex('attinq', theNCid, theVarid, theAttname);% if status >= 0% theStruct.itsAtttype = '';% theStruct.itsAttvalue = '';% theItem = ncitem(theAttname, theNCid, -1, theVarid, theAttnum);% result = class(theStruct, 'ncatt', theItem);% else% result = [];% end% if nargout > 0% self = result;% else% ncans(result)% end% return%end%%if nargin == 3% switch ncclass(theAttvalue)% case {'netcdf', 'ncvar'}% theParent = theAttvalue;% theAttvalue = theAtttype;% theAtttype = ncclass(theAttvalue);% if isa(theParent, 'ncvar')% switch theAttname% case {'_FillValue'}% theAtttype = datatype(theParent);% case {'scale_factor', 'add_offset'}% otherwise% end% end% result = ncatt(theAttname, theAtttype, theAttvalue, theParent);% if nargout > 0% self = result;% else% ncans(result)% end% return% otherwise% end%end%%if strcmp(theAtttype, 'int'), theAtttype = 'long'; end% %status = 0;%if nargin < 4% theNCid = -1;% theVarid = -1;% theAttnum = -1;%else% theNCid = ncid(theParent);% theVarid = varid(theParent);% theAttnum = 0;% if isa(theParent, 'ncvar')% switch theAttname% case {'_FillValue'}% theAtttype = datatype(theParent);% case {'scale_factor', 'add_offset'}% otherwise% end% end% if isstr(theAttvalue)% theAttvalue = strrep(theAttvalue, '\0', setstr(0));% end% theTempname = theAttname;% if (1)% theTempname(:) = '-'; % Is this necessary any longer?% end% status = 0;% [theType, theLen, theStatus] = ...% ncmex('attinq', theNCid, theVarid, theAttname);% if theStatus >= 0 & ~strcmp(theAttname, theTempname)% status = ncmex('attrename', theNCid, theVarid, ...% theAttname, theTempname);% end% if status >= 0% status = ncmex('attput', theNCid, theVarid, ...% theTempname, theAtttype, -1, theAttvalue);% end% if status < 0% theNetCDF = redef(parent(theParent));% if ~isempty(theNetCDF), status = 0; end% if status >= 0% status = ncmex('attput', theNCid, theVarid, ...% theTempname, theAtttype, -1, theAttvalue);% end% end% if status >= 0 & ~strcmp(theAttname, theTempname)% status = ncmex('attrename', theNCid, theVarid, ...% theTempname, theAttname);% end%end%%if status >= 0% theStruct.itsAtttype = theAtttype;% theStruct.itsAttvalue = theAttvalue;% result = class(theStruct, 'ncatt', ...% ncitem(theAttname, theNCid, -1, theVarid, theAttnum));%else% result = [];%end%%if nargout > 0% self = result;%else% ncans(result)%endfclose(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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -