⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netcdf_install.m

📁 netcdf插件安装和.nc格式数据的读取,主要操作mexcdf53.dll和netcdf.dll文件,适于从事海洋和大气专业的的数据格式.作者在实际中用matlab处理了一些此类数据
💻 M
📖 第 1 页 / 共 5 页
字号:
% Installer: "netcdf_install.m"% Created: 30-Apr-2003 11:16:19.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;endc = 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	pausecatch	disp([' ## Installation interrupted.'])	disp([' '])	returnend% eval('pause', 'disp(''Installation interrupted.''), return')ticw = which(mfilename);fin = fopen(w, 'r');if fin < 0, return, endfound = ~~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;	endendfout = -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 '"'])% 				endeval(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	endendfclose(fin);disp([' ## Elapsed time: ' num2str(fix(10*toc)/10) ' s.'])function bund_databund_setdir('netcdf')bund_setdir('@listpick')disp(' ## Installing: "event.m" (text)')fout = fopen('event.m', 'w');%function theResult = Event(self, theMode)%%% ListMove/Event -- Event handler.%%  Event(self) handles mouse events associated%%   with self, a "listpick" object.%%if nargin < 1, help(mfilename), return, end%if nargin < 2, theMode = 'normal'; end%%theFigure = self.itSelf;%%theSource = findobj(theFigure, 'Tag', 'Source');%theDestination = findobj(theFigure, 'Tag', 'Destination');%theOkay = findobj(theFigure, 'Tag', 'Okay');%%theSourceString = get(theSource, 'String');%theDestinationString = get(theDestination, 'String');%%theTag = get(gcbo, 'Tag');%theValue = get(gcbo, 'Value');%theOldValue = get(gcbo, 'UserData');%%switch lower(theTag)%case {'source', 'destination'}%   if theValue == 1 & 0%      set(gcbo, 'Value', theOldValue)%      return%   end%otherwise%end%%switch lower(theTag)%case 'source'%   theSrc = theSource;%   theDst = theDestination;%   theTag = 'Move';%case 'destination'%   theSrc = theDestination;%   theDst = theSource;%   theTag = 'Move';%otherwise%end%%switch lower(theTag)%case 'move'%   theSrcList = get(theSrc, 'String');%   theDstList = get(theDst, 'String');%   theSrcValue = get(theSrc, 'Value');%   theDstValue = get(theDst, 'Value');%   s = theSrcList{theSrcValue};%   switch lower(theMode)%   case 'unique'%      theDstList = [theDstList; {s}];%      theSrcList(theSrcValue) = [];%      theSrcValue = min(theSrcValue, length(theSrcList));%      theDstValue = length(theDstList);%   case 'multiple'%      if theDst == theDestination%         theDstList = [theDstList; {s}];%         theDstValue = length(theDstList);%      elseif theDst == theSource%         theSrcList(theSrcValue) = [];%         theSrcValue = min(theSrcValue, length(theSrcList));%      end%   otherwise%   end%   set(theSrc, 'String', theSrcList, 'UserData', theSrcValue)%   set(theDst, 'String', theDstList, 'UserData', theDstValue)%   if length(theSrcList) > 0, set(theSrc, 'Value', theSrcValue), end%   if length(theDstList) > 0, set(theDst, 'Value', theDstValue), end%   set(theOkay, 'UserData', get(theDestination, 'String'))%case {'cancel', 'okay'}%   set(theFigure, 'UserData', [])%otherwise%endfclose(fout);disp(' ## Installing: "listpick.m" (text)')fout = fopen('listpick.m', 'w');%function theResult = ListPick(theSourceList, thePrompt, ...%                                theName, theMode, varargin)%%% ListPick/ListPick -- Move items from one listbox to another.%%  ListPick({theSourceList}, 'thePrompt', 'theName', 'theMode') creates%%   a modal dialog with {theSourceList} strings in a listbox, whose items%%   can be moved to and from the adjacent listbox by clicking on them.%%   The "Okay" button causes the destination list to be returned.%%   Otherwise, the empty-list is returned.  'ThePrompt' appears at the%%   top of the dialog, and 'theName' is the dialog's figure name.%%   'TheMode' is 'unique' (default) or 'multiple'.  In 'unique' mode,%%   the clicked item moves from one list to the other, whereas in 'multiple'%%   mode, the SourceList remains intact and only copies of its items move%%   to and from the destination list.%%  ListPick (no argument) demonstrates itself.%%%  N.B. Multiple-selections in a listbox can be enabled by setting%%   the "Max" property to the maximum number of selections allowed.%%   Do not try to set "Value" to 0.  If the "String" is set to an%%   empty cell array, leave the "Value" as is.%%%%  N.B. With an "edit" control, use the "Max" property to specify%%   the number of allowed lines, separated by newlines.%%if nargin < 1, help(mfilename), theSourceList = 'demo'; end%%if isstr(theSourceList) & strcmp(theSourceList, 'demo')%   theSourceList = {'fum'; 'fi'; 'fee'; 'fo'};%   thePrompt = 'Rearrange' ;%   theMode = 'Unique';%   theName = ['ListPick -- ' theMode];%   theList = listpick(theSourceList, thePrompt, theName, theMode)%   theNotes = {'do', 'do_', 're', 'mi', 'mi_', 'fa', 'fa_', 'so', 'la', 'la_', 'ti', 'ti_', ...%               'Do', 'Do_', 'Re', 'Mi', 'Mi_', 'Fa', 'Fa_', 'So', 'La', 'La_', 'Ti', 'Ti_', ...%               'DO', 'DO_', 'RE', 'MI', 'MI_', 'FA', 'FA_', 'SO', 'LA', 'LA_', 'TI', 'TI_', ...%               'rest'};%   theSourceList = theNotes;%   thePrompt = 'Compose Music' ;%   theMode = 'Multiple';%   theName = ['ListPick -- ' theMode];%   theSampleRate = 8192;%   t = 2 .* pi .* (0:theSampleRate/2) ./ theSampleRate;%   theFundamental = 220;   % A below middle-C (264 Hz).%   theFrequencies = theFundamental .* (2 .^ (1/12)) .^ (0:length(theNotes)-1);%   theFrequencies(length(theFrequencies)) = 0;%% Frequencies from John Pierce's book.%   theFrequencies = [220.00, 233.08, 246.94, 261.63, 277.18, 293.66, ...%                     311.13, 329.63, 349.23, 369.99, 392.00, 415.30].';%   theFrequencies = theFrequencies * [1 2 4];%   theFrequencies = [theFrequencies(:).', 0];%%%   theSounds = [];%   for i = 1:length(theNotes)%      theSounds = setfield(theSounds, theNotes{i}, theFrequencies(i));%   end%   theSounds;%   thePlayedNotes = listpick(theSourceList, thePrompt, theName, theMode)%   for i = 1:length(thePlayedNotes)%      f = getfield(theSounds, thePlayedNotes{i});%      sound(sin(f .* t), theSampleRate)%   end%   return%end%%if nargin < 2, thePrompt = '<== Pick Items ==>'; end%if nargin < 3, theName = ''; end%if nargin < 4, theMode = 'unique'; end%%% N.B. We should use the prompt as follows:%%         {thePrompt, from_label, to_label}.%%if ~iscell(thePrompt), thePrompt = {thePrompt}; end%if length(thePrompt) < 2, thePrompt{2} = 'From'; end%if length(thePrompt) < 3, thePrompt{3} = 'To'; end%%theSourceList = [theSourceList(:)];%theDestinationList = cell(0, 1);%%if nargout > 1, theResult = cell(0, 1); end%%theFigure = figure('Name', theName, 'NumberTitle', 'off', ...%   'WindowStyle', 'modal', 'Visible', 'off', 'Resize', 'off');%thePosition = get(theFigure, 'Position');%thePosition(2) = thePosition(2) + 0.10 .* thePosition(4);%thePosition(3) = 0.5 .* thePosition(3);%thePosition(4) = 0.80 .* thePosition(4);%set(theFigure, 'Position', thePosition)%%theStruct.itSelf = theFigure;%self = class(theStruct, 'listpick');%set(theFigure, 'UserData', self)%%if isempty(self), return, end%%theFrame = uicontrol('Style', 'frame', 'Visible', 'on', ...%   'Units', 'normalized', 'Position', [0 0 1 1], ...%   'BackgroundColor', [0.5 1 1]);%%theControls = zeros(7, 1);%theControls(1) = uicontrol('Style', 'text', 'Tag', 'Label', ...%   'String', thePrompt{1});%theControls(2) = uicontrol('Style', 'text', 'Tag', 'Label', ...%   'String', thePrompt{2});%theControls(3) = uicontrol('Style', 'text', 'Tag', 'Label', ...%   'String', thePrompt{3});%theControls(4) = uicontrol('Style', 'listbox', 'Tag', 'Source', ...%   'String', theSourceList);%theControls(5) = uicontrol('Style', 'listbox', 'Tag', 'Destination', ...%   'String', theDestinationList);%theControls(6) = uicontrol('Style', 'pushbutton', 'Tag', 'Cancel', ...%   'String', 'Cancel', 'UserData', []);%theControls(7) = uicontrol('Style', 'pushbutton', 'Tag', 'Okay', ...%   'String', 'Okay', 'UserData', theDestinationList);%%theLayout = [  10   10   10   10   10   10   10   10%               20   20   20   20   30   30   30   30%               40   40   40   40   50   50   50   50%               40   40   40   40   50   50   50   50%               40   40   40   40   50   50   50   50%               40   40   40   40   50   50   50   50%               40   40   40   40   50   50   50   50%               40   40   40   40   50   50   50   50%              Inf   60   60  Inf  Inf   70   70  Inf];%%uilayout(theControls, theLayout, [2 2 96 92]./100)%set(theFrame, 'UserData', theControls)%%theCallback = ['event(get(gcf, ''UserData''), ''' theMode ''')'];%set(theControls(4:7), 'Callback', theCallback)%set(theControls(1:3), 'BackgroundColor', [0.5 1 1]);%%if any(findstr(computer, 'MAC'))%    set(theControls(4:5),   'FontName', 'Monaco', ...%                            'FontSize', 12, ...%                            'FontAngle', 'normal', ...%                            'FontWeight', 'normal')%end%%if length(varargin) > 0%    set(theControls(4:5), varargin{:})%end%%set(theFigure, 'Visible', 'on')%waitfor(theFigure, 'UserData', [])%%result = get(gco, 'UserData');%%delete(theFigure)%%if nargout > 0%   theResult = result;%else%   disp(result)%endfclose(fout);disp(' ## Installing: "version.m" (text)')fout = fopen('version.m', 'w');%function version(self)%%% Version of 25-Mar-2003 11:36:42.%%helpdlg(help(mfilename), 'listpick')fclose(fout);cd ('..')bund_setdir('@ncatt')disp(' ## Installing: "copy.m" (text)')fout = fopen('copy.m', 'w');%function theResult = copy(self, theDestination)%%% ncatt/copy -- Copy a NetCDF attribute.%% copy(self, theDestination) copys the NetCDF attribute%%  associated with self, an ncatt object, to the location%%  associated with theDestination, a netcdf or ncvar object.%%  If successful, the new ncatt object is returned; otherwise,%%  the empty-matrix [] is returned.% %% 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 < 2, help(mfilename), return, end%%result = [];%%switch ncclass(theDestination)%case 'netcdf'%   result = ncatt(name(self), datatype(self), self(:), theDestination);%case 'ncvar'%   result = ncatt(name(self), datatype(self), self(:), theDestination);%case 'ncatt'%   switch ncclass(self)%   case 'ncatt'%      theDestination(:) = self(:);%      result = theDestination;%   case {'double', 'char'}%      theDestination(:) = self;%      result = theDestination;%   otherwise%   end%otherwise%end%%if nargout > 0, theResult = result; endfclose(fout);disp(' ## Installing: "datatype.m" (text)')fout = fopen('datatype.m', 'w');%function theResult = datatype(self)%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -