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

📄 omp2gui.m

📁 用MATLAB进行海洋水团的模拟程序
💻 M
📖 第 1 页 / 共 2 页
字号:
	'end,' ...	'if esx(7) == 1,' ...		'G1(i,:) = G0(4,:);,' ...		'i = i+1;,' ...	'end,' ...	'if esx(8) == 1,' ...		'G1(i,:) = G0(5,:);,' ...		'i = i+1;,' ...	'end,' ...	'if esx(9) == 1,' ...		'G1(i,:) = G0(6,:);,' ...		'i = i+1;,' ...	'end,' ...	'if esx(10) == 1,' ...		'G1(i,:) = abs(G0(8,:));,' ...		'i = i+1;,' ...	'end,' ...	'G1(i,:) = G0(7,:);,' ...	'set(selwtxt,''String'',''Change your water types''),' ...	'set(donewt,''Visible'',''on'');,' ...	'set(status,''String'',status1);,' ...	], ...	'Position',[0.24 0.16 0.16 0.05], ...	'String','[1 2 3 4]', ...	'Style','edit');% whichwght and inwght are the routines to read the weights. Only weights needed% for the selected variables are selected.whichwght = uicontrol('Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Callback','omp2int', ...	'Position',[0.01 0.65 0.15 0.05], ...	'String','Weights:', ...	'Style','text');	inwght = uicontrol('Units','normalized', ...	'BackgroundColor',[0.6 0.8 0.9], ...	'Callback',[ ...	'newfile = get(inwght,''String'');,' ...	'set(status,''String'',status2);,' ...	'eval([''load '' newfile]),' ...	'set(status,''String'',status1);,' ...	'A = diag(Wx);,' ...	'A1 = A(8);,' ...   % change order of weights so that mass conservation is last	'A(8) = A(7);' ...	'A(7) = A1;' ...	'if esx(5) == 0 A(1) = 0;,' ...	'ratio(1) = -999; end,' ...			% no pot. temperature weight if not needed	'if esx(4) == 0 A(2) = 0;,' ...	'ratio(2) = -999; end,' ...			% no salinity weight if not needed	'if esx(6) == 0 A(3) = 0;,' ...	'ratio(3) = -999; end,' ...			% no oxygen weight if no oxygen	'if esx(7) == 0 A(4) = 0;,' ...	'ratio(4) = -999;  end,' ...		% no phosphate weight if no phosphate	'if esx(8) == 0 A(5) = 0;,' ...	'ratio(5) = -999;  end,' ...		% no nitrate weight if no nitrate	'if esx(9) == 0 A(6) = 0;,' ...	'ratio(6) = -999;  end,' ...		% no silicate weight if no silicate	'if esx(10) == 0 A(7) = 0;,' ...	'ratio(7) = -999;  end,' ...		% no pot. vorticity weight if not needed	'statind = find(A>0);,' ...	'Wx = diag(A(statind));,' ...        'clear A A1,' ...                    %%% remove A and A1 - conflict with OMP2.M!!!	'statind = find(ratio>-999);,' ...	'redfrat = ratio(statind);,' ... % Redfield ratio for selected variables only	'set(whichhi,''Visible'',''on'');,' ...	'set(inhi,''Visible'',''on'');,' ...	'set(inwght,''Style'',''Text'',''HorizontalAlignment'',''Left'',''BackgroundColor'',[0.2 0.6 0.8]);,' ...	], ...	'Position',[0.17 0.66 0.21 0.05], ...	'String','testwght', ...	'Style','edit');%whichhi, inhi, whichlo and inlo display and select the data limits	selec_str='Select data range: pot. density between 23 and 28 and oxygen greater 20 write:  pdens>=23&pdens<=28&oxy>=20';whichhi = uicontrol('Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Callback','omp2int', ...	'Position',[0.02 0.4 0.34 0.25], ...	'String',selec_str, ...	'Style','text');	inhi = uicontrol('Units','normalized', ...	'BackgroundColor',[0.6 0.8 0.9], ...	'Callback',[ ...	'selection = get(inhi,''String'');,' ...	'lim = 1;,' ...	'if lim == 1,' ...     'set(inhi,''Style'',''Text'',''HorizontalAlignment'',''Left'',''BackgroundColor'',[0.2 0.6 0.8]);,' ...     'set(start,''Visible'',''on'');,' ...	'end'], ...	'Position',[0.05 0.46 0.34 0.05], ...	'String','pdens>=23&pdens<=28&oxy>=20', ...	'Style','edit');	% The following radiobuttons display the possible selection of variables from% the set of variables which exist in the data file. Their association is% self-explanatory (see the String definitions).% When the Done button is pressed buttons db(1) - db(10) change from Radiobuttons% to Text, which prevents further selection changes.db(1) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'ForegroundColor',[0.2 0.2 0.2], ...	'Position',[0.6 0.7 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'set(db(1),''Value'',1),' ...	'esx(1) = (get(db(1),''Value''));'], ...	'Style','radiobutton', ...	'String','latitude');	db(2) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'ForegroundColor',[0.2 0.2 0.2], ...	'Position',[0.6 0.65 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'set(db(2),''Value'',1),' ...	'esx(2) = (get(db(2),''Value''));'], ...	'Style','radiobutton', ...	'String','longitude');db(3) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'ForegroundColor',[0.2 0.2 0.2], ...	'Position',[0.6 0.6 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'set(db(3),''Value'',1),' ...	'esx(3) = (get(db(3),''Value''));'], ...	'Style','radiobutton', ...	'String','pressure');	db(4) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.55 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'set(db(4),''Value'',1),' ...	'esx(4) = (get(db(4),''Value''));'], ...	'Style','radiobutton', ...	'String','salinity');db(5) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.5 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'if eex(5) == 0 set(db(5),''Value'',0); end,' ...	'esx(5) = (get(db(5),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','potential temperature');	db(6) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.45 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'if eex(6) == 0 set(db(6),''Value'',0); end,' ...	'esx(6) = (get(db(6),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','oxygen');	db(7) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.4 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'if eex(7) == 0 set(db(7),''Value'',0); end,' ...	'esx(7) = (get(db(7),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','phosphate');	db(8) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.35 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'if eex(8) == 0 set(db(8),''Value'',0); end,' ...	'esx(8) = (get(db(8),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','nitrate');	db(9) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.3 0.25 0.06], ...	'Value',1, ...	'Callback',[...	'if eex(9) == 0 set(db(9),''Value'',0); end,' ...	'esx(9) = (get(db(9),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','silicate');	db(10) = uicontrol('Parent',mainfig, ...	'Units','normalized', ...	'BackgroundColor',[0.2 0.6 0.8], ...	'Position',[0.6 0.25 0.25 0.06], ...	'Value',0, ...	'Callback',[...	'esx(10) = (get(db(10),''Value''));,' ...	], ...	'Style','radiobutton', ...	'String','potential vorticity');% Pressing the Done button indicates that the selection of variables is complete.% This causes the program to calculate necessary additional variables if desired% (potential vorticity, density, potential temperature) and freezes all db buttons% by changing their Style to Text. It also freezes the selected data file by setting% the Style of Infile to Text.done = uicontrol('Parent',mainfig,'Units','normalized', ...	'BackgroundColor',[0.5 0.5 0.5], ...	'Callback',[...	'axes(''position'',[0.455 0.17 0.6 0.71],''color'',[0.2 0.6 0.8],''xcolor'',' ...	'[0.7 0.83 0.8],''ycolor'',[0.7 0.83 0.8],''xtick'',[],''ytick'',[]);,' ...	'text(0.45,0.9,''  '',''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz);,' ...	'pause(0.25);,' ...	'set(status,''String'',status2);,' ...	'set(db,''Style'',''Text'',''HorizontalAlignment'',''Left'');,' ...	'set(infile,''Style'',''Text'',''HorizontalAlignment'',''Left'',''BackgroundColor'',[0.2 0.6 0.8]);,' ...	'if eex(11) == 0 & eex(5) == 1,' ...	'set(status,''String'',''Status: calculating temperature'');,' ...	'temp = sw_temp(sal,ptemp,press,0);,' ...	'eex(11) = 1;,' ...	'end,' ...	'set(status,''String'',status1);,' ...	'if eex(5) == 0,' ...		'set(status,''String'',''Status: calculating potential temperature'');,' ...		'ptemp = sw_ptmp(sal,temp,press,0);,' ...		'eex(5) = 1;,' ...		'set(db(5),''Value'',1);,' ...	'end,' ...	'set(status,''String'',''Status: checking for potential density'');,' ...	'if exist(''pdens'') == 0,' ...		'pdens = sw_dens0(sal,ptemp) - 1000;,' ...	'end,' ...	'if eex(10) == 0 & esx(10) == 1,' ...		'set(status,''String'',''Status: calculating potential vorticity'');,' ...		'statind=[0 find(diff(press)<0)'' length(press)];,' ...		'vvort =[];,' ...		'pp = [];,' ...		'[bfrq,vort,p_ave] = sw_bfrq(sal,temp,press,lat);,' ...		'for i = 1:size(vort(:)),' ...			'vvort = [vvort vort(i)];,' ...			'pp    = [pp p_ave(i)];,' ...		'end,' ...		'vvort = 10E08*[vvort 0];,' ...		'pp    = [pp 10000];,' ...		'pvort = -999999*ones(size(press));,' ...		'for i = 2:size(statind(:)),' ...			'pvort(statind(i-1)+2:statind(i)-1) = interp1(pp(statind(i-1)+1:statind(i)-1),vvort(statind(i-1)+1:statind(i)-1),press(statind(i-1)+2:statind(i)-1));,' ...		'end,' ...		'clear bfrq vort vvort p_ave pp,' ...		'pvort = abs(pvort);,' ...		'eex(10) = 1;,' ...	'end,' ...								% end potential vorticity calculation	'set(status,''String'',status1);,' ...	'set(whichwt,''Visible'',''on'');,' ...	'set(inwt,''Visible'',''on'');,' ...	'set(done,''Visible'',''off'');,' ...	'for i=1:10,' ...		'if esx(i) == 0 set(db(i),''Visible'',''off''); end,' ...	'end,' ...	], ...	'Position',[0.85 0.775 0.066 0.06], ...	'String','done', ...	'Style','pushbutton');% Pressing the Donewt button indicates that the selection of water masses is% complete. This freezes the selected water masses.donewt = uicontrol('Parent',mainfig,'Units','normalized', ...	'BackgroundColor',[0.5 0.5 0.5], ...	'Callback',[...	'set(db,''Style'',''Text'',''HorizontalAlignment'',''Left'');,' ...	'set(infile,''Style'',''Text'',''HorizontalAlignment'',''Left'',''BackgroundColor'',[0.2 0.6 0.8]);,' ...	'set(selwt,''Visible'',''off'');,' ...	'set(selwtxt,''Visible'',''off'');,' ...	'set(inwt,''Style'',''Text'',''HorizontalAlignment'',''Left'',''BackgroundColor'',[0.2 0.6 0.8]);,' ...	'set(selax,''color'',[0.2 0.6 0.8]);,' ...	'set(donewt,''Visible'',''off'');,' ...	'set(whichwght,''Visible'',''on'');,' ...	'set(inwght,''Visible'',''on'');,' ...	'for i=1:10,' ...		'if eex(i) == 0 set(db(i),''Visible'',''off''); end,' ...	'end,' ...	], ...	'Position',[0.27 0.27 0.06 0.05], ...	'String','done', ...	'Style','pushbutton');% The start button is where the real action is: the call to omp2.m which does the science.start= uicontrol('Parent',mainfig,'Units','normalized', ...	'BackgroundColor',[0.8 0 0.1], ...	'Callback',['close all,' ...	'switchpot = ''n'';,' ...  %needed for compatibility with omp2.m	'if esx(10) == 1 switchpot = ''y''; end,' ...	'omp2,' ...	], ...	'Position',[0.46 0.05 0.116 0.066], ...	'String','start', ...	'Style','pushbutton');% A few statements to define the initial appearance of the windowset(db,'Visible','off');set(selwt,'Visible','off');set(selwtxt,'Visible','off');set(whichwt,'Visible','off');set(inwt,'Visible','off');set(whichwght,'Visible','off');set(inwght,'Visible','off');set(whichhi,'Visible','off');set(inhi,'Visible','off');set(done,'Visible','off');set(donewt,'Visible','off');set(start,'Visible','off');

⌨️ 快捷键说明

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