1 | %'get_field': display variables and attributes from a Netcdf file, and RUN selected fields |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | %function varargout = get_field(varargin) |
---|
4 | % associated with the GUI get_field.fig |
---|
5 | % |
---|
6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
9 | % This file is part of the toolbox UVMAT. |
---|
10 | % |
---|
11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
12 | % it under the terms of the GNU General Public License as published by |
---|
13 | % the Free Software Foundation; either version 2 of the License, or |
---|
14 | % (at your option) any later version. |
---|
15 | % |
---|
16 | % UVMAT is distributed in the hope that it will be useful, |
---|
17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
21 | |
---|
22 | function varargout = get_field(varargin) |
---|
23 | |
---|
24 | % Last Modified by GUIDE v2.5 06-Feb-2010 09:58:13 |
---|
25 | |
---|
26 | % Begin initialization code - DO NOT EDIT |
---|
27 | gui_Singleton = 0; |
---|
28 | gui_State = struct('gui_Name', mfilename, ... |
---|
29 | 'gui_Singleton', gui_Singleton, ... |
---|
30 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
---|
31 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
---|
32 | 'gui_LayoutFcn', [] , ... |
---|
33 | 'gui_Callback', []); |
---|
34 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
36 | end |
---|
37 | |
---|
38 | if nargout |
---|
39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
40 | else |
---|
41 | gui_mainfcn(gui_State, varargin{:}); |
---|
42 | end |
---|
43 | % End initialization code - DO NOT EDIT |
---|
44 | |
---|
45 | %------------------------------------------------------------------------ |
---|
46 | % --- Executes just before get_field is made visible. |
---|
47 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,Field,haxes) |
---|
48 | %------------------------------------------------------------------------ |
---|
49 | global nb_builtin |
---|
50 | |
---|
51 | %% look at the existing figues in the work space |
---|
52 | browse_fig(handles.list_fig) |
---|
53 | |
---|
54 | %% Choose default command line output for get_field |
---|
55 | handles.output = hObject; |
---|
56 | |
---|
57 | %% Update handles structure |
---|
58 | guidata(hObject, handles); |
---|
59 | |
---|
60 | %% activate the mouse action function: visualise the current field on work space by right click action |
---|
61 | set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) |
---|
62 | |
---|
63 | %% prepare the list of builtin fcts and set their paths |
---|
64 | menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included by default in 'get_field.m' |
---|
65 | nb_builtin=numel(menu_str); |
---|
66 | path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat' |
---|
67 | addpath(fullfile(path_uvmat,'get_field')) |
---|
68 | testexist=zeros(size(menu_str'));%default |
---|
69 | for ilist=1:length(menu_str) |
---|
70 | if exist(menu_str{ilist},'file') |
---|
71 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
72 | testexist(ilist)=1; |
---|
73 | else |
---|
74 | fct_handle{ilist,1}=[]; |
---|
75 | testexist(ilist)=0; |
---|
76 | end |
---|
77 | end |
---|
78 | rmpath(fullfile(path_uvmat,'get_field')) |
---|
79 | dir_perso=prefdir; |
---|
80 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
81 | if exist(profil_perso,'file') |
---|
82 | % menu={'RUN';'raw2phys';'histogram';'FFT';'peaklocking'}; |
---|
83 | h=load (profil_perso); |
---|
84 | if isfield(h,'get_field_fct') && iscell(h.get_field_fct) |
---|
85 | for ilist=1:length(h.get_field_fct) |
---|
86 | [path,file]=fileparts(h.get_field_fct{ilist}); |
---|
87 | addpath(path) |
---|
88 | if exist(file,'file') |
---|
89 | h_func=str2func(file); |
---|
90 | testexist=[testexist 1]; |
---|
91 | else |
---|
92 | h_func=[]; |
---|
93 | testexist=[testexist 0]; |
---|
94 | end |
---|
95 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths |
---|
96 | rmpath(path) |
---|
97 | menu_str=[menu_str; {file}]; |
---|
98 | end |
---|
99 | end |
---|
100 | end |
---|
101 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0) |
---|
102 | fct_handle=fct_handle(testexist==1); |
---|
103 | menu_str=[menu_str;{'more...'}]; |
---|
104 | set(handles.ACTION,'String',menu_str) |
---|
105 | set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
106 | set(handles.path_action,'String',fullfile(path_uvmat,'get_field')) |
---|
107 | set(handles.ACTION,'Value',1)% PLOT option selected |
---|
108 | |
---|
109 | %% settings for 'slave' mode, called by uvamt, or 'master' mode |
---|
110 | if exist('filename','var') && ischar(filename) %transfer input file name in slave mode |
---|
111 | set(handles.inputfile,'String',filename)% prefill the input file name |
---|
112 | set(handles.inputfile,'Enable','off')% desactivate the input file edit box |
---|
113 | set(handles.list_fig,'Value',2)% plotting axes =uvmat selected |
---|
114 | set(handles.list_fig,'Visible','off')% |
---|
115 | set(handles.RUN,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt) |
---|
116 | set(handles.MenuOpen,'Visible','off') |
---|
117 | set(handles.MenuExport,'Visible','off') |
---|
118 | set(handles.MenuHelp,'Visible','off') |
---|
119 | inputfile_Callback(hObject, eventdata, handles) |
---|
120 | else %master mode |
---|
121 | set(handles.inputfile,'String','') |
---|
122 | % load the list of previously browsed files for the upper bar menu Open |
---|
123 | dir_perso=prefdir; |
---|
124 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% |
---|
125 | if exist(profil_perso,'file') |
---|
126 | h=load (profil_perso); |
---|
127 | if isfield(h,'MenuFile_1') |
---|
128 | set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
129 | end |
---|
130 | if isfield(h,'MenuFile_1') |
---|
131 | set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
132 | end |
---|
133 | if isfield(h,'MenuFile_1') |
---|
134 | set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
135 | end |
---|
136 | if isfield(h,'MenuFile_1') |
---|
137 | set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
138 | end |
---|
139 | if isfield(h,'MenuFile_1') |
---|
140 | set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
141 | end |
---|
142 | end |
---|
143 | end |
---|
144 | %transfer input field in slave mode |
---|
145 | if exist('Field','var') && isstruct(Field) |
---|
146 | Field_input(eventdata,handles,Field) |
---|
147 | % if exist('haxes','var') |
---|
148 | % 'TESTget' |
---|
149 | % get(haxes,'Tag') |
---|
150 | % Field.PlotAxes=haxes; |
---|
151 | % end |
---|
152 | set(hObject,'UserData',Field); |
---|
153 | end |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | %------------------------------------------------------------------------ |
---|
158 | % --- Outputs from this function are returned to the command line. |
---|
159 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
160 | %------------------------------------------------------------------------ |
---|
161 | varargout{1} = handles.output; |
---|
162 | |
---|
163 | %------------------------------------------------------------------------ |
---|
164 | % --- Executes on button press in browse. |
---|
165 | function browse_Callback(hObject, eventdata, handles) |
---|
166 | %------------------------------------------------------------------------ |
---|
167 | |
---|
168 | %------------------------------------------------------------------------ |
---|
169 | function inputfile_Callback(hObject, eventdata, handles) |
---|
170 | %------------------------------------------------------------------------ |
---|
171 | inputfile=get(handles.inputfile,'String'); |
---|
172 | Field=nc2struct(inputfile);% reads the whole field |
---|
173 | hfig=get(handles.inputfile,'parent'); |
---|
174 | set(hfig,'UserData',Field); |
---|
175 | Field_input(eventdata,handles,Field); |
---|
176 | |
---|
177 | %------------------------------------------------------------------------ |
---|
178 | function Field_input(eventdata,handles,Field) |
---|
179 | %------------------------------------------------------------------------ |
---|
180 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
181 | Tabcell(:,1)=Field.ListDimName; |
---|
182 | for iline=1:length(Field.ListDimName) |
---|
183 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
184 | end |
---|
185 | Tabchar=cell2tab(Tabcell,'='); |
---|
186 | set(handles.dimensions,'String',Tabchar) |
---|
187 | end |
---|
188 | if ~isfield(Field,'ListVarName') |
---|
189 | return |
---|
190 | end |
---|
191 | Txt=Field.ListVarName; |
---|
192 | set(handles.variables,'Value',1) |
---|
193 | set(handles.variables,'String',[{'*'} Txt]) |
---|
194 | variables_Callback(handles.variables,[], handles) |
---|
195 | set(handles.abscissa,'String',[{''} Txt ]) |
---|
196 | set(handles.ordinate,'String',Txt) |
---|
197 | set(handles.vector_x,'String',[Txt ]) |
---|
198 | set(handles.vector_y,'String',[Txt ]) |
---|
199 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
200 | set(handles.vec_color,'String',[{''} Txt ]) |
---|
201 | set(handles.coord_x_scalar,'String',[{''} Txt ]) |
---|
202 | set(handles.coord_y_scalar,'String',[{''} Txt ]) |
---|
203 | set(handles.coord_x_vectors,'String',[{''} Txt ]) |
---|
204 | set(handles.coord_y_vectors,'String',[{''} Txt ]) |
---|
205 | set(handles.coord_z_scalar,'String',[{''} Txt ]) |
---|
206 | set(handles.coord_z_vectors,'String',[{''} Txt ]) |
---|
207 | set(handles.scalar,'Value',1) |
---|
208 | set(handles.scalar,'String', Txt ) |
---|
209 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field); |
---|
210 | if ~isempty(errormsg) |
---|
211 | msgbox_uvmat('ERROR',['error in get_field/Field_input/find_field_indices: ' errormsg]) |
---|
212 | return |
---|
213 | end |
---|
214 | [maxdim,imax]=max(NbDim); |
---|
215 | |
---|
216 | if maxdim>=3 |
---|
217 | set(handles.vector_z,'Visible','on') |
---|
218 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
219 | set(handles.coord_z_vectors,'Visible','on') |
---|
220 | set(handles.coord_z_vectors,'String',[{''} Txt ]) |
---|
221 | set(handles.coord_z_scalar,'Visible','on') |
---|
222 | set(handles.coord_z_scalar,'String',[{''} Txt ]) |
---|
223 | else |
---|
224 | set(handles.vector_z,'Visible','off') |
---|
225 | set(handles.coord_z_vectors,'Visible','off') |
---|
226 | set(handles.coord_z_scalar,'Visible','off') |
---|
227 | end |
---|
228 | if maxdim>=2 |
---|
229 | set(handles.check_1Dplot,'Value',0) |
---|
230 | if ~isempty(VarType{imax}.vector_x) && ~isempty(VarType{imax}.vector_y) |
---|
231 | set(handles.check_vector,'Value',1) |
---|
232 | set(handles.check_scalar,'Value',0) |
---|
233 | set(handles.vector_x,'Value',VarType{imax}.vector_x) |
---|
234 | set(handles.vector_y,'Value',VarType{imax}.vector_y) |
---|
235 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) |
---|
236 | set(handles.coord_x_vectors,'Value',VarType{imax}.coord_x+1) |
---|
237 | set(handles.coord_y_vectors,'Value',VarType{imax}.coord_y+1) |
---|
238 | end |
---|
239 | if ~isempty(VarType{imax}.coord) |
---|
240 | set(handles.coord_y_vectors,'Value',VarType{imax}.coord(1)+1) |
---|
241 | if numel(VarType{imax}.coord)>=2 |
---|
242 | set(handles.coord_x_vectors,'Value',VarType{imax}.coord(2)+1) |
---|
243 | end |
---|
244 | end |
---|
245 | else |
---|
246 | set(handles.check_scalar,'Value',1) |
---|
247 | set(handles.check_vector,'Value',0) |
---|
248 | if isfield(VarType{imax},'scalar') && length(VarType{imax}.scalar)>=1 |
---|
249 | set(handles.scalar,'Value',VarType{imax}.scalar(1)) |
---|
250 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) |
---|
251 | set(handles.coord_x_scalar,'Value',VarType{imax}.coord_x+1) |
---|
252 | set(handles.coord_y_scalar,'Value',VarType{imax}.coord_y+1) |
---|
253 | end |
---|
254 | if ~isempty(VarType{imax}.coord) |
---|
255 | set(handles.coord_y_scalar,'Value',VarType{imax}.coord(1)+1) |
---|
256 | if numel(VarType{imax}.coord)>=2 |
---|
257 | set(handles.coord_x_scalar,'Value',VarType{imax}.coord(2)+1) |
---|
258 | end |
---|
259 | end |
---|
260 | end |
---|
261 | end |
---|
262 | check_1Dplot_Callback(handles.check_1Dplot, eventdata, handles) |
---|
263 | check_scalar_Callback(handles.check_scalar, eventdata, handles) |
---|
264 | check_vector_Callback(handles.check_vector, eventdata, handles) |
---|
265 | end |
---|
266 | |
---|
267 | %------------------------------------------------------------------------ |
---|
268 | function ordinate_Callback(hObject, eventdata, handles) |
---|
269 | %------------------------------------------------------------------------ |
---|
270 | %update_field(hObject, eventdata, handles) |
---|
271 | % A REVOIR |
---|
272 | hselect_field=get(handles.inputfile,'parent'); |
---|
273 | Field=get(hselect_field,'UserData'); |
---|
274 | % xindex=get(handles.abscissa,'Value'); |
---|
275 | list=get(handles.ordinate,'String'); |
---|
276 | yindex=get(handles.ordinate,'Value'); |
---|
277 | yindex=name2index(list{yindex(1)},Field.ListVarName); |
---|
278 | if ~isempty(yindex) |
---|
279 | set(handles.variables,'Value',yindex+1) |
---|
280 | variables_Callback(hObject, eventdata, handles) |
---|
281 | end |
---|
282 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field); |
---|
283 | for icell=1:numel(CellVarIndex) |
---|
284 | VarIndex=CellVarIndex{icell}; |
---|
285 | if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex)) |
---|
286 | cell_select=icell; |
---|
287 | break |
---|
288 | end |
---|
289 | end |
---|
290 | |
---|
291 | val=get(handles.abscissa,'Value'); |
---|
292 | set(handles.abscissa,'Value',min(val,2)); |
---|
293 | coord_x_index=VarType{cell_select}.coord; |
---|
294 | coord_x_index=coord_x_index(coord_x_index~=0); |
---|
295 | set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) |
---|
296 | % Field.VarIndex.y=yindex; |
---|
297 | % set(hselect_field,'UserData',Field); |
---|
298 | %update_UserData(handles) |
---|
299 | |
---|
300 | %------------------------------------------------------------------------ |
---|
301 | % --- Executes on selection change in abscissa. |
---|
302 | function abscissa_Callback(hObject, eventdata, handles) |
---|
303 | %------------------------------------------------------------------------ |
---|
304 | hselect_field=get(handles.inputfile,'parent'); |
---|
305 | Field=get(hselect_field,'UserData');%current input field |
---|
306 | xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa |
---|
307 | % test_2D=get(handles.check_vector,'Value');% =1 for vector fields |
---|
308 | % test_scalar=get(handles.check_scalar,'Value');% =1 for scalar fields |
---|
309 | %if isequal(xdispindex,1)% blank selection, no selected variable for abscissa |
---|
310 | % Txt=Field.ListVarName; |
---|
311 | % set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates |
---|
312 | % xindex=[]; |
---|
313 | % else |
---|
314 | xlist=get(handles.abscissa,'String');%list of abscissa |
---|
315 | VarName=xlist{xdispindex}; %selected variable name |
---|
316 | update_field(hObject, eventdata, handles,VarName) |
---|
317 | % xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables |
---|
318 | % if ~isempty(xindex) |
---|
319 | % set(handles.variables,'Value',xindex+1) |
---|
320 | % variables_Callback(hObject, eventdata, handles) |
---|
321 | % end |
---|
322 | % set(handles.variables,'Value',xindex+1)%outline in the list of variables |
---|
323 | % variables_Callback(hObject, eventdata, handles) %display properties of the variable (dim, attributes) |
---|
324 | % if ~test_2D & ~test_scalar% look for possible varaibles to RUN in ordinate |
---|
325 | % index=Field.VarDimIndex{xindex};%dimension indices of the variable selected for abscissa |
---|
326 | % VarIndex=[]; |
---|
327 | % for ilist=1:length(Field.VarDimIndex)%detect |
---|
328 | % index_i=Field.VarDimIndex{ilist}; |
---|
329 | % if ~isempty(index_i) |
---|
330 | % if isequal(index_i(1),index(1))%if the first dimension of the variable coincide with the selected one, RUN is possible |
---|
331 | % VarIndex=[VarIndex ilist]; |
---|
332 | % end |
---|
333 | % end |
---|
334 | % end |
---|
335 | % % set(handles.ordinate,'Value',1) |
---|
336 | % set(handles.ordinate,'String',Field.ListVarName(VarIndex)) |
---|
337 | % end |
---|
338 | % end |
---|
339 | % |
---|
340 | % update_UserData(handles) |
---|
341 | |
---|
342 | %------------------------------------------------------------------------ |
---|
343 | % --- Executes on selection change in scalar menu. |
---|
344 | function scalar_Callback(hObject, eventdata, handles) |
---|
345 | %------------------------------------------------------------------------ |
---|
346 | Aindex=get(handles.scalar,'Value'); |
---|
347 | Astring=get(handles.scalar,'String'); |
---|
348 | VarName=Astring{Aindex}; |
---|
349 | update_field(hObject, eventdata, handles,VarName) |
---|
350 | |
---|
351 | %------------------------------------------------------------------------ |
---|
352 | % --- Executes on selection change in coord_x_scalar. |
---|
353 | function coord_x_scalar_Callback(hObject, eventdata, handles) |
---|
354 | %------------------------------------------------------------------------ |
---|
355 | index=get(handles.coord_x_scalar,'Value'); |
---|
356 | string=get(handles.coord_x_scalar,'String'); |
---|
357 | VarName=string{index}; |
---|
358 | update_field(hObject, eventdata, handles,VarName) |
---|
359 | |
---|
360 | %------------------------------------------------------------------------ |
---|
361 | % --- Executes on selection change in coord_y_scalar. |
---|
362 | function coord_y_scalar_Callback(hObject, eventdata, handles) |
---|
363 | %------------------------------------------------------------------------ |
---|
364 | index=get(handles.coord_y_scalar,'Value'); |
---|
365 | string=get(handles.coord_y_scalar,'String'); |
---|
366 | VarName=string{index}; |
---|
367 | update_field(hObject, eventdata, handles,VarName) |
---|
368 | |
---|
369 | %------------------------------------------------------------------------ |
---|
370 | % --- Executes on selection change in coord_z_scalar. |
---|
371 | function coord_z_scalar_Callback(hObject, eventdata, handles) |
---|
372 | %------------------------------------------------------------------------ |
---|
373 | index=get(handles.coord_z_scalar,'Value'); |
---|
374 | string=get(handles.coord_z_scalar,'String'); |
---|
375 | VarName=string{index}; |
---|
376 | update_field(hObject, eventdata, handles,VarName) |
---|
377 | |
---|
378 | %------------------------------------------------------------------------ |
---|
379 | % --- Executes on selection change in vector_x. |
---|
380 | function vector_x_Callback(hObject, eventdata, handles) |
---|
381 | %------------------------------------------------------------------------ |
---|
382 | index=get(handles.vector_x,'Value'); |
---|
383 | string=get(handles.vector_x,'String'); |
---|
384 | VarName=string{index}; |
---|
385 | update_field(hObject, eventdata, handles,VarName) |
---|
386 | |
---|
387 | %------------------------------------------------------------------------ |
---|
388 | % --- Executes on selection change in vector_y. |
---|
389 | function vector_y_Callback(hObject, eventdata, handles) |
---|
390 | %------------------------------------------------------------------------ |
---|
391 | index=get(handles.vector_y,'Value'); |
---|
392 | string=get(handles.vector_y,'String'); |
---|
393 | VarName=string{index}; |
---|
394 | update_field(hObject, eventdata, handles,VarName) |
---|
395 | |
---|
396 | %------------------------------------------------------------------------ |
---|
397 | % --- Executes on selection change in vector_z. |
---|
398 | function vector_z_Callback(hObject, eventdata, handles) |
---|
399 | %------------------------------------------------------------------------ |
---|
400 | index=get(handles.vector_z,'Value'); |
---|
401 | string=get(handles.vector_z,'String'); |
---|
402 | VarName=Astring{index}; |
---|
403 | update_field(hObject, eventdata, handles,VarName) |
---|
404 | |
---|
405 | %------------------------------------------------------------------------ |
---|
406 | % --- Executes on selection change in coord_x_vectors. |
---|
407 | function coord_x_vectors_Callback(hObject, eventdata, handles) |
---|
408 | %------------------------------------------------------------------------ |
---|
409 | index=get(handles.coord_x_vectors,'Value'); |
---|
410 | string=get(handles.coord_x_vectors,'String'); |
---|
411 | VarName=string{index}; |
---|
412 | update_field(hObject, eventdata, handles,VarName) |
---|
413 | |
---|
414 | %------------------------------------------------------- |
---|
415 | % --- Executes on selection change in coord_y_vectors. |
---|
416 | %------------------------------------------------------- |
---|
417 | function coord_y_vectors_Callback(hObject, eventdata, handles) |
---|
418 | index=get(handles.coord_y_vectors,'Value'); |
---|
419 | string=get(handles.coord_y_vectors,'String'); |
---|
420 | VarName=string{index}; |
---|
421 | update_field(hObject, eventdata, handles,VarName) |
---|
422 | |
---|
423 | %------------------------------------------------------- |
---|
424 | % --- Executes on selection change in coord_z_scalar. |
---|
425 | function coord_z_vectors_Callback(hObject, eventdata, handles) |
---|
426 | %------------------------------------------------------- |
---|
427 | index=get(handles.coord_z_vectors,'Value'); |
---|
428 | string=get(handles.coord_z_vectors,'String'); |
---|
429 | VarName=string{index}; |
---|
430 | update_field(hObject, eventdata, handles,VarName) |
---|
431 | |
---|
432 | %------------------------------------------------------- |
---|
433 | % --- Executes on selection change in vec_color. |
---|
434 | function vec_color_Callback(hObject, eventdata, handles) |
---|
435 | %------------------------------------------------------- |
---|
436 | index=get(handles.vec_color,'Value'); |
---|
437 | string=get(handles.vec_color,'String'); |
---|
438 | VarName=string{index}; |
---|
439 | update_field(hObject, eventdata, handles,VarName) |
---|
440 | |
---|
441 | %--------------------------------- |
---|
442 | function update_field(hObject, eventdata, handles,VarName) |
---|
443 | % VarName= input variable name for scalar or vector plots |
---|
444 | hselect_field=get(handles.inputfile,'parent'); |
---|
445 | Field=get(hselect_field,'UserData'); |
---|
446 | index=name2index(VarName,Field.ListVarName); |
---|
447 | if ~isempty(index) |
---|
448 | set(handles.variables,'Value',index+1) |
---|
449 | variables_Callback(hObject, eventdata, handles) |
---|
450 | end |
---|
451 | % |
---|
452 | % |
---|
453 | % hselect_field=get(handles.inputfile,'parent'); |
---|
454 | % Field=get(hselect_field,'UserData'); |
---|
455 | % ivar_sel=[];%default |
---|
456 | % for ivar=1:length(Field.ListVarName)%detect |
---|
457 | % if isequal(Field.ListVarName{ivar},VarName) |
---|
458 | % ivar_sel=ivar; %ivar_sel = index of the input variable in the list ListVarName |
---|
459 | % break |
---|
460 | % end |
---|
461 | % end |
---|
462 | % if isempty(ivar_sel) |
---|
463 | % return |
---|
464 | % end |
---|
465 | % set(handles.variables,'Value',ivar_sel+1)%select the corresponding item in the displayed list 'variables' |
---|
466 | % variables_Callback(hObject, eventdata, handles)%show the dimensions and attributes of the input variable |
---|
467 | % |
---|
468 | % index=Field.VarDimIndex{ivar_sel};%dimension indices of the input variable |
---|
469 | % DimValue=Field.DimValue(index);%dimension values of the input variable |
---|
470 | % ind_1=find(DimValue==1); |
---|
471 | % index(ind_1)=[];%Mremove singletons |
---|
472 | % |
---|
473 | % |
---|
474 | % % detect possible variables for abscissa and ordinate |
---|
475 | % VarIndex=[];%initiate list of selected variable indices |
---|
476 | % ind_coordvar=[]; %initiate list of coordinate variables |
---|
477 | % for ilist=1:length(Field.VarDimIndex) |
---|
478 | % if ~isequal(ilist,ivar_sel) |
---|
479 | % index_i=Field.VarDimIndex{ilist};%indices of dimensions associated with variable #ilist |
---|
480 | % if length(index_i)>1 |
---|
481 | % DimValue=Field.DimValue(index_i); |
---|
482 | % ind_1=find(DimValue==1); |
---|
483 | % index_i(ind_1)=[];%Mremove singletons |
---|
484 | % if isequal(index,index_i) |
---|
485 | % VarIndex=[VarIndex ilist]; %selected variable withb the same dimensions of the input variable |
---|
486 | % end |
---|
487 | % else |
---|
488 | % idim=find(index==index_i(1)); |
---|
489 | % if ~isempty(idim) |
---|
490 | % VarIndex=[VarIndex ilist]; %possible dimension variable |
---|
491 | % if isequal(Field.ListDimName{index_i(1)},Field.ListVarName{ilist}) |
---|
492 | % ind_coordvar=[ind_coordvar length(VarIndex)]; |
---|
493 | % end |
---|
494 | % end |
---|
495 | % end |
---|
496 | % end |
---|
497 | % end |
---|
498 | % % val=get(handles.abscissa,'Value'); |
---|
499 | % % if val>length(Field.ListVarName(VarIndex))+1 |
---|
500 | % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) |
---|
501 | % % end |
---|
502 | % % val=get(handles.ordinate,'Value'); |
---|
503 | % % if val>length(Field.ListVarName(VarIndex))+1 |
---|
504 | % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) |
---|
505 | % % end |
---|
506 | % % val=get(handles.coord_z_vectors_scalar,'Value'); |
---|
507 | % % if val>length(Field.ListVarName(VarIndex))+1 |
---|
508 | % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) |
---|
509 | % % end |
---|
510 | % set(handles.abscissa,'Value',1)%default |
---|
511 | % set(handles.ordinate,'Value',1)%default |
---|
512 | % set(handles.coord_z_scalar,'Value',1)%default |
---|
513 | % set(handles.abscissa,'String',[{''} Field.ListVarName(VarIndex) ]) |
---|
514 | % set(handles.ordinate,'String',[{''} Field.ListVarName(VarIndex) ]) |
---|
515 | % set(handles.coord_z_scalar,'String',[{''} Field.ListVarName(VarIndex) ]) |
---|
516 | % if length(ind_coordvar)>=1 |
---|
517 | % set(handles.abscissa,'Value',ind_coordvar(1)+1) |
---|
518 | % elseif length(index)==1 && length(VarIndex)>=1 |
---|
519 | % set(handles.abscissa,'Value',2) |
---|
520 | % end |
---|
521 | % if length(ind_coordvar)>=2 |
---|
522 | % set(handles.ordinate,'Value',ind_coordvar(2)+1) |
---|
523 | % elseif length(index)==1 && length(VarIndex)>=2 |
---|
524 | % set(handles.ordinate,'Value',3) |
---|
525 | % end |
---|
526 | % if length(ind_coordvar)>=3 |
---|
527 | % set(handles.coord_z_scalar,'Value',ind_coordvar(3)+1) |
---|
528 | % elseif length(index)==1 && length(VarIndex)>=3 |
---|
529 | % set(handles.coord_z_scalar,'Value',4) |
---|
530 | % end |
---|
531 | |
---|
532 | %--------------------------------------------------------- |
---|
533 | % update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback) |
---|
534 | function update_UserData(handles) |
---|
535 | %--------------------------------------------------------- |
---|
536 | return |
---|
537 | % global SubField |
---|
538 | hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface |
---|
539 | Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface |
---|
540 | if isfield(Field,'VarAttribute') |
---|
541 | VarAttribute=Field.VarAttribute; |
---|
542 | else |
---|
543 | VarAttribute={}; |
---|
544 | end |
---|
545 | |
---|
546 | |
---|
547 | % select the indices of field variables for 2D plots |
---|
548 | test_check_1Dplot=get(handles.check_1Dplot,'Value'); |
---|
549 | test_scalar=get(handles.check_scalar,'Value'); |
---|
550 | test_vector=get(handles.check_vector,'Value'); |
---|
551 | |
---|
552 | %transform if needed (calibration) |
---|
553 | list=get(handles.menu_coord,'String'); |
---|
554 | index=get(handles.menu_coord,'Value'); |
---|
555 | transform=list{index}; |
---|
556 | if ~isequal(transform,'') |
---|
557 | Field=feval(transform,Field); |
---|
558 | end |
---|
559 | VarIndex.u=[]; |
---|
560 | VarIndex.v=[]; |
---|
561 | VarIndex.w=[]; |
---|
562 | VarIndex.A=[]; |
---|
563 | VarIndex_tot=[]; |
---|
564 | iuA=[]; |
---|
565 | if test_scalar |
---|
566 | Astring=get(handles.scalar,'String'); |
---|
567 | Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox |
---|
568 | list_var=Astring(Aindex); |
---|
569 | VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName |
---|
570 | VarIndex_tot= [VarIndex_tot VarIndex.A]; |
---|
571 | DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable |
---|
572 | DimValue=Field.DimValue(DimIndex); |
---|
573 | ind=find(DimValue==1); |
---|
574 | DimIndex(ind)=[];%Mremove singleton |
---|
575 | end |
---|
576 | if test_vector |
---|
577 | Ustring=get(handles.vector_x,'String'); |
---|
578 | Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox |
---|
579 | list_var=Ustring{Uindex};%name of the selected scalar |
---|
580 | VarIndex.u=name2index(list_var,Field.ListVarName); |
---|
581 | Vstring=get(handles.vector_y,'String'); |
---|
582 | Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox |
---|
583 | list_var=Ustring{Vindex};%name of the selected scalar |
---|
584 | VarIndex.v=name2index(list_var,Field.ListVarName); |
---|
585 | if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A) |
---|
586 | iuA=VarIndex.A; %same variable used for vector and scalar |
---|
587 | VarIndex_tot(iuA)=[]; |
---|
588 | end |
---|
589 | VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v]; |
---|
590 | %dimensions |
---|
591 | DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable |
---|
592 | DimValue=Field.DimValue(DimIndex_u); |
---|
593 | ind=find(DimValue==1); |
---|
594 | DimIndex_u(ind)=[];%Mremove singleton |
---|
595 | DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable |
---|
596 | DimValue=Field.DimValue(DimIndex_v); |
---|
597 | ind=find(DimValue==1); |
---|
598 | DimIndex_v(ind)=[];%Mremove singleton |
---|
599 | if ~isequal(DimIndex_u,DimIndex_v) |
---|
600 | msgbox_uvmat('ERROR','inconsistent dimensions for u and v') |
---|
601 | set(handles.vector_y,'Value',1); |
---|
602 | return |
---|
603 | elseif test_scalar & ~isequal(DimIndex_u,DimIndex) |
---|
604 | msgbox_uvmat('ERROR','inconsistent dimensions for vector and scalar represented as vector color') |
---|
605 | set(handles.scalar,'Value',1); |
---|
606 | return |
---|
607 | end |
---|
608 | DimIndex=DimIndex_u; |
---|
609 | %TODO possibility of selecting 3 times the same variable for u, v, w components |
---|
610 | end |
---|
611 | |
---|
612 | |
---|
613 | % select the variable index (or indices) for z coordinates |
---|
614 | test_grid=0; |
---|
615 | if test_scalar | test_vector |
---|
616 | nbdim=length(DimIndex); |
---|
617 | if nbdim > 3 |
---|
618 | msgbox_uvmat('ERROR','array with more than three dimensions, not supported') |
---|
619 | return |
---|
620 | else |
---|
621 | perm_ind=[1:nbdim]; |
---|
622 | end |
---|
623 | if nbdim==3 |
---|
624 | zstring=get(handles.coord_z_vectors_scalar,'String'); |
---|
625 | zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox |
---|
626 | list_var=zstring(zindex); |
---|
627 | VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable |
---|
628 | if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z) |
---|
629 | if zindex ~= 1 |
---|
630 | set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
631 | return |
---|
632 | end |
---|
633 | else |
---|
634 | VarIndex_tot=[VarIndex_tot VarIndex_z]; |
---|
635 | DimIndex_z=Field.VarDimIndex{VarIndex_z}; |
---|
636 | DimValue=Field.DimValue(DimIndex_z); |
---|
637 | ind=find(DimValue==1); |
---|
638 | DimIndex_z(ind)=[];%Mremove singleton |
---|
639 | if isequal(DimIndex_z,DimIndex) |
---|
640 | VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates |
---|
641 | elseif length(DimIndex_z)==1 |
---|
642 | VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; %dimension variable |
---|
643 | ind_z=find(DimIndex==DimIndex_z(1)); |
---|
644 | perm_ind(ind_z)=1; |
---|
645 | test_grid=1; |
---|
646 | else |
---|
647 | msgbox_uvmat('ERROR','multiple dimensions for the z coordinate') |
---|
648 | return |
---|
649 | end |
---|
650 | end |
---|
651 | % if ~isempty(VarIndex_z) |
---|
652 | % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable |
---|
653 | % if length(DimIndex_z)==1 & nbdim==3 %dimension variable |
---|
654 | % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; |
---|
655 | % ind_z=find(DimIndex==DimIndex_z(1)); |
---|
656 | % perm_ind(ind_z)=1; |
---|
657 | % test_grid=1; |
---|
658 | % end |
---|
659 | % end |
---|
660 | end |
---|
661 | end |
---|
662 | |
---|
663 | % select the variable index (or indices) for ordinate |
---|
664 | ystring=get(handles.ordinate,'String'); |
---|
665 | yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox |
---|
666 | list_var=ystring(yindex); |
---|
667 | VarIndex.y=name2index(list_var,Field.ListVarName); |
---|
668 | if isequal(VarIndex.A,VarIndex.y) |
---|
669 | set(handles.coord_y_scalar,'Value',1) |
---|
670 | elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) |
---|
671 | set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
672 | else |
---|
673 | for ivar=1:length(VarIndex.y) |
---|
674 | VarAttribute{VarIndex.y(ivar)}.Role='coord_y'; |
---|
675 | end |
---|
676 | VarIndex_tot=[VarIndex_tot VarIndex.y]; |
---|
677 | end |
---|
678 | if (test_scalar | test_vector) & ~isempty(VarIndex.y) |
---|
679 | DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable |
---|
680 | if length(DimIndex_y)==1 |
---|
681 | ind_y=find(DimIndex==DimIndex_y(1)); |
---|
682 | test_grid=1; |
---|
683 | if nbdim==3 |
---|
684 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
685 | perm_ind(ind_y)=2; |
---|
686 | elseif nbdim==2 |
---|
687 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
688 | perm_ind(ind_y)=1; |
---|
689 | end |
---|
690 | elseif test_grid |
---|
691 | msgbox_uvmat('ERROR','the dimension of the y coordinate variable should be 1') |
---|
692 | end |
---|
693 | end |
---|
694 | |
---|
695 | %select the variable index for the abscissa |
---|
696 | xstring=get(handles.abscissa,'String'); |
---|
697 | xindex=get(handles.abscissa,'Value'); |
---|
698 | list_var=xstring(xindex); |
---|
699 | VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var |
---|
700 | if length(VarIndex.x)==1 |
---|
701 | DimIndex_x=Field.VarDimIndex{VarIndex.x}; |
---|
702 | DimValue=Field.DimValue(DimIndex_x); |
---|
703 | ind=find(DimValue==1); |
---|
704 | DimIndex_x(ind)=[];%Mremove singleton |
---|
705 | VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; %dimension variable |
---|
706 | % VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified) |
---|
707 | index_detect=find(VarIndex_tot==VarIndex.x); |
---|
708 | else |
---|
709 | index_detect=[];%coord x variable not already used |
---|
710 | end |
---|
711 | if isempty(index_detect) |
---|
712 | VarIndex_tot=[VarIndex_tot VarIndex.x]; |
---|
713 | elseif ~test_check_1Dplot |
---|
714 | VarIndex.x=[]; |
---|
715 | set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa |
---|
716 | end |
---|
717 | |
---|
718 | if (test_scalar | test_vector) & ~isempty(VarIndex.x) |
---|
719 | DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable |
---|
720 | if length(DimIndex_x)==1 |
---|
721 | ind_x=find(DimIndex==DimIndex_x(1)); |
---|
722 | if nbdim==3 |
---|
723 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
724 | perm_ind(ind_x)=3; |
---|
725 | elseif nbdim==2 |
---|
726 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
727 | perm_ind(ind_x)=2; |
---|
728 | end |
---|
729 | if isequal(perm_ind,1:nbdim) |
---|
730 | test_grid=0; |
---|
731 | end |
---|
732 | DimIndex=DimIndex(perm_ind); |
---|
733 | elseif test_grid |
---|
734 | msgbox_uvmat('ERROR','the dimension of the x coordinate variable should be 1') |
---|
735 | end |
---|
736 | if isequal(DimIndex_x,DimIndex) |
---|
737 | VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates |
---|
738 | end |
---|
739 | end |
---|
740 | |
---|
741 | %defined the selected sub-field SubField |
---|
742 | SubField.ListGlobalAttribute{1}='InputFile'; |
---|
743 | SubField.InputFile=get(handles.inputfile,'String'); |
---|
744 | SubField.ListDimName=Field.ListDimName; |
---|
745 | SubField.DimValue=Field.DimValue; |
---|
746 | SubField.ListVarName=Field.ListVarName(VarIndex_tot); |
---|
747 | SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot); |
---|
748 | |
---|
749 | testperm=0; |
---|
750 | testattr=0; |
---|
751 | for ivar=VarIndex.u |
---|
752 | VarAttribute{ivar}.Role='vector_x'; |
---|
753 | testattr=1; |
---|
754 | if test_grid |
---|
755 | VarDimIndex{ivar}=DimIndex; %permute dimensions |
---|
756 | testperm=1; |
---|
757 | end |
---|
758 | end |
---|
759 | for ivar=VarIndex.v |
---|
760 | VarAttribute{ivar}.Role='vector_y'; |
---|
761 | testattr=1; |
---|
762 | if test_grid |
---|
763 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
764 | testperm=1; |
---|
765 | end |
---|
766 | end |
---|
767 | for ivar=VarIndex.A |
---|
768 | if test_grid |
---|
769 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
770 | testperm=1; |
---|
771 | end |
---|
772 | if isempty(iuA) |
---|
773 | VarAttribute{ivar}.Role='scalar';%Role =scalar |
---|
774 | testattr=1; |
---|
775 | else |
---|
776 | VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable |
---|
777 | nbattr=length(VarAttribute); |
---|
778 | VarAttribute{nbattr}.Role='scalar'; |
---|
779 | testattr=1; |
---|
780 | end |
---|
781 | end |
---|
782 | if testperm |
---|
783 | SubField.VarDimIndex=VarDimIndex(VarIndex_tot); |
---|
784 | end |
---|
785 | if testattr |
---|
786 | SubField.VarAttribute=VarAttribute(VarIndex_tot); |
---|
787 | end |
---|
788 | set(hselect_field,'UserData',Field) |
---|
789 | |
---|
790 | %--------------------------------------------------------- |
---|
791 | % --- Executes on button press in RUN. |
---|
792 | function RUN_Callback(hObject, eventdata, handles) |
---|
793 | %--------------------------------------------------------- |
---|
794 | index=get(handles.ACTION,'Value'); |
---|
795 | list_func=get(handles.ACTION,'UserData'); |
---|
796 | h_fun=list_func{index}; |
---|
797 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
798 | drawnow |
---|
799 | SubField=h_fun(handles.figure1);%handles.figure1 =handles of the GUI get_field |
---|
800 | if ~isempty(SubField) |
---|
801 | plot_get_field(SubField,handles) |
---|
802 | end |
---|
803 | browse_fig(handles.list_fig); %update the list of new existing figures |
---|
804 | |
---|
805 | %------------------------------------------------------------------------ |
---|
806 | function plot_get_field(SubField,handles) |
---|
807 | %------------------------------------------------------------------------ |
---|
808 | list_fig=get(handles.list_fig,'String'); |
---|
809 | val=get(handles.list_fig,'Value'); |
---|
810 | if strcmp(list_fig{val},'uvmat') |
---|
811 | set(handles.figure1,'Name','uvmat_field') |
---|
812 | set(handles.inputfile,'Enable','off')% desactivate the input file edit box |
---|
813 | % set(handles.list_fig,'Visible','off')% |
---|
814 | set(handles.RUN,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt) |
---|
815 | set(handles.MenuOpen,'Visible','off') |
---|
816 | set(handles.MenuExport,'Visible','off') |
---|
817 | uvmat(get(handles.inputfile,'String')) |
---|
818 | else |
---|
819 | hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI |
---|
820 | if isempty(hfig) |
---|
821 | hfig=figure; |
---|
822 | list_fig=[list_fig;num2str(hfig)]; |
---|
823 | set(handles.list_fig,'String',list_fig); |
---|
824 | haxes=axes; |
---|
825 | else |
---|
826 | figure(hfig); |
---|
827 | end |
---|
828 | haxes=findobj(hfig,'Type','axes'); |
---|
829 | plot_field(SubField,haxes) |
---|
830 | end |
---|
831 | |
---|
832 | % %------------------------------------------------ |
---|
833 | % % --- Executes on button press in Plot_histo. |
---|
834 | % %RUN global histograms |
---|
835 | % %------------------------------------------------- |
---|
836 | % function RUN_histo_Callback(hObject, eventdata, handles) |
---|
837 | % % hObject handle to RUN (see GCBO) |
---|
838 | % % eventdata reserved - to be defined in a future version of MATLAB |
---|
839 | % % handles structure with handles and user data (see GUIDATA) |
---|
840 | % |
---|
841 | % %time plots |
---|
842 | % leg={}; |
---|
843 | % n=0; |
---|
844 | % if (get(handles.cm_switch,'Value')==1) |
---|
845 | % Uval_p=Uval_cm; |
---|
846 | % Vval_p=Vval_cm; |
---|
847 | % Uhist_p=Uhist_cm; |
---|
848 | % Vhist_p=Vhist_cm; |
---|
849 | % xlab='velocity (cm/s)'; |
---|
850 | % else |
---|
851 | % Uval_p=Uval; |
---|
852 | % Vval_p=Vval; |
---|
853 | % Uhist_p=Uhist; |
---|
854 | % Vhist_p=Vhist; |
---|
855 | % xlab='velocity (pixels)'; |
---|
856 | % end |
---|
857 | % if (get(handles.vector_y,'Value') == 1) |
---|
858 | % hhh=figure(2); |
---|
859 | % hold on |
---|
860 | % title([filebase ', ' strindex ', ' fieldtitle]) |
---|
861 | % plot(Uval_p,Uhist_p,'b-') |
---|
862 | % n=n+1; |
---|
863 | % leg{n}='Uhist'; |
---|
864 | % xlabel(xlab) |
---|
865 | % end |
---|
866 | % if (get(handles.Vhist_input,'Value') == 1) |
---|
867 | % hhh=figure(2); |
---|
868 | % hold on |
---|
869 | % title([filebase ', ' strindex ', ' fieldtitle]) |
---|
870 | % plot(Vval_p,Vhist_p,'r-') |
---|
871 | % n=n+1; |
---|
872 | % leg{n}='Vhist'; |
---|
873 | % xlabel(xlab); |
---|
874 | % end |
---|
875 | % if (get(handles.Chist_input,'Value') == 1) |
---|
876 | % hhhh=figure(3); |
---|
877 | % hold on |
---|
878 | % title([filebase ', ' strindex ', ' fieldtitle]) |
---|
879 | % plot(Cval,Chist,'k-') |
---|
880 | % leg{1}='Chist'; |
---|
881 | % end |
---|
882 | % % hold off |
---|
883 | % grid on |
---|
884 | % legend(leg); |
---|
885 | |
---|
886 | % %------------------------------------------------------------- |
---|
887 | % % --- Executes on button press in Save_input. |
---|
888 | % function Save_input_Callback(hObject, eventdata, handles) |
---|
889 | % list_str=get(handles.abscissa,'String'); |
---|
890 | % val=get(handles.abscissa,'Value'); |
---|
891 | % var=list_str{val}; |
---|
892 | % hselect_field=get(handles.Save_input,'parent') |
---|
893 | % set(hselect_field,'UserData',var); |
---|
894 | % set(hselect_field,'Tag','idle') |
---|
895 | |
---|
896 | % |
---|
897 | % %------------------------------------------------------------- |
---|
898 | % % --- Executes on button press in save_histo. |
---|
899 | % function save_histo_Callback(hObject, eventdata, handles) |
---|
900 | % global filebase |
---|
901 | % |
---|
902 | % pathstr = fileparts(filebase) |
---|
903 | % if (get(handles.Chist_input,'Value') == 1) |
---|
904 | % def = {[pathstr pathstr(1) 'PIV_corr_histo.fig']}; |
---|
905 | % else |
---|
906 | |
---|
907 | % def = {[pathstr pathstr(1) 'vel_histo.fig']}; |
---|
908 | % end |
---|
909 | % prompt={'save figure(2) as'} |
---|
910 | % dlg_title = 'save figure'; |
---|
911 | % num_lines= 1; |
---|
912 | % answer = inputdlg(prompt,dlg_title,num_lines,def) |
---|
913 | % saveas(2,answer{1}) |
---|
914 | |
---|
915 | |
---|
916 | %%------------------------------------------------------- |
---|
917 | % --- Executes on button press in peaklocking. |
---|
918 | %------------------------------------------------- |
---|
919 | function peaklocking(handles) |
---|
920 | %evaluation of peacklocking errors |
---|
921 | %use splinhist: give spline coeff cc for a smooth histo (call spline4) |
---|
922 | %use histsmooth(x,cc): calculate the smooth histo for any value x |
---|
923 | %use histder(x,cc): calculate the derivative of the smooth histo |
---|
924 | global hfig1 hfig2 hfig3 |
---|
925 | global nbb Uval Vval Uhist Vhist % nbb resolution of the histogram nbb=10: 10 values in unity interval |
---|
926 | global xval xerror yval yerror |
---|
927 | |
---|
928 | set(handles.vector_y,'Value',1)% trigger the option Uhist on the interface |
---|
929 | set(handles.Vhist_input,'Value',1) |
---|
930 | set(handles.cm_switch,'Value',0) % put the switch to 'pixel' |
---|
931 | |
---|
932 | %adjust the extremal values of the histogram in U with respect to integer |
---|
933 | %values |
---|
934 | minimU=round(min(Uval)-0.5)+0.5; %first value of the histogram with integer bins |
---|
935 | maximU=round(max(Uval)-0.5)+0.5; |
---|
936 | minim_fin=(minimU-0.5+1/(2*nbb)); % first bin valueat the beginning of an integer interval |
---|
937 | maxim_fin=(maximU+0.5-1/(2*nbb)); % last integer value |
---|
938 | nb_bin_min= round(-(minim_fin - min(Uval))*nbb); % nbre of bins added below |
---|
939 | nb_bin_max=round((maxim_fin -max(Uval))*nbb); %nbre of bins added above |
---|
940 | Uval=[minim_fin:(1/nbb):maxim_fin]; |
---|
941 | histu_min=zeros(nb_bin_min,1); |
---|
942 | histu_max=zeros(nb_bin_max,1); |
---|
943 | Uhist=[histu_min; Uhist ;histu_max]; % column vector |
---|
944 | |
---|
945 | %adjust the extremal values of the histogram in V |
---|
946 | minimV=round(min(Vval-0.5)+0.5); |
---|
947 | maximV=round(max(Vval-0.5)+0.5); |
---|
948 | minim_fin=minimV-0.5+1/(2*nbb); % first bin valueat the beginning of an integer interval |
---|
949 | maxim_fin=maximV+0.5-1/(2*nbb); % last integer value |
---|
950 | nb_bin_min=round((min(Vval) - minim_fin)*nbb); % nbre of bins added below |
---|
951 | nb_bin_max=round((maxim_fin -max(Vval))*nbb); |
---|
952 | Vval=[minim_fin:(1/nbb):maxim_fin]; |
---|
953 | histu_min=zeros(nb_bin_min,1); |
---|
954 | histu_max=zeros(nb_bin_max,1); |
---|
955 | Vhist=[histu_min; Vhist ;histu_max]; % column vector |
---|
956 | |
---|
957 | % RUN_histo_Callback(hObject, eventdata, handles) |
---|
958 | % %adjust the histogram to integer values: |
---|
959 | |
---|
960 | %histoU and V |
---|
961 | [Uhistinter,xval,xerror]=peaklock(nbb,minimU,maximU,Uhist); |
---|
962 | [Vhistinter,yval,yerror]=peaklock(nbb,minimV,maximV,Vhist); |
---|
963 | |
---|
964 | % selection of value ranges such that histo>=10 (enough statistics) |
---|
965 | Uval_ind=find(Uhist>=10); |
---|
966 | ind_min=min(Uval_ind); |
---|
967 | ind_max=max(Uval_ind); |
---|
968 | U_min=Uval(ind_min);% minimum allowed value |
---|
969 | U_max=Uval(ind_max);%maximum allowed value |
---|
970 | |
---|
971 | % selection of value ranges such that histo>=10 (enough statistics) |
---|
972 | Vval_ind=find(Vhist>=10); |
---|
973 | ind_min=min(Vval_ind); |
---|
974 | ind_max=max(Vval_ind); |
---|
975 | V_min=Vval(ind_min);% minimum allowed value |
---|
976 | V_max=Vval(ind_max);%maximum allowed value |
---|
977 | |
---|
978 | figure(4)% plot U histogram with smoothed one |
---|
979 | plot(Uval,Uhist,'b') |
---|
980 | grid on |
---|
981 | hold on |
---|
982 | plot(Uval,Uhistinter,'r'); |
---|
983 | hold off |
---|
984 | |
---|
985 | figure(5)% plot V histogram with smoothed one |
---|
986 | plot(Vval,Vhist,'b') |
---|
987 | grid on |
---|
988 | hold on |
---|
989 | plot(Vval,Vhistinter,'r'); |
---|
990 | hold off |
---|
991 | |
---|
992 | figure(6)% plot pixel error in two subplots |
---|
993 | hfig4=subplot(2,1,1); |
---|
994 | hfig5=subplot(2,1,2); |
---|
995 | axes(hfig4) |
---|
996 | plot(xval,xerror) |
---|
997 | axis([U_min U_max -0.4 0.4]) |
---|
998 | xlabel('velocity u (pix)') |
---|
999 | ylabel('peaklocking error (pix)') |
---|
1000 | grid on |
---|
1001 | axes(hfig5) |
---|
1002 | plot(yval,yerror) |
---|
1003 | axis([V_min V_max -0.4 0.4]); |
---|
1004 | xlabel('velocity v (pix)') |
---|
1005 | ylabel('peaklocking error (pix)') |
---|
1006 | grid on |
---|
1007 | |
---|
1008 | |
---|
1009 | % ------------------------------------------------------------------ |
---|
1010 | function variables_Callback(hObject, eventdata, handles) |
---|
1011 | Tabchar={''};%default |
---|
1012 | Tabcell=[]; |
---|
1013 | hselect_field=get(handles.variables,'parent'); |
---|
1014 | Field=get(hselect_field,'UserData'); |
---|
1015 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
1016 | if isequal(index,1) |
---|
1017 | set(handles.attributes_txt,'String','global attributes') |
---|
1018 | % list global attribute names and values if index=1 (blank variable display) is selected |
---|
1019 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
1020 | for iline=1:length(Field.ListGlobalAttribute) |
---|
1021 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
1022 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
1023 | eval(['val=Field.' Field.ListGlobalAttribute{iline} ';']) |
---|
1024 | if ischar(val);% attribute value is char string |
---|
1025 | Tabcell{iline,2}=val; |
---|
1026 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
1027 | Tabcell{iline,2}=num2str(val); |
---|
1028 | end |
---|
1029 | end |
---|
1030 | end |
---|
1031 | Tabchar=cell2tab(Tabcell,'='); |
---|
1032 | end |
---|
1033 | else |
---|
1034 | %list attribute names and values associated to the variable # injdex-1 |
---|
1035 | list_var=get(handles.variables,'String'); |
---|
1036 | var_select=list_var{index}; |
---|
1037 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
1038 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
1039 | % nbline=0; |
---|
1040 | VarAttr=Field.VarAttribute{index-1}; |
---|
1041 | if isstruct(VarAttr) |
---|
1042 | attr_list=fieldnames(VarAttr); |
---|
1043 | for iline=1:length(attr_list) |
---|
1044 | Tabcell{iline,1}=attr_list{iline}; |
---|
1045 | eval(['val=VarAttr.' attr_list{iline} ';']) |
---|
1046 | if ischar(val); |
---|
1047 | Tabcell{iline,2}=val; |
---|
1048 | else |
---|
1049 | Tabcell{iline,2}=num2str(val); |
---|
1050 | end |
---|
1051 | end |
---|
1052 | end |
---|
1053 | end |
---|
1054 | |
---|
1055 | end |
---|
1056 | if ~isempty(Tabcell) |
---|
1057 | Tabchar=cell2tab(Tabcell,'='); |
---|
1058 | Tabchar=[{''};Tabchar]; |
---|
1059 | end |
---|
1060 | set(handles.attributes,'Value',1);% select the first item |
---|
1061 | set(handles.attributes,'String',Tabchar); |
---|
1062 | |
---|
1063 | % list_var=get(handles.dimensions,'String'); |
---|
1064 | % val=get(handles.dimensions,'Value'); |
---|
1065 | |
---|
1066 | % update dimensions; |
---|
1067 | if isfield(Field,'VarDimIndex') |
---|
1068 | Tabdim={};%default |
---|
1069 | if isequal(index,1) |
---|
1070 | dim_indices=1:length(Field.ListDimName); |
---|
1071 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
1072 | else |
---|
1073 | dim_indices=Field.VarDimIndex{index-1}; |
---|
1074 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
1075 | end |
---|
1076 | for iline=1:length(dim_indices) |
---|
1077 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
1078 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
1079 | end |
---|
1080 | Tabchar=cell2tab(Tabdim,'='); |
---|
1081 | Tabchar=[{''} ;Tabchar]; |
---|
1082 | set(handles.dimensions,'String',Tabchar) |
---|
1083 | end |
---|
1084 | |
---|
1085 | % --- Executes on button press in check_1Dplot. |
---|
1086 | function check_1Dplot_Callback(hObject, eventdata, handles) |
---|
1087 | val=get(handles.check_1Dplot,'Value'); |
---|
1088 | if isequal(val,0) |
---|
1089 | set(handles.Panel1Dplot,'Visible','off') |
---|
1090 | % set(handles.scalar,'Visible','off') |
---|
1091 | % set(handles.ordinate,'Max',2.0)%allow multiple ordinate input option |
---|
1092 | % if isequal(get(handles.check_vector,'Value'),0); |
---|
1093 | % set(handles.coord_z_vectors_scalar,'Visible','off') |
---|
1094 | % end |
---|
1095 | else |
---|
1096 | set(handles.Panel1Dplot,'Visible','on') |
---|
1097 | % set(handles.scalar,'Visible','on') |
---|
1098 | % val=get(handles.ordinate,'Value'); |
---|
1099 | % val=val(1); |
---|
1100 | % set(handles.ordinate,'Value',val);%suppress multiple ordinates |
---|
1101 | % set(handles.ordinate,'Max',1.0);%suppress multiple ordinate input option |
---|
1102 | % set(handles.coord_z_vectors_scalar,'Visible','on') |
---|
1103 | end |
---|
1104 | |
---|
1105 | % --- Executes on button press in check_scalar. |
---|
1106 | function check_scalar_Callback(hObject, eventdata, handles) |
---|
1107 | val=get(handles.check_scalar,'Value'); |
---|
1108 | if isequal(val,0) |
---|
1109 | set(handles.PanelScalar,'Visible','off') |
---|
1110 | else |
---|
1111 | set(handles.PanelScalar,'Visible','on') |
---|
1112 | end |
---|
1113 | |
---|
1114 | %--------------------------- |
---|
1115 | % --- Executes on button press in check_vector. |
---|
1116 | function check_vector_Callback(hObject, eventdata, handles) |
---|
1117 | val=get(handles.check_vector,'Value'); |
---|
1118 | if isequal(val,0) |
---|
1119 | set(handles.PanelVectors,'Visible','off') |
---|
1120 | else |
---|
1121 | set(handles.PanelVectors,'Visible','on') |
---|
1122 | end |
---|
1123 | |
---|
1124 | %----------------------------- |
---|
1125 | function mouse_up_gui(ggg,eventdata,handles) |
---|
1126 | if isequal(get(ggg,'SelectionType'),'alt') |
---|
1127 | message=''; |
---|
1128 | global CurData |
---|
1129 | inputfield=get(handles.inputfile,'String'); |
---|
1130 | if exist(inputfield,'file') |
---|
1131 | CurData=nc2struct(inputfield); |
---|
1132 | else |
---|
1133 | CurData=get(ggg,'UserData');% get_field opened from a input field, not a file |
---|
1134 | end |
---|
1135 | %%%% TODO: put the matalb command window in front |
---|
1136 | evalin('base','global CurData')%make CurData global in the workspace |
---|
1137 | evalin('base','CurData') %display CurData in the workspace |
---|
1138 | end |
---|
1139 | |
---|
1140 | %--------------------------------------------- |
---|
1141 | % --- Executes on selection change in ACTION. |
---|
1142 | function ACTION_Callback(hObject, eventdata, handles) |
---|
1143 | global nb_builtin |
---|
1144 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
1145 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
1146 | ACTION= list_ACTION{index_ACTION}; % selected string |
---|
1147 | list_func_handles=get(handles.ACTION,'UserData');% get list of function handles (full address of the function, including name and path) |
---|
1148 | ff=functions(list_func_handles{end}); |
---|
1149 | % add a new function to the menu |
---|
1150 | if isequal(ACTION,'more...') |
---|
1151 | % pathfct=fileparts(path_get_field); |
---|
1152 | % browse_name=fullfile(path_get_field,'FIELD_FCT'); |
---|
1153 | % if length(list_path)>nb_builtin |
---|
1154 | % browse_name=list_path{end};% initialize browser with the path of the last introduced function |
---|
1155 | % end |
---|
1156 | [FileName, PathName] = uigetfile( ... |
---|
1157 | {'*.m', ' (*.m)'; |
---|
1158 | '*.m', '.m files '; ... |
---|
1159 | '*.*', 'All Files (*.*)'}, ... |
---|
1160 | 'Pick a file',ff.file); |
---|
1161 | if length(FileName)<2 |
---|
1162 | return |
---|
1163 | end |
---|
1164 | [pp,ACTION,ext_fct]=fileparts(FileName); |
---|
1165 | if ~isequal(ext_fct,'.m') |
---|
1166 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1167 | return |
---|
1168 | end |
---|
1169 | |
---|
1170 | % insert the choice in the action menu |
---|
1171 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
1172 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
1173 | addpath(PathName) |
---|
1174 | list_func_handles{index_ACTION}=str2func(ACTION);% create the function handle corresponding to the newly seleced function |
---|
1175 | set(handles.ACTION,'UserData',list_func_handles) |
---|
1176 | set(handles.path_action,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1177 | %list_path{index_ACTION}=PathName; |
---|
1178 | if length(menu_str)>nb_builtin+5; |
---|
1179 | nbremove=length(menu_str)-nb_builtin-5; |
---|
1180 | menu_str(nb_builtin+1:end-5)=[]; |
---|
1181 | list_func_handles(nb_builtin+1:end-4)=[]; |
---|
1182 | index_ACTION=index_ACTION-nbremove; |
---|
1183 | set(handles.ACTION,'Value',index_ACTION) |
---|
1184 | set(handles.ACTION,'String',menu_str) |
---|
1185 | end |
---|
1186 | %record the current menu in personal file profil_perso |
---|
1187 | dir_perso=prefdir; |
---|
1188 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1189 | for ilist=nb_builtin+1:length(menu_str)-1 |
---|
1190 | ff=functions(list_func_handles{ilist}); |
---|
1191 | get_field_fct{ilist-nb_builtin}=ff.file; |
---|
1192 | end |
---|
1193 | if exist(profil_perso,'file') |
---|
1194 | save(profil_perso,'get_field_fct','-append') |
---|
1195 | else |
---|
1196 | txt=ver; |
---|
1197 | Release=txt(1).Release; |
---|
1198 | relnumb=str2num(Release(3:4)); |
---|
1199 | if relnumb >= 14 |
---|
1200 | save(profil_perso,'get_field_fct','-V6') |
---|
1201 | else |
---|
1202 | save(profil_perso, 'get_field_fct') |
---|
1203 | end |
---|
1204 | end |
---|
1205 | end |
---|
1206 | |
---|
1207 | %check the current path to the selected function |
---|
1208 | h_fun=list_func_handles{index_ACTION}; |
---|
1209 | if isa(h_fun,'function_handle') |
---|
1210 | func=functions(h_fun); |
---|
1211 | set(handles.path_action,'String',fileparts(func.file)); %show the path to the senlected function |
---|
1212 | GUI_input=h_fun();%handles.figure1 =handles of the GUI get_field |
---|
1213 | else |
---|
1214 | set(handles.path_action,'String','') |
---|
1215 | msgbox_uvmat('ERROR','unknown path to ACTION function, reload it') |
---|
1216 | return |
---|
1217 | end |
---|
1218 | |
---|
1219 | %prepare the GUI options for the selected ACTION |
---|
1220 | test_1Dplot=0; |
---|
1221 | test_scalar=0; |
---|
1222 | test_vector=0; |
---|
1223 | if iscell(GUI_input) |
---|
1224 | for ilist=1:length(GUI_input) |
---|
1225 | switch GUI_input{ilist} |
---|
1226 | %RootFile always visible |
---|
1227 | case 'check_1Dplot' |
---|
1228 | test_1Dplot=1; |
---|
1229 | case 'check_scalar' |
---|
1230 | test_scalar=1; |
---|
1231 | case 'check_vector' |
---|
1232 | test_vector=1; |
---|
1233 | end |
---|
1234 | end |
---|
1235 | end |
---|
1236 | set(handles.check_1Dplot,'Value',test_1Dplot); |
---|
1237 | set(handles.check_scalar,'Value',test_scalar); |
---|
1238 | set(handles.check_vector,'Value',test_vector); |
---|
1239 | check_1Dplot_Callback(hObject, eventdata, handles) |
---|
1240 | check_scalar_Callback(hObject, eventdata, handles) |
---|
1241 | check_vector_Callback(hObject, eventdata, handles) |
---|
1242 | |
---|
1243 | |
---|
1244 | %----------------------------------------------------- |
---|
1245 | % --- browse existing figures |
---|
1246 | %----------------------------------------------------- |
---|
1247 | function browse_fig(menu_handle) |
---|
1248 | hh=findobj(allchild(0),'Type','figure'); |
---|
1249 | ilist=0; |
---|
1250 | list={}; |
---|
1251 | for ifig=1:length(hh) %look for all existing figures |
---|
1252 | name=get(hh(ifig),'Name'); |
---|
1253 | if ~isequal(name,'uvmat')%case of uvmat GUI |
---|
1254 | hchild=get(hh(ifig),'children');% look for axes contained in each figure |
---|
1255 | nbaxe=0; |
---|
1256 | for ichild=1:length(hchild) |
---|
1257 | Type=get(hchild(ichild),'Type'); |
---|
1258 | Tag=get(hchild(ichild),'Tag'); |
---|
1259 | if isequal(Type,'axes') |
---|
1260 | if ~isequal(Tag,'Colorbar')& ~isequal(Tag,'legend')% don't select colorbars for plotting |
---|
1261 | nbaxe=nbaxe+1;%count the existing axis |
---|
1262 | end |
---|
1263 | end |
---|
1264 | end |
---|
1265 | if nbaxe==1 |
---|
1266 | ilist=ilist+1;%add a line in the list of axis |
---|
1267 | list{ilist,1}=num2str(hh(ifig)); |
---|
1268 | elseif nbaxe>1 |
---|
1269 | for iaxe=1:nbaxe |
---|
1270 | ilist=ilist+1;%add a line in the list of axis |
---|
1271 | list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)]; |
---|
1272 | end |
---|
1273 | end |
---|
1274 | end |
---|
1275 | end |
---|
1276 | list=['new fig...';'uvmat';list]; |
---|
1277 | set(menu_handle,'Value',1) |
---|
1278 | set(menu_handle,'String',list) |
---|
1279 | |
---|
1280 | |
---|
1281 | %----------------------------------------------------- |
---|
1282 | function list_fig_Callback(hObject, eventdata, handles) |
---|
1283 | %----------------------------------------------------- |
---|
1284 | list_fig=get(handles.list_fig,'String'); |
---|
1285 | fig_val=get(handles.list_fig,'Value'); |
---|
1286 | plot_fig=list_fig{fig_val}; |
---|
1287 | if isequal(plot_fig,'uvmat') |
---|
1288 | huvmat=findobj(allchild(0),'name','uvmat'); |
---|
1289 | if ~isempty(huvmat) |
---|
1290 | uistack(huvmat,'top') |
---|
1291 | end |
---|
1292 | elseif ~isequal(plot_fig,'new fig...') & ~isequal(plot_fig,'uvmat') |
---|
1293 | sep=regexp(plot_fig,'_'); |
---|
1294 | if ~isempty(sep) |
---|
1295 | plot_fig=plot_fig([1:sep-1]); |
---|
1296 | end |
---|
1297 | if ishandle(str2num(plot_fig)) |
---|
1298 | figure(str2num(plot_fig))% display existing figure |
---|
1299 | else |
---|
1300 | browse_fig(handles.list_fig); %reset the current list of figures |
---|
1301 | end |
---|
1302 | end |
---|
1303 | |
---|
1304 | |
---|
1305 | %------------------------------------------------- |
---|
1306 | % give index numbers of the strings str in the list ListvarName |
---|
1307 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
1308 | VarIndex_y=[]; |
---|
1309 | if ischar(cell_str) |
---|
1310 | for ivar=1:length(ListVarName) |
---|
1311 | varlist=ListVarName{ivar}; |
---|
1312 | if isequal(varlist,cell_str) |
---|
1313 | VarIndex_y= ivar; |
---|
1314 | break |
---|
1315 | end |
---|
1316 | end |
---|
1317 | elseif iscell(cell_str) |
---|
1318 | for isel=1:length(cell_str) |
---|
1319 | varsel=cell_str{isel}; |
---|
1320 | for ivar=1:length(ListVarName) |
---|
1321 | varlist=ListVarName{ivar}; |
---|
1322 | if isequal(varlist,varsel) |
---|
1323 | VarIndex_y=[VarIndex_y ivar]; |
---|
1324 | end |
---|
1325 | end |
---|
1326 | end |
---|
1327 | end |
---|
1328 | |
---|
1329 | % -------------------------------------------------------------------- |
---|
1330 | function MenuOpen_Callback(hObject, eventdata, handles) |
---|
1331 | % hObject handle to MenuOpen (see GCBO) |
---|
1332 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
1333 | % handles structure with handles and user data (see GUIDATA) |
---|
1334 | |
---|
1335 | |
---|
1336 | % -------------------------------------------------------------------- |
---|
1337 | function MenuExport_Callback(hObject, eventdata, handles) |
---|
1338 | % hObject handle to MenuExport (see GCBO) |
---|
1339 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
1340 | % handles structure with handles and user data (see GUIDATA) |
---|
1341 | |
---|
1342 | |
---|
1343 | % -------------------------------------------------------------------- |
---|
1344 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
1345 | |
---|
1346 | oldfile=get(handles.inputfile,'String'); |
---|
1347 | testrootfile=0; |
---|
1348 | testsubdir=0; |
---|
1349 | if isempty(oldfile)|isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
1350 | oldfile=''; |
---|
1351 | dir_perso=prefdir; |
---|
1352 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1353 | if exist(profil_perso,'file') |
---|
1354 | h=load (profil_perso); |
---|
1355 | if isfield(h,'RootPath') |
---|
1356 | RootPath=h.RootPath; |
---|
1357 | end |
---|
1358 | if isfield(h,'SubDir') |
---|
1359 | SubDir=h.SubDir; |
---|
1360 | if ~isempty(SubDir) |
---|
1361 | testsubdir=1; |
---|
1362 | end |
---|
1363 | end |
---|
1364 | if isfield(h,'RootFile') |
---|
1365 | RootFile=h.RootFile; |
---|
1366 | if ~isempty(RootFile) |
---|
1367 | testrootfile=1; |
---|
1368 | end |
---|
1369 | end |
---|
1370 | end |
---|
1371 | end |
---|
1372 | if testrootfile |
---|
1373 | if ~testsubdir |
---|
1374 | oldfile=fullfile(RootPath,RootFile); |
---|
1375 | else |
---|
1376 | oldfile=fullfile(RootPath,SubDir,RootFile); |
---|
1377 | end |
---|
1378 | end |
---|
1379 | [FileName, PathName] = uigetfile( ... |
---|
1380 | {'*.nc', ' *.nc';... |
---|
1381 | '*.cdf', ' *.cdf';... |
---|
1382 | '*.*', 'All Files (*.*)'}, ... |
---|
1383 | 'Pick a file',oldfile); |
---|
1384 | |
---|
1385 | %global inputfile |
---|
1386 | fileinput=[PathName FileName];%complete file name |
---|
1387 | testblank=findstr(fileinput,' ');%look for blanks |
---|
1388 | if ~isempty(testblank) |
---|
1389 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name']) |
---|
1390 | return |
---|
1391 | end |
---|
1392 | sizf=size(fileinput); |
---|
1393 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
1394 | set(handles.inputfile,'String',fileinput) |
---|
1395 | inputfile_Callback(hObject, eventdata, handles) |
---|
1396 | |
---|
1397 | |
---|
1398 | %update list of recent files in the menubar |
---|
1399 | MenuFile_1=fileinput; |
---|
1400 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
1401 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
1402 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
1403 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
1404 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
1405 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
1406 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
1407 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
1408 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
1409 | dir_perso=prefdir; |
---|
1410 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1411 | display(profil_perso) |
---|
1412 | if exist(profil_perso,'file') |
---|
1413 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
1414 | else |
---|
1415 | txt=ver; |
---|
1416 | Release=txt(1).Release; |
---|
1417 | relnumb=str2double(Release(3:4)); |
---|
1418 | if relnumb >= 14 |
---|
1419 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
1420 | else |
---|
1421 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
1422 | end |
---|
1423 | end |
---|
1424 | |
---|
1425 | % -------------------------------------------------------------------- |
---|
1426 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
1427 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
1428 | set(handles.inputfile,'String',fileinput) |
---|
1429 | inputfile_Callback(hObject, eventdata, handles) |
---|
1430 | |
---|
1431 | % -------------------------------------------------------------------- |
---|
1432 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
1433 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
1434 | set(handles.inputfile,'String',fileinput) |
---|
1435 | inputfile_Callback(hObject, eventdata, handles) |
---|
1436 | |
---|
1437 | % -------------------------------------------------------------------- |
---|
1438 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
1439 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
1440 | set(handles.inputfile,'String',fileinput) |
---|
1441 | inputfile_Callback(hObject, eventdata, handles) |
---|
1442 | |
---|
1443 | % -------------------------------------------------------------------- |
---|
1444 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
1445 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
1446 | set(handles.inputfile,'String',fileinput) |
---|
1447 | inputfile_Callback(hObject, eventdata, handles) |
---|
1448 | |
---|
1449 | % -------------------------------------------------------------------- |
---|
1450 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
1451 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
1452 | set(handles.inputfile,'String',fileinput) |
---|
1453 | inputfile_Callback(hObject, eventdata, handles) |
---|
1454 | |
---|
1455 | % -------------------------------------------------------------------- |
---|
1456 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
1457 | global Data_get_field |
---|
1458 | % huvmat=findobj(allchild(0),'Name','uvmat'); |
---|
1459 | inputfile=get(handles.inputfile,'String'); |
---|
1460 | Data_get_field=nc2struct(inputfile); |
---|
1461 | % Data_view_field=UvData.ProjField_2; |
---|
1462 | evalin('base','global Data_get_field')%make CurData global in the workspace |
---|
1463 | display(['content of ' inputfile ':']) |
---|
1464 | evalin('base','Data_get_field') %display CurData in the workspace |
---|
1465 | commandwindow; |
---|
1466 | |
---|
1467 | % -------------------------------------------------------------------- |
---|
1468 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
1469 | % hObject handle to MenuHelp (see GCBO) |
---|
1470 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
1471 | % handles structure with handles and user data (see GUIDATA) |
---|
1472 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
1473 | pathelp=fileparts(path_to_uvmat); |
---|
1474 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
1475 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
1476 | else |
---|
1477 | web([helpfile '#get_field']) |
---|
1478 | end |
---|
1479 | |
---|