NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/icq4info.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function icq4struct=icq4info(command,option)
2 %ICQ4INFO
3 %   ICQ4INFO provides information on an input fem_icq4_struct
4 %   or an icq4 file.  It optionally returns the icq4 data in
5 %   a fem_icq4_struct, and can read only the header information.
6 %
7 %   Input:  arg1  -  fem_icq4_struct or icq4 filename
8 %           arg2  -  If arg1 is an icq4 filename, then
9 %                    arg2 can be either 0 (read only
10 %                    file headers) or 1 (read entire file).
11 %                    If arg1 is a fem_icq4_struct, then
12 %                    arg2 is ignored.
13 %           arg2 can also be a [1X2] vector; the first element
14 %           is the "read" option above, and the second element
15 %           is whether or not (0|1) to post the display figure.
16 %           This option is ignored if arg1 is a fem_icq4_struct.
17 %           The default is to display the figure.
18 %
19 %  Output:  fem_icq4_struct - If arg1 was a filename, ICQ4INFO
20 %           returns the fem_icq4_struct if an output argument
21 %           is provided. icq4 file information is displayed to
22 %           a new figure.
23 %
24 % Call as: >> icq4info(icq4filename)
25 %          >> icq4=icq4info(icq4filename);
26 %          >> icq4=icq4info(icq4filename,0|1);
27 %          >> icq4=icq4info(icq4filename,[0|1 0|1]);
28 %          etc...
29 %
30
31 % Written by: Brian Blanton, Spring 99
32 if nargin>2
33    error('Too many arguments to ICQ4INFO')
34 elseif nargin==0
35    disp('Call as: icq4info(icq4filename)')
36    return
37 elseif nargin==1
38    if isa(command,'char')
39       option=1;  % default to read entire icq4 file
40    else
41       option='none';
42    end
43    nofig=0;
44 else
45    nofig=0;
46    if isa(command,'struct') & exist('option')
47       disp('Option to ICQ4INFO ignored.')
48    elseif isa(command,'char') &~(strcmp(command,'Initialize')|...
49                                  strcmp(command,'SetInfo')| ...
50                                  strcmp(command,'CloseFig'))
51       if option~=0 & option ~=1
52          error('Option to ICQ4INFO must be 0|1')
53       end   
54       [m,n]=size(option);
55       if m*n==1,
56          nofig=0;
57       elseif m*n==2
58          nofig=option(2);
59       else
60          error('Too many elements in options vector to ICQ4INFO.')
61       end
62    end
63
64 end
65
66 if isa(command,'struct')
67    icq4=command;
68    command='Initialize';
69    if nargout==1
70       error(['ICQ4INFO does not return a fem_icq4_struct if the input is' ...
71              ' a fem_icq4_struct.'])
72    end
73 elseif isa(command,'char')
74    % Check to see of command is a icq4filename
75    if exist(command)==2
76       icq4filename=command;
77       command='Initialize';
78       switch option(1)
79       case 0, disp(['Reading ' icq4filename ' headers.'])
80       case 1, disp(['Reading ' icq4filename])
81       end
82       icq4=read_icq4(icq4filename,option(1));
83    elseif ~(strcmp(command,'Initialize')|strcmp(command,'SetInfo')| ...
84             strcmp(command,'CloseFig'))
85       error([command ' does not exist.'])
86    end
87 end
88
89 % Return if the nofig option is set.
90 if nofig
91    icq4struct=icq4;
92    return
93 else
94
95 switch command
96    case 'Initialize'
97       % Figure defaults
98       fontsize=get(0,'DefaultTextFontSize');
99       set(0,'DefaultTextFontWeight','bold')
100       %%%%  Build ICQ4INFO Figure
101       sfig=figure('Position',[300 100 350 600],...
102                   'IntegerHandle','off',...
103                   'NumberTitle','off',...
104                   'MenuBar','none',...
105                   'Name','Icq4 Info',...
106                   'Resize','on',...
107                   'Units','pixels',...
108                   'Tag','Icq4_Info_Fig',...
109                   'CloseRequestFcn','closereq',...
110                   'Visible','on');
111       uicontrol(sfig,'Style','frame',...
112                      'Units','normalized',...
113                      'Position',[.01 .005 .98 .985],...
114                      'BackgroundColor',[1 1 1]*.7);
115       uicontrol(sfig,'Style','text',...
116                      'Units','normalized',...
117                      'Position',[.02 .94 .96 .04],...
118                      'BackgroundColor',[1 1 1]*.7,...
119                      'FontSize',fontsize,...
120                      'Units','pixels',...
121                      'String','Icq4 File Information');
122                        
123       varlist={'codename :'
124                'casename :'
125             'inqfilename :'
126            'initcondname :'
127                      'nn :'
128                     'nnv :'
129                     'day :'
130                   'month :'
131                    'year :'
132            'curr_seconds :'
133                    'ZMID :'
134                    'ZOLD :'
135                   'UZMID :'
136                   'VZMID :'
137                   'WZMID :'
138                   'Q2MID :'
139                  'Q2LMID :'
140                  'TMPMID :'
141                  'SALMID :'};
142       xs1=.02;xs2=.51;dx=.45;
143       ystart=.85;dy=.04;dyy=.035;
144       for i=1:length(varlist)
145          y=ystart-(i-1)*dy;
146          uicontrol(sfig,'Style','text',...
147                         'Units','normalized',...
148                         'Position',[xs1 y dx dyy],...
149                         'Units','pixels',...
150                         'String',varlist{i},...
151                         'HorizontalAlignment','right');
152          tag=['Icq4_Info_Line' int2str(i)];
153          string=varlist{i};
154          string=['<' string(1:length(string)-2) '>'];
155          uicontrol(sfig,'Style','text',...
156                         'Units','normalized',...
157                         'Position',[xs2 y dx dyy],...
158                         'BackgroundColor','w',...
159                         'Tag',tag,...
160                         'String',string,...
161                         'ForeGroundColor','r',...
162                         'HorizontalAlignment','left');
163       end
164
165       uicontrol(sfig,'Style','push',...
166                      'Units','normalized',...
167                      'Position',[.4 .05 .20 .05],...
168                      'Units','pixels',...
169                      'String','Close',...
170                      'Callback','icq4info(''CloseFig'')',...
171                      'ToolTipString','Close icq4info Popup')
172       if ~isempty(icq4)
173          icq4info('SetInfo',icq4);
174       end
175  case 'SetInfo'
176       icq4=option;
177       if ~isa(icq4,'struct')
178          error('icq4 to ICQ4INFO not a structure')
179       end
180       % Get the Icq4_Info_Line handles
181       fig=findobj(0,'Type','figure','Tag','Icq4_Info_Fig');
182       for i=1:19
183          Icq4_Info_Line(i)=...
184                findobj(fig,'Type','uicontrol','Tag',['Icq4_Info_Line' int2str(i)]);
185       end
186       nn=icq4.nn;nnv=icq4.nnv;
187       set(Icq4_Info_Line(1),'String',icq4.codename)
188       set(Icq4_Info_Line(2),'String',icq4.casename)
189       set(Icq4_Info_Line(3),'String',icq4.inqfilename)
190       set(Icq4_Info_Line(4),'String',icq4.initcondname)
191       set(Icq4_Info_Line(5),'String',int2str(nn))
192       set(Icq4_Info_Line(6),'String',int2str(nnv))
193       set(Icq4_Info_Line(7),'String',int2str(icq4.day))
194       set(Icq4_Info_Line(8),'String',int2str(icq4.month))
195       set(Icq4_Info_Line(9),'String',int2str(icq4.year))
196       set(Icq4_Info_Line(10),'String',int2str(icq4.curr_seconds))
197       string2d=['[' int2str(nn)  ' double]'];
198       string3d=['[' int2str(nn) 'x' int2str(nnv) ' double]'];
199       if isempty(icq4.HMID)
200          string2d='not read in';
201          string3d=string2d;
202      end         
203       set(Icq4_Info_Line(11),'String',string3d)
204       set(Icq4_Info_Line(12),'String',string3d)
205       set(Icq4_Info_Line(13),'String',string3d)
206       set(Icq4_Info_Line(14),'String',string3d)
207       set(Icq4_Info_Line(15),'String',string3d)
208       set(Icq4_Info_Line(16),'String',string3d)
209       set(Icq4_Info_Line(17),'String',string3d)
210       set(Icq4_Info_Line(18),'String',string3d)
211       set(Icq4_Info_Line(19),'String',string3d)
212      
213       % Attach the icq4 structure to the fig UD
214       set(fig,'UserData',icq4)
215      
216    case 'CloseFig'
217       delete(findobj(0,'Type','figure','Tag','Icq4_Info_Fig'))
218 end    % end switch
219 end    % end nofig if
220
221 if nargout~=0
222    fig=findobj(0,'Type','figure','Tag','Icq4_Info_Fig');
223    icq4struct=get(fig,'UserData');
224 end
Note: See TracBrowser for help on using the browser.