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 TransformName (menu for coordinate transforms) |
---|
9 | % .menu_coord_val: value for TransformName (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 | %------------------------------------------------------------------------ |
---|
33 | %------------------------------------------------------------------------ |
---|
34 | % I - MAIN FUNCTION series |
---|
35 | %------------------------------------------------------------------------ |
---|
36 | %------------------------------------------------------------------------ |
---|
37 | function varargout = series(varargin) |
---|
38 | |
---|
39 | % Begin initialization code - DO NOT EDIT |
---|
40 | gui_Singleton = 1; |
---|
41 | gui_State = struct('gui_Name', mfilename, ... |
---|
42 | 'gui_Singleton', gui_Singleton, ... |
---|
43 | 'gui_OpeningFcn', @series_OpeningFcn, ... |
---|
44 | 'gui_OutputFcn', @series_OutputFcn, ... |
---|
45 | 'gui_LayoutFcn', [] , ... |
---|
46 | 'gui_Callback', []); |
---|
47 | if nargin && ischar(varargin{1}) |
---|
48 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
49 | end |
---|
50 | |
---|
51 | if nargout |
---|
52 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
53 | else |
---|
54 | gui_mainfcn(gui_State, varargin{:}); |
---|
55 | end |
---|
56 | % End initialization code - DO NOT EDIT |
---|
57 | |
---|
58 | %-------------------------------------------------------------------------- |
---|
59 | % --- Executes just before series is made visible. |
---|
60 | %-------------------------------------------------------------------------- |
---|
61 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
62 | global nb_builtin_ACTION nb_builtin_transform |
---|
63 | % Choose default command line output for series |
---|
64 | handles.output = hObject; |
---|
65 | % Update handles structure |
---|
66 | guidata(hObject, handles); |
---|
67 | %default initial parameters |
---|
68 | drawnow |
---|
69 | set(hObject,'Units','pixels') |
---|
70 | set(handles.PairString,'ColumnName',{'pairs'}) |
---|
71 | set(handles.PairString,'ColumnEditable',logical(0)) |
---|
72 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
73 | set(handles.PairString,'Data',{''}) |
---|
74 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size |
---|
75 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
76 | dir_perso=prefdir; |
---|
77 | test_profil_perso=0; |
---|
78 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
79 | if exist(profil_perso,'file') |
---|
80 | h=load (profil_perso); |
---|
81 | if isfield(h,'MenuFile') |
---|
82 | for ifile=1:min(length(h.MenuFile),5) |
---|
83 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
84 | end |
---|
85 | end |
---|
86 | test_profil_perso=1; |
---|
87 | end |
---|
88 | |
---|
89 | %check default input data |
---|
90 | if ~exist('param','var') |
---|
91 | param=[]; %default |
---|
92 | end |
---|
93 | |
---|
94 | %% file name and browser initialisation |
---|
95 | if isfield(param,'transform_str') |
---|
96 | set(handles.TransformName,'String',param.transform_str) |
---|
97 | end |
---|
98 | if isfield(param,'transform_val') |
---|
99 | set(handles.TransformName,'Value',param.transform_val); |
---|
100 | else |
---|
101 | set(handles.TransformName,'Value',1);%default |
---|
102 | end |
---|
103 | if isfield(param,'FileName') |
---|
104 | InputTable={'','','','',''}; |
---|
105 | set(handles.InputTable,'Data',InputTable) |
---|
106 | if isfield(param,'FileName_1') |
---|
107 | display_file_name(handles,param.FileName_1,0) |
---|
108 | display_file_name(handles,param.FileName,1) |
---|
109 | else |
---|
110 | display_file_name(handles,param.FileName,0) |
---|
111 | end |
---|
112 | end |
---|
113 | if isfield(param,'incr_i') |
---|
114 | set(handles.num_incr_i,'String',num2str(param.incr_i)) |
---|
115 | end |
---|
116 | if isfield(param,'incr_j') |
---|
117 | set(handles.num_incr_j,'String',num2str(param.incr_j)) |
---|
118 | end |
---|
119 | |
---|
120 | %% fields input initialisation |
---|
121 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
122 | set(handles.FieldName,'String',param.list_fields);% list menu fields |
---|
123 | set(handles.FieldName,'Value',param.index_fields);% selected string index |
---|
124 | end |
---|
125 | if isfield(param,'Coord_x_str')&& isfield(param,'Coord_x_val') |
---|
126 | set(handles.Coord_x,'String',param.Coord_x_str);% list menu fields |
---|
127 | set(handles.Coord_x,'Value',param.Coord_x_val);% selected string index |
---|
128 | end |
---|
129 | if isfield(param,'Coord_y_str')&& isfield(param,'Coord_y_val') |
---|
130 | set(handles.Coord_y,'String',param.Coord_y_str);% list menu fields |
---|
131 | set(handles.Coord_y,'Value',param.Coord_y_val);% selected string index |
---|
132 | end |
---|
133 | |
---|
134 | %loads the information stored in prefdir to initiate the list of ActionName functions |
---|
135 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
136 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
137 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
138 | nb_transform=numel(transform_menu); |
---|
139 | [path_series,name,ext]=fileparts(which('series')); |
---|
140 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
141 | 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) |
---|
142 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
143 | for ilist=1:length(fct_menu) |
---|
144 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
145 | end |
---|
146 | |
---|
147 | %% TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
148 | menu_str={'';'sub_field';'phys';'phys_polar'}; |
---|
149 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
150 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
151 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
152 | fct_handle{1,1}=[]; |
---|
153 | testexist(1)=1; |
---|
154 | for ilist=2:length(menu_str) |
---|
155 | if exist(menu_str{ilist},'file') |
---|
156 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
157 | testexist(ilist)=1; |
---|
158 | else |
---|
159 | testexist(ilist)=0; |
---|
160 | end |
---|
161 | end |
---|
162 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
163 | |
---|
164 | %% read the list of transform functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
165 | if test_profil_perso |
---|
166 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
167 | for ilist=1:length(h.series_fct) |
---|
168 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
169 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
170 | fct_menu=[fct_menu; {file}]; |
---|
171 | end |
---|
172 | end |
---|
173 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
174 | for ilist=1:length(h.transform_fct); |
---|
175 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
176 | addpath(path) |
---|
177 | if exist(file,'file') |
---|
178 | h_func=str2func(file); |
---|
179 | testexist=[testexist 1]; |
---|
180 | else |
---|
181 | h_func=[]; |
---|
182 | testexist=[testexist 0]; |
---|
183 | end |
---|
184 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
185 | rmpath(path) |
---|
186 | menu_str=[menu_str; {file}]; |
---|
187 | end |
---|
188 | end |
---|
189 | end |
---|
190 | fct_menu=[fct_menu;{'more...'}]; |
---|
191 | set(handles.ActionName,'String',fct_menu) |
---|
192 | set(handles.ActionName,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
193 | menu_str=menu_str(find(testexist)); |
---|
194 | fct_handle=fct_handle(find(testexist)); |
---|
195 | menu_str=[menu_str;{'more...'}]; |
---|
196 | set(handles.TransformName,'String',menu_str) |
---|
197 | set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
198 | |
---|
199 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
200 | path_uvmat=fileparts(which('uvmat')); %path to civ |
---|
201 | addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
202 | errormsg=[];%default error message |
---|
203 | xmlfile='PARAM.xml'; |
---|
204 | if exist(xmlfile,'file') |
---|
205 | try |
---|
206 | t=xmltree(xmlfile); |
---|
207 | sparam=convert(t); |
---|
208 | catch ME |
---|
209 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; |
---|
210 | end |
---|
211 | else |
---|
212 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
213 | end |
---|
214 | if ~isempty(errormsg) |
---|
215 | msgbox_uvmat('WARNING',errormsg); |
---|
216 | end |
---|
217 | test_batch=0;%default: ,no batch mode available |
---|
218 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
219 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
220 | end |
---|
221 | RUNVal=get(handles.RunMode,'Value'); |
---|
222 | if test_batch==0 |
---|
223 | if RUNVal>2 |
---|
224 | set(handles.RunMode,'Value',1) |
---|
225 | end |
---|
226 | set(handles.RunMode,'String',{'local';'background'}) |
---|
227 | else |
---|
228 | set(handles.RunMode,'String',{'local';'background';'cluster'}) |
---|
229 | end |
---|
230 | |
---|
231 | %------------------------------------------------------------------------ |
---|
232 | % --- Outputs from this function are returned to the command line. |
---|
233 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
234 | %------------------------------------------------------------------------ |
---|
235 | % varargout cell array for returning output args (see VARARGOUT); |
---|
236 | % hObject handle to figure |
---|
237 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
238 | % handles structure with handles and user data (see GUIDATA) |
---|
239 | % Get default command line output from handles structure |
---|
240 | varargout{1} = handles.output; |
---|
241 | |
---|
242 | %------------------------------------------------------------------------ |
---|
243 | %------------------------------------------------------------------------ |
---|
244 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
245 | % automatically sets the global properties when the rootfile name is introduced |
---|
246 | % then activate the view-field actionname if selected |
---|
247 | % it is activated either by clicking on the RootPath window or by the |
---|
248 | % browser |
---|
249 | %------------------------------------------------------------------------ |
---|
250 | %------------------------------------------------------------------------ |
---|
251 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
252 | %------------------------------------------------------------------------ |
---|
253 | InputTable=get(handles.InputTable,'Data'); |
---|
254 | if isempty(InputTable) |
---|
255 | RootPathCell={}; |
---|
256 | else |
---|
257 | RootPathCell=InputTable(:,1); |
---|
258 | end |
---|
259 | oldfile=''; %default |
---|
260 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
261 | dir_perso=prefdir; |
---|
262 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
263 | if exist(profil_perso,'file') |
---|
264 | h=load (profil_perso); |
---|
265 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
266 | oldfile=h.filebase; |
---|
267 | end |
---|
268 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
269 | oldfile=h.RootPath; |
---|
270 | end |
---|
271 | end |
---|
272 | else |
---|
273 | SubDirCell=InputTable(:,2); |
---|
274 | RootFileCell=InputTable(:,3); |
---|
275 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
276 | end |
---|
277 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
278 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
279 | '*.xml', '.xml files '; ... |
---|
280 | '*.xls', '.xls files '; ... |
---|
281 | '*.png','.png image files'; ... |
---|
282 | '*.tif','.tif image files'; ... |
---|
283 | '*.avi;*.AVI','.avi movie files'; ... |
---|
284 | '*.nc','.netcdf files'; ... |
---|
285 | '*.*', 'All Files (*.*)'}, ... |
---|
286 | 'Pick a file',oldfile); |
---|
287 | fileinput=[PathName FileName];%complete file name |
---|
288 | if isempty(fileinput),return;end %abandon if no file is introduced by the browser |
---|
289 | [path,name,ext]=fileparts(fileinput); |
---|
290 | if isequal(ext,'.xml') |
---|
291 | [Param,Heading]=xml2struct(fileinput); |
---|
292 | if ~strcmp(Heading,'Series') |
---|
293 | msg_box_uvmat('ERROR','xml file heading is not <Series>') |
---|
294 | else |
---|
295 | fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file |
---|
296 | if isfield(Param,'CheckObject')&& Param.CheckObject |
---|
297 | set_object(Param.ProjObject) |
---|
298 | end |
---|
299 | set(handles.REFRESH,'UserData',[1:size(Param.InputTable,1)]) |
---|
300 | REFRESH_Callback([],[], handles) |
---|
301 | return |
---|
302 | end |
---|
303 | elseif isequal(ext,'.xls') |
---|
304 | msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
305 | else |
---|
306 | display_file_name(handles,fileinput,0) |
---|
307 | end |
---|
308 | |
---|
309 | % -------------------------------------------------------------------- |
---|
310 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
311 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
312 | display_file_name(handles,fileinput,0) |
---|
313 | |
---|
314 | % -------------------------------------------------------------------- |
---|
315 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
316 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
317 | display_file_name(handles,fileinput,0) |
---|
318 | |
---|
319 | % -------------------------------------------------------------------- |
---|
320 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
321 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
322 | display_file_name( handles,fileinput,0) |
---|
323 | |
---|
324 | % -------------------------------------------------------------------- |
---|
325 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
326 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
327 | display_file_name(handles,fileinput,0) |
---|
328 | |
---|
329 | % -------------------------------------------------------------------- |
---|
330 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
331 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
332 | display_file_name(handles,fileinput,0) |
---|
333 | |
---|
334 | % -------------------------------------------------------------------- |
---|
335 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
336 | InputTable=get(handles.InputTable,'Data'); |
---|
337 | RootPathCell=InputTable(:,1); |
---|
338 | SubDirCell=InputTable(:,3); |
---|
339 | RootFileCell=InputTable(:,2); |
---|
340 | oldfile=''; %default |
---|
341 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
342 | dir_perso=prefdir; |
---|
343 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
344 | if exist(profil_perso,'file') |
---|
345 | h=load (profil_perso); |
---|
346 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
347 | oldfile=h.filebase; |
---|
348 | end |
---|
349 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
350 | oldfile=h.RootPath; |
---|
351 | end |
---|
352 | end |
---|
353 | else |
---|
354 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
355 | end |
---|
356 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
357 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
358 | '*.xml', '.xml files '; ... |
---|
359 | '*.xls', '.xls files '; ... |
---|
360 | '*.png','.png image files'; ... |
---|
361 | '*.avi;*.AVI','.avi movie files'; ... |
---|
362 | '*.nc','.netcdf files'; ... |
---|
363 | '*.*', 'All Files (*.*)'}, ... |
---|
364 | 'Pick a file',oldfile); |
---|
365 | fileinput=[PathName FileName];%complete file name |
---|
366 | sizf=size(fileinput); |
---|
367 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
368 | [path,name,ext]=fileparts(fileinput); |
---|
369 | if isequal(ext,'.xml') |
---|
370 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
371 | elseif isequal(ext,'.xls') |
---|
372 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
373 | else |
---|
374 | display_file_name(handles,fileinput,'append') |
---|
375 | end |
---|
376 | |
---|
377 | % -------------------------------------------------------------------- |
---|
378 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
379 | % -------------------------------------------------------------------- |
---|
380 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
381 | display_file_name(handles,fileinput,'append') |
---|
382 | |
---|
383 | % -------------------------------------------------------------------- |
---|
384 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
385 | % -------------------------------------------------------------------- |
---|
386 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
387 | display_file_name(handles,fileinput,'append') |
---|
388 | |
---|
389 | % -------------------------------------------------------------------- |
---|
390 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
391 | % -------------------------------------------------------------------- |
---|
392 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
393 | display_file_name( handles,fileinput,'append') |
---|
394 | |
---|
395 | % -------------------------------------------------------------------- |
---|
396 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
397 | % -------------------------------------------------------------------- |
---|
398 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
399 | display_file_name( handles,fileinput,'append') |
---|
400 | |
---|
401 | % -------------------------------------------------------------------- |
---|
402 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
403 | % -------------------------------------------------------------------- |
---|
404 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
405 | display_file_name(handles,fileinput,'append') |
---|
406 | |
---|
407 | %------------------------------------------------------------------------ |
---|
408 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
409 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
410 | %------------------------------------------------------------------------ |
---|
411 | set(handles.REFRESH,'Visible','on') |
---|
412 | iview=eventdata.Indices(1); |
---|
413 | view_set=get(handles.REFRESH,'UserData'); |
---|
414 | if isempty(find(view_set==iview)) |
---|
415 | set(handles.REFRESH,'UserData',[view_set iview]) |
---|
416 | end |
---|
417 | %% enable other menus and uicontrols |
---|
418 | set(handles.MenuOpen_insert,'Enable','on') |
---|
419 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
420 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
421 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
422 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
423 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
424 | set(handles.RUN, 'Enable','On') |
---|
425 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
426 | |
---|
427 | %update the output dir |
---|
428 | % SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
429 | % SubDirOut=SubDir{1}; |
---|
430 | % if numel(SubDir)>1 |
---|
431 | % for ilist=2:numel(SubDir) |
---|
432 | % SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
433 | % end |
---|
434 | % end |
---|
435 | % set(handles.OutputSubDir,'String',SubDirOut) |
---|
436 | |
---|
437 | %------------------------------------------------------------------------ |
---|
438 | % --- Executes on button press in REFRESH. |
---|
439 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
440 | %------------------------------------------------------------------------ |
---|
441 | InputTable=get(handles.InputTable,'Data'); |
---|
442 | view_set=get(handles.REFRESH,'UserData'); |
---|
443 | set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])% set REFRESH button to grey color |
---|
444 | drawnow |
---|
445 | for iview=view_set |
---|
446 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2}); |
---|
447 | if ~exist(RootPath,'dir') |
---|
448 | i1_series=[]; |
---|
449 | RootPath=fileparts(RootPath); %will try the upped forldr |
---|
450 | else |
---|
451 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=... |
---|
452 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
453 | end |
---|
454 | if isempty(i1_series) |
---|
455 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
456 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
457 | '*.xml', '.xml files '; ... |
---|
458 | '*.xls', '.xls files '; ... |
---|
459 | '*.png','.png image files'; ... |
---|
460 | '*.tif','.tif image files'; ... |
---|
461 | '*.avi;*.AVI','.avi movie files'; ... |
---|
462 | '*.nc','.netcdf files'; ... |
---|
463 | '*.*', 'All Files (*.*)'}, ... |
---|
464 | ['unvalid entry at line ' num2str(iview) ', pick a file'],RootPath); |
---|
465 | fileinput=[PathName FileName];%complete file name |
---|
466 | if isempty(fileinput),return;end %abandon if the operation has been cancelled: no input from browser |
---|
467 | [path,name,ext]=fileparts(fileinput); |
---|
468 | display_file_name(handles,fileinput,iview) |
---|
469 | else |
---|
470 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview) |
---|
471 | end |
---|
472 | end |
---|
473 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to grey color |
---|
474 | set(handles.REFRESH,'Visible','off') |
---|
475 | set(handles.REFRESH,'UserData',[]) |
---|
476 | |
---|
477 | %------------------------------------------------------------------------ |
---|
478 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser |
---|
479 | function display_file_name(handles,fileinput,iview) |
---|
480 | %------------------------------------------------------------------------ |
---|
481 | % |
---|
482 | % INPUT: |
---|
483 | % handles: handles of elements in the GUI |
---|
484 | % fielinput: input file name, including path |
---|
485 | % append =0 (refresh the Input table with the new file), ='append' append a new line in the table |
---|
486 | |
---|
487 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
488 | if ~exist(fileinput,'file') |
---|
489 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
490 | return |
---|
491 | end |
---|
492 | |
---|
493 | %% enable other menus and uicontrols |
---|
494 | set(handles.MenuOpen_insert,'Enable','on') |
---|
495 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
496 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
497 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
498 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
499 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
500 | set(handles.RUN, 'Enable','On') |
---|
501 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
502 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
503 | drawnow |
---|
504 | |
---|
505 | %% detect root name, nomenclature and indices in the input file name: |
---|
506 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
507 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
508 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
509 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
510 | if isempty(RootFile)&&isempty(i1_series) |
---|
511 | errormsg='no input file in the series'; |
---|
512 | return |
---|
513 | end |
---|
514 | |
---|
515 | %% fill the list of file series |
---|
516 | InputTable=get(handles.InputTable,'Data'); |
---|
517 | if strcmp(iview,'append') % display the input data as a new line in the table |
---|
518 | iview=size(InputTable,1); |
---|
519 | InputTable(iview+1,:)={'','','','',''}; |
---|
520 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
521 | elseif iview==0 % or re-initialise the list of input file series |
---|
522 | iview=1; |
---|
523 | InputTable=[{'','','','',''};{'','','','',''}]; |
---|
524 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
525 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
526 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
527 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
528 | set(handles.ListView,'Value',1) |
---|
529 | set(handles.ListView,'String',{'1'}) |
---|
530 | end |
---|
531 | nbview=size(InputTable,1); |
---|
532 | set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1))) |
---|
533 | set(handles.ListView,'Value',iview) |
---|
534 | set(handles.InputTable,'Data',InputTable) |
---|
535 | |
---|
536 | %% determine the selected reference field indices for pair display |
---|
537 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
538 | if ~isempty(i1) |
---|
539 | ref_i=i1; |
---|
540 | if ~isempty(i2) |
---|
541 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
542 | end |
---|
543 | end |
---|
544 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
545 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
546 | if ~isempty(j1) |
---|
547 | ref_j=j1; |
---|
548 | if ~isempty(j2) |
---|
549 | ref_j=floor((j1+j2)/2); |
---|
550 | end |
---|
551 | end |
---|
552 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
553 | |
---|
554 | %% update the list of recent files in the menubar and save it for future opening |
---|
555 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
556 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
557 | str_find=strcmp(fileinput,MenuFile); |
---|
558 | if isempty(find(str_find,1)) |
---|
559 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
560 | end |
---|
561 | for ifile=1:min(length(MenuFile),5) |
---|
562 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
563 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
564 | end |
---|
565 | dir_perso=prefdir; |
---|
566 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
567 | if exist(profil_perso,'file') |
---|
568 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
569 | else |
---|
570 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
571 | end |
---|
572 | |
---|
573 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
574 | |
---|
575 | %% initiate input file series and refresh the current field view: |
---|
576 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview); |
---|
577 | |
---|
578 | %------------------------------------------------------------------------ |
---|
579 | % --- Update information about a new field series (indices to scan, timing, |
---|
580 | % calibration from an xml file |
---|
581 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
582 | %------------------------------------------------------------------------ |
---|
583 | %% update the output dir |
---|
584 | InputTable=get(handles.InputTable,'Data'); |
---|
585 | SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order |
---|
586 | SubDirOut=SubDir{1}; |
---|
587 | if numel(SubDir)>1 |
---|
588 | for ilist=2:numel(SubDir) |
---|
589 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
590 | end |
---|
591 | end |
---|
592 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
593 | |
---|
594 | %% display the min and max indices for the file series |
---|
595 | if size(i1_series,2)==1 |
---|
596 | MinIndex_j=1; |
---|
597 | MaxIndex_j=1; |
---|
598 | MinIndex_i=min(find(i1_series)); |
---|
599 | MaxIndex_i=max(find(i1_series)); |
---|
600 | else |
---|
601 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
602 | j_max=max(pair_max,[],1); |
---|
603 | %i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index |
---|
604 | MaxIndex_i=max(find(j_max))-1;% max ref index i |
---|
605 | MinIndex_i=min(find(j_max))-1;% min ref index i |
---|
606 | diff_i_max=diff(j_max); |
---|
607 | if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) |
---|
608 | set(handles.num_incr_i,'String',num2str(diff_i_max(1))) |
---|
609 | end |
---|
610 | i_max=max(pair_max,[],2); |
---|
611 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
612 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
613 | diff_j_max=diff(i_max); |
---|
614 | if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) |
---|
615 | set(handles.num_incr_j,'String',num2str(diff_j_max(1))) |
---|
616 | end |
---|
617 | end |
---|
618 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
619 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
620 | MinIndex{iview,1}=MinIndex_i; |
---|
621 | MinIndex{iview,2}=MinIndex_j; |
---|
622 | MaxIndex{iview,1}=MaxIndex_i; |
---|
623 | MaxIndex{iview,2}=MaxIndex_j; |
---|
624 | |
---|
625 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
626 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
627 | |
---|
628 | %% adjust the first and last indices if requested by the bounds |
---|
629 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
630 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
631 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
632 | if isempty(first_i) |
---|
633 | first_i=ref_i; |
---|
634 | elseif first_i < MinIndex_i |
---|
635 | first_i=MinIndex_i; |
---|
636 | elseif first_i >MaxIndex_i |
---|
637 | first_i=MinIndex_i; |
---|
638 | end |
---|
639 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
640 | if isempty(first_j) |
---|
641 | first_j=ref_j; |
---|
642 | elseif first_j<MinIndex_j |
---|
643 | first_j=MinIndex_j; |
---|
644 | elseif first_j >MaxIndex_j |
---|
645 | first_j=MinIndex_j; |
---|
646 | end |
---|
647 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
648 | if isempty(last_i) |
---|
649 | last_i=ref_i; |
---|
650 | elseif last_i > MaxIndex_i |
---|
651 | last_i=MaxIndex_i; |
---|
652 | elseif last_i<first_i |
---|
653 | last_i=first_i; |
---|
654 | end |
---|
655 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
656 | if isempty(last_j) |
---|
657 | last_j=ref_j; |
---|
658 | elseif last_j>MaxIndex_j |
---|
659 | last_j=MaxIndex_j; |
---|
660 | elseif last_i<first_i |
---|
661 | last_i=first_i; |
---|
662 | end |
---|
663 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
664 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
665 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
666 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
667 | |
---|
668 | %% read timing and total frame number from the current file (movie files) may be overrid by xml file |
---|
669 | InputTable=get(handles.InputTable,'Data'); |
---|
670 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
671 | time=[];%default |
---|
672 | % case of movies |
---|
673 | if strcmp(InputTable{iview,4},'*') |
---|
674 | if ~isempty(VideoObject) |
---|
675 | imainfo=get(VideoObject); |
---|
676 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
677 | % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
678 | ColorType='truecolor'; |
---|
679 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
680 | if ~isempty(InputTable{iview,2}) |
---|
681 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
682 | else |
---|
683 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
684 | end |
---|
685 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
686 | if length(imainfo) >1 %case of image with multiple frames |
---|
687 | nbfield=length(imainfo); |
---|
688 | nbfield_j=1; |
---|
689 | end |
---|
690 | end |
---|
691 | end |
---|
692 | |
---|
693 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
694 | XmlData=[]; |
---|
695 | NbSlice_calib={}; |
---|
696 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); |
---|
697 | if ~isempty(XmlFileName) |
---|
698 | [XmlData,warntext]=imadoc2struct(XmlFileName); |
---|
699 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
700 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
701 | end |
---|
702 | if isfield(XmlData,'Time') |
---|
703 | time=XmlData.Time; |
---|
704 | end |
---|
705 | if isfield(XmlData,'Camera') |
---|
706 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
707 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
708 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
709 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
710 | end |
---|
711 | end |
---|
712 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
713 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
714 | end |
---|
715 | end |
---|
716 | if ~isempty(warntext) |
---|
717 | msgbox_uvmat('WARNING',warntext) |
---|
718 | end |
---|
719 | end |
---|
720 | |
---|
721 | %% update time table |
---|
722 | if ~isempty(time) |
---|
723 | TimeTable=get(handles.TimeTable,'Data'); |
---|
724 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
725 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
726 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
727 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
728 | MinIndexTable=get(handles.MinIndex,'Data'); |
---|
729 | MinIndex_i=MinIndexTable{iview,1}; |
---|
730 | MinIndex_j=MinIndexTable{iview,2}; |
---|
731 | MaxIndexTable=get(handles.MaxIndex,'Data'); |
---|
732 | MaxIndex_i=MaxIndexTable{iview,1}; |
---|
733 | MaxIndex_j=MaxIndexTable{iview,2}; |
---|
734 | if isempty(MinIndex_j) |
---|
735 | if MinIndex_i>0 |
---|
736 | TimeTable{iview,1}=time(MinIndex_i); |
---|
737 | end |
---|
738 | TimeTable{iview,2}=time(first_i); |
---|
739 | TimeTable{iview,3}=time(last_i); |
---|
740 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
741 | elseif ~isempty(time) |
---|
742 | if MinIndex_i>0 |
---|
743 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
744 | end |
---|
745 | TimeTable{iview,2}=time(first_i,first_j); |
---|
746 | TimeTable{iview,3}=time(last_i,last_j); |
---|
747 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
748 | end |
---|
749 | set(handles.TimeTable,'Data',TimeTable) |
---|
750 | end |
---|
751 | |
---|
752 | %% number of slices |
---|
753 | NbSlice=1;%default |
---|
754 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
755 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
756 | if siz(1)>1 |
---|
757 | NbSlice=siz(1); |
---|
758 | end |
---|
759 | end |
---|
760 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
761 | |
---|
762 | %% update pair menus |
---|
763 | set(handles.Pairs,'Visible','on') |
---|
764 | set(handles.PairString,'Visible','on') |
---|
765 | ListView=get(handles.ListView,'String'); |
---|
766 | ListView{iview}=num2str(iview); |
---|
767 | set(handles.ListView,'String',ListView); |
---|
768 | set(handles.ListView,'Value',iview) |
---|
769 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
770 | |
---|
771 | %% update the series info in 'UserData' |
---|
772 | SeriesData=get(handles.series,'UserData'); |
---|
773 | SeriesData.i1_series{iview}=i1_series; |
---|
774 | SeriesData.i2_series{iview}=i2_series; |
---|
775 | SeriesData.j1_series{iview}=j1_series; |
---|
776 | SeriesData.j2_series{iview}=j2_series; |
---|
777 | SeriesData.FileType{iview}=FileType; |
---|
778 | SeriesData.Time{iview}=time; |
---|
779 | set(handles.series,'UserData',SeriesData) |
---|
780 | |
---|
781 | %% enable j index visibilitycellfun(@isempty,regexp(PairString,'^j')) |
---|
782 | state='off'; |
---|
783 | check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices |
---|
784 | if isempty(find(check_jindex)) |
---|
785 | enable_j(handles,'off') % no j index needed |
---|
786 | else |
---|
787 | PairString=get(handles.PairString,'Data'); |
---|
788 | if isempty(find(cellfun(@isempty,regexp(PairString,'^j'))))% if all pair string begins by j (burst) |
---|
789 | enable_j(handles,'off') % no j index needed |
---|
790 | else |
---|
791 | enable_j(handles,'on') |
---|
792 | end |
---|
793 | end |
---|
794 | |
---|
795 | %% display the set of existing files as an image |
---|
796 | set(handles.FileStatus,'Units','pixels') |
---|
797 | Position=get(handles.FileStatus,'Position'); |
---|
798 | set(handles.FileStatus,'Units','normalized') |
---|
799 | xI=0.5:Position(3)-0.5; |
---|
800 | nbview=numel(SeriesData.i1_series); |
---|
801 | pair_max=cell(1,nbview); |
---|
802 | for iview=1:nbview |
---|
803 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
804 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
805 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
806 | end |
---|
807 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
808 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
809 | end |
---|
810 | index_min=min(index_min); |
---|
811 | index_max=max(index_max); |
---|
812 | range_index=index_max-index_min+1; |
---|
813 | scale_y=Position(4)/nbview; |
---|
814 | scale_x=Position(3)/range_index; |
---|
815 | x=(0.5:range_index-0.5)*Position(3)/range_index; |
---|
816 | % y=(0.5:nbview-0.5)*Position(4)/nbview; |
---|
817 | range_y=max(1,floor(Position(4)/nbview)); |
---|
818 | CData=zeros(nbview*range_y,Position(3)); |
---|
819 | for iview=1:nbview |
---|
820 | ind_y=1+(iview-1)*range_y:iview*range_y; |
---|
821 | LineData=zeros(1,range_index); |
---|
822 | x_index=find(pair_max{iview}>0)-index_min+1; |
---|
823 | LineData(x_index)=1; |
---|
824 | LineData=interp1(x,LineData,xI,'nearest'); |
---|
825 | CData(ind_y,:)=ones(size(ind_y'))*LineData; |
---|
826 | end |
---|
827 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); |
---|
828 | set(handles.FileStatus,'CData',CData); |
---|
829 | |
---|
830 | |
---|
831 | %% enable field and veltype menus, in accordance with the current action |
---|
832 | ActionName_Callback([],[], handles) |
---|
833 | |
---|
834 | %% check for pair display |
---|
835 | check_pairs=0; |
---|
836 | for iview=1:numel(SeriesData.i2_series) |
---|
837 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
838 | check_pairs=1; |
---|
839 | end |
---|
840 | end |
---|
841 | if check_pairs |
---|
842 | set(handles.Pairs,'Visible','on') |
---|
843 | set(handles.PairString,'Visible','on') |
---|
844 | else |
---|
845 | set(handles.Pairs,'Visible','off') |
---|
846 | set(handles.PairString,'Visible','off') |
---|
847 | end |
---|
848 | |
---|
849 | %% set length of waitbar |
---|
850 | displ_time(handles) |
---|
851 | |
---|
852 | |
---|
853 | %% set default options in menu 'Fields' |
---|
854 | switch FileType |
---|
855 | case {'civx','civdata'} |
---|
856 | [FieldList,ColorList]=calc_field; |
---|
857 | set(handles.FieldName,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
858 | set(handles.FieldName,'Value',2) % set menu to 'velocity |
---|
859 | set(handles.Coord_x,'Value',1); |
---|
860 | set(handles.Coord_x,'String',{'X'}); |
---|
861 | set(handles.Coord_y,'Value',1); |
---|
862 | set(handles.Coord_y,'String',{'Y'}); |
---|
863 | case 'netcdf' |
---|
864 | set(handles.FieldName,'Value',1) |
---|
865 | set(handles.FieldName,'String',{'get_field...'}) |
---|
866 | if isempty(i2_series) |
---|
867 | i2=[]; |
---|
868 | else |
---|
869 | i2=i2_series(1,ref_j+1,ref_i+1); |
---|
870 | end |
---|
871 | if isempty(j1_series) |
---|
872 | j1=[];j2=[]; |
---|
873 | else |
---|
874 | j1=j1_series(1,ref_j+1,ref_i+1); |
---|
875 | if isempty(j2_series) |
---|
876 | j2=[]; |
---|
877 | else |
---|
878 | j2=j2_series(1,ref_j+1,ref_i+1); |
---|
879 | end |
---|
880 | end |
---|
881 | FileName=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1_series(1,ref_j+1,ref_i+1),i2,j1,j2); |
---|
882 | hget_field=get_field(FileName); |
---|
883 | hhget_field=guidata(hget_field); |
---|
884 | get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
885 | otherwise |
---|
886 | set(handles.FieldName,'Value',1) % set menu to 'image' |
---|
887 | set(handles.FieldName,'String',{'image'}) |
---|
888 | set(handles.Coord_x,'Value',1); |
---|
889 | set(handles.Coord_x,'String',{'AX'}); |
---|
890 | set(handles.Coord_y,'Value',1); |
---|
891 | set(handles.Coord_y,'String',{'AY'}); |
---|
892 | end |
---|
893 | |
---|
894 | %------------------------------------------------------------------------ |
---|
895 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
896 | %------------------------------------------------------------------------ |
---|
897 | num_last_i_Callback(hObject, eventdata, handles) |
---|
898 | |
---|
899 | %------------------------------------------------------------------------ |
---|
900 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
901 | %------------------------------------------------------------------------ |
---|
902 | SeriesData=get(handles.series,'UserData'); |
---|
903 | if ~isfield(SeriesData,'Time') |
---|
904 | SeriesData.Time{1}=[]; |
---|
905 | end |
---|
906 | displ_time(handles); |
---|
907 | |
---|
908 | %------------------------------------------------------------------------ |
---|
909 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
910 | %------------------------------------------------------------------------ |
---|
911 | num_last_j_Callback(hObject, eventdata, handles) |
---|
912 | |
---|
913 | %------------------------------------------------------------------------ |
---|
914 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
915 | %------------------------------------------------------------------------ |
---|
916 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
917 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
918 | ref_j=ceil((first_j+last_j)/2); |
---|
919 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
920 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
921 | SeriesData=get(handles.series,'UserData'); |
---|
922 | if ~isfield(SeriesData,'Time') |
---|
923 | SeriesData.Time{1}=[]; |
---|
924 | end |
---|
925 | displ_time(handles); |
---|
926 | |
---|
927 | |
---|
928 | %------------------------------------------------------------------------ |
---|
929 | % ---- find the times corresponding to the first and last indices of a series |
---|
930 | function displ_time(handles) |
---|
931 | %------------------------------------------------------------------------ |
---|
932 | SeriesData=get(handles.series,'UserData');% |
---|
933 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
934 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
935 | TimeTable=get(handles.TimeTable,'Data'); |
---|
936 | Pairs=get(handles.PairString,'Data'); |
---|
937 | for iview=1:size(TimeTable,1) |
---|
938 | if size(SeriesData.Time,1)<iview |
---|
939 | break |
---|
940 | end |
---|
941 | i1=ref_i; |
---|
942 | j1=ref_j; |
---|
943 | i2=ref_i; |
---|
944 | j2=ref_j; |
---|
945 | % case of pairs |
---|
946 | if ~isempty(Pairs{iview,1}) |
---|
947 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
948 | if isempty(r) |
---|
949 | r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
950 | end |
---|
951 | switch r.mode |
---|
952 | case 'Di=' % case 'series(Di)') |
---|
953 | i1=ref_i-str2num(r.num1); |
---|
954 | i2=ref_i+str2num(r.num2); |
---|
955 | case 'Dj=' % case 'series(Dj)' |
---|
956 | j1=ref_j-str2num(r.num1); |
---|
957 | j2=ref_j+str2num(r.num2); |
---|
958 | case '-' % case 'bursts' |
---|
959 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
960 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
961 | end |
---|
962 | end |
---|
963 | TimeTable{iview,2}=[]; |
---|
964 | TimeTable{iview,3}=[]; |
---|
965 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
966 | if isempty(ref_j) |
---|
967 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
968 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
969 | else |
---|
970 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
971 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
972 | end |
---|
973 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
974 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
975 | end |
---|
976 | end |
---|
977 | set(handles.TimeTable,'Data',TimeTable) |
---|
978 | |
---|
979 | %% set the waitbar position with respect to the min and max in the series |
---|
980 | for iview=1:numel(SeriesData.i1_series) |
---|
981 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
982 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
983 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
984 | end |
---|
985 | pair_max{iview}=reshape(pair_max{iview},1,[]); |
---|
986 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
987 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
988 | end |
---|
989 | [index_min,iview_min]=min(index_min); |
---|
990 | [index_max,iview_max]=min(index_max); |
---|
991 | if size(SeriesData.i1_series{iview_min},2)==1% movie |
---|
992 | index_first=ref_i(1); |
---|
993 | index_last=ref_i(2); |
---|
994 | else |
---|
995 | index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; |
---|
996 | index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; |
---|
997 | end |
---|
998 | range=index_max-index_min+1; |
---|
999 | coeff_min=(index_first-index_min)/range; |
---|
1000 | coeff_max=(index_last-index_min+1)/range; |
---|
1001 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] |
---|
1002 | Position_status=get(handles.FileStatus,'Position'); |
---|
1003 | Position(1)=coeff_min*Position_status(3)+Position_status(1); |
---|
1004 | Position(3)=Position_status(3)*(coeff_max-coeff_min); |
---|
1005 | set(handles.Waitbar,'Position',Position) |
---|
1006 | update_waitbar(handles.Waitbar,0) |
---|
1007 | |
---|
1008 | %------------------------------------------------------------------------ |
---|
1009 | % --- Executes when selected cell(s) is changed in PairString. |
---|
1010 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
1011 | %------------------------------------------------------------------------ |
---|
1012 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
1013 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
1014 | |
---|
1015 | %------------------------------------------------------------------------ |
---|
1016 | %------------------------------------------------------------------------ |
---|
1017 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
1018 | %------------------------------------------------------------------------ |
---|
1019 | %------------------------------------------------------------------------ |
---|
1020 | % --- Executes on selection change in ListView. |
---|
1021 | function ListView_Callback(hObject, eventdata, handles) |
---|
1022 | %------------------------------------------------------------------------ |
---|
1023 | SeriesData=get(handles.series,'UserData'); |
---|
1024 | i2_series=[]; |
---|
1025 | j2_series=[]; |
---|
1026 | iview=get(handles.ListView,'Value'); |
---|
1027 | if ~isempty(SeriesData.i2_series{iview}) |
---|
1028 | i2_series=SeriesData.i2_series{iview}; |
---|
1029 | end |
---|
1030 | if ~isempty(SeriesData.j2_series{iview}) |
---|
1031 | j2_series=SeriesData.j2_series{iview}; |
---|
1032 | end |
---|
1033 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1034 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1035 | |
---|
1036 | %------------------------------------------------------------------------ |
---|
1037 | % --- Executes on button press in mode. |
---|
1038 | function mode_Callback(hObject, eventdata, handles) |
---|
1039 | %------------------------------------------------------------------------ |
---|
1040 | SeriesData=get(handles.series,'UserData'); |
---|
1041 | iview=get(handles.ListView,'Value'); |
---|
1042 | mode_list=get(handles.mode,'String'); |
---|
1043 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1044 | if isequal(mode,'bursts') |
---|
1045 | enable_i(handles,'On') |
---|
1046 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1047 | else |
---|
1048 | enable_i(handles,'On') |
---|
1049 | enable_j(handles,'Off') |
---|
1050 | end |
---|
1051 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1052 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
1053 | ListPairs_Callback([],[],handles) |
---|
1054 | |
---|
1055 | %------------------------------------------------------------- |
---|
1056 | % --- Executes on selection in ListPairs. |
---|
1057 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
1058 | %------------------------------------------------------------ |
---|
1059 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
1060 | if isempty(list_pair) |
---|
1061 | string=''; |
---|
1062 | else |
---|
1063 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
1064 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
1065 | end |
---|
1066 | PairString=get(handles.PairString,'Data'); |
---|
1067 | iview=get(handles.ListView,'Value'); |
---|
1068 | PairString{iview,1}=string; |
---|
1069 | % report the selected pair string to the table PairString |
---|
1070 | set(handles.PairString,'Data',PairString) |
---|
1071 | |
---|
1072 | %------------------------------------------------------------------------ |
---|
1073 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
1074 | %------------------------------------------------------------------------ |
---|
1075 | mode_list=get(handles.mode,'String'); |
---|
1076 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1077 | SeriesData=get(handles.series,'UserData'); |
---|
1078 | iview=get(handles.ListView,'Value'); |
---|
1079 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
1080 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
1081 | ListPairs_Callback([],[],handles) |
---|
1082 | |
---|
1083 | %------------------------------------------------------------------------ |
---|
1084 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
1085 | %------------------------------------------------------------------------ |
---|
1086 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
1087 | |
---|
1088 | %------------------------------------------------------------------------ |
---|
1089 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1090 | %------------------------------------------------------------------------ |
---|
1091 | % check_burst=0; |
---|
1092 | if isempty(j2_series)% no j pair |
---|
1093 | if isempty(i2_series) |
---|
1094 | set(handles.mode,'Value',1) |
---|
1095 | set(handles.mode,'String',{''})% no pair menu to display |
---|
1096 | else |
---|
1097 | set(handles.mode,'Value',1) |
---|
1098 | set(handles.mode,'String',{'series(Di)'}) % pair menu with only option Di |
---|
1099 | end |
---|
1100 | else %existence of j pairs |
---|
1101 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
1102 | j_max=max(pair_max,[],1); |
---|
1103 | MaxIndex_i=max(find(j_max))-1;% max ref index i |
---|
1104 | MinIndex_i=min(find(j_max))-1;% min ref index i |
---|
1105 | i_max=max(pair_max,[],2); |
---|
1106 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
1107 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
1108 | if MaxIndex_j==MinIndex_j |
---|
1109 | set(handles.mode,'Value',1); |
---|
1110 | set(handles.mode,'String',{'bursts'}) |
---|
1111 | % check_burst=1; |
---|
1112 | elseif MaxIndex_i==MinIndex_i |
---|
1113 | set(handles.mode,'Value',1); |
---|
1114 | set(handles.mode,'String',{'series(Dj)'}) |
---|
1115 | else |
---|
1116 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
1117 | if (MaxIndex_j-MinIndex_j)>10 |
---|
1118 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
1119 | else |
---|
1120 | set(handles.mode,'Value',1); |
---|
1121 | % check_burst=1; |
---|
1122 | end |
---|
1123 | end |
---|
1124 | end |
---|
1125 | % if check_burst |
---|
1126 | % enable_i(handles,'On') |
---|
1127 | % enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
1128 | % else |
---|
1129 | % enable_i(handles,'On') |
---|
1130 | % if isempty(j1_series) |
---|
1131 | % enable_j(handles,'Off') |
---|
1132 | % else |
---|
1133 | % enable_j(handles,'On') |
---|
1134 | % end |
---|
1135 | % end |
---|
1136 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1137 | ListPairs_Callback([],[],handles) |
---|
1138 | |
---|
1139 | %-------------------------------------------------------------- |
---|
1140 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
1141 | % with the reference indices num_ref_i and num_ref_j |
---|
1142 | %---------------------------------------------------------------- |
---|
1143 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
1144 | |
---|
1145 | mode_list=get(handles.mode,'String'); |
---|
1146 | mode=mode_list{get(handles.mode,'Value')}; |
---|
1147 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
1148 | if isempty(ref_i) |
---|
1149 | ref_i=1; |
---|
1150 | end |
---|
1151 | if strcmp(get(handles.num_ref_j,'Visible'),'on') |
---|
1152 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
1153 | if isempty(ref_j) |
---|
1154 | ref_j=1; |
---|
1155 | end |
---|
1156 | else |
---|
1157 | ref_j=1; |
---|
1158 | end |
---|
1159 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
1160 | if length(TimeUnit)>=1 |
---|
1161 | dtunit=['m' TimeUnit]; |
---|
1162 | else |
---|
1163 | dtunit='e-03'; |
---|
1164 | end |
---|
1165 | |
---|
1166 | displ_pair={}; |
---|
1167 | if strcmp(mode,'series(Di)') |
---|
1168 | if isempty(i2_series) |
---|
1169 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
1170 | return |
---|
1171 | end |
---|
1172 | diff_i=i2_series-i1_series; |
---|
1173 | min_diff=min(diff_i(diff_i>0)); |
---|
1174 | max_diff=max(diff_i(diff_i>0)); |
---|
1175 | for ipair=min_diff:max_diff |
---|
1176 | if numel(diff_i(diff_i==ipair))>0 |
---|
1177 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1178 | if ~isempty(time) |
---|
1179 | if ref_i<=floor(ipair/2) |
---|
1180 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1181 | end |
---|
1182 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
1183 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1184 | end |
---|
1185 | displ_pair=[displ_pair;{pair_string}]; |
---|
1186 | end |
---|
1187 | end |
---|
1188 | if ~isempty(displ_pair) |
---|
1189 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
1190 | end |
---|
1191 | elseif strcmp(mode,'series(Dj)') |
---|
1192 | if isempty(j2_series) |
---|
1193 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1194 | return |
---|
1195 | end |
---|
1196 | diff_j=j2_series-j1_series; |
---|
1197 | min_diff=min(diff_j(diff_j>0)); |
---|
1198 | max_diff=max(diff_j(diff_j>0)); |
---|
1199 | for ipair=min_diff:max_diff |
---|
1200 | if numel(diff_j(diff_j==ipair))>0 |
---|
1201 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
1202 | if ~isempty(time) |
---|
1203 | if ref_j<=floor(ipair/2) |
---|
1204 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
1205 | end |
---|
1206 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
1207 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
1208 | end |
---|
1209 | displ_pair=[displ_pair;{pair_string}]; |
---|
1210 | end |
---|
1211 | end |
---|
1212 | if ~isempty(displ_pair) |
---|
1213 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
1214 | end |
---|
1215 | elseif strcmp(mode,'bursts') |
---|
1216 | if isempty(j2_series) |
---|
1217 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
1218 | return |
---|
1219 | end |
---|
1220 | diff_j=j2_series-j1_series; |
---|
1221 | min_j1=min(j1_series(j1_series>0)); |
---|
1222 | max_j1=max(j1_series(j1_series>0)); |
---|
1223 | min_j2=min(j2_series(j2_series>0)); |
---|
1224 | max_j2=max(j2_series(j2_series>0)); |
---|
1225 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
1226 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
1227 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
1228 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
1229 | end |
---|
1230 | end |
---|
1231 | end |
---|
1232 | if ~isempty(displ_pair) |
---|
1233 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
1234 | end |
---|
1235 | end |
---|
1236 | set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j |
---|
1237 | set(handles.num_ref_j,'String',num2str(ref_j)) |
---|
1238 | |
---|
1239 | %% display list of pairstring |
---|
1240 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
1241 | NewVal=[]; |
---|
1242 | if ~isempty(displ_pair_list) |
---|
1243 | Val=get(handles.ListPairs,'Value'); |
---|
1244 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
1245 | end |
---|
1246 | if ~isempty(NewVal) |
---|
1247 | set(handles.ListPairs,'Value',NewVal) |
---|
1248 | else |
---|
1249 | set(handles.ListPairs,'Value',1) |
---|
1250 | end |
---|
1251 | set(handles.ListPairs,'String',displ_pair) |
---|
1252 | |
---|
1253 | %------------------------------------- |
---|
1254 | function enable_i(handles,state) |
---|
1255 | set(handles.i_txt,'Visible',state) |
---|
1256 | set(handles.num_first_i,'Visible',state) |
---|
1257 | set(handles.num_last_i,'Visible',state) |
---|
1258 | set(handles.num_incr_i,'Visible',state) |
---|
1259 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
1260 | set(handles.num_ref_i,'Visible',state) |
---|
1261 | set(handles.ref_i_text,'Visible',state) |
---|
1262 | |
---|
1263 | %----------------------------------- |
---|
1264 | function enable_j(handles,state) |
---|
1265 | set(handles.j_txt,'Visible',state) |
---|
1266 | set(handles.num_first_j,'Visible',state) |
---|
1267 | set(handles.num_last_j,'Visible',state) |
---|
1268 | set(handles.num_incr_j,'Visible',state) |
---|
1269 | set(handles.num_ref_j,'Visible',state) |
---|
1270 | set(handles.ref_j_text,'Visible',state) |
---|
1271 | % if strcmp(state,'off') |
---|
1272 | % set(handles.MinIndex,'ColumnName',{'imax'}) |
---|
1273 | % set(handles.MinIndex,'ColumnEditable',logical(0)) |
---|
1274 | % else |
---|
1275 | % set(handles.MinIndex,'ColumnName',{'imax','jmax'}) |
---|
1276 | % end |
---|
1277 | |
---|
1278 | |
---|
1279 | %%%%%%%%%%%%%%%%%%%% |
---|
1280 | %% MAIN ActionName FUNCTIONS |
---|
1281 | %%%%%%%%%%%%%%%%%%%% |
---|
1282 | %------------------------------------------------------------------------ |
---|
1283 | % --- Executes on button press in RUN. |
---|
1284 | function RUN_Callback(hObject, eventdata, handles) |
---|
1285 | %------------------------------------------------------------------------ |
---|
1286 | set(handles.RUN,'BusyAction','queue'); |
---|
1287 | set(0,'CurrentFigure',handles.series) |
---|
1288 | set(handles.RUN, 'Enable','Off') |
---|
1289 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1290 | drawnow |
---|
1291 | [h_fun,Series,filexml,errormsg]=prepare_jobs(handles); |
---|
1292 | if ~isempty(errormsg) |
---|
1293 | msgbox_uvmat('ERROR',errormsg) |
---|
1294 | return |
---|
1295 | end |
---|
1296 | RunModeList=get(handles.RunMode,'String'); |
---|
1297 | RunMode=RunModeList{get(handles.RunMode,'Value')}; |
---|
1298 | |
---|
1299 | switch RunMode |
---|
1300 | case 'local' |
---|
1301 | Series=h_fun(Series); |
---|
1302 | if ~isempty(filexml) |
---|
1303 | t=struct2xml(Series); |
---|
1304 | t=set(t,1,'name','Series'); |
---|
1305 | save(t,filexml); |
---|
1306 | end |
---|
1307 | case 'background' |
---|
1308 | if isempty(filexml) |
---|
1309 | Series=h_fun(Series);% no background in the absence of output file |
---|
1310 | else |
---|
1311 | % update the xml file after interactive input with the function |
---|
1312 | Series.Specific='?'; |
---|
1313 | Series=h_fun(Series); |
---|
1314 | t=struct2xml(Series); |
---|
1315 | t=set(t,1,'name','Series'); |
---|
1316 | save(t,filexml); |
---|
1317 | path_uvmat=fileparts(which('uvmat')); |
---|
1318 | |
---|
1319 | filename_bat=regexprep(filexml,'.xml$','.bat'); |
---|
1320 | [fid,message]=fopen(filename_bat,'w'); |
---|
1321 | if isequal(fid,-1) |
---|
1322 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
1323 | return |
---|
1324 | end |
---|
1325 | path_fct=get(handles.ActionPath,'String'); |
---|
1326 | filelog=regexprep(filexml,'.xml$','.log'); |
---|
1327 | |
---|
1328 | switch computer |
---|
1329 | case {'GLNX86','GLNXA64','MACI64'} |
---|
1330 | text_matlabscript=[... |
---|
1331 | '#!/bin/bash \n'... |
---|
1332 | '. /etc/sysprofile \n'... |
---|
1333 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... |
---|
1334 | 'addpath(''' path_uvmat '''); \n'... |
---|
1335 | 'addpath(''' Series.Action.ActionPath '''); \n'... |
---|
1336 | '' Series.Action.ActionName '( ''' filexml '''); \n'... |
---|
1337 | 'exit \n'... |
---|
1338 | 'END_MATLAB \n']; |
---|
1339 | fprintf(fid,text_matlabscript); |
---|
1340 | fclose(fid); |
---|
1341 | system(['chmod +x ' filename_bat]);% set the file to executable |
---|
1342 | system(['. ' filename_bat ' &']);%execute fct |
---|
1343 | |
---|
1344 | case {'PCWIN','PCWIN64'} |
---|
1345 | text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
1346 | ' -r "addpath(''' regexprep(path_uvmat,'\\','\\\\') ''');'... |
---|
1347 | 'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'... |
---|
1348 | '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
1349 | fprintf(fid,text_matlabscript); |
---|
1350 | fclose(fid); |
---|
1351 | dos([filename_bat ' &']); |
---|
1352 | end |
---|
1353 | end |
---|
1354 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate lounching is finished |
---|
1355 | end |
---|
1356 | |
---|
1357 | set(handles.RUN, 'Enable','On') |
---|
1358 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1359 | |
---|
1360 | %------------------------------------------------------------------------ |
---|
1361 | function STOP_Callback(hObject, eventdata, handles) |
---|
1362 | %------------------------------------------------------------------------ |
---|
1363 | set(handles.RUN, 'BusyAction','cancel') |
---|
1364 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1365 | set(handles.RUN,'enable','on') |
---|
1366 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1367 | % set(handles.BATCH,'enable','on') |
---|
1368 | |
---|
1369 | %------------------------------------------------------------------------ |
---|
1370 | % --- Executes on button press in BATCH. |
---|
1371 | function BATCH_Callback(hObject, eventdata, handles) |
---|
1372 | %------------------------------------------------------------------------ |
---|
1373 | |
---|
1374 | |
---|
1375 | % %------------------------------------------------------------------------ |
---|
1376 | % % --- Executes on button press in BIN. |
---|
1377 | % function BIN_Callback(hObject, eventdata, handles) |
---|
1378 | % %------------------------------------------------------------------------ |
---|
1379 | % cmd=['#!/bin/bash \n '... |
---|
1380 | % '#$ -cwd \n '... |
---|
1381 | % 'hostname && date \n '... |
---|
1382 | % 'umask 002 \n'... |
---|
1383 | % Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; |
---|
1384 | % |
---|
1385 | %------------------------------------------------------------------------ |
---|
1386 | % --- Main launch command, called by RUN and BATCH |
---|
1387 | function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles,run) |
---|
1388 | %INPUT: |
---|
1389 | % handles: handles of graphic objects on the GUI series |
---|
1390 | % run=0, just to display parameters for MenuExport/GUI config |
---|
1391 | % run=1 (default) prepare the computation |
---|
1392 | |
---|
1393 | %------------------------------------------------------------------------ |
---|
1394 | h_fun=[]; |
---|
1395 | filexml=''; |
---|
1396 | errormsg=''; |
---|
1397 | if ~exist('run','var') |
---|
1398 | run=1; |
---|
1399 | end |
---|
1400 | %% Read parameters from series |
---|
1401 | Series=read_GUI(handles.series); |
---|
1402 | if isfield(Series,'Pairs') |
---|
1403 | Series=rmfield(Series,'Pairs'); %info Pairs not needed for output |
---|
1404 | end |
---|
1405 | |
---|
1406 | %% read index ranges |
---|
1407 | first_i=1; |
---|
1408 | last_i=1; |
---|
1409 | incr_i=1; |
---|
1410 | first_j=1; |
---|
1411 | last_j=1; |
---|
1412 | incr_j=1; |
---|
1413 | if isfield(Series.IndexRange,'first_i') |
---|
1414 | first_i=Series.IndexRange.first_i; |
---|
1415 | incr_i=Series.IndexRange.incr_i; |
---|
1416 | last_i=Series.IndexRange.last_i; |
---|
1417 | end |
---|
1418 | if isfield(Series.IndexRange,'first_j') |
---|
1419 | first_j=Series.IndexRange.first_j; |
---|
1420 | incr_j=Series.IndexRange.incr_j; |
---|
1421 | last_j=Series.IndexRange.last_j; |
---|
1422 | end |
---|
1423 | |
---|
1424 | %% read input file parameters and set menus |
---|
1425 | menu_coord_state=get(handles.TransformName,'Visible'); |
---|
1426 | if isequal(menu_coord_state,'on') |
---|
1427 | menu_index=get(handles.TransformName,'Value'); |
---|
1428 | transform_list=get(handles.TransformName,'UserData'); |
---|
1429 | Series.FieldTransform.TransformHandle=transform_list{menu_index};% transform function handles |
---|
1430 | end |
---|
1431 | |
---|
1432 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1433 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1434 | |
---|
1435 | %% projection object |
---|
1436 | if isfield(Series,'CheckObject') |
---|
1437 | if Series.CheckObject |
---|
1438 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
1439 | Series.ProjObject=read_GUI(hset_object); |
---|
1440 | CheckObject_Callback([], [], handles) |
---|
1441 | end |
---|
1442 | else |
---|
1443 | Series.CheckObject=0; |
---|
1444 | end |
---|
1445 | |
---|
1446 | %% get_field GUI |
---|
1447 | if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') |
---|
1448 | if strcmp(Series.InputFields.Field,'get_field...') |
---|
1449 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1450 | Series.GetField=read_GUI(hget_field); |
---|
1451 | end |
---|
1452 | end |
---|
1453 | |
---|
1454 | if ~run |
---|
1455 | return |
---|
1456 | end |
---|
1457 | |
---|
1458 | %% defining the ActionName function handle |
---|
1459 | list_action=get(handles.ActionName,'String');% list menu action |
---|
1460 | index=get(handles.ActionName,'Value'); |
---|
1461 | action= list_action{index}; % selected string |
---|
1462 | %Series.Action=action;%name of the processing programme |
---|
1463 | Series.hseries=handles.series; % handles to the series GUI |
---|
1464 | path_series=which('series'); |
---|
1465 | list_path=get(handles.ActionName,'UserData'); |
---|
1466 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
1467 | if ~isequal(fct_path,path_series) |
---|
1468 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
1469 | if ~exist(fct_path,'dir') |
---|
1470 | errormsg=['The prescribed function path ' fct_path ' does not exist']; |
---|
1471 | return |
---|
1472 | end |
---|
1473 | if ~isequal(spath,fct_path) |
---|
1474 | addpath(fct_path)% add the prescribed path if not the current one |
---|
1475 | end |
---|
1476 | end |
---|
1477 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
1478 | if ~isequal(fct_path,path_series) |
---|
1479 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
1480 | end |
---|
1481 | |
---|
1482 | %% create the output data directory and write in it the xml file from the GUI config |
---|
1483 | %determine the root file corresponding to the first sub dir |
---|
1484 | if isfield(Series,'OutputSubDir') |
---|
1485 | SubDirOut=[Series.OutputSubDir Series.OutputDirExt]; |
---|
1486 | SubDirOutNew=SubDirOut; |
---|
1487 | iview=1; |
---|
1488 | SeriesData=get(handles.series,'UserData'); |
---|
1489 | if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort) |
---|
1490 | [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
1491 | Series.InputTable=Series.InputTable(iview,:); |
---|
1492 | end |
---|
1493 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
1494 | check_create=1; %need to create the result directory by default |
---|
1495 | while detect |
---|
1496 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
1497 | if isequal(answer,'Yes') |
---|
1498 | detect=0; |
---|
1499 | check_create=0; |
---|
1500 | else |
---|
1501 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
1502 | if isempty(r) |
---|
1503 | r(1).root=[SubDirOutNew '_']; |
---|
1504 | r(1).num1='0'; |
---|
1505 | end |
---|
1506 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
1507 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
1508 | check_create=1; |
---|
1509 | end |
---|
1510 | end |
---|
1511 | Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); |
---|
1512 | % Series.OutputSubDir=SubDirOutNew; |
---|
1513 | % Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results |
---|
1514 | Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output |
---|
1515 | set(handles.OutputDirExt,'String',Series.OutputDirExt) |
---|
1516 | % create output directory |
---|
1517 | OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]); |
---|
1518 | if check_create |
---|
1519 | [tild,msg1]=mkdir(OutputDir); |
---|
1520 | if ~strcmp(msg1,'') |
---|
1521 | errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation |
---|
1522 | return |
---|
1523 | end |
---|
1524 | end |
---|
1525 | filexml=fullfile(OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory |
---|
1526 | end |
---|
1527 | %removes redondant information |
---|
1528 | Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); |
---|
1529 | Series.IndexRange=rmfield(Series.IndexRange,'MinIndex'); |
---|
1530 | Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex'); |
---|
1531 | %removes empty lines of InputTable |
---|
1532 | empty_line=zeros(size(Series.InputTable,1),1); |
---|
1533 | for iline=1:size(Series.InputTable,1) |
---|
1534 | empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''}); |
---|
1535 | end |
---|
1536 | Series.InputTable(find(empty_line),:)=[]; |
---|
1537 | |
---|
1538 | %------------------------------------------------------------------------ |
---|
1539 | % --- Executes on selection change in ActionName. |
---|
1540 | function ActionName_Callback(hObject, eventdata, handles) |
---|
1541 | %------------------------------------------------------------------------ |
---|
1542 | global nb_builtin_ACTION |
---|
1543 | list_ACTION=get(handles.ActionName,'String');% list menu fields |
---|
1544 | index_ACTION=get(handles.ActionName,'Value');% selected string index |
---|
1545 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
1546 | path_series=which('series');%path to series.m |
---|
1547 | list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION |
---|
1548 | default_file=fullfile(list_path{end},ACTION); |
---|
1549 | % add a new function to the menu if the selected item is 'more...' |
---|
1550 | if isequal(ACTION,'more...') |
---|
1551 | pathfct=fileparts(path_series); |
---|
1552 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1553 | {'*.m', ' (*.m)'; |
---|
1554 | '*.m', '.m files '; ... |
---|
1555 | '*.*', 'All Files (*.*)'}, ... |
---|
1556 | 'Pick a file',default_file); |
---|
1557 | if length(FileName)<2 |
---|
1558 | return |
---|
1559 | end |
---|
1560 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
1561 | if ~isequal(ext_fct,'.m') |
---|
1562 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1563 | return |
---|
1564 | end |
---|
1565 | |
---|
1566 | % insert the choice in the actionname menu |
---|
1567 | menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed |
---|
1568 | index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list |
---|
1569 | list_path{index_ACTION}=PathName; |
---|
1570 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1571 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
1572 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
1573 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
1574 | index_ACTION=index_ACTION-nbremove; |
---|
1575 | set(handles.ActionName,'Value',index_ACTION) |
---|
1576 | set(handles.ActionName,'String',menu_str) |
---|
1577 | end |
---|
1578 | list_path{index_ACTION}=PathName; |
---|
1579 | set(handles.ActionName,'UserData',list_path); |
---|
1580 | set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1581 | |
---|
1582 | %record the current menu in personal file profil_perso |
---|
1583 | dir_perso=prefdir; |
---|
1584 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1585 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
1586 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
1587 | end |
---|
1588 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
1589 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
1590 | save(profil_perso,'series_fct','-append') |
---|
1591 | else |
---|
1592 | txt=ver('MATLAB'); |
---|
1593 | Release=txt.Release; |
---|
1594 | relnumb=str2num(Release(3:4)); |
---|
1595 | if relnumb >= 14%recent relaese of Matlab |
---|
1596 | save(profil_perso,'series_fct','-V6') |
---|
1597 | else |
---|
1598 | save(profil_perso, 'series_fct') |
---|
1599 | end |
---|
1600 | end |
---|
1601 | end |
---|
1602 | end |
---|
1603 | |
---|
1604 | %check the current ActionPath to the selected function |
---|
1605 | PathName=list_path{index_ACTION};%current recorded path |
---|
1606 | set(handles.ActionPath,'String',PathName); %show the path to the senlected function |
---|
1607 | |
---|
1608 | %reinitialise the waitbar |
---|
1609 | update_waitbar(handles.Waitbar,0) |
---|
1610 | |
---|
1611 | %default setting for the visibility of the GUI elements |
---|
1612 | set(handles.num_NbSlice,'Visible','off') |
---|
1613 | set(handles.NbSlice_title,'Visible','off') |
---|
1614 | set(handles.VelType,'Visible','off'); |
---|
1615 | set(handles.VelType_text,'Visible','off'); |
---|
1616 | set(handles.VelType_1,'Visible','off'); |
---|
1617 | set(handles.VelType_text_1,'Visible','off'); |
---|
1618 | set(handles.InputFields,'Visible','off') |
---|
1619 | set(handles.FieldName_1,'Visible','off') |
---|
1620 | %view_FieldMenu_1(handles,'off') |
---|
1621 | set(handles.FieldTransform,'Visible','off') |
---|
1622 | set(handles.CheckObject,'Visible','off'); |
---|
1623 | set(handles.ProjObject,'Visible','off'); |
---|
1624 | set(handles.CheckMask,'Visible','off') |
---|
1625 | set(handles.Mask,'Visible','off') |
---|
1626 | set(handles.OutputDirExt,'Visible','off') |
---|
1627 | set(handles.OutputSubDir,'Visible','off') |
---|
1628 | set(handles.OutputDir_title,'Visible','off') |
---|
1629 | %set the displayed GUI item needed for input parameters |
---|
1630 | if ~isequal(path_series,PathName) |
---|
1631 | addpath(PathName) |
---|
1632 | end |
---|
1633 | eval(['h_function=@' ACTION ';']); |
---|
1634 | try |
---|
1635 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
1636 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
1637 | fclose(fid) |
---|
1638 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
1639 | end |
---|
1640 | if ~isequal(path_series,PathName) |
---|
1641 | rmpath(PathName) |
---|
1642 | end |
---|
1643 | varargout=h_function(); |
---|
1644 | Param_list={}; |
---|
1645 | |
---|
1646 | InputTable=get(handles.InputTable,'Data'); |
---|
1647 | nbview=size(InputTable,1); |
---|
1648 | SeriesData=get(handles.series,'UserData'); |
---|
1649 | nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType))); |
---|
1650 | nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); |
---|
1651 | for ilist=1:length(varargout)-1 |
---|
1652 | switch varargout{ilist} |
---|
1653 | case 'AllowInputSort' |
---|
1654 | if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir |
---|
1655 | SeriesData.AllowInputSort=1; |
---|
1656 | set(handles.series,'UserData',SeriesData) |
---|
1657 | end |
---|
1658 | case 'WholeIndexRange' |
---|
1659 | if isequal(lower(varargout{ilist+1}),'on')% set by default the input index range from min to max |
---|
1660 | MinIndex=get(handles.MinIndex,'Data'); |
---|
1661 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
1662 | if ~isempty(MinIndex) |
---|
1663 | set(handles.num_first_i,'String',num2str(MinIndex{1})) |
---|
1664 | set(handles.num_last_i,'String',num2str(MaxIndex{1})) |
---|
1665 | set(handles.num_incr_i,'String','1') |
---|
1666 | if size(MinIndex,2)>=2 |
---|
1667 | set(handles.num_first_j,'String',num2str(MinIndex{1,2})) |
---|
1668 | set(handles.num_last_j,'String',num2str(MaxIndex{1,2})) |
---|
1669 | set(handles.num_incr_j,'String','1') |
---|
1670 | end |
---|
1671 | end |
---|
1672 | end |
---|
1673 | case 'NbSlice' %hidden by default |
---|
1674 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1675 | set(handles.num_NbSlice,'Visible','on') |
---|
1676 | set(handles.NbSlice_title,'Visible','on') |
---|
1677 | end |
---|
1678 | case 'VelType' %hidden by default |
---|
1679 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
1680 | if nb_civ>=1 |
---|
1681 | set(handles.VelType,'Visible','on') |
---|
1682 | set(handles.VelType_text,'Visible','on'); |
---|
1683 | end |
---|
1684 | end |
---|
1685 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1686 | if nb_civ>=2 |
---|
1687 | set(handles.VelType_1,'Visible','on') |
---|
1688 | set(handles.VelType_text_1,'Visible','on'); |
---|
1689 | end |
---|
1690 | end |
---|
1691 | case 'FieldName' %hidden by default |
---|
1692 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
1693 | if (nb_civ+nb_netcdf)>=1 |
---|
1694 | set(handles.FieldName,'Visible','on') % test for MenuBorser |
---|
1695 | set(handles.InputFields,'Visible','on') |
---|
1696 | end |
---|
1697 | end |
---|
1698 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1699 | if (nb_civ+nb_netcdf)>=1 |
---|
1700 | set(handles.FieldName_1,'Visible','on') |
---|
1701 | end |
---|
1702 | end |
---|
1703 | case 'FieldTransform' %hidden by default |
---|
1704 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1705 | set(handles.TransformName,'Enable','on') |
---|
1706 | set(handles.FieldTransform,'Visible','on') |
---|
1707 | TransformName_Callback([],[], handles) |
---|
1708 | end |
---|
1709 | case 'ProjObject' %hidden by default |
---|
1710 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1711 | set(handles.CheckObject,'Visible','on') |
---|
1712 | set(handles.ProjObject,'Visible','on') |
---|
1713 | end |
---|
1714 | case 'Mask' %hidden by default |
---|
1715 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1716 | set(handles.Mask,'Visible','on') |
---|
1717 | set(handles.CheckMask,'Visible','on'); |
---|
1718 | end |
---|
1719 | case 'OutputDirExt' |
---|
1720 | if ~isempty(varargout{ilist+1}) |
---|
1721 | set(handles.OutputDirExt,'String',varargout{ilist+1}) |
---|
1722 | set(handles.OutputDirExt,'Visible','on') |
---|
1723 | set(handles.OutputSubDir,'Visible','on') |
---|
1724 | set(handles.OutputDir_title,'Visible','on') |
---|
1725 | end |
---|
1726 | end |
---|
1727 | end |
---|
1728 | if ~isempty(Param_list) |
---|
1729 | set(handles.ParamKey,'String',Param_list) |
---|
1730 | set(handles.ParamVal,'Visible','on') |
---|
1731 | end |
---|
1732 | |
---|
1733 | %------------------------------------------------------------------------ |
---|
1734 | % --- Executes on selection change in FieldName. |
---|
1735 | function FieldName_Callback(hObject, eventdata, handles) |
---|
1736 | %------------------------------------------------------------------------ |
---|
1737 | field_str=get(handles.FieldName,'String'); |
---|
1738 | field_index=get(handles.FieldName,'Value'); |
---|
1739 | field=field_str{field_index(1)}; |
---|
1740 | if isequal(field,'get_field...') |
---|
1741 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1742 | if ~isempty(hget_field) |
---|
1743 | delete(hget_field)%delete opened versions of get_field |
---|
1744 | end |
---|
1745 | filecell=get_file_series(read_GUI(handles.series)); |
---|
1746 | if exist(filecell{1,1},'file') |
---|
1747 | get_field(filecell{1,1}) |
---|
1748 | end |
---|
1749 | elseif isequal(field,'more...') |
---|
1750 | str=calc_field; |
---|
1751 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1752 | 'SelectionMode','single',... |
---|
1753 | 'ListString',str); |
---|
1754 | % edit the choice in the fields and actionname menu |
---|
1755 | scalar=cell2mat(str(ind_answer)); |
---|
1756 | update_menu(handles.FieldName,scalar) |
---|
1757 | end |
---|
1758 | |
---|
1759 | %------------------------------------------------------------------------ |
---|
1760 | % --- Executes on selection change in FieldName_1. |
---|
1761 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
1762 | %------------------------------------------------------------------------ |
---|
1763 | field_str=get(handles.FieldName_1,'String'); |
---|
1764 | field_index=get(handles.FieldName_1,'Value'); |
---|
1765 | field=field_str{field_index}; |
---|
1766 | if isequal(field,'get_field...') |
---|
1767 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
1768 | if ~isempty(hget_field) |
---|
1769 | delete(hget_field) |
---|
1770 | end |
---|
1771 | SeriesData=get(handles.series,'UserData'); |
---|
1772 | filename=SeriesData.CurrentInputFile_1; |
---|
1773 | if exist(filename,'file') |
---|
1774 | hget_field=get_field(filename); |
---|
1775 | set(hget_field,'name','get_field_1') |
---|
1776 | end |
---|
1777 | elseif isequal(field,'more...') |
---|
1778 | str=calc_field; |
---|
1779 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1780 | 'SelectionMode','single',... |
---|
1781 | 'ListString',str); |
---|
1782 | % edit the choice in the fields and actionname menu |
---|
1783 | scalar=cell2mat(str(ind_answer)); |
---|
1784 | update_menu(handles.FieldName_1,scalar) |
---|
1785 | end |
---|
1786 | |
---|
1787 | |
---|
1788 | %%%%%%%%%%%%% |
---|
1789 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
1790 | indsel=ind_i; |
---|
1791 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
1792 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
1793 | if ~isempty(indiff) |
---|
1794 | indiff2=diff(indiff); |
---|
1795 | indiffp=[indiff2 1]; |
---|
1796 | indiffm=[1 indiff2]; |
---|
1797 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
1798 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
1799 | %for each multiplet, select the most recent file |
---|
1800 | ind_remove=[]; |
---|
1801 | for i=1:length(ind_multi_m) |
---|
1802 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
1803 | for imulti=1:length(ind_pairs) |
---|
1804 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
1805 | end |
---|
1806 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
1807 | ind_s=indsort2(1:end-1);% |
---|
1808 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
1809 | end |
---|
1810 | end |
---|
1811 | |
---|
1812 | %------------------------------------------------------------------------ |
---|
1813 | % --- determine the list of index pairstring of processing file |
---|
1814 | 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) |
---|
1815 | %------------------------------------------------------------------------ |
---|
1816 | num_i1=num_i;% set of first image numbers by default |
---|
1817 | num_i2=num_i; |
---|
1818 | num_j1=num_j; |
---|
1819 | num_j2=num_j; |
---|
1820 | num_i_out=num_i; |
---|
1821 | num_j_out=num_j; |
---|
1822 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
1823 | if isequal(mode,'series(Di)') |
---|
1824 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
1825 | num_i2_line=num_i+ind_shift(4); |
---|
1826 | % adjust the first and last field number |
---|
1827 | indsel=find(num_i1_line >= 1); |
---|
1828 | num_i_out=num_i(indsel); |
---|
1829 | num_i1_line=num_i1_line(indsel); |
---|
1830 | num_i2_line=num_i2_line(indsel); |
---|
1831 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1832 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1833 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
1834 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
1835 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
1836 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
1837 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
1838 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
1839 | else |
---|
1840 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
1841 | num_j2_col=num_j+ind_shift(2); |
---|
1842 | % adjust the first field number |
---|
1843 | indsel=find((num_j1_col >= 1)); |
---|
1844 | num_j_out=num_j(indsel); |
---|
1845 | num_j1_col=num_j1_col(indsel); |
---|
1846 | num_j2_col=num_j2_col(indsel); |
---|
1847 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
1848 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
1849 | end |
---|
1850 | end |
---|
1851 | |
---|
1852 | %------------------------------------------------------------------------ |
---|
1853 | % --- Executes on button press in CheckObject. |
---|
1854 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
1855 | %------------------------------------------------------------------------ |
---|
1856 | % SeriesData=get(handles.series,'UserData'); |
---|
1857 | value=get(handles.CheckObject,'Value'); |
---|
1858 | if value |
---|
1859 | set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
1860 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
1861 | if ishandle(hset_object) |
---|
1862 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
1863 | else |
---|
1864 | %get the object file |
---|
1865 | InputTable=get(handles.InputTable,'Data'); |
---|
1866 | defaultname=InputTable{1,1}; |
---|
1867 | if isempty(defaultname) |
---|
1868 | defaultname={''}; |
---|
1869 | end |
---|
1870 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1871 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
1872 | '*.xml', '.xml files '; ... |
---|
1873 | '*.mat', '.mat matlab files '}, ... |
---|
1874 | 'Pick an xml object file (or use uvmat to create it)',defaultname); |
---|
1875 | fileinput=[PathName FileName];%complete file name |
---|
1876 | sizf=size(fileinput); |
---|
1877 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
1878 | %read the file |
---|
1879 | data=xml2struct(fileinput); |
---|
1880 | if ~isfield(data,'Type') |
---|
1881 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
1882 | return |
---|
1883 | end |
---|
1884 | if ~isfield(data,'ProjMode') |
---|
1885 | data.ProjMode='none'; |
---|
1886 | end |
---|
1887 | hset_object=set_object(data);% call the set_object interface |
---|
1888 | end |
---|
1889 | Object=read_GUI(hset_object); |
---|
1890 | set(handles.ProjObject,'String',Object.Name);%display the object name |
---|
1891 | else |
---|
1892 | set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
1893 | end |
---|
1894 | %set(handles.series,'UserData',SeriesData) |
---|
1895 | |
---|
1896 | %-------------------------------------------------------------- |
---|
1897 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1898 | value=get(handles.CheckMask,'Value'); |
---|
1899 | if value |
---|
1900 | msgbox_uvmat('ERROR','not implemented yet') |
---|
1901 | end |
---|
1902 | %-------------------------------------------------------------- |
---|
1903 | |
---|
1904 | %------------------------------------------------------------------- |
---|
1905 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
1906 | function ncbrowser_uvmat(hObject, eventdata) |
---|
1907 | %------------------------------------------------------------------- |
---|
1908 | bla=get(gcbo,'String'); |
---|
1909 | ind=get(gcbo,'Value'); |
---|
1910 | filename=cell2mat(bla(ind)); |
---|
1911 | blank=find(filename==' '); |
---|
1912 | filename=filename(1:blank-1); |
---|
1913 | get_field(filename) |
---|
1914 | |
---|
1915 | % ------------------------------------------------------------------ |
---|
1916 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
1917 | %------------------------------------------------------------------- |
---|
1918 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
1919 | pathelp=fileparts(path_to_uvmat); |
---|
1920 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
1921 | 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') |
---|
1922 | else |
---|
1923 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
1924 | web([helpfile '#series']) |
---|
1925 | end |
---|
1926 | |
---|
1927 | %------------------------------------------------------------------- |
---|
1928 | % --- Executes on selection change in TransformName. |
---|
1929 | function TransformName_Callback(hObject, eventdata, handles) |
---|
1930 | %------------------------------------------------------------------- |
---|
1931 | global nb_transform |
---|
1932 | |
---|
1933 | menu=get(handles.TransformName,'String'); |
---|
1934 | ind_coord=get(handles.TransformName,'Value'); |
---|
1935 | coord_option=menu{ind_coord}; |
---|
1936 | list_transform=get(handles.TransformName,'UserData'); |
---|
1937 | ff=functions(list_transform{end}); |
---|
1938 | if isequal(coord_option,'more...'); |
---|
1939 | coord_fct=''; |
---|
1940 | prompt = {'Enter the name of the transform function'}; |
---|
1941 | dlg_title = 'user defined transform'; |
---|
1942 | num_lines= 1; |
---|
1943 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1944 | {'*.m', ' (*.m)'; |
---|
1945 | '*.m', '.m files '; ... |
---|
1946 | '*.*', 'All Files (*.*)'}, ... |
---|
1947 | 'Pick a file', ff.file); |
---|
1948 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
1949 | PathName(end)=[]; |
---|
1950 | end |
---|
1951 | transform_selected =fullfile(PathName,FileName); |
---|
1952 | if ~exist(transform_selected,'file') |
---|
1953 | return |
---|
1954 | end |
---|
1955 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
1956 | if ~isequal(ext_fct,'.m') |
---|
1957 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1958 | return |
---|
1959 | end |
---|
1960 | menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu |
---|
1961 | ind_coord=get(handles.TransformName,'Value'); |
---|
1962 | addpath(PathName) |
---|
1963 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
1964 | set(handles.TransformName,'UserData',list_transform) |
---|
1965 | rmpath(PathName) |
---|
1966 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
1967 | dir_perso=prefdir;%personal Matalb directory |
---|
1968 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1969 | if exist(profil_perso,'file') |
---|
1970 | for ilist=nb_transform+1:numel(list_transform) |
---|
1971 | ff=functions(list_transform{ilist}); |
---|
1972 | transform_fct{ilist-nb_transform}=ff.file; |
---|
1973 | end |
---|
1974 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
1975 | end |
---|
1976 | end |
---|
1977 | |
---|
1978 | %check the current ActionPath to the selected function |
---|
1979 | if ~isempty(list_transform{ind_coord}) |
---|
1980 | func=functions(list_transform{ind_coord}); |
---|
1981 | set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function |
---|
1982 | else |
---|
1983 | set(handles.TransformPath,'String',''); %show the path to the senlected function |
---|
1984 | end |
---|
1985 | |
---|
1986 | |
---|
1987 | |
---|
1988 | % -------------------------------------------------------------------- |
---|
1989 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
1990 | global Series |
---|
1991 | [tild,Series,errormsg]=prepare_jobs(handles,0); |
---|
1992 | % Series=read_GUI(handles.series); |
---|
1993 | |
---|
1994 | evalin('base','global Series')%make CurData global in the workspace |
---|
1995 | display('current series config :') |
---|
1996 | evalin('base','Series') %display CurData in the workspace |
---|
1997 | commandwindow; %brings the Matlab command window to the front |
---|
1998 | |
---|
1999 | |
---|
2000 | % --- Executes on selection change in RunMode. |
---|
2001 | function RunMode_Callback(hObject, eventdata, handles) |
---|
2002 | |
---|
2003 | % --- Executes on selection change in Coord_x. |
---|
2004 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
2005 | |
---|
2006 | |
---|
2007 | % --- Executes on selection change in Coord_y. |
---|
2008 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
2009 | |
---|
2010 | |
---|
2011 | |
---|
2012 | % --- Executes when series is resized. |
---|
2013 | function series_ResizeFcn(hObject, eventdata, handles) |
---|
2014 | %% input table |
---|
2015 | set(handles.InputTable,'Unit','pixel') |
---|
2016 | Pos=get(handles.InputTable,'Position'); |
---|
2017 | set(handles.InputTable,'Unit','normalized') |
---|
2018 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52)); |
---|
2019 | ColumnWidth=num2cell(ColumnWidth); |
---|
2020 | set(handles.InputTable,'ColumnWidth',ColumnWidth) |
---|
2021 | |
---|
2022 | %% MinIndex and MaxIndex |
---|
2023 | set(handles.MinIndex,'Unit','pixel') |
---|
2024 | Pos=get(handles.MinIndex,'Position'); |
---|
2025 | set(handles.MinIndex,'Unit','normalized') |
---|
2026 | ColumnWidth=get(handles.MinIndex,'ColumnWidth'); |
---|
2027 | if numel(ColumnWidth)==2 |
---|
2028 | ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20))); |
---|
2029 | else |
---|
2030 | ColumnWidth={Pos(3)-5}; |
---|
2031 | end |
---|
2032 | set(handles.MinIndex,'ColumnWidth',ColumnWidth) |
---|
2033 | set(handles.MaxIndex,'ColumnWidth',ColumnWidth) |
---|
2034 | |
---|
2035 | %% TimeTable |
---|
2036 | set(handles.TimeTable,'Unit','pixel') |
---|
2037 | Pos=get(handles.TimeTable,'Position'); |
---|
2038 | set(handles.TimeTable,'Unit','normalized') |
---|
2039 | ColumnWidth=get(handles.TimeTable,'ColumnWidth'); |
---|
2040 | ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20))); |
---|
2041 | set(handles.TimeTable,'ColumnWidth',ColumnWidth) |
---|
2042 | |
---|
2043 | |
---|
2044 | %% PairString |
---|
2045 | set(handles.PairString,'Unit','pixel') |
---|
2046 | Pos=get(handles.PairString,'Position'); |
---|
2047 | set(handles.PairString,'Unit','normalized') |
---|
2048 | set(handles.PairString,'ColumnWidth',{Pos(3)-5}) |
---|