1 | %'series': master function associated to the GUI series.m for analysis field series |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function varargout = series(varargin) |
---|
4 | % associated with the GUI series.fig |
---|
5 | % |
---|
6 | %INPUT |
---|
7 | % param: structure with input parameters (link with the GUI uvmat) |
---|
8 | % .menu_coord_str: string for the transform_fct (menu for coordinate transforms) |
---|
9 | % .menu_coord_val: value for transform_fct (menu for coordinate transforms) |
---|
10 | % .FileName: input file name |
---|
11 | % .FileName_1: second input file name |
---|
12 | % .list_field: menu of input fields |
---|
13 | % .index_fields: chosen index |
---|
14 | % .civ1=0 or 1, .interp1, ... : input civ field type |
---|
15 | % |
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
17 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
18 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
19 | % This file is part of the toolbox UVMAT. |
---|
20 | % |
---|
21 | % UVMAT is free software; you can redistribute it and/or modify |
---|
22 | % it under the terms of the GNU General Public License as published by |
---|
23 | % the Free Software Foundation; either version 2 of the License, or |
---|
24 | % (at your option) any later version. |
---|
25 | % |
---|
26 | % UVMAT is distributed in the hope that it will be useful, |
---|
27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
29 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
30 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
31 | |
---|
32 | function varargout = series(varargin) |
---|
33 | |
---|
34 | % Begin initialization code - DO NOT EDIT |
---|
35 | gui_Singleton = 1; |
---|
36 | gui_State = struct('gui_Name', mfilename, ... |
---|
37 | 'gui_Singleton', gui_Singleton, ... |
---|
38 | 'gui_OpeningFcn', @series_OpeningFcn, ... |
---|
39 | 'gui_OutputFcn', @series_OutputFcn, ... |
---|
40 | 'gui_LayoutFcn', [] , ... |
---|
41 | 'gui_Callback', []); |
---|
42 | if nargin && ischar(varargin{1}) |
---|
43 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
44 | end |
---|
45 | |
---|
46 | if nargout |
---|
47 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
48 | else |
---|
49 | gui_mainfcn(gui_State, varargin{:}); |
---|
50 | end |
---|
51 | % End initialization code - DO NOT EDIT |
---|
52 | |
---|
53 | %-------------------------------------------------------------------------- |
---|
54 | % --- Executes just before series is made visible. |
---|
55 | %-------------------------------------------------------------------------- |
---|
56 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
57 | global nb_builtin_ACTION nb_builtin_transform |
---|
58 | % Choose default command line output for series |
---|
59 | handles.output = hObject; |
---|
60 | % Update handles structure |
---|
61 | guidata(hObject, handles); |
---|
62 | %default initial parameters |
---|
63 | drawnow |
---|
64 | set(hObject,'Units','pixels') |
---|
65 | % set(0,'Units','pixels') |
---|
66 | % screensize=get(0,'ScreenSize'); %screen size in pixels |
---|
67 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
68 | %set(hObject,'Position',[150 100 1000 600] );%position and size in pixels (get adjusted to the screen size in case of excess) |
---|
69 | %load the list of previously browsed files in menus Open and Open_1 |
---|
70 | dir_perso=prefdir; |
---|
71 | test_profil_perso=0; |
---|
72 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
73 | if exist(profil_perso,'file') |
---|
74 | h=load (profil_perso); |
---|
75 | test_profil_perso=1; |
---|
76 | if isfield(h,'MenuFile_1') |
---|
77 | set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
78 | set(handles.MenuFile_insert_1,'Label',h.MenuFile_1); |
---|
79 | end |
---|
80 | if isfield(h,'MenuFile_1') |
---|
81 | set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
82 | set(handles.MenuFile_insert_2,'Label',h.MenuFile_2); |
---|
83 | end |
---|
84 | if isfield(h,'MenuFile_1') |
---|
85 | set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
86 | set(handles.MenuFile_insert_3,'Label',h.MenuFile_3); |
---|
87 | end |
---|
88 | if isfield(h,'MenuFile_1') |
---|
89 | set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
90 | set(handles.MenuFile_insert_4,'Label',h.MenuFile_4); |
---|
91 | end |
---|
92 | if isfield(h,'MenuFile_1') |
---|
93 | set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
94 | set(handles.MenuFile_insert_5,'Label',h.MenuFile_5); |
---|
95 | end |
---|
96 | end |
---|
97 | |
---|
98 | %check default input data |
---|
99 | if ~exist('param','var') |
---|
100 | param=[]; %default |
---|
101 | end |
---|
102 | |
---|
103 | %% file name and browser initialisation |
---|
104 | if isfield(param,'menu_coord_str') |
---|
105 | set(handles.transform_fct,'String',param.menu_coord_str) |
---|
106 | end |
---|
107 | if isfield(param,'menu_coord_val') |
---|
108 | set(handles.transform_fct,'Value',param.menu_coord_val); |
---|
109 | else |
---|
110 | set(handles.transform_fct,'Value',1);%default |
---|
111 | end |
---|
112 | if isfield(param,'FileName') |
---|
113 | if isfield(param,'FileName_1') |
---|
114 | update_rootfile(handles,param.FileName_1,0) |
---|
115 | update_rootfile(handles,param.FileName,1) |
---|
116 | else |
---|
117 | update_rootfile(handles,param.FileName,0) |
---|
118 | end |
---|
119 | end |
---|
120 | |
---|
121 | %% fields input initialisation |
---|
122 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
123 | set(handles.FieldMenu,'String',param.list_fields);% list menu fields |
---|
124 | set(handles.FieldMenu,'Value',param.index_fields);% selected string index |
---|
125 | FieldCell{1}=param.list_fields{param.index_fields}; |
---|
126 | end |
---|
127 | |
---|
128 | %REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
129 | %loads the information stored in prefdir to initiate the list of ACTION functions |
---|
130 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
131 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
132 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
133 | nb_transform=numel(transform_menu); |
---|
134 | [path_series,name,ext]=fileparts(which('series')); |
---|
135 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
136 | addpath (path_series) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
137 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
138 | for ilist=1:length(fct_menu) |
---|
139 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
140 | end |
---|
141 | |
---|
142 | %% TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
143 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
144 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
145 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
146 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
147 | fct_handle{1,1}=[]; |
---|
148 | testexist(1)=1; |
---|
149 | for ilist=2:length(menu_str) |
---|
150 | if exist(menu_str{ilist},'file') |
---|
151 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
152 | testexist(ilist)=1; |
---|
153 | else |
---|
154 | testexist(ilist)=0; |
---|
155 | end |
---|
156 | end |
---|
157 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
158 | |
---|
159 | %% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
160 | if test_profil_perso |
---|
161 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
162 | for ilist=1:length(h.series_fct) |
---|
163 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
164 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
165 | fct_menu=[fct_menu; {file}]; |
---|
166 | end |
---|
167 | end |
---|
168 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
169 | for ilist=1:length(h.transform_fct); |
---|
170 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
171 | addpath(path) |
---|
172 | if exist(file,'file') |
---|
173 | h_func=str2func(file); |
---|
174 | testexist=[testexist 1]; |
---|
175 | else |
---|
176 | h_func=[]; |
---|
177 | testexist=[testexist 0]; |
---|
178 | end |
---|
179 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
180 | rmpath(path) |
---|
181 | menu_str=[menu_str; {file}]; |
---|
182 | end |
---|
183 | end |
---|
184 | end |
---|
185 | fct_menu=[fct_menu;{'more...'}]; |
---|
186 | set(handles.ACTION,'String',fct_menu) |
---|
187 | set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
188 | menu_str=menu_str(find(testexist)); |
---|
189 | fct_handle=fct_handle(find(testexist)); |
---|
190 | menu_str=[menu_str;{'more...'}]; |
---|
191 | set(handles.transform_fct,'String',menu_str) |
---|
192 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
193 | |
---|
194 | % display the GUI for the default action 'check_data_files' |
---|
195 | ACTION_Callback(hObject, eventdata, handles) |
---|
196 | |
---|
197 | %-------------------------------------------------------------- |
---|
198 | % --- Outputs from this function are returned to the command line. |
---|
199 | %----------------------------------------------------------------- |
---|
200 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
201 | % varargout cell array for returning output args (see VARARGOUT); |
---|
202 | % hObject handle to figure |
---|
203 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
204 | % handles structure with handles and user data (see GUIDATA) |
---|
205 | % Get default command line output from handles structure |
---|
206 | varargout{1} = handles.output; |
---|
207 | |
---|
208 | % -------------------------------------------------------------------- |
---|
209 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
210 | InputTable=get(handles.InputTable,'Data'); |
---|
211 | RootPathCell=InputTable(:,1); |
---|
212 | SubDirCell=InputTable(:,2); |
---|
213 | RootFileCell=InputTable(:,3); |
---|
214 | %RootPathCell=get(handles.RootPath,'String'); |
---|
215 | %SubDirCell=get(handles.SubDir,'String'); |
---|
216 | %RootFileCell=get(handles.RootFile,'String'); |
---|
217 | oldfile=''; %default |
---|
218 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
219 | dir_perso=prefdir; |
---|
220 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
221 | if exist(profil_perso,'file') |
---|
222 | h=load (profil_perso); |
---|
223 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
224 | oldfile=h.filebase; |
---|
225 | end |
---|
226 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
227 | oldfile=h.RootPath; |
---|
228 | end |
---|
229 | end |
---|
230 | else |
---|
231 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
232 | end |
---|
233 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
234 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
235 | '*.xml', '.xml files '; ... |
---|
236 | '*.xls', '.xls files '; ... |
---|
237 | '*.png','.png image files'; ... |
---|
238 | '*.tif','.tif image files'; ... |
---|
239 | '*.avi;*.AVI','.avi movie files'; ... |
---|
240 | '*.nc','.netcdf files'; ... |
---|
241 | '*.*', 'All Files (*.*)'}, ... |
---|
242 | 'Pick a file',oldfile); |
---|
243 | fileinput=[PathName FileName];%complete file name |
---|
244 | %testblank=findstr(fileinput,' ');%look for blanks |
---|
245 | % if ~isempty(testblank) |
---|
246 | % errordlg('forbidden input file name: contain blanks') |
---|
247 | % return |
---|
248 | % end |
---|
249 | sizf=size(fileinput); |
---|
250 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
251 | [path,name,ext]=fileparts(fileinput); |
---|
252 | SeriesData=[];%dfault |
---|
253 | if isequal(ext,'.xml') |
---|
254 | warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
255 | elseif isequal(ext,'.xls') |
---|
256 | warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
257 | else |
---|
258 | update_rootfile(handles,fileinput,0) |
---|
259 | %update list of recent files in the menubar |
---|
260 | MenuFile_1=fileinput; |
---|
261 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
262 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
263 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
264 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
265 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
266 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
267 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
268 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
269 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
270 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
271 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
272 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
273 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
274 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
275 | dir_perso=prefdir; |
---|
276 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
277 | if exist(profil_perso,'file') |
---|
278 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
279 | else |
---|
280 | txt=ver('MATLAB'); |
---|
281 | Release=txt.Release; |
---|
282 | relnumb=str2num(Release(3:4)); |
---|
283 | if relnumb >= 14 |
---|
284 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
285 | else |
---|
286 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
287 | end |
---|
288 | end |
---|
289 | end |
---|
290 | |
---|
291 | |
---|
292 | % -------------------------------------------------------------------- |
---|
293 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
294 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
295 | update_rootfile(handles,fileinput,0) |
---|
296 | |
---|
297 | % -------------------------------------------------------------------- |
---|
298 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
299 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
300 | update_rootfile(handles,fileinput,0) |
---|
301 | |
---|
302 | % -------------------------------------------------------------------- |
---|
303 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
304 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
305 | update_rootfile( handles,fileinput,0) |
---|
306 | |
---|
307 | % -------------------------------------------------------------------- |
---|
308 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
309 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
310 | update_rootfile(handles,fileinput,0) |
---|
311 | |
---|
312 | % -------------------------------------------------------------------- |
---|
313 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
314 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
315 | update_rootfile(handles,fileinput,0) |
---|
316 | |
---|
317 | % -------------------------------------------------------------------- |
---|
318 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
319 | InputTable=get(handles.InputTable,'Data'); |
---|
320 | RootPathCell=InputTable(:,1); |
---|
321 | SubDirCell=InputTable(:,3); |
---|
322 | RootFileCell=InputTable(:,2); |
---|
323 | % RootPathCell=get(handles.RootPath,'String'); |
---|
324 | % RootFileCell=get(handles.RootFile,'String'); |
---|
325 | oldfile=''; %default |
---|
326 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
327 | dir_perso=prefdir; |
---|
328 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
329 | if exist(profil_perso,'file') |
---|
330 | h=load (profil_perso); |
---|
331 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
332 | oldfile=h.filebase; |
---|
333 | end |
---|
334 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
335 | oldfile=h.RootPath; |
---|
336 | end |
---|
337 | end |
---|
338 | else |
---|
339 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
340 | end |
---|
341 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
342 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
343 | '*.xml', '.xml files '; ... |
---|
344 | '*.xls', '.xls files '; ... |
---|
345 | '*.png','.png image files'; ... |
---|
346 | '*.avi;*.AVI','.avi movie files'; ... |
---|
347 | '*.nc','.netcdf files'; ... |
---|
348 | '*.*', 'All Files (*.*)'}, ... |
---|
349 | 'Pick a file',oldfile); |
---|
350 | fileinput=[PathName FileName];%complete file name |
---|
351 | % testblank=findstr(fileinput,' ');%look for blanks |
---|
352 | % if ~isempty(testblank) |
---|
353 | % errordlg('forbidden input file name: contain blanks') |
---|
354 | % return |
---|
355 | % end |
---|
356 | sizf=size(fileinput); |
---|
357 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
358 | [path,name,ext]=fileparts(fileinput); |
---|
359 | SeriesData=[];%dfault |
---|
360 | if isequal(ext,'.xml') |
---|
361 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
362 | elseif isequal(ext,'.xls') |
---|
363 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
364 | else |
---|
365 | update_rootfile(handles,fileinput,1) |
---|
366 | %update list of recent files in the menubar |
---|
367 | MenuFile_1=fileinput; |
---|
368 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
369 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
370 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
371 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
372 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
373 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
374 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
375 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
376 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
377 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
378 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
379 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
380 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
381 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
382 | dir_perso=prefdir; |
---|
383 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
384 | if exist(profil_perso,'file') |
---|
385 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
386 | else |
---|
387 | txt=ver('MATLAB'); |
---|
388 | Release=txt.Release; |
---|
389 | relnumb=str2num(Release(3:4)); |
---|
390 | if relnumb >= 14 |
---|
391 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
392 | else |
---|
393 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
394 | end |
---|
395 | end |
---|
396 | end |
---|
397 | %------------------------------------------------ |
---|
398 | |
---|
399 | % -------------------------------------------------------------------- |
---|
400 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
401 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
402 | update_rootfile(handles,fileinput,1) |
---|
403 | |
---|
404 | % -------------------------------------------------------------------- |
---|
405 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
406 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
407 | update_rootfile(handles,fileinput,1) |
---|
408 | |
---|
409 | % -------------------------------------------------------------------- |
---|
410 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
411 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
412 | update_rootfile( handles,fileinput,1) |
---|
413 | |
---|
414 | % -------------------------------------------------------------------- |
---|
415 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
416 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
417 | update_rootfile( handles,fileinput,1) |
---|
418 | |
---|
419 | % -------------------------------------------------------------------- |
---|
420 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
421 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
422 | update_rootfile(handles,fileinput,1) |
---|
423 | |
---|
424 | %------------------------------------------------------------------------ |
---|
425 | % --- refresh the GUI data after introduction of a new file series |
---|
426 | % INPUT: |
---|
427 | % handles: |
---|
428 | % fileinput: name of the input file |
---|
429 | % addtest: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert') |
---|
430 | function update_rootfile(handles,fileinput,addtest) |
---|
431 | %------------------------------------------------------------------------ |
---|
432 | |
---|
433 | %% enable other menus and uicontrols |
---|
434 | set(handles.MenuOpen_insert,'Enable','on') |
---|
435 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
436 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
437 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
438 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
439 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
440 | set(handles.RUN, 'Enable','On') |
---|
441 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
442 | % set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
443 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
444 | drawnow |
---|
445 | |
---|
446 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
447 | if ~exist(fileinput,'file') |
---|
448 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
449 | return |
---|
450 | end |
---|
451 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); |
---|
452 | |
---|
453 | %% fill the list of file series |
---|
454 | InputTable=get(handles.InputTable,'Data'); |
---|
455 | if addtest % display the input data as a new line in the table |
---|
456 | val=size(InputTable,1)+1; |
---|
457 | InputTable(val,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
458 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
459 | else % or re-initialise the list of input file series |
---|
460 | val=1; |
---|
461 | InputTable=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
462 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
463 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
464 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
465 | end |
---|
466 | set(handles.InputTable,'Data',InputTable) |
---|
467 | check_lines(val)=1; %select the edited line for refresh |
---|
468 | set(handles.REFRESH_INDICES,'UserData',check_lines); |
---|
469 | |
---|
470 | %% refresh menus with info from the new series |
---|
471 | REFRESH_INDICES_Callback([],[], handles) |
---|
472 | |
---|
473 | %% determine the selected reference field indices for pair dispaly |
---|
474 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
475 | if ~isempty(i1) |
---|
476 | ref_i=i1; |
---|
477 | if ~isempty(i2) |
---|
478 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
479 | end |
---|
480 | end |
---|
481 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
482 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
483 | if ~isempty(j1) |
---|
484 | ref_j=j1; |
---|
485 | if ~isempty(j2) |
---|
486 | ref_j=floor((j1+j2)/2); |
---|
487 | end |
---|
488 | end |
---|
489 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
490 | ref_i_Callback([],[], handles) |
---|
491 | ref_j_Callback([],[], handles) |
---|
492 | |
---|
493 | %% update the first and last reference indices if empty |
---|
494 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
495 | if isempty(first_i) |
---|
496 | set(handles.num_first_i,'String',num2str(ref_i)); |
---|
497 | set(handles.num_last_i,'String',num2str(ref_i)); |
---|
498 | set(handles.num_first_j,'String',num2str(ref_j)) |
---|
499 | set(handles.num_last_j,'String',num2str(ref_j)); |
---|
500 | end |
---|
501 | |
---|
502 | %% store the root name for future opening of uvmat |
---|
503 | dir_perso=prefdir; |
---|
504 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
505 | if exist(profil_perso,'file') |
---|
506 | save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat |
---|
507 | else |
---|
508 | txt=ver('MATLAB'); |
---|
509 | Release=txt.Release; |
---|
510 | relnumb=str2num(Release(3:4)); |
---|
511 | if relnumb >= 14 |
---|
512 | save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6') %store the root name for future opening of uvmat |
---|
513 | else |
---|
514 | save(profil_perso,'RootPath','SubDir','RootFile','NomType') |
---|
515 | end |
---|
516 | end |
---|
517 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
518 | % set(handles.PathCampaign,'String',SeriesData.PathCampaign) |
---|
519 | %num_last_j_Callback([], [], handles)% TODO:update |
---|
520 | %num_last_i_Callback([], [], handles) |
---|
521 | |
---|
522 | |
---|
523 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
524 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
525 | % hObject handle to InputTable (see GCBO) |
---|
526 | % eventdata structure with the following fields (see UITABLE) |
---|
527 | % Indices: row and column indices of the cell(s) edited |
---|
528 | % PreviousData: previous data for the cell(s) edited |
---|
529 | % EditData: string(s) entered by the user |
---|
530 | % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed |
---|
531 | % Error: error string when failed to convert EditData to appropriate value for Data |
---|
532 | % handles structure with handles and user data (see GUIDATA) |
---|
533 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
534 | check_lines(eventdata.Indices(1))=1; %select the edited line for refresh |
---|
535 | set(handles.REFRESH_INDICES,'UserData',check_lines); |
---|
536 | set(handles.REFRESH_INDICES,'Visible','on') |
---|
537 | |
---|
538 | |
---|
539 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%???????????? |
---|
540 | % --- Executes on button press in mode. |
---|
541 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
542 | function mode_Callback(hObject, eventdata, handles) |
---|
543 | |
---|
544 | SeriesData=get(handles.series,'UserData'); |
---|
545 | mode_list=get(handles.mode,'String'); |
---|
546 | mode_value=get(handles.mode,'Value'); |
---|
547 | mode=mode_list{mode_value}; |
---|
548 | time=[]; |
---|
549 | if isfield(SeriesData,'Time') |
---|
550 | time=SeriesData.Time{1}; %get the set of times |
---|
551 | end |
---|
552 | if isequal(mode,'bursts') |
---|
553 | enable_i(handles,'On') |
---|
554 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
555 | else |
---|
556 | enable_i(handles,'On') |
---|
557 | enable_j(handles,'Off') |
---|
558 | end |
---|
559 | find_netcpair_civ(handles) |
---|
560 | |
---|
561 | %------------------------------------- |
---|
562 | function enable_i(handles,state) |
---|
563 | set(handles.i_txt,'Visible',state) |
---|
564 | set(handles.num_first_i,'Visible',state) |
---|
565 | set(handles.num_last_i,'Visible',state) |
---|
566 | set(handles.num_incr_i,'Visible',state) |
---|
567 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
568 | set(handles.ref_i,'Visible',state) |
---|
569 | set(handles.ref_i_text,'Visible',state) |
---|
570 | |
---|
571 | %----------------------------------- |
---|
572 | function enable_j(handles,state) |
---|
573 | set(handles.j_txt,'Visible',state) |
---|
574 | % set(handles.num_MinIndex_j,'Visible',state) |
---|
575 | set(handles.num_first_j,'Visible',state) |
---|
576 | set(handles.num_last_j,'Visible',state) |
---|
577 | set(handles.num_incr_j,'Visible',state) |
---|
578 | % set(handles.num_MaxIndex_j,'Visible',state) |
---|
579 | set(handles.ref_j,'Visible',state) |
---|
580 | set(handles.ref_j_text,'Visible',state) |
---|
581 | |
---|
582 | %----------------------------------- |
---|
583 | function view_FieldMenu(handles,state) |
---|
584 | % set(handles.FieldMenu,'Visible',state) |
---|
585 | % set(handles.Field_text,'Visible',state) |
---|
586 | set(handles.InputFields,'Visible',state) |
---|
587 | |
---|
588 | %----------------------------------- |
---|
589 | function view_FieldMenu_1(handles,state) |
---|
590 | set(handles.FieldMenu_1,'Visible',state) |
---|
591 | set(handles.Field_text_1,'Visible',state) |
---|
592 | |
---|
593 | % %----------------------------------- |
---|
594 | % function view_TRANSFORM(handles,state) |
---|
595 | % set(handles.TRANSFORM_frame,'Visible',state) |
---|
596 | % set(handles.transform_fct,'Visible',state); |
---|
597 | % set(handles.TRANSFORM_title,'Visible',state) |
---|
598 | |
---|
599 | %-------------------------------------------------------------- |
---|
600 | % determine the menu for civ1 pairs depending on existing netcdf files |
---|
601 | % with the reference indices ref_i and ref_j |
---|
602 | %---------------------------------------------------------------- |
---|
603 | function find_netcpair_civ(handles) |
---|
604 | SeriesData=get(handles.series,'UserData'); |
---|
605 | set(handles.Pairs,'Visible','on')% makes the panel "Pairs' visible |
---|
606 | mode_list=get(handles.mode,'String'); |
---|
607 | mode_value=get(handles.mode,'Value'); |
---|
608 | mode=mode_list{mode_value}; |
---|
609 | |
---|
610 | %reads image numbers from the interface |
---|
611 | % ref_i=str2num(get(handles.ref_i,'String')); |
---|
612 | % ref_j=str2num(get(handles.ref_j,'String')); |
---|
613 | % ref_time=0; |
---|
614 | % nbfield=50; |
---|
615 | % nbfield2=50;%default max number of pairs |
---|
616 | |
---|
617 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
618 | % be performed, while the result is needed for next steps. |
---|
619 | |
---|
620 | % ind_exist=0; |
---|
621 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
622 | if length(TimeUnit)>=1 |
---|
623 | dtunit=['m' TimeUnit]; |
---|
624 | else |
---|
625 | dtunit='e-03'; |
---|
626 | end |
---|
627 | |
---|
628 | %% NEW |
---|
629 | for Val=1:numel(SeriesData.i1_series) |
---|
630 | |
---|
631 | i1_series=SeriesData.i1_series{Val}; |
---|
632 | i2_series=SeriesData.i2_series{Val}; |
---|
633 | j1_series=SeriesData.j1_series{Val}; |
---|
634 | j2_series=SeriesData.j2_series{Val}; |
---|
635 | displ_pair={}; |
---|
636 | if strcmp(mode,'series(Di)') |
---|
637 | if isempty(i2_series) |
---|
638 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
639 | return |
---|
640 | end |
---|
641 | diff_i=i2_series-i1_series; |
---|
642 | min_diff=min(diff_i(diff_i>0)); |
---|
643 | max_diff=max(diff_i(diff_i>0)); |
---|
644 | for ipair=min_diff:max_diff |
---|
645 | if numel(diff_i(diff_i==ipair))>0 |
---|
646 | displ_pair=[displ_pair;{['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}]; |
---|
647 | end |
---|
648 | end |
---|
649 | if ~isempty(displ_pair) |
---|
650 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
651 | end |
---|
652 | elseif strcmp(mode,'series(Dj)') |
---|
653 | if isempty(j2_series) |
---|
654 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
655 | return |
---|
656 | end |
---|
657 | diff_j=j2_series-j1_series; |
---|
658 | min_diff=min(diff_j(diff_j>0)); |
---|
659 | max_diff=max(diff_j(diff_j>0)); |
---|
660 | for ipair=min_diff:max_diff |
---|
661 | if numel(diff_j(diff_j==ipair))>0 |
---|
662 | displ_pair=[displ_pair;{['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}]; |
---|
663 | end |
---|
664 | end |
---|
665 | if ~isempty(displ_pair) |
---|
666 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
667 | end |
---|
668 | elseif strcmp(mode,'bursts') |
---|
669 | if isempty(j2_series) |
---|
670 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
671 | return |
---|
672 | end |
---|
673 | diff_j=j2_series-j1_series; |
---|
674 | min_j1=min(j1_series(j1_series>0)); |
---|
675 | max_j1=max(j1_series(j1_series>0)); |
---|
676 | min_j2=min(j2_series(j2_series>0)); |
---|
677 | max_j2=max(j2_series(j2_series>0)); |
---|
678 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
679 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
680 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
681 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
682 | end |
---|
683 | end |
---|
684 | end |
---|
685 | if ~isempty(displ_pair) |
---|
686 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
687 | end |
---|
688 | end |
---|
689 | end |
---|
690 | %% display list of pairs |
---|
691 | displ_pair_list=get(handles.list_pair_civ,'String'); |
---|
692 | NewVal=[]; |
---|
693 | if ~isempty(displ_pair_list) |
---|
694 | Val=get(handles.list_pair_civ,'Value'); |
---|
695 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pâir |
---|
696 | end |
---|
697 | if ~isempty(NewVal) |
---|
698 | set(handles.list_pair_civ,'Value',NewVal) |
---|
699 | else |
---|
700 | set(handles.list_pair_civ,'Value',1) |
---|
701 | end |
---|
702 | set(handles.list_pair_civ,'String',displ_pair) |
---|
703 | if isempty(displ_pair) |
---|
704 | msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' subdir]) |
---|
705 | end |
---|
706 | return |
---|
707 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END FUNCTION |
---|
708 | |
---|
709 | |
---|
710 | if ind_exist==0 |
---|
711 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
712 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir]) |
---|
713 | else |
---|
714 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir]) |
---|
715 | end |
---|
716 | if isequal(mode,'bursts') %case of bursts |
---|
717 | set(handles.list_pair_civ,'String',{'j=*-*'}); |
---|
718 | elseif isequal(mode,'series(Di)') %case of bursts |
---|
719 | set(handles.list_pair_civ,'String',{'Di=*|*'}); |
---|
720 | elseif isequal(mode,'series(Dj)') %case of bursts |
---|
721 | set(handles.list_pair_civ,'String',{'Dj=*|*'}); |
---|
722 | end |
---|
723 | end |
---|
724 | return |
---|
725 | %TO update |
---|
726 | val=get(handles.list_pair_civ,'Value'); |
---|
727 | if val > length(displ_pair) |
---|
728 | set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu |
---|
729 | val=1; |
---|
730 | end |
---|
731 | iview=get(handles.NomType,'Value'); |
---|
732 | SeriesData.displ_num(iview,:)=(displ_num(:,val))'; |
---|
733 | SeriesData.ref_time=ref_time; |
---|
734 | set(handles.series,'UserData',SeriesData) |
---|
735 | list_pair_civ_Callback([],[],handles) |
---|
736 | |
---|
737 | %------------------------------------------------------------- |
---|
738 | % --- Executes on selection in list_pair_civ. |
---|
739 | function list_pair_civ_Callback(hObject,eventdata,handles) |
---|
740 | %------------------------------------------------------------ |
---|
741 | return |
---|
742 | %%%%%%%% |
---|
743 | %update num_first_i and num_last_i according to the chosen image pairs |
---|
744 | testupdate=0; |
---|
745 | Val=get(handles.RootPath,'Value'); |
---|
746 | IndexCell=get(handles.NomType,'String'); |
---|
747 | SeriesData=get(handles.series,'UserData'); |
---|
748 | NomType=SeriesData.NomType{Val}; |
---|
749 | list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs |
---|
750 | index_pair=get(handles.list_pair_civ,'Value'); |
---|
751 | str_pair=list_pair{index_pair}; |
---|
752 | ind_equ=strfind(str_pair,'=');%find '=' |
---|
753 | ind_sep=strfind(str_pair,'|');%find pair separator '|' |
---|
754 | ind_com=strfind(str_pair,':');%find ':' |
---|
755 | test_bursts=0; |
---|
756 | if isempty(ind_sep) |
---|
757 | ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|' |
---|
758 | test_bursts=1;% we are in the case of bursts |
---|
759 | end |
---|
760 | displ_num=[0 0 0 0]; %default |
---|
761 | if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-') |
---|
762 | num1_str=str_pair(ind_equ(1)+1:ind_sep-1); |
---|
763 | num2_str=str_pair(ind_sep+1:ind_com-1); |
---|
764 | num1=str2double(num1_str); |
---|
765 | num2=str2double(num2_str); |
---|
766 | if isequal(num1_str(1),' ') |
---|
767 | num1_str(1)=[]; |
---|
768 | end |
---|
769 | if isequal(num2_str(end),' ') |
---|
770 | num2_str(end)=[]; |
---|
771 | end |
---|
772 | switch NomType |
---|
773 | case {'_1-2_1'} |
---|
774 | if isequal(num1_str(1),'0') |
---|
775 | IndexCell{Val}=['_(i-(i+' num2_str ')_j']; |
---|
776 | else |
---|
777 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j']; |
---|
778 | end |
---|
779 | displ_num(3)=num1; |
---|
780 | displ_num(4)=num2; |
---|
781 | case {'_1-2'} |
---|
782 | if isequal(num1_str(1),'0') |
---|
783 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
784 | else |
---|
785 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
786 | end |
---|
787 | displ_num(3)=num1; |
---|
788 | displ_num(4)=num2; |
---|
789 | case '_1_1-2' |
---|
790 | if test_bursts |
---|
791 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
792 | else |
---|
793 | if isequal(num1_str(1),'0') |
---|
794 | IndexCell{Val}=['_i_j-(j+' num2_str ')']; |
---|
795 | else |
---|
796 | IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')']; |
---|
797 | end |
---|
798 | end |
---|
799 | displ_num(1)=num1; |
---|
800 | displ_num(2)=num2; |
---|
801 | case {'#_ab'} %TO COMPLETE |
---|
802 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
803 | |
---|
804 | end |
---|
805 | end |
---|
806 | set(handles.NomType,'String',IndexCell) |
---|
807 | SeriesData.displ_num(Val,:)=displ_num; |
---|
808 | set(handles.series,'UserData',SeriesData) |
---|
809 | % set(handles.NomType,'Value',Val) |
---|
810 | |
---|
811 | if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*') |
---|
812 | mode_list=get(handles.mode,'String'); |
---|
813 | mode_value=get(handles.mode,'Value'); |
---|
814 | mode=mode_list{mode_value}; |
---|
815 | if isequal(mode,'series(Di)') |
---|
816 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
817 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
818 | incr_i=str2num(get(handles.num_incr_i,'String')); |
---|
819 | num1=first_i:incr_i:last_i; |
---|
820 | lastfieldCell=get(handles.num_MaxIndex_i,'String'); |
---|
821 | lastfield=str2num(lastfieldCell{1}); |
---|
822 | if ~isempty(lastfield) |
---|
823 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
824 | num1=num1(ind); |
---|
825 | end |
---|
826 | if ~isempty(num1) |
---|
827 | set(handles.num_first_i,'String',num2str(num1(1))); |
---|
828 | set(handles.num_last_i,'String',num2str(num1(end))); |
---|
829 | end |
---|
830 | testupdate=1; |
---|
831 | elseif isequal(mode,'series(Dj)') |
---|
832 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
833 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
834 | incr_j=str2num(get(handles.num_incr_j,'String')); |
---|
835 | num_j=first_j:incr_j:last_j; |
---|
836 | lastfieldCell=get(handles.num_MaxIndex_j,'String'); |
---|
837 | if ~isempty(lastfieldCell) |
---|
838 | lastfield2=lastfieldCell{1}; |
---|
839 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
840 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
841 | end |
---|
842 | testupdate=1; |
---|
843 | end |
---|
844 | |
---|
845 | %update the first and last times of the series |
---|
846 | if testupdate && isfield(SeriesData,'Time') |
---|
847 | if ~isempty(SeriesData.Time{1}) |
---|
848 | displ_time(handles); |
---|
849 | end |
---|
850 | end |
---|
851 | end |
---|
852 | |
---|
853 | %------------------------------------------------------------------------ |
---|
854 | % --- Executes on button press in RUN. |
---|
855 | function RUN_Callback(hObject, eventdata, handles) |
---|
856 | %------------------------------------------------------------------------ |
---|
857 | %% Read parameters from series |
---|
858 | Series=read_GUI(handles.series);%TODO: extend to all input param |
---|
859 | Series.hseries=handles.series; % handles to the series GUI |
---|
860 | |
---|
861 | %% read root name and field type |
---|
862 | set(handles.RUN,'BusyAction','queue'); |
---|
863 | set(0,'CurrentFigure',handles.series) |
---|
864 | if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1) |
---|
865 | Series.GetObject=1; |
---|
866 | GetObject_Callback(hObject, eventdata, handles) |
---|
867 | else |
---|
868 | Series.GetObject=0; |
---|
869 | end |
---|
870 | % SeriesData=get(handles.series,'UserData'); |
---|
871 | |
---|
872 | % Series.hseries=handles.series; % handles to the series GUI |
---|
873 | first_i=1; |
---|
874 | last_i=1; |
---|
875 | incr_i=1; |
---|
876 | first_j=1; |
---|
877 | last_j=1; |
---|
878 | incr_j=1; |
---|
879 | if isfield(Series.IndexRange,'first_i') |
---|
880 | first_i=Series.IndexRange.first_i; |
---|
881 | incr_i=Series.IndexRange.incr_i; |
---|
882 | last_i=Series.IndexRange.last_i; |
---|
883 | end |
---|
884 | if isfield(Series.IndexRange,'first_j') |
---|
885 | first_j=Series.IndexRange.first_j; |
---|
886 | incr_j=Series.IndexRange.incr_j; |
---|
887 | last_j=Series.IndexRange.last_j; |
---|
888 | end |
---|
889 | |
---|
890 | %% read input file parameters and set menus |
---|
891 | Series.PathProject=get(handles.PathCampaign,'String'); |
---|
892 | % InputTable=get(handles.InputTable,'Data'); |
---|
893 | % RootPath=Series.InputTable(:,1); |
---|
894 | % SubDir=Series.InputTable(:,2); |
---|
895 | % RootFile=Series.InputTable(:,3); |
---|
896 | % NomType=Series.InputTable(:,4); |
---|
897 | % FileExt=Series.InputTable(:,5); |
---|
898 | % if isempty(SeriesData) |
---|
899 | % msgbox_uvmat('ERROR','no input file series') |
---|
900 | % return |
---|
901 | % end |
---|
902 | % NomType=SeriesData.NomType; |
---|
903 | % if length(RootPath)==1 %string character input for user fct |
---|
904 | % Series.RootPath=RootPath{1}; |
---|
905 | % Series.RootFile=RootFile{1}; |
---|
906 | % Series.SubDir=SubDir{1}; |
---|
907 | % Series.FileExt=FileExt{1}; |
---|
908 | % Series.NomType=NomType{1}; |
---|
909 | % else %cell input for user fct |
---|
910 | % Series.RootPath=RootPath; |
---|
911 | % Series.RootFile=RootFile; |
---|
912 | % Series.SubDir=SubDir; |
---|
913 | % Series.FileExt=FileExt; |
---|
914 | % Series.NomType=NomType; |
---|
915 | % end |
---|
916 | % if isequal(get(handles.FieldMenu,'Visible'),'on') |
---|
917 | % FieldMenu=get(handles.FieldMenu,'String'); |
---|
918 | % FieldValue=get(handles.FieldMenu,'Value'); |
---|
919 | % Series.Field=FieldMenu(FieldValue); |
---|
920 | % end |
---|
921 | menu_coord_state=get(handles.transform_fct,'Visible'); |
---|
922 | Series.CoordType='';%default |
---|
923 | if isequal(menu_coord_state,'on') |
---|
924 | % menu_coord=get(handles.transform_fct,'String'); |
---|
925 | menu_index=get(handles.transform_fct,'Value'); |
---|
926 | transform_list=get(handles.transform_fct,'UserData'); |
---|
927 | Series.FieldTransform.fct_handle=transform_list{menu_index};% transform function handles |
---|
928 | end |
---|
929 | |
---|
930 | %reinitiate waitbar position |
---|
931 | Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS |
---|
932 | waitbarpos=Series.WaitbarPos; |
---|
933 | waitbarpos(4)=0.005;%reinitialize waitbar to zero height |
---|
934 | waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005; |
---|
935 | % set(handles.waitbar,'Position',waitbarpos) |
---|
936 | |
---|
937 | if isfield(Series.IndexRange,'NbSlice') |
---|
938 | Series.NbSlice=Series.IndexRange.NbSlice; |
---|
939 | end |
---|
940 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
941 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
942 | num_i=first_i:incr_i:last_i; |
---|
943 | num_j=first_j:incr_j:last_j; |
---|
944 | % nbfield_cell=get(handles.num_MaxIndex_i,'String'); |
---|
945 | nbfield=cell2mat(Series.IndexRange.MaxIndex); |
---|
946 | nb=min(nbfield,1); |
---|
947 | % nbfield=nb(1); |
---|
948 | % nbfield2=nb(2); |
---|
949 | |
---|
950 | %get complementary information from the 'series' interface |
---|
951 | list_action=get(handles.ACTION,'String');% list menu action |
---|
952 | index_action=get(handles.ACTION,'Value');% selected string index |
---|
953 | action= list_action{index_action}; % selected string |
---|
954 | mode_list=get(handles.mode,'String'); |
---|
955 | index_mode=get(handles.mode,'Value'); |
---|
956 | mode=mode_list{index_mode}; |
---|
957 | ind_shift=0;%default |
---|
958 | |
---|
959 | |
---|
960 | %% defining the ACTION function handle |
---|
961 | path_series=which('series'); |
---|
962 | list_path=get(handles.ACTION,'UserData'); |
---|
963 | index=get(handles.ACTION,'Value'); |
---|
964 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
965 | if ~isequal(fct_path,path_series) |
---|
966 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
967 | if ~exist(fct_path,'dir') |
---|
968 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
969 | return |
---|
970 | end |
---|
971 | if ~isequal(spath,fct_path) |
---|
972 | addpath(fct_path)% add the prescribed path if not the current one |
---|
973 | end |
---|
974 | end |
---|
975 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
976 | if ~isequal(fct_path,path_series) |
---|
977 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
978 | end |
---|
979 | |
---|
980 | %% RUN ACTION |
---|
981 | Series.Action=action;%name of the processing programme |
---|
982 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
983 | h_fun(Series); |
---|
984 | % if length(RootPath)>1 |
---|
985 | % h_fun(i1_series_cell,i2_series_cell,j1_series_cell,j2_series_cell,Series); |
---|
986 | % else |
---|
987 | % h_fun(i1_series,i2_series,j1_series,j2_series,Series); |
---|
988 | % end |
---|
989 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
990 | |
---|
991 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
992 | % detect=1; |
---|
993 | % while detect==1 |
---|
994 | % namefigfull=[namedoc '.fig']; |
---|
995 | % hh=dir(namefigfull); |
---|
996 | % if ~isempty(hh) |
---|
997 | % detect=1; |
---|
998 | % namedoc=[namedoc '.0']; |
---|
999 | % else |
---|
1000 | % detect=0; |
---|
1001 | % end |
---|
1002 | % end |
---|
1003 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
1004 | |
---|
1005 | %------------------------------------------------------------------------ |
---|
1006 | function STOP_Callback(hObject, eventdata, handles) |
---|
1007 | %------------------------------------------------------------------------ |
---|
1008 | set(handles.RUN, 'BusyAction','cancel') |
---|
1009 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1010 | |
---|
1011 | |
---|
1012 | %------------------------------------------------------------------------ |
---|
1013 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
1014 | %------------------------------------------------------------------------ |
---|
1015 | num_last_i_Callback(hObject, eventdata, handles) |
---|
1016 | |
---|
1017 | %------------------------------------------------------------------------ |
---|
1018 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
1019 | %------------------------------------------------------------------------ |
---|
1020 | SeriesData=get(handles.series,'UserData'); |
---|
1021 | if ~isfield(SeriesData,'Time') |
---|
1022 | SeriesData.Time{1}=[]; |
---|
1023 | end |
---|
1024 | displ_time(handles); |
---|
1025 | |
---|
1026 | %------------------------------------------------------------------------ |
---|
1027 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
1028 | %------------------------------------------------------------------------ |
---|
1029 | num_last_j_Callback(hObject, eventdata, handles) |
---|
1030 | |
---|
1031 | %------------------------------------------------------------------------ |
---|
1032 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
1033 | %------------------------------------------------------------------------ |
---|
1034 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
1035 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
1036 | ref_j=ceil((first_j+last_j)/2); |
---|
1037 | set(handles.ref_j,'String', num2str(ref_j)) |
---|
1038 | ref_j_Callback(hObject, eventdata, handles) |
---|
1039 | SeriesData=get(handles.series,'UserData'); |
---|
1040 | if ~isfield(SeriesData,'Time') |
---|
1041 | SeriesData.Time{1}=[]; |
---|
1042 | end |
---|
1043 | displ_time(handles); |
---|
1044 | |
---|
1045 | |
---|
1046 | %------------------------------------------------------------------------ |
---|
1047 | function ref_i_Callback(hObject, eventdata, handles) |
---|
1048 | %------------------------------------------------------------------------ |
---|
1049 | mode_list=get(handles.mode,'String'); |
---|
1050 | mode_value=get(handles.mode,'Value'); |
---|
1051 | mode=mode_list{mode_value}; |
---|
1052 | SeriesData=get(handles.series,'UserData'); |
---|
1053 | % if ~isempty(SeriesData) |
---|
1054 | if ~isempty(SeriesData.i2_series)||~isempty(SeriesData.j2_series) |
---|
1055 | if isequal(mode,'series(Di)') |
---|
1056 | find_netcpair_civ(handles);% update the menu of pairs depending on the available netcdf files |
---|
1057 | end |
---|
1058 | end |
---|
1059 | % end |
---|
1060 | |
---|
1061 | %------------------------------------------------------------------------ |
---|
1062 | function ref_j_Callback(hObject, eventdata, handles) |
---|
1063 | %------------------------------------------------------------------------ |
---|
1064 | mode_list=get(handles.mode,'String'); |
---|
1065 | mode_value=get(handles.mode,'Value'); |
---|
1066 | mode=mode_list{mode_value}; |
---|
1067 | SeriesData=get(handles.series,'UserData'); |
---|
1068 | if ~isempty(SeriesData) |
---|
1069 | if ~isempty(SeriesData.i2_series)||~isempty(SeriesData.j2_series) |
---|
1070 | if isequal(mode,'series(Di)') |
---|
1071 | find_netcpair_civ(handles);% update the menu of pairs depending on the available netcdf files |
---|
1072 | end |
---|
1073 | end |
---|
1074 | end |
---|
1075 | % NomTypeCell=SeriesData.NomType; |
---|
1076 | % if ~isempty(NomTypeCell) |
---|
1077 | % Val=get(handles.NomType,'Value'); |
---|
1078 | % NomType=NomTypeCell{Val}; |
---|
1079 | % if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2') |
---|
1080 | % if isequal(mode,'series(Dj)') |
---|
1081 | % find_netcpair_civ(handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
1082 | % end |
---|
1083 | % end |
---|
1084 | % end |
---|
1085 | |
---|
1086 | %------------------------------------------------------------------------ |
---|
1087 | % --- Executes on selection change in ACTION. |
---|
1088 | function ACTION_Callback(hObject, eventdata, handles) |
---|
1089 | %------------------------------------------------------------------------ |
---|
1090 | global nb_builtin_ACTION |
---|
1091 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
1092 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
1093 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
1094 | path_series=which('series');%path to series.m |
---|
1095 | list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION |
---|
1096 | default_file=fullfile(list_path{end},ACTION); |
---|
1097 | % add a new function to the menu if the selected item is 'more...' |
---|
1098 | if isequal(ACTION,'more...') |
---|
1099 | pathfct=fileparts(path_series); |
---|
1100 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1101 | {'*.m', ' (*.m)'; |
---|
1102 | '*.m', '.m files '; ... |
---|
1103 | '*.*', 'All Files (*.*)'}, ... |
---|
1104 | 'Pick a file',default_file); |
---|
1105 | if length(FileName)<2 |
---|
1106 | return |
---|
1107 | end |
---|
1108 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
1109 | if ~isequal(ext_fct,'.m') |
---|
1110 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1111 | return |
---|
1112 | end |
---|
1113 | |
---|
1114 | % insert the choice in the action menu |
---|
1115 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
1116 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
1117 | list_path{index_ACTION}=PathName; |
---|
1118 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1119 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
1120 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
1121 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
1122 | index_ACTION=index_ACTION-nbremove; |
---|
1123 | set(handles.ACTION,'Value',index_ACTION) |
---|
1124 | set(handles.ACTION,'String',menu_str) |
---|
1125 | end |
---|
1126 | list_path{index_ACTION}=PathName; |
---|
1127 | set(handles.ACTION,'UserData',list_path); |
---|
1128 | set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1129 | |
---|
1130 | %record the current menu in personal file profil_perso |
---|
1131 | dir_perso=prefdir; |
---|
1132 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1133 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
1134 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
1135 | end |
---|
1136 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
1137 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
1138 | save(profil_perso,'series_fct','-append') |
---|
1139 | else |
---|
1140 | txt=ver('MATLAB'); |
---|
1141 | Release=txt.Release; |
---|
1142 | relnumb=str2num(Release(3:4)); |
---|
1143 | if relnumb >= 14%recent relaese of Matlab |
---|
1144 | save(profil_perso,'series_fct','-V6') |
---|
1145 | else |
---|
1146 | save(profil_perso, 'series_fct') |
---|
1147 | end |
---|
1148 | end |
---|
1149 | end |
---|
1150 | end |
---|
1151 | |
---|
1152 | %check the current path to the selected function |
---|
1153 | PathName=list_path{index_ACTION};%current recorded path |
---|
1154 | set(handles.path,'String',PathName); %show the path to the senlected function |
---|
1155 | |
---|
1156 | %default setting for the visibility of the GUI elements |
---|
1157 | % set(handles.RootPath,'UserData','many') |
---|
1158 | % set(handles.SubDir,'Visible','on') |
---|
1159 | % set(handles.RootFile,'Visible','on') |
---|
1160 | % set(handles.NomType,'Visible','on') |
---|
1161 | % set(handles.FileExt,'Visible','on') |
---|
1162 | set(handles.num_NbSlice,'Visible','off') |
---|
1163 | set(handles.NbSlice_title,'Visible','off') |
---|
1164 | set(handles.VelTypeMenu,'Visible','off'); |
---|
1165 | set(handles.VelType_text,'Visible','off'); |
---|
1166 | set(handles.VelTypeMenu_1,'Visible','off'); |
---|
1167 | set(handles.VelType_text_1,'Visible','off'); |
---|
1168 | view_FieldMenu(handles,'off') |
---|
1169 | view_FieldMenu_1(handles,'off') |
---|
1170 | set(handles.FieldTransform,'Visible','off') |
---|
1171 | % view_TRANSFORM(handles,'off')Visible','off') |
---|
1172 | set(handles.Objects,'Visible','off'); |
---|
1173 | set(handles.GetMask,'Visible','off') |
---|
1174 | set(handles.Mask,'Visible','off') |
---|
1175 | % set(handles.GetObject,'Visible','off'); |
---|
1176 | set(handles.OutputDir,'Visible','off'); |
---|
1177 | % set(handles.PARAMETERS_frame,'Visible','off'); |
---|
1178 | % set(handles.PARAMETERS_title,'Visible','off'); |
---|
1179 | set(handles.ParamKey,'Visible','off') |
---|
1180 | set(handles.ParamVal,'Visible','off') |
---|
1181 | ParamKey={}; |
---|
1182 | set(handles.FieldMenu,'Enable','off') |
---|
1183 | set(handles.VelTypeMenu,'Enable','off') |
---|
1184 | set(handles.FieldMenu_1,'Enable','off') |
---|
1185 | set(handles.VelTypeMenu_1,'Enable','off') |
---|
1186 | set(handles.transform_fct,'Enable','off') |
---|
1187 | %set the displayed GUI item needed for input parameters |
---|
1188 | if ~isequal(path_series,PathName) |
---|
1189 | addpath(PathName) |
---|
1190 | end |
---|
1191 | eval(['h_function=@' ACTION ';']); |
---|
1192 | try |
---|
1193 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
1194 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1195 | fclose(fid) |
---|
1196 | set(handles.ACTION,'ToolTipString',InputText{1}{1}) |
---|
1197 | end |
---|
1198 | if ~isequal(path_series,PathName) |
---|
1199 | rmpath(PathName) |
---|
1200 | end |
---|
1201 | varargout=h_function(); |
---|
1202 | Param_list={}; |
---|
1203 | |
---|
1204 | %nb_series=length(RootFile); |
---|
1205 | % FileExt=get(handles.FileExt,'String'); |
---|
1206 | % nb_series=length(FileExt); |
---|
1207 | InputTable=get(handles.InputTable,'Data'); |
---|
1208 | nb_series=size(InputTable,1); |
---|
1209 | % if ~isempty(checkcell) |
---|
1210 | % nb_series=checkcell(end); |
---|
1211 | % end |
---|
1212 | % nb_series=size(InputFiles,1) |
---|
1213 | testima_series=1; %test for a list of images only |
---|
1214 | testima=1; |
---|
1215 | testima_1=1; |
---|
1216 | testciv_series=1; |
---|
1217 | for iview=1:nb_series |
---|
1218 | ext=InputTable{iview,5}; |
---|
1219 | if length(ext)<2 |
---|
1220 | ext='.none'; |
---|
1221 | end |
---|
1222 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
1223 | if ~testimaview |
---|
1224 | if iview==1 |
---|
1225 | testima=0; |
---|
1226 | end |
---|
1227 | if iview==2 |
---|
1228 | testima_1=0; |
---|
1229 | end |
---|
1230 | testima_series=0; |
---|
1231 | end |
---|
1232 | end |
---|
1233 | for ilist=1:length(varargout)-1 |
---|
1234 | switch varargout{ilist} |
---|
1235 | |
---|
1236 | %RootFile always visible |
---|
1237 | % case 'RootPath' %visible by default |
---|
1238 | % value=lower(varargout{ilist+1}); |
---|
1239 | % if isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1240 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1241 | % end |
---|
1242 | % case 'SubDir' %visible by default |
---|
1243 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1244 | % set(handles.SubDir,'Visible','off') |
---|
1245 | % end |
---|
1246 | % case 'RootFile' %visible by default |
---|
1247 | % value=lower(varargout{ilist+1}); |
---|
1248 | % if isequal(value,'off') |
---|
1249 | % set(handles.RootFile,'Visible','off') |
---|
1250 | % elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1251 | % set(handles.RootFile,'Visible','on') |
---|
1252 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1253 | % end |
---|
1254 | % case 'NomType' %visible by default |
---|
1255 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1256 | % set(handles.NomType,'Visible','off') |
---|
1257 | % end |
---|
1258 | % case 'FileExt' %visible by default |
---|
1259 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
1260 | % set(handles.FileExt,'Visible','off') |
---|
1261 | % end |
---|
1262 | case 'NbSlice' %hidden by default |
---|
1263 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1264 | set(handles.num_NbSlice,'Visible','on') |
---|
1265 | set(handles.NbSlice_title,'Visible','on') |
---|
1266 | end |
---|
1267 | case 'VelTypeMenu' %hidden by default |
---|
1268 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
1269 | set(handles.VelTypeMenu,'Enable','on') |
---|
1270 | if nb_series >=1 && ~testima_series |
---|
1271 | set(handles.VelTypeMenu,'Visible','on') |
---|
1272 | set(handles.VelType_text,'Visible','on'); |
---|
1273 | % set(handles.Field_frame,'Visible','on') |
---|
1274 | end |
---|
1275 | end |
---|
1276 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1277 | set(handles.VelTypeMenu_1,'Enable','on') |
---|
1278 | if nb_series >=2 && ~testima_series |
---|
1279 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
1280 | set(handles.VelType_text_1,'Visible','on'); |
---|
1281 | end |
---|
1282 | end |
---|
1283 | case 'FieldMenu' %hidden by default |
---|
1284 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
1285 | set(handles.FieldMenu,'Enable','on') % test for MenuBorser |
---|
1286 | if nb_series >=1 && ~testima_series |
---|
1287 | view_FieldMenu(handles,'on') |
---|
1288 | end |
---|
1289 | end |
---|
1290 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1291 | set(handles.FieldMenu_1,'Enable','on') |
---|
1292 | if nb_series >=2 && ~testima_1 |
---|
1293 | view_FieldMenu_1(handles,'on') |
---|
1294 | end |
---|
1295 | end |
---|
1296 | case 'CoordType' %hidden by default |
---|
1297 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1298 | set(handles.transform_fct,'Enable','on') |
---|
1299 | set(handles.FieldTransform,'Visible','on') |
---|
1300 | % view_TRANSFORM(handles,'on') |
---|
1301 | end |
---|
1302 | case 'GetObject' %hidden by default |
---|
1303 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1304 | set(handles.Objects,'Visible','on') |
---|
1305 | % set(handles.GetObject,'Visible','on'); |
---|
1306 | end |
---|
1307 | case 'Mask' %hidden by default |
---|
1308 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1309 | set(handles.Objects,'Visible','on') |
---|
1310 | % set(handles.GetMask,'Visible','on'); |
---|
1311 | end |
---|
1312 | case 'PARAMETER' |
---|
1313 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
1314 | set(handles.PARAMETERS_title,'Visible','on') |
---|
1315 | set(handles.ParamKey,'Visible','on') |
---|
1316 | %set(handles.ParamVal,'Visible','on') |
---|
1317 | Param_str=varargout{ilist+1}; |
---|
1318 | Param_list=[Param_list; {Param_str}]; |
---|
1319 | end |
---|
1320 | end |
---|
1321 | if ~isempty(Param_list) |
---|
1322 | set(handles.ParamKey,'String',Param_list) |
---|
1323 | set(handles.ParamVal,'Visible','on') |
---|
1324 | end |
---|
1325 | |
---|
1326 | %------------------------------------------------------------------------ |
---|
1327 | % --- Executes on selection change in FieldMenu. |
---|
1328 | function FieldMenu_Callback(hObject, eventdata, handles) |
---|
1329 | %------------------------------------------------------------------------ |
---|
1330 | field_str=get(handles.FieldMenu,'String'); |
---|
1331 | field_index=get(handles.FieldMenu,'Value'); |
---|
1332 | field=field_str{field_index(1)}; |
---|
1333 | if isequal(field,'get_field...') |
---|
1334 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1335 | if ~isempty(hget_field) |
---|
1336 | delete(hget_field)%delete opened versions of get_field |
---|
1337 | end |
---|
1338 | SeriesData=get(handles.series,'UserData'); |
---|
1339 | filename=SeriesData.CurrentInputFile; |
---|
1340 | if exist(filename,'file') |
---|
1341 | get_field(filename) |
---|
1342 | end |
---|
1343 | elseif isequal(field,'more...') |
---|
1344 | str=calc_field; |
---|
1345 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1346 | 'SelectionMode','single',... |
---|
1347 | 'ListString',str); |
---|
1348 | % edit the choice in the fields and action menu |
---|
1349 | scalar=cell2mat(str(ind_answer)); |
---|
1350 | update_menu(handles.FieldMenu,scalar) |
---|
1351 | end |
---|
1352 | |
---|
1353 | %------------------------------------------------------------------------ |
---|
1354 | % --- Executes on selection change in FieldMenu_1. |
---|
1355 | function FieldMenu_1_Callback(hObject, eventdata, handles) |
---|
1356 | %------------------------------------------------------------------------ |
---|
1357 | field_str=get(handles.FieldMenu_1,'String'); |
---|
1358 | field_index=get(handles.FieldMenu_1,'Value'); |
---|
1359 | field=field_str{field_index}; |
---|
1360 | if isequal(field,'get_field...') |
---|
1361 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
1362 | if ~isempty(hget_field) |
---|
1363 | delete(hget_field) |
---|
1364 | end |
---|
1365 | SeriesData=get(handles.series,'UserData'); |
---|
1366 | filename=SeriesData.CurrentInputFile_1; |
---|
1367 | if exist(filename,'file') |
---|
1368 | hget_field=get_field(filename); |
---|
1369 | set(hget_field,'name','get_field_1') |
---|
1370 | end |
---|
1371 | elseif isequal(field,'more...') |
---|
1372 | str=calc_field; |
---|
1373 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1374 | 'SelectionMode','single',... |
---|
1375 | 'ListString',str); |
---|
1376 | % edit the choice in the fields and action menu |
---|
1377 | scalar=cell2mat(str(ind_answer)); |
---|
1378 | update_menu(handles.FieldMenu_1,scalar) |
---|
1379 | end |
---|
1380 | |
---|
1381 | |
---|
1382 | %%%%%%%%%%%%% |
---|
1383 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
1384 | indsel=ind_i; |
---|
1385 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
1386 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
1387 | if ~isempty(indiff) |
---|
1388 | indiff2=diff(indiff); |
---|
1389 | indiffp=[indiff2 1]; |
---|
1390 | indiffm=[1 indiff2]; |
---|
1391 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
1392 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
1393 | %for each multiplet, select the most recent file |
---|
1394 | ind_remove=[]; |
---|
1395 | for i=1:length(ind_multi_m) |
---|
1396 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
1397 | for imulti=1:length(ind_pairs) |
---|
1398 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
1399 | end |
---|
1400 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
1401 | ind_s=indsort2(1:end-1);% |
---|
1402 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
1403 | end |
---|
1404 | end |
---|
1405 | |
---|
1406 | %------------------------------------------------------------------------ |
---|
1407 | % --- determine the list of index pairs of processing file |
---|
1408 | function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode) |
---|
1409 | %------------------------------------------------------------------------ |
---|
1410 | num_i1=num_i;% set of first image numbers by default |
---|
1411 | num_i2=num_i; |
---|
1412 | num_j1=num_j; |
---|
1413 | num_j2=num_j; |
---|
1414 | num_i_out=num_i; |
---|
1415 | num_j_out=num_j; |
---|
1416 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
1417 | if isequal(mode,'series(Di)') |
---|
1418 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
1419 | num_i2_line=num_i+ind_shift(4); |
---|
1420 | % adjust the first and last field number |
---|
1421 | indsel=find(num_i1_line >= 1); |
---|
1422 | num_i_out=num_i(indsel); |
---|
1423 | num_i1_line=num_i1_line(indsel); |
---|
1424 | num_i2_line=num_i2_line(indsel); |
---|
1425 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1426 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1427 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
1428 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
1429 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
1430 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
1431 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
1432 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
1433 | else |
---|
1434 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
1435 | num_j2_col=num_j+ind_shift(2); |
---|
1436 | % adjust the first field number |
---|
1437 | indsel=find((num_j1_col >= 1)); |
---|
1438 | num_j_out=num_j(indsel); |
---|
1439 | num_j1_col=num_j1_col(indsel); |
---|
1440 | num_j2_col=num_j2_col(indsel); |
---|
1441 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
1442 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
1443 | end |
---|
1444 | end |
---|
1445 | |
---|
1446 | %------------------------------------------------------------------------ |
---|
1447 | % ---- find the times corresponding to the first and last indices of a series |
---|
1448 | function displ_time(handles) |
---|
1449 | %------------------------------------------------------------------------ |
---|
1450 | SeriesData=get(handles.series,'UserData');% |
---|
1451 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
1452 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
1453 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
1454 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
1455 | InputTable=get(handles.InputTable,'Data'); |
---|
1456 | NomType=InputTable(:,4); |
---|
1457 | % NomType=SeriesData.NomType; |
---|
1458 | mode_list=get(handles.mode,'String'); |
---|
1459 | index_mode=get(handles.mode,'Value'); |
---|
1460 | mode=mode_list{index_mode}; |
---|
1461 | |
---|
1462 | time_first=[]; |
---|
1463 | time_last=[]; |
---|
1464 | if ~isfield(SeriesData,'Time') |
---|
1465 | SeriesData.Time{1}=[]; |
---|
1466 | end |
---|
1467 | for iview=1:length(NomType) |
---|
1468 | time_first_cell{iview}='?'; |
---|
1469 | time_last_cell{iview}='?';%default |
---|
1470 | time=SeriesData.Time{iview}; |
---|
1471 | if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2') |
---|
1472 | if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num) |
---|
1473 | ind_shift=SeriesData.displ_num(iview,:); |
---|
1474 | if isequal(mode,'bursts') |
---|
1475 | first_j=0; |
---|
1476 | last_j=0; |
---|
1477 | end |
---|
1478 | first_i1=first_i +ind_shift(3); |
---|
1479 | first_i2 =first_i +ind_shift(4); |
---|
1480 | first_j1 =first_j +ind_shift(1); |
---|
1481 | first_j2 =first_j +ind_shift(2); |
---|
1482 | last_i1=last_i +ind_shift(3); |
---|
1483 | last_i2 =last_i +ind_shift(4); |
---|
1484 | last_j1 =last_j +ind_shift(1); |
---|
1485 | last_j2 =last_j +ind_shift(2); |
---|
1486 | siz=size(SeriesData.Time{1}); |
---|
1487 | if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2 |
---|
1488 | time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2; |
---|
1489 | time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2; |
---|
1490 | else%read the time in the nc files |
---|
1491 | RootPath=get(handles.RootPath,'String'); |
---|
1492 | RootFile=get(handles.RootFile,'String'); |
---|
1493 | SubDir=get(handles.SubDir,'String'); |
---|
1494 | %VelType=get(handles.VelType,'String'); |
---|
1495 | VelType_str=get(handles.VelTypeMenu,'String'); |
---|
1496 | VelType_val=get(handles.VelTypeMenu,'Value'); |
---|
1497 | VelType=VelType_str{VelType_val}; |
---|
1498 | filebase=fullfile(RootPath{1},RootFile{1}); |
---|
1499 | [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview}); |
---|
1500 | if exist(filefirst,'file') |
---|
1501 | Attrib=nc2struct(filefirst,[]); |
---|
1502 | if isfield(Attrib,'Time') |
---|
1503 | time_first=Attrib.Time; |
---|
1504 | else |
---|
1505 | if isfield(Attrib,'absolut_time_T0') |
---|
1506 | time_first=Attrib.absolut_time_T0; |
---|
1507 | end |
---|
1508 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
1509 | time_first=Attrib.absolut_time_T0_2; |
---|
1510 | end |
---|
1511 | end |
---|
1512 | end |
---|
1513 | [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview}); |
---|
1514 | if exist(filelast,'file') |
---|
1515 | Attrib=nc2struct(filelast,[]); |
---|
1516 | if isfield(Attrib,'Time') |
---|
1517 | time_last=Attrib.Time; |
---|
1518 | else |
---|
1519 | if isfield(Attrib,'absolut_time_T0') |
---|
1520 | time_last=Attrib.absolut_time_T0; |
---|
1521 | end |
---|
1522 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
1523 | time_last=Attrib.absolut_time_T0_2; |
---|
1524 | end |
---|
1525 | end |
---|
1526 | end |
---|
1527 | end |
---|
1528 | end |
---|
1529 | else |
---|
1530 | siz=size(time); |
---|
1531 | if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1 |
---|
1532 | time_first=times(first_i,first_j); |
---|
1533 | time_last=times(last_i,last_j); |
---|
1534 | end |
---|
1535 | end |
---|
1536 | time_first_cell{iview}=num2str(time_first,4); |
---|
1537 | time_last_cell{iview}=num2str(time_last,4); |
---|
1538 | end |
---|
1539 | % set(handles.time_first,'Value',1) |
---|
1540 | % set(handles.time_last,'Value',1) |
---|
1541 | % set(handles.time_first,'String',time_first_cell); |
---|
1542 | % set(handles.time_last,'String',time_last_cell); |
---|
1543 | |
---|
1544 | %------------------------------------------------------------------------ |
---|
1545 | % --- Executes on button press in GetObject. |
---|
1546 | function GetObject_Callback(hObject, eventdata, handles) |
---|
1547 | %------------------------------------------------------------------------ |
---|
1548 | SeriesData=get(handles.series,'UserData'); |
---|
1549 | value=get(handles.GetObject,'Value'); |
---|
1550 | if value |
---|
1551 | set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
1552 | % DataInit.ParentButton=handles.GetObject; |
---|
1553 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
1554 | if ishandle(hset_object) |
---|
1555 | uistack(hset_object,'top') |
---|
1556 | %[SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface |
---|
1557 | else |
---|
1558 | %get the object file |
---|
1559 | InputTable=get(handles.InputTable,'Data'); |
---|
1560 | defaultname=InputTable{1,1}; |
---|
1561 | % defaultname=get(handles.RootPath,'String'); |
---|
1562 | if isempty(defaultname) |
---|
1563 | defaultname={''}; |
---|
1564 | end |
---|
1565 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1566 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
1567 | '*.xml', '.xml files '; ... |
---|
1568 | '*.mat', '.mat matlab files '}, ... |
---|
1569 | 'Pick an xml object file (or use uvmat to create it)',defaultname{1}); |
---|
1570 | fileinput=[PathName FileName];%complete file name |
---|
1571 | testblank=findstr(fileinput,' ');%look for blanks |
---|
1572 | if ~isempty(testblank) |
---|
1573 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks') |
---|
1574 | return |
---|
1575 | end |
---|
1576 | sizf=size(fileinput); |
---|
1577 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
1578 | %read the file |
---|
1579 | t=xmltree(fileinput); |
---|
1580 | data=convert(t); |
---|
1581 | if ~isfield(data,'Style') |
---|
1582 | data.Style='points'; |
---|
1583 | end |
---|
1584 | if ~isfield(data,'ProjMode') |
---|
1585 | data.ProjMode='projection'; |
---|
1586 | end |
---|
1587 | transform_menu=get(handles.transform_fct,'String'); |
---|
1588 | ichoice=get(handles.transform_fct,'Value'); |
---|
1589 | % if isequal(transform_menu{ichoice},'px'); |
---|
1590 | % data.CoordType='px'; |
---|
1591 | % else |
---|
1592 | % data.CoordType='phys'; |
---|
1593 | % end |
---|
1594 | data.desable_plot=1; |
---|
1595 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface |
---|
1596 | end |
---|
1597 | else |
---|
1598 | set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
1599 | % if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object) |
---|
1600 | % close(SeriesData.hset_object) |
---|
1601 | % end |
---|
1602 | end |
---|
1603 | set(handles.series,'UserData',SeriesData) |
---|
1604 | |
---|
1605 | %-------------------------------------------------------------- |
---|
1606 | function GetMask_Callback(hObject, eventdata, handles) |
---|
1607 | value=get(handles.GetMask,'Value'); |
---|
1608 | if value |
---|
1609 | msgbox_uvmat('ERROR','not implemented yet') |
---|
1610 | end |
---|
1611 | %-------------------------------------------------------------- |
---|
1612 | |
---|
1613 | %------------------------------------------------------------------- |
---|
1614 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
1615 | function ncbrowser_uvmat(hObject, eventdata) |
---|
1616 | %------------------------------------------------------------------- |
---|
1617 | bla=get(gcbo,'String'); |
---|
1618 | ind=get(gcbo,'Value'); |
---|
1619 | filename=cell2mat(bla(ind)); |
---|
1620 | blank=find(filename==' '); |
---|
1621 | filename=filename(1:blank-1); |
---|
1622 | get_field(filename) |
---|
1623 | |
---|
1624 | % ------------------------------------------------------------------ |
---|
1625 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
1626 | %------------------------------------------------------------------- |
---|
1627 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
1628 | pathelp=fileparts(path_to_uvmat); |
---|
1629 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
1630 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
1631 | else |
---|
1632 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
1633 | web([helpfile '#series']) |
---|
1634 | end |
---|
1635 | |
---|
1636 | %------------------------------------------------------------------- |
---|
1637 | % --- Executes on selection change in transform_fct. |
---|
1638 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
1639 | %------------------------------------------------------------------- |
---|
1640 | global nb_transform |
---|
1641 | |
---|
1642 | menu=get(handles.transform_fct,'String'); |
---|
1643 | ind_coord=get(handles.transform_fct,'Value'); |
---|
1644 | coord_option=menu{ind_coord}; |
---|
1645 | list_transform=get(handles.transform_fct,'UserData'); |
---|
1646 | ff=functions(list_transform{end}); |
---|
1647 | if isequal(coord_option,'more...'); |
---|
1648 | coord_fct=''; |
---|
1649 | prompt = {'Enter the name of the transform function'}; |
---|
1650 | dlg_title = 'user defined transform'; |
---|
1651 | num_lines= 1; |
---|
1652 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1653 | {'*.m', ' (*.m)'; |
---|
1654 | '*.m', '.m files '; ... |
---|
1655 | '*.*', 'All Files (*.*)'}, ... |
---|
1656 | 'Pick a file', ff.file); |
---|
1657 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
1658 | PathName(end)=[]; |
---|
1659 | end |
---|
1660 | transform_selected =fullfile(PathName,FileName); |
---|
1661 | if ~exist(transform_selected,'file') |
---|
1662 | return |
---|
1663 | end |
---|
1664 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
1665 | if ~isequal(ext_fct,'.m') |
---|
1666 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1667 | return |
---|
1668 | end |
---|
1669 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
1670 | ind_coord=get(handles.transform_fct,'Value'); |
---|
1671 | addpath(PathName) |
---|
1672 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
1673 | set(handles.transform_fct,'UserData',list_transform) |
---|
1674 | rmpath(PathName) |
---|
1675 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
1676 | dir_perso=prefdir;%personal Matalb directory |
---|
1677 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1678 | if exist(profil_perso,'file') |
---|
1679 | for ilist=nb_transform+1:numel(list_transform) |
---|
1680 | ff=functions(list_transform{ilist}); |
---|
1681 | transform_fct{ilist-nb_transform}=ff.file; |
---|
1682 | end |
---|
1683 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
1684 | end |
---|
1685 | end |
---|
1686 | |
---|
1687 | %check the current path to the selected function |
---|
1688 | if ~isempty(list_transform{ind_coord}) |
---|
1689 | func=functions(list_transform{ind_coord}); |
---|
1690 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
1691 | else |
---|
1692 | set(handles.path_transform,'String',''); %show the path to the senlected function |
---|
1693 | end |
---|
1694 | |
---|
1695 | % --- Executes on button press in REFRESH_INDICES. |
---|
1696 | function REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
1697 | % hObject handle to REFRESH_INDICES (see GCBO) |
---|
1698 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
1699 | % handles structure with handles and user data (see GUIDATA) |
---|
1700 | set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1701 | InputTable=get(handles.InputTable,'Data'); |
---|
1702 | check_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
1703 | |
---|
1704 | %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
1705 | for ind_list=1:length(check_lines) |
---|
1706 | if check_lines(ind_list) |
---|
1707 | InputLine=InputTable(ind_list,:); |
---|
1708 | detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
1709 | detect_idem=detect_idem(detect_idem>0); |
---|
1710 | if ~isempty (detect_idem) |
---|
1711 | InputLine(detect_idem)=InputTable(ind_list-1,detect_idem); |
---|
1712 | set(handles.InputTable,'Data',InputTable) |
---|
1713 | end |
---|
1714 | fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2); |
---|
1715 | %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}) |
---|
1716 | %update file series defined by the selected line |
---|
1717 | [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list); |
---|
1718 | if ~isempty(errormsg) |
---|
1719 | msgbox_uvmat('ERROR',errormsg) |
---|
1720 | return |
---|
1721 | end |
---|
1722 | end |
---|
1723 | end |
---|
1724 | set(handles.InputTable,'Data',InputTable) |
---|
1725 | SeriesData=get(handles.series,'UserData'); |
---|
1726 | |
---|
1727 | state_j='off'; |
---|
1728 | state_Pairs='off'; |
---|
1729 | state_InputFields='off'; |
---|
1730 | val=get(handles.ListView,'Value'); |
---|
1731 | ListViewString={''}; |
---|
1732 | if ~isempty(SeriesData) |
---|
1733 | % ListViewString={}; |
---|
1734 | for iview=1:size(InputTable,1) |
---|
1735 | if ~isempty(SeriesData.j1_series{iview}) |
---|
1736 | state_j='on'; |
---|
1737 | end |
---|
1738 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
1739 | state_Pairs='on'; |
---|
1740 | ListViewString{iview}=num2str(iview); |
---|
1741 | if check_lines(iview) |
---|
1742 | val=iview;%select the last pair if it is a new entry |
---|
1743 | end |
---|
1744 | end |
---|
1745 | if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata') |
---|
1746 | state_InputFields='on'; |
---|
1747 | end |
---|
1748 | end |
---|
1749 | end |
---|
1750 | set(handles.ListView,'Value',val) |
---|
1751 | set(handles.ListView,'String',ListViewString) |
---|
1752 | if strcmp(state_Pairs,'on') |
---|
1753 | ListView_Callback(hObject,eventdata,handles) |
---|
1754 | end |
---|
1755 | set(handles.Pairs,'Visible',state_Pairs) |
---|
1756 | enable_j(handles,state_j) |
---|
1757 | set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0]) |
---|
1758 | set(handles.REFRESH_INDICES,'visible','off') |
---|
1759 | |
---|
1760 | % ----------------------------------------------------------------------- |
---|
1761 | % --- Update min and max indices of a file series by scanning with find_file_series |
---|
1762 | % --- which also changes the root file and NomType in case of movie. Also adjust the string representation of indices (e.g; |
---|
1763 | % --- 1 or 001 by the function find_file_series |
---|
1764 | % --- This function also dispaly the set of availbale files in the series |
---|
1765 | % --- and the menus appropriate to the file type as well as timing possibly set |
---|
1766 | % --- by an xml image documentation file |
---|
1767 | function [RootFile,NomType,errormsg]=update_indices(handles,fileinput,iview) |
---|
1768 | % ----------------------------------------------------------------------- |
---|
1769 | %% look for min and max indices existing in the file series and update SeriesData |
---|
1770 | errormsg=''; |
---|
1771 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
1772 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
1773 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
1774 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
1775 | |
---|
1776 | % |
---|
1777 | % [RootPathSub,FileName,FileExt]=fileparts(fileinput); |
---|
1778 | % [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPathSub,[FileName FileExt]); |
---|
1779 | if isempty(RootFile)&&isempty(i1_series) |
---|
1780 | errormsg='no input file in the series'; |
---|
1781 | return |
---|
1782 | end |
---|
1783 | % [tild,tild,FileExt]=fileparts(fileinput); |
---|
1784 | |
---|
1785 | MinIndex=get(handles.MinIndex,'Data'); |
---|
1786 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
1787 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
1788 | if ~isempty(i2_series) |
---|
1789 | MaxIndex_i=max(i2_series(i2_series>0)); |
---|
1790 | else |
---|
1791 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
1792 | end |
---|
1793 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
1794 | if ~isempty(j2_series) |
---|
1795 | MaxIndex_j=max(j2_series(j2_series>0)); |
---|
1796 | else |
---|
1797 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
1798 | end |
---|
1799 | MinIndex{iview,1}=MinIndex_i; |
---|
1800 | MinIndex{iview,2}=MinIndex_j; |
---|
1801 | MaxIndex{iview,1}=MaxIndex_i; |
---|
1802 | MaxIndex{iview,2}=MaxIndex_j; |
---|
1803 | set(handles.MinIndex,'Data',MinIndex) |
---|
1804 | set(handles.MaxIndex,'Data',MaxIndex) |
---|
1805 | SeriesData=get(handles.series,'UserData'); |
---|
1806 | SeriesData.i1_series{iview}=i1_series; |
---|
1807 | SeriesData.i2_series{iview}=i2_series; |
---|
1808 | SeriesData.j1_series{iview}=j1_series; |
---|
1809 | SeriesData.j2_series{iview}=j2_series; |
---|
1810 | SeriesData.FileType{iview}=FileType; |
---|
1811 | |
---|
1812 | %% display the set of existing files as an image |
---|
1813 | set(handles.waitbar_frame,'Units','pixels') |
---|
1814 | pos=get(handles.waitbar_frame,'Position'); |
---|
1815 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
1816 | yima=0.5:pos(4)-0.5; |
---|
1817 | [XIma,YIma]=meshgrid(xima,yima); |
---|
1818 | nb_i=size(i1_series,1); |
---|
1819 | nb_j=size(i1_series,2); |
---|
1820 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
1821 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
1822 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
1823 | CData=zeros([size(XIma) 3]); |
---|
1824 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
1825 | if numel(file_ima)>=2 |
---|
1826 | if size(file_ima,1)==1 |
---|
1827 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
1828 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
1829 | else |
---|
1830 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
1831 | end |
---|
1832 | set(handles.waitbar_frame,'CData',CData) |
---|
1833 | end |
---|
1834 | set(handles.waitbar_frame,'Units','normalized') |
---|
1835 | |
---|
1836 | %% enable field and veltype menus |
---|
1837 | testfield=isequal(get(handles.FieldMenu,'enable'),'on'); |
---|
1838 | testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on'); |
---|
1839 | testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); |
---|
1840 | testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); |
---|
1841 | testtransform=isequal(get(handles.transform_fct,'Enable'),'on'); |
---|
1842 | % testnc=0; |
---|
1843 | % testnc_1=0; |
---|
1844 | % testcivx=0; |
---|
1845 | % testcivx_1=0; |
---|
1846 | % testima=0; %test for image input |
---|
1847 | % if isequal(lower(FileExt),'.avi') %.avi file |
---|
1848 | % testima=1; |
---|
1849 | % elseif ~isempty(imformats(FileExt(2:end))) |
---|
1850 | % testima=1; |
---|
1851 | % elseif isequal(FileExt,'.vol') |
---|
1852 | % testima=1; |
---|
1853 | % end |
---|
1854 | %TODO: update |
---|
1855 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
1856 | % for iview=1:length(FileExtCell) |
---|
1857 | % if isequal(FileExtCell{iview},'.nc') |
---|
1858 | % testnc=1; |
---|
1859 | % end |
---|
1860 | % if isequal(FileTypeCell{iview},'civx') |
---|
1861 | % testcivx=1; |
---|
1862 | % end |
---|
1863 | % end |
---|
1864 | % elseif length(FileExtCell)==2 |
---|
1865 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
1866 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
1867 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
1868 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
1869 | % end |
---|
1870 | switch FileType |
---|
1871 | case {'civx','civdata'} |
---|
1872 | view_FieldMenu(handles,'on') |
---|
1873 | menustr=get(handles.FieldMenu,'String'); |
---|
1874 | if isequal(menustr,{'get_field...'}) |
---|
1875 | set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
1876 | end |
---|
1877 | set(handles.VelTypeMenu,'Visible','on') |
---|
1878 | set(handles.FieldTransform,'Visible','on') |
---|
1879 | % view_TRANSFORM(handles,'on') |
---|
1880 | % TODO: second menu |
---|
1881 | % view_FieldMenu_1(handles,'on') |
---|
1882 | % if testcivx_1 |
---|
1883 | % menustr=get(handles.FieldMenu_1,'String'); |
---|
1884 | % if isequal(menustr,{'get_field...'}) |
---|
1885 | % set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
1886 | % end |
---|
1887 | % else |
---|
1888 | % set(handles.FieldMenu_1,'Value',1) |
---|
1889 | % set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
1890 | % set(handles.VelTypeMenu_1,'Visible','on') |
---|
1891 | % set(handles.VelType_text_1,'Visible','on'); |
---|
1892 | % end |
---|
1893 | % view_FieldMenu_1(handles,'off') |
---|
1894 | case 'netcdf' |
---|
1895 | view_FieldMenu(handles,'on') |
---|
1896 | set(handles.FieldMenu,'Value',1) |
---|
1897 | set(handles.FieldMenu,'String',{'get_field...'}) |
---|
1898 | set(handles.FieldTransform,'Visible','off') |
---|
1899 | % view_TRANSFORM(handles,'off') |
---|
1900 | case {'image','multimage','video'} |
---|
1901 | view_FieldMenu(handles,'off') |
---|
1902 | view_FieldMenu_1(handles,'off') |
---|
1903 | set(handles.VelTypeMenu,'Visible','off') |
---|
1904 | set(handles.VelType_text,'Visible','off'); |
---|
1905 | end |
---|
1906 | |
---|
1907 | |
---|
1908 | %TODO:update |
---|
1909 | % if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
1910 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
1911 | % return |
---|
1912 | % end |
---|
1913 | |
---|
1914 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1915 | ext_imadoc=''; |
---|
1916 | FileBase=fullfile(RootPath,RootFile); |
---|
1917 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
1918 | ext_imadoc=FileExt; |
---|
1919 | elseif exist([FileBase '.xml'],'file') |
---|
1920 | ext_imadoc='.xml'; |
---|
1921 | elseif exist([FileBase '.civ'],'file') |
---|
1922 | ext_imadoc='.civ'; |
---|
1923 | end |
---|
1924 | %read the ImaDoc file |
---|
1925 | XmlData=[]; |
---|
1926 | NbSlice_calib={}; |
---|
1927 | if isequal(ext_imadoc,'.xml') |
---|
1928 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
1929 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
1930 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
1931 | end |
---|
1932 | if isfield(XmlData,'Time') |
---|
1933 | time=XmlData.Time; |
---|
1934 | end |
---|
1935 | if isfield(XmlData,'Camera') |
---|
1936 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
1937 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
1938 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
1939 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
1940 | end |
---|
1941 | end |
---|
1942 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
1943 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
1944 | end |
---|
1945 | end |
---|
1946 | if ~isempty(warntext) |
---|
1947 | msgbox_uvmat('WARNING',warntext) |
---|
1948 | end |
---|
1949 | elseif isequal(ext_imadoc,'.civ') |
---|
1950 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
1951 | time=XmlData.Time; |
---|
1952 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
1953 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
1954 | end |
---|
1955 | end |
---|
1956 | |
---|
1957 | |
---|
1958 | %% number of slices |
---|
1959 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
1960 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
1961 | if siz(1)>1 |
---|
1962 | NbSlice=siz(1); |
---|
1963 | else |
---|
1964 | NbSlice=1; |
---|
1965 | end |
---|
1966 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
1967 | end |
---|
1968 | % set(handles.mode,'Visible','off') % do not show index pairs by default |
---|
1969 | set(handles.Pairs,'Visible','off') |
---|
1970 | % set(handles.ref_i,'Visible','off') |
---|
1971 | % set(handles.ref_i_text,'Visible','off') |
---|
1972 | testpair=0; |
---|
1973 | %set the menus of image pairs and default selection for series |
---|
1974 | %list pairs if relevant |
---|
1975 | % Val=get(handles.NomType,'Value'); |
---|
1976 | % synchronise_view(handles,Val) |
---|
1977 | |
---|
1978 | % if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index}) |
---|
1979 | % state_j='off'; %no need for j index |
---|
1980 | % else |
---|
1981 | % state_j='on'; %case of j index |
---|
1982 | % end |
---|
1983 | % show index pairs if files exist |
---|
1984 | set(handles.series,'UserData',SeriesData) |
---|
1985 | |
---|
1986 | |
---|
1987 | |
---|
1988 | % --- Executes on button press in BATCH. |
---|
1989 | function BATCH_Callback(hObject, eventdata, handles) |
---|
1990 | % hObject handle to BATCH (see GCBO) |
---|
1991 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
1992 | % handles structure with handles and user data (see GUIDATA) |
---|
1993 | Series=read_GUI(handles.series); |
---|
1994 | t=struct2xml(Series); |
---|
1995 | save(t); %TODO: determine a xml file name |
---|
1996 | |
---|
1997 | % list_action=get(handles.ACTION,'String');% list menu action |
---|
1998 | % index_action=get(handles.ACTION,'Value');% selected string index |
---|
1999 | % action= list_action{index_action}; % selected string |
---|
2000 | |
---|
2001 | %% defining the ACTION function handle |
---|
2002 | path_series=which('series'); |
---|
2003 | list_path=get(handles.ACTION,'UserData'); |
---|
2004 | index=get(handles.ACTION,'Value'); |
---|
2005 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
2006 | if ~isequal(fct_path,path_series) |
---|
2007 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
2008 | if ~exist(fct_path,'dir') |
---|
2009 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
2010 | return |
---|
2011 | end |
---|
2012 | if ~isequal(spath,fct_path) |
---|
2013 | addpath(fct_path)% add the prescribed path if not the current one |
---|
2014 | end |
---|
2015 | end |
---|
2016 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
2017 | if ~isequal(fct_path,path_series) |
---|
2018 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
2019 | end |
---|
2020 | |
---|
2021 | h_fun('BATCH');% TODO modify the called function to read the xml file as input parameter |
---|
2022 | |
---|
2023 | |
---|
2024 | % --- Executes on selection change in txt_Pairs |
---|
2025 | function txt_Pairs_Callback(hObject, eventdata, handles) |
---|
2026 | |
---|
2027 | %------------------------------------------------------------------------ |
---|
2028 | % --- Executes on selection change in ListView. |
---|
2029 | function ListView_Callback(hObject, eventdata, handles) |
---|
2030 | %------------------------------------------------------------------------ |
---|
2031 | ListViewString=get(handles.ListView,'String'); |
---|
2032 | if isempty(ListViewString) |
---|
2033 | ListViewString={''}; |
---|
2034 | end |
---|
2035 | ListViewValue=get(handles.ListView,'Value'); |
---|
2036 | View=str2double(ListViewString{ListViewValue}); |
---|
2037 | if isnan(View) |
---|
2038 | set(handles.Pairs,'Visible','off') |
---|
2039 | else |
---|
2040 | set(handles.Pairs,'Visible','on') |
---|
2041 | SeriesData=get(handles.series,'UserData'); |
---|
2042 | if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{View})||~isempty(SeriesData.j2_series{View})) |
---|
2043 | if ~isempty(SeriesData.i2_series{View}) %pairs with i View |
---|
2044 | set(handles.mode,'Value',1) |
---|
2045 | set(handles.mode,'String',{'series(Di)'}) |
---|
2046 | else %pairs with j View |
---|
2047 | nbfield=size(SeriesData.j2_series{View},1); |
---|
2048 | nbfield2=size(SeriesData.j2_series{View},2); |
---|
2049 | set(handles.mode,'Value',1) |
---|
2050 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
2051 | if nbfield2>10 || nbfield==1 |
---|
2052 | set(handles.mode,'Value',2); |
---|
2053 | else |
---|
2054 | set(handles.mode,'Value',1); |
---|
2055 | end |
---|
2056 | end |
---|
2057 | end |
---|
2058 | mode_Callback([],[], handles) |
---|
2059 | end |
---|
2060 | |
---|
2061 | |
---|