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