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