📄 omp2gui.m
字号:
% ######### OMP analysis main program version 2 ###################% % omp2gui.m%% This is the GUI version of an easy-to-handle package for the use of % OMP analysis to resolve fractions of water masses involved in the% mixing of water masses at a given point in the ocean. The original% version was prepared by Johannes Karstensen. This version incorporates% improvements by Matthias Tomczak.%% This program will run without any changes, using the default settings% supplied for all necessary input, and produce output based on% the data file testdata.mat supplied with this package. For details% see the README.ps or README.html files.%% Some preparation work is necessary if you want to use the program with% your own data and water type definitions. Again, details can be found% in the README.ps or README.html files.%%% Function calls used: qwt2.m qwt_tst.m nansum.m (Philip Morgan, CSIRO)% sw_ptmp sw_dens0.m (Philip Morgan, CSIRO) may be called for some data files% sw_dist.m (Philip Morgan, CSIRO) is called through the contour2 call% This program is part of the OMP package from:% Institut fuer Meereskunde FIAMS, Flinders University% J. Karstensen Matthias Tomczak% Troplowitzstr. 7 GPO Box 2100% 22529 Hamburg Adelaide, SA% Germany Australia%% BUGS: karstens@ifm.uni-hamburg.de% or matthias.tomczak@flinders.edu.auclearglobal ftm ftz fts % controls font size for different screensfontset; % list of font sizes to choose fromstatus1 = 'Status: waiting for input';status2 = 'Status: reading data';eex(1:11) = [0 0 0 0 0 0 0 0 0 0 0]; % index of available variablesesx(1:11) = [0 0 0 0 0 0 0 0 0 0 0]; % index of selected variables % 1: latitude % 2: longitude % 3: pressure % 4: salinity % 5: potential temperature % 6: oxygen % 7: phosphate % 8: nitrate % 9: silicate %10: potential vorticity %11: temperature% NOTE: For historical reasons the two columns mass conservation and potential vorticity are% swapped in the program so that mass conservation is always the last column, after potential vorticity.% The arrangement of the water type matrix and the weight vector thus differs from the description% in the user manual. This should not be of concern but has to be watched when changing the code. lim = [0 0]; % checks which data limits are setOMP = 'cla'; % classic or extended analysis h1 = [' OMP Analysis version 2.0'];h2 = [''];h3 = [' Johannes Karstensen'];h4 = [' and'];h5 = [' Matthias Tomczak'];h6 = [''];h7 = [' This is an updated version of a program package for the use'];h8 = [' of OMP analysis to resolve fractions of water masses involved'];h9 = [' in the mixing of water masses at a given point in the ocean.'];ht1 = str2mat(h1,h2,h3,h4,h5,h6,h7,h8,h9);h1 = [''];h3 = [' The original version was prepared by Johannes Karstensen.'];h4 = [' This version incorporates improvements by Matthias Tomczak.'];h5 = [''];h6 = [' August 1999'];ht2 = str2mat(h1,h2,h3,h4,h5,h6);h1 = [''];h2 = [''];h3 = [''];h4 = [' OMP Analysis version 2.0 by Johannes Karstensen and Matthias Tomczak'];ht3 = str2mat(h1,h2,h3,h4);h1 = [' Credits:'];h2 = [''];h3 = [' Version 1 by Johannes Karstensen (Institut fuer Meereskunde an der Universitaet Hamburg, Germany)'];h4 = [' email: karstens@ifm.uni-hamburg.de'];h5 = [' Version 2.0 by Johannes Karstensen and Matthias Tomczak (FIAMS, Flinders University, Adelaide, Australia)'];h6 = [' email: karstens@ifm.uni-hamburg.de or matthias.tomczak@flinders.edu.au'];h7 = [' Seawater routines from the Seawater toolbox of Phillip P. Morgan, CSIRO Marine Research'];h8 = [''];credit = str2mat(h1,h2,h3,h4,h5,h6,h7,h8);dist = [0.:10.:400.];mainfig = figure('Color',[0.2 0.6 0.8],'MenuBar','none', ... % main GUI window 'Name','OMP Analysis version 2.0', ... 'NumberTitle','off','Position',[10 20 600 420],'Resize','off');b = uicontrol('Parent',mainfig, ... % Static title 'Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'ForegroundColor',[1 1 0], ... 'Position',[0.1 0.9 0.8 0.05], ... 'HorizontalAlignment','center', ... 'String','OMP Analysis version 2.0 by Johannes Karstensen and Matthias Tomczak', ... 'Style','text', ... 'Tag','StaticText1');ex = uicontrol('Parent',mainfig,'Units','normalized', ... % exit button 'BackgroundColor',[0.9 0.9 0.2], ... 'Callback',['clear all, close all, omp2gui'], ... 'Position',[0.85 0.05 0.075 0.066], ... 'String','restart', ... 'Style','pushbutton'); hlp = uicontrol('Parent',mainfig,'Units','normalized', ... % help button 'BackgroundColor',[0.9 0.9 0.2], ... 'Callback','helpint', ... 'Position',[0.75 0.05 0.066 0.066], ... 'String','help', ... 'Style','pushbutton'); cr = uicontrol('Parent',mainfig,'Units','normalized', ... % credits button 'BackgroundColor',[1 0.4 0.2], ... 'Callback',['crf = figure(''Color'',[0.5 0.6 0.8],''MenuBar'',''none'','... '''Name'',''OMP Analysis: Credits'',' ... '''Position'',[10 20 600 420],''NumberTitle'',''off'',''Resize'',''off'');' ... 'displtxt(credit);', ... 'pause(5),close(crf),' ... ], ... 'Position',[0.6 0.05 0.116 0.066], ... 'String','credits', ... 'Style','pushbutton');% status indicates current action, also problems (see help file)status = uicontrol('Parent',mainfig,'Units','normalized', ... 'BackgroundColor',[1 0.8 0.5], ... 'Callback','omp2int', ... 'HorizontalAlignment','Center', ... 'Position',[0.02 0.057 0.4 0.05], ... 'String',status1, ... 'Style','text');h1 = ['Data sets for this program must contain the following information:'];h2 = [''];h3 = [' latitude: essential'];h4 = [' longitude: essential'];h5 = [' pressure: essential'];h6 = [' salinity: essential'];ht1 = str2mat(h1,h2,h3,h4,h5,h6);ax1 = axes('position',[0.455 0.17 0.6 0.71],'color',[0.85 0.95 0.95], ... 'xcolor',[0.7 0.83 0.8],'ycolor',[0.7 0.83 0.8],'xtick',[],'ytick',[]);hold onfor i = 1:6 %display the above text lines text(0.02,1-0.05*i,ht1(i,:),'color','k','fontname',eval(ftm),'fontsize',ftz);endax2 = axes('position',[0.455 0.17 0.6 0.48],'color',[0.85 0.95 0.95], ... 'xcolor',[0.7 0.83 0.8],'ycolor',[0.7 0.83 0.8],'xtick',[],'ytick',[]);h1 = [' temperature: essential unless potential temperature is supplied'];h2 = [' potential temperature: optional (will be calculated if not supplied)'];h3 = [' density: optional (will be calculated if not supplied)'];h4 = [' oxygen: optional'];h5 = [' phosphate: optional'];h6 = [' nitrate: optional'];h7 = [' silicate: optional'];h8 = [' potential vorticity: optional (will be calculated if necessary)'];h9 = [''];h10 = [' NOTE: All data entry fields have to be activated before the run'];h11 = [' is started. A START button will appear when entry is complete.'];ht2 = str2mat(h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);for i = 1:11 %display the above text lines text(0.02,1-0.08*i,ht2(i,:),'color','k','fontname',eval(ftm),'fontsize',ftz);enda(1,1:8) = [' basic '];a(2,1:8) = ['analysis'];rb1 = uicontrol('Parent',mainfig, ... % classical OMP button 'Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'Position',[0.01 0.82 0.2 0.06], ... 'Value',1, ... 'Callback',[... 'OMP = ''cla'';,' ... 'set(rb1,''Value'',1),' ... 'set(rb2,''Value'',0),'], ... 'Style','radiobutton', ... 'String','basic OMP analysis'); rb2 = uicontrol('Parent',mainfig, ... % extended OMP button 'Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'Position',[0.23 0.82 0.22 0.06], ... 'Value',0, ... 'Callback',[... 'OMP = ''ext'';,' ... 'set(rb1,''Value'',0),' ... 'set(rb2,''Value'',1),'], ... 'Style','radiobutton', ... 'String','extended OMP analysis'); % whichfile and infile are the routines to read data.% If a data file is correctly loaded, the routines make the radiobuttons for the% existing variables visible. Initially all buttons for existing variables are% switched on. Optional variables can be deselected. Potential vorticity can be% activated by selecting it.% Infile changes Type from Edit to Text when the selection of variables is complete% (ie the Done button is pressed).whichfile = uicontrol('Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'Position',[0.01 0.75 0.15 0.05], ... 'String','Data:', ... 'Style','text'); infile = uicontrol('Units','normalized', ... 'BackgroundColor',[0.6 0.8 0.9], ... 'Callback',[ ... 'clear lat long press temp sal ptemp oxy ph ni si pvort,' ... 'dataset = get(infile,''String'');,' ... 'set(status,''String'',status2);,' ... 'eex(1:11) = [1 1 1 1 1 1 1 1 1 1 1];,' ... 'eval([''load '' dataset]),' ... '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.15,0.9,''Select your variables for analysis'',''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz);,' ... 'pause(0.25);,' ... 'set(db,''Visible'',''on'');,' ... 'set(db,''Value'',1);,' ... 'if exist(''temp'') == 0 eex(11)=0; end,' ... 'if exist(''lat'') == 0 eex(1)=0; end,' ... 'if exist(''long'') == 0 eex(2)=0; end,' ... 'if exist(''press'') == 0 eex(3)=0; end,' ... 'if exist(''sal'') == 0 set(db(4),''Value'',0); eex(4)=0; end,' ... 'if exist(''ptemp'') == 0 set(db(5),''Value'',0); eex(5)=0; end,' ... 'if exist(''oxy'') == 0 set(db(6),''Value'',0); eex(6)=0; end,' ... 'if exist(''ph'') == 0 set(db(7),''Value'',0); eex(7)=0; end,' ... 'if exist(''ni'') == 0 set(db(8),''Value'',0); eex(8)=0; end,' ... 'if exist(''si'') == 0 set(db(9),''Value'',0); eex(9)=0; end,' ... 'if exist(''pvort'') == 0 set(db(10),''Value'',0); eex(10)=0; end,' ... 'set(status,''String'',status1);,' ... 'set(done,''Visible'',''on''),' ... 'if (eex(11)==0 & eex(5)==0) | sum(eex(1:4)~=[1 1 1 1])>0,' ... 'set(status,''String'','' WARNING: essential parameter missing!'');,' ... 'set(done,''Visible'',''off''),' ... 'end,' ... 'esx = eex;,' ... ], ... 'Position',[0.17 0.76 0.21 0.05], ... 'String','testdata', ... 'Style','edit');% whichwt and inwt are the routines to read the water type matrix. Initially all% available water types are displayed. The final number of water types and the% water types themselves are then selected using selwt. Selwtxt displays the%text for the selection field.whichwt = uicontrol('Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'Callback','omp2int', ... 'Position',[0.01 0.7 0.15 0.05], ... 'String','Water types:', ... 'Style','text'); inwt = uicontrol('Units','normalized', ... 'BackgroundColor',[0.6 0.8 0.9], ... 'Callback',[ ... 'newfile = get(inwt,''String'');,' ... 'set(status,''String'',status2);,' ... 'qwt_pos = [1 2];,' ... '[G0,wmnames,k]=eval([newfile ''(qwt_pos,0)'']);,' ... 'qwt_pos = [];,' ... 'for i=1:k,' ... 'qwt_pos = [qwt_pos i];,' ... 'end,' ... 'axes(''position'',[0.05 0.25 0.3 0.2],''color'',[0.85 0.95 0.95],''xcolor'',' ... '[0.7 0.83 0.8],''ycolor'',[0.7 0.83 0.8],''xtick'',[],''ytick'',[]);,' ... 'text(0.15,0.9,''Available water types'',''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz);,' ... 'for i = 1:20:length(wmnames),' ... 'j = i+20;,' ... 'if j>length(wmnames) j=length(wmnames); end,' ... 'text(0.05,0.77-0.008*i,wmnames(i:j),''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz);,' ... 'end,' ... 'set(status,''String'',status1);,' ... 'set(selwt,''Visible'',''on'');,' ... 'set(selwtxt,''Visible'',''on'');,' ... ], ... 'Position',[0.17 0.71 0.21 0.05], ... 'String','qwt2', ... 'Style','edit');selwtxt = uicontrol('Units','normalized', ... 'BackgroundColor',[0.2 0.6 0.8], ... 'Position',[0.03 0.15 0.2 0.05], ... 'String','Select your water types', ... 'Style','text'); selwt = uicontrol('Units','normalized', ... 'BackgroundColor',[0.6 0.8 0.9], ... 'Callback',[ ... 'qwt_pos = str2num(get(selwt,''String''));,' ... 'set(status,''String'',status2);,' ... 'selax = axes(''position'',[0.05 0.25 0.3 0.2],''color'',[0.85 0.95 0.95],''xcolor'',' ... '[0.7 0.83 0.8],''ycolor'',[0.7 0.83 0.8],''xtick'',[],''ytick'',[]);,' ... 'text(0.15,0.9,''Selected water types'',''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz);,' ... 'wm_index = [];,' ... 'wm_ind0 = [ ];,' ... 'wm_ind1 = [ ];,' ... 'j = 0;,' ... 'tit_index = [];,' ... 'for i = 1:length(qwt_pos),' ... 'ii = 0;,' ... 'wm_ind1 = wmnames(5*(qwt_pos(i)-1)+1:5*(qwt_pos(i)-1)+5);,' ... 'text(0.05+0.1*ii,0.83-0.13*(i-ii),wmnames(5*(qwt_pos(i)-1)+1:5*(qwt_pos(i)-1)+5),''color'',''k'',''fontname'',eval(ftm),''fontsize'',ftz),' ... 'k = strcmp(wm_ind0,wm_ind1);,' ... 'if k == 0,' ... 'j = j+1;,' ... 'tit_index = [tit_index wmnames(5*(qwt_pos(i)-1)+1:5*(qwt_pos(i)-1)+5)];,' ... 'end,' ... 'wm_ind0 = wm_ind1;,' ... 'wm_index = [wm_index j];,' ... 'end,' ... 'nr_of_wm = wm_index(length(wm_index));,' ... 'i = 3;,' ... 'clear G1;,' ... '[G0,wmnames,k]=eval([newfile ''(qwt_pos,0)'']);,' ... 'G1(1,:) = G0(1,:);,' ... 'G1(2,:) = G0(2,:);,' ... 'if esx(6) == 1,' ... 'G1(3,:) = G0(3,:);,' ... 'i = i+1;,' ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -