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 |
|
---|
17 | %=======================================================================
|
---|
18 | % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
---|
19 | % http://www.legi.grenoble-inp.fr
|
---|
20 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
21 | %
|
---|
22 | % This file is part of the toolbox UVMAT.
|
---|
23 | %
|
---|
24 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
25 | % it under the terms of the GNU General Public License as published
|
---|
26 | % by the Free Software Foundation; either version 2 of the license,
|
---|
27 | % or (at your option) any later version.
|
---|
28 | %
|
---|
29 | % UVMAT is distributed in the hope that it will be useful,
|
---|
30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
32 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
33 | %=======================================================================
|
---|
34 |
|
---|
35 | %------------------------------------------------------------------------
|
---|
36 | %------------------------------------------------------------------------
|
---|
37 | % I - MAIN FUNCTION series
|
---|
38 | %------------------------------------------------------------------------
|
---|
39 | %------------------------------------------------------------------------
|
---|
40 | function varargout = series(varargin)
|
---|
41 |
|
---|
42 | % Begin initialization code - DO NOT EDIT
|
---|
43 | gui_Singleton = 1;
|
---|
44 | gui_State = struct('gui_Name', mfilename, ...
|
---|
45 | 'gui_Singleton', gui_Singleton, ...
|
---|
46 | 'gui_OpeningFcn', @series_OpeningFcn, ...
|
---|
47 | 'gui_OutputFcn', @series_OutputFcn, ...
|
---|
48 | 'gui_LayoutFcn', [] , ...
|
---|
49 | 'gui_Callback', []);
|
---|
50 | if nargin && ischar(varargin{1})
|
---|
51 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
52 | end
|
---|
53 |
|
---|
54 | if nargout
|
---|
55 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
56 | else
|
---|
57 | gui_mainfcn(gui_State, varargin{:});
|
---|
58 | end
|
---|
59 | % End initialization code - DO NOT EDIT
|
---|
60 |
|
---|
61 | %--------------------------------------------------------------------------
|
---|
62 | % --- Executes just before series is made visible.
|
---|
63 | %--------------------------------------------------------------------------
|
---|
64 | function series_OpeningFcn(hObject, eventdata, handles,Param)
|
---|
65 |
|
---|
66 | % Choose default command line output for series
|
---|
67 | handles.output = hObject;
|
---|
68 | % Update handles structure
|
---|
69 | guidata(hObject, handles);
|
---|
70 |
|
---|
71 | %% initial settings
|
---|
72 | % position and size of the GUI at opening
|
---|
73 | set(0,'Unit','points')
|
---|
74 | ScreenSize=get(0,'ScreenSize');%size of the current screen, in points (1/72 inch)
|
---|
75 | Width=900;% prefered width of the GUI in points (1/72 inch)
|
---|
76 | Height=624;% prefered height of the GUI in points (1/72 inch)
|
---|
77 | %adjust to screen size (reduced by a min margin)
|
---|
78 | RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
|
---|
79 | if RescaleFactor>1
|
---|
80 | RescaleFactor=min(RescaleFactor,1);
|
---|
81 | end
|
---|
82 | Width=Width*RescaleFactor;
|
---|
83 | Height=Height*RescaleFactor;
|
---|
84 | LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin)
|
---|
85 | LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
|
---|
86 | set(hObject,'Units','points')
|
---|
87 | set(hObject,'Position',[LeftX LowY Width Height])% position and size of the GUI at opening
|
---|
88 |
|
---|
89 | % settings of table MinIndex_j
|
---|
90 | set(handles.MinIndex_i,'ColumnFormat',{'numeric'})
|
---|
91 | set(handles.MinIndex_i,'ColumnEditable',false)
|
---|
92 | set(handles.MinIndex_i,'ColumnName',{'i min'})
|
---|
93 | set(handles.MinIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
94 |
|
---|
95 | % settings of table MinIndex_j
|
---|
96 | set(handles.MinIndex_j,'ColumnFormat',{'numeric'})
|
---|
97 | set(handles.MinIndex_j,'ColumnEditable',false)
|
---|
98 | set(handles.MinIndex_j,'ColumnName',{'j min'})
|
---|
99 | set(handles.MinIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
100 |
|
---|
101 | % settings of table MaxIndex_i
|
---|
102 | set(handles.MaxIndex_i,'ColumnFormat',{'numeric'})
|
---|
103 | set(handles.MaxIndex_i,'ColumnEditable',false)
|
---|
104 | set(handles.MaxIndex_i,'ColumnName',{'i max'})
|
---|
105 | set(handles.MaxIndex_i,'Data',[])% initiate Data to double (not cell)
|
---|
106 |
|
---|
107 | % settings of table MaxIndex_j
|
---|
108 | set(handles.MaxIndex_j,'ColumnFormat',{'numeric'})
|
---|
109 | set(handles.MaxIndex_j,'ColumnEditable',false)
|
---|
110 | set(handles.MaxIndex_j,'ColumnName',{'j max'})
|
---|
111 | set(handles.MaxIndex_j,'Data',[])% initiate Data to double (not cell)
|
---|
112 |
|
---|
113 | % settings of table PairString
|
---|
114 | set(handles.PairString,'ColumnName',{'pairs'})
|
---|
115 | set(handles.PairString,'ColumnEditable',false)
|
---|
116 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
117 | set(handles.PairString,'Data',{''})
|
---|
118 |
|
---|
119 | % settings of table MaskTable
|
---|
120 | set(handles.MaskTable,'ColumnName',{'mask name'})
|
---|
121 | set(handles.PairString,'ColumnEditable',false)
|
---|
122 | set(handles.PairString,'ColumnFormat',{'char'})
|
---|
123 | set(handles.PairString,'Data',{''})
|
---|
124 |
|
---|
125 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
|
---|
126 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
|
---|
127 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
128 |
|
---|
129 | % check default input data
|
---|
130 | if ~exist('Param','var')
|
---|
131 | Param=[]; %default
|
---|
132 | end
|
---|
133 |
|
---|
134 | %% list of builtin functions in the mebu ActionName
|
---|
135 | ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
|
---|
136 | NbBuiltinAction=numel(ActionList);
|
---|
137 | set(handles.Action,'UserData',NbBuiltinAction)
|
---|
138 | [path_series,name,ext]=fileparts(which('series'));% path to the GUI series
|
---|
139 | path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
|
---|
140 | [code, message] = system...
|
---|
141 | ('LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') |... [s for s in p if ''matlab'' not in s] | '':''.join(p)") python -c "import fluiddyn"');
|
---|
142 | if code==0
|
---|
143 | ActionExtList={'.m';'.sh';'.py (in dev.)'};% default choice of extensions (Matlab fct .m or compiled version .sh
|
---|
144 | else
|
---|
145 | ActionExtList={'.m';'.sh'}; % python options not installed
|
---|
146 | end
|
---|
147 | ActionPathList=cell(NbBuiltinAction,1);%initiate the cell matrix of Action fct paths
|
---|
148 | ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members
|
---|
149 | RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh)
|
---|
150 | [s,w]=system('oarstat');% look for cluster system 'oar'
|
---|
151 | if isequal(s,0)
|
---|
152 | RunModeList=[RunModeList;{'cluster_oar'}];
|
---|
153 | set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika
|
---|
154 | set(handles.num_CPUTime,'Visible','on'); % make visible button for access to Monika
|
---|
155 | set(handles.CPUTime_txt,'Visible','on'); % make visible button for access to Monika
|
---|
156 | end
|
---|
157 | [s,w]=system('qstat --version');% look for cluster system 'sge'
|
---|
158 | if isequal(s,0)
|
---|
159 | if regexp(w,'^pbs')
|
---|
160 | RunModeList=[RunModeList;{'cluster_pbs'}];
|
---|
161 | else
|
---|
162 | RunModeList=[RunModeList;{'cluster_sge'}];
|
---|
163 | end
|
---|
164 | end
|
---|
165 | set(handles.RunMode,'String',RunModeList)
|
---|
166 |
|
---|
167 | %% list of builtin transform functions in the menu TransformName
|
---|
168 | TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback
|
---|
169 | NbBuiltinTransform=numel(TransformList);
|
---|
170 | path_transform_fct=fullfile(path_series,'transform_field');
|
---|
171 | TransformPathList=cell(NbBuiltinTransform,1);%initiate the cell matrix of Action fct paths
|
---|
172 | TransformPathList(:)={path_transform_fct}; %set the default path to series fcts to all list members
|
---|
173 |
|
---|
174 | %% get the user defined functions stored in the personal file uvmat_perso.mat
|
---|
175 | dir_perso=prefdir;
|
---|
176 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
177 | if exist(profil_perso,'file')
|
---|
178 | h=load (profil_perso);
|
---|
179 | %get the list of previous input files in the upper bar menu Open
|
---|
180 | if isfield(h,'MenuFile')
|
---|
181 | for ifile=1:min(length(h.MenuFile),5)
|
---|
182 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
|
---|
183 | set(handles.(['MenuFile_' num2str(ifile+5)]),'Label',h.MenuFile{ifile});
|
---|
184 | end
|
---|
185 | end
|
---|
186 | %get the list of previous campaigns in the upper bar menu Open campaign
|
---|
187 | if isfield(h,'MenuCampaign')
|
---|
188 | for ifile=1:min(length(h.MenuCampaign),5)
|
---|
189 | set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile});
|
---|
190 | end
|
---|
191 | end
|
---|
192 | %get the menu of actions
|
---|
193 | % if isfield(h,'ActionExtListUser') && iscell(h.ActionExtListUser)
|
---|
194 | % ActionExtList=[ActionExtList; h.ActionExtListUser];
|
---|
195 | % end
|
---|
196 | if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser)
|
---|
197 | ActionList=[ActionList;h.ActionListUser];
|
---|
198 | ActionPathList=[ActionPathList;h.ActionPathListUser(:,1)];
|
---|
199 | end
|
---|
200 | %get the menu of transform fct
|
---|
201 | if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser)
|
---|
202 | TransformList=[TransformList;h.TransformListUser];
|
---|
203 | TransformPathList=[TransformPathList;h.TransformPathListUser];
|
---|
204 | end
|
---|
205 | end
|
---|
206 |
|
---|
207 | %% selection of the input Action fct
|
---|
208 | ActionCheckExist=true(size(ActionList));%initiate the check of the path to the listed action fct
|
---|
209 | for ilist=NbBuiltinAction+1:numel(ActionList)%check the validity of the path of the user defined Action fct
|
---|
210 | ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file');
|
---|
211 | end
|
---|
212 | ActionPathList=ActionPathList(ActionCheckExist,:);% suppress the menu options which are not valid anymore
|
---|
213 | ActionList=ActionList(ActionCheckExist);
|
---|
214 | set(handles.ActionName,'String',[ActionList;{'more...'}])
|
---|
215 | set(handles.ActionName,'UserData',ActionPathList)
|
---|
216 | ActionIndex=[];
|
---|
217 | if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat
|
---|
218 | ActionIndex=find(strcmp(Param.ActionName,ActionList),1);
|
---|
219 | end
|
---|
220 | if isempty(ActionIndex)
|
---|
221 | ActionIndex=1;
|
---|
222 | end
|
---|
223 | set(handles.ActionName,'Value',ActionIndex)
|
---|
224 | set(handles.ActionPath,'String',ActionPathList{ActionIndex})
|
---|
225 | set(handles.ActionExt,'Value',1)
|
---|
226 | set(handles.ActionExt,'String',ActionExtList)
|
---|
227 |
|
---|
228 | %% selection of the input transform fct
|
---|
229 | TransformCheckExist=true(size(TransformList));
|
---|
230 | for ilist=NbBuiltinTransform+1:numel(TransformList)
|
---|
231 | TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file');
|
---|
232 | end
|
---|
233 | TransformPathList=TransformPathList(TransformCheckExist);
|
---|
234 | TransformList=TransformList(TransformCheckExist);
|
---|
235 | set(handles.TransformName,'String',[TransformList;{'more...'}])
|
---|
236 | set(handles.TransformName,'UserData',TransformPathList)
|
---|
237 | TransformIndex=[];
|
---|
238 | if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat
|
---|
239 | TransformIndex=find(strcmp(Param.TransformName,TransformList),1);
|
---|
240 | end
|
---|
241 | if isempty(TransformIndex)
|
---|
242 | TransformIndex=1;
|
---|
243 | end
|
---|
244 | set(handles.TransformName,'Value',TransformIndex)
|
---|
245 | set(handles.TransformPath,'String',TransformPathList{TransformIndex})
|
---|
246 |
|
---|
247 | %% fields input initialisation
|
---|
248 | if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields)
|
---|
249 | set(handles.FieldName,'String',Param.list_fields);% list menu fields
|
---|
250 | set(handles.FieldName,'Value',Param.index_fields);% selected string index
|
---|
251 | end
|
---|
252 | if isfield(Param,'Coordinates')
|
---|
253 | if isfield(Param.Coordinates,'Coord_x')
|
---|
254 | set(handles.Coord_x,'String',Param.Coordinates.Coord_x)
|
---|
255 | end
|
---|
256 | if isfield(Param.Coordinates,'Coord_y')
|
---|
257 | set(handles.Coord_y,'String',Param.Coordinates.Coord_y)
|
---|
258 | end
|
---|
259 | if isfield(Param.Coordinates,'Coord_z')
|
---|
260 | set(handles.Coord_z,'String',Param.Coordinates.Coord_z)
|
---|
261 | end
|
---|
262 | end
|
---|
263 | % if isfield(Param,'Coord_x_str') && ischar(Param.Coord_x_str)
|
---|
264 | % set(handles.Coord_x,'String',Param.Coord_x_str);% list menu fields
|
---|
265 | % end
|
---|
266 | % if isfield(Param,'Coord_y_str')&& ischar(Param.Coord_y_str)
|
---|
267 | % set(handles.Coord_y,'String',Param.Coord_y_str);% list menu fields
|
---|
268 | % end
|
---|
269 |
|
---|
270 | %% introduce the input file name(s) if defined from input Param,
|
---|
271 | set(handles.series,'UserData',[])% initiate Userdata
|
---|
272 | if isfield(Param,'InputFile')
|
---|
273 |
|
---|
274 | %% fill the list of file series
|
---|
275 | InputTable=[{Param.InputFile.RootPath},{Param.InputFile.SubDir},{Param.InputFile.RootFile},{Param.InputFile.NomType},{Param.InputFile.FileExt}];
|
---|
276 | if isempty(find(cellfun('isempty',InputTable)==0));% if there is no input file, do not introduce input info
|
---|
277 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
278 | return
|
---|
279 | end
|
---|
280 | TimeTable=[{Param.InputFile.TimeName},{[]},{[]},{[]},{[]}];
|
---|
281 | if isfield(Param.InputFile,'RootPath_1')
|
---|
282 | InputTable=[InputTable;[{Param.InputFile.RootPath_1},{Param.InputFile.SubDir_1},{Param.InputFile.RootFile_1},{Param.InputFile.NomType_1},{Param.InputFile.FileExt_1}]];
|
---|
283 | TimeTable=[TimeTable; [{Param.InputFile.TimeName_1},{[]},{[]},{[]},{[]}]];
|
---|
284 | end
|
---|
285 | set(handles.InputTable,'Data',InputTable)
|
---|
286 | %% determine the selected reference field indices for pair display
|
---|
287 |
|
---|
288 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(Param.InputFile.FileIndex);
|
---|
289 | if isempty(i1)
|
---|
290 | i1=1;
|
---|
291 | end
|
---|
292 | if isempty(i2)
|
---|
293 | i2=i1;
|
---|
294 | end
|
---|
295 | ref_i=floor((i1+i2)/2);% reference image number corresponding to the file
|
---|
296 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
297 | if isempty(j1)
|
---|
298 | j1=1;
|
---|
299 | end
|
---|
300 | if isempty(j2)
|
---|
301 | j2=j1;
|
---|
302 | end
|
---|
303 | ref_j=floor((j1+j2)/2);% reference image number corresponding to the file
|
---|
304 | SeriesData.ref_i=ref_i;
|
---|
305 | SeriesData.ref_j=ref_j;
|
---|
306 | set(handles.series,'UserData',SeriesData)
|
---|
307 | update_rootinfo(handles,Param.HiddenData.i1_series{1},Param.HiddenData.i2_series{1},Param.HiddenData.j1_series{1},Param.HiddenData.j2_series{1},...
|
---|
308 | Param.HiddenData.FileInfo{1},Param.HiddenData.MovieObject{1},1)
|
---|
309 | if isfield(Param,'FileName_1')
|
---|
310 | % display_file_name(handles,Param,2)
|
---|
311 | update_rootinfo(handles,Param.HiddenData.i1_series{2},Param.HiddenData.i2_series{2},Param.HiddenData.j1_series{2},Param.HiddenData.j2_series{2},...
|
---|
312 | Param.HiddenData.FileInfo{2},Param.HiddenData.MovieObject{2},2)
|
---|
313 | end
|
---|
314 | %% enable field and veltype menus, in accordance with the current action
|
---|
315 | ActionName_Callback([],[], handles)
|
---|
316 |
|
---|
317 | %% set length of waitbar
|
---|
318 | displ_time(handles)
|
---|
319 |
|
---|
320 | else
|
---|
321 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
322 | end
|
---|
323 | if isfield(Param,'incr_i')
|
---|
324 | set(handles.num_incr_i,'String',num2str(Param.incr_i))
|
---|
325 | else
|
---|
326 | set(handles.num_incr_i,'String','1')
|
---|
327 | end
|
---|
328 | if isfield(Param,'incr_j')
|
---|
329 | set(handles.num_incr_j,'String',num2str(Param.incr_j))
|
---|
330 | else
|
---|
331 | set(handles.num_incr_j,'String','1')
|
---|
332 | end
|
---|
333 |
|
---|
334 | %------------------------------------------------------------------------
|
---|
335 | % --- Outputs from this function are returned to the command line.
|
---|
336 | function varargout = series_OutputFcn(hObject, eventdata, handles)
|
---|
337 | %------------------------------------------------------------------------
|
---|
338 | varargout{1} = handles.output;
|
---|
339 |
|
---|
340 | %------------------------------------------------------------------------
|
---|
341 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist
|
---|
342 | function closefcn(gcbo,eventdata)
|
---|
343 | %------------------------------------------------------------------------
|
---|
344 |
|
---|
345 | % delete set_object_series if detected
|
---|
346 | hh=findobj(allchild(0),'name','view_object_series');
|
---|
347 | if ~isempty(hh)
|
---|
348 | delete(hh)
|
---|
349 | end
|
---|
350 | hh=findobj(allchild(0),'name','edit_object_series');
|
---|
351 | if ~isempty(hh)
|
---|
352 | delete(hh)
|
---|
353 | end
|
---|
354 |
|
---|
355 | %delete the bowser if detected
|
---|
356 | hh=findobj(allchild(0),'tag','browser');
|
---|
357 | if ~isempty(hh)
|
---|
358 | delete(hh)
|
---|
359 | end
|
---|
360 |
|
---|
361 |
|
---|
362 | %------------------------------------------------------------------------
|
---|
363 | %------------------------------------------------------------------------
|
---|
364 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
365 | % automatically sets the global properties when the rootfile name is introduced
|
---|
366 | % then activate the view-field actionname if selected
|
---|
367 | % it is activated either by clicking on the RootPath window or by the
|
---|
368 | % browser
|
---|
369 | %------------------------------------------------------------------------
|
---|
370 | %------------------------------------------------------------------------
|
---|
371 | % --- fct activated by the browser under 'Open'
|
---|
372 | %------------------------------------------------------------------------
|
---|
373 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
374 | %% look for the previously opened file 'oldfile'
|
---|
375 | InputTable=get(handles.InputTable,'Data');
|
---|
376 | oldfile=InputTable{1,1};
|
---|
377 | if isempty(oldfile)
|
---|
378 | % use a file name stored in prefdir
|
---|
379 | dir_perso=prefdir;
|
---|
380 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
381 | if exist(profil_perso,'file')
|
---|
382 | h=load (profil_perso);
|
---|
383 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
384 | oldfile=h.RootPath;
|
---|
385 | end
|
---|
386 | end
|
---|
387 | end
|
---|
388 | %% launch the browser
|
---|
389 | fileinput=uigetfile_uvmat('pick an input file in the series',oldfile);
|
---|
390 | hh=dir(fileinput);
|
---|
391 | if numel(hh)>1
|
---|
392 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
393 | else
|
---|
394 | if ~isempty(fileinput)
|
---|
395 | display_file_name(handles,fileinput,'one')
|
---|
396 | end
|
---|
397 | end
|
---|
398 |
|
---|
399 | % --------------------------------------------------------------------
|
---|
400 | function MenuBrowseAppend_Callback(hObject, eventdata, handles)
|
---|
401 |
|
---|
402 | %% look for the previously opened file 'oldfile'
|
---|
403 | InputTable=get(handles.InputTable,'Data');
|
---|
404 | RootPathCell=InputTable(:,1);
|
---|
405 | if isempty(RootPathCell{1})% no input file in the table
|
---|
406 | MenuBrowse_Callback(hObject, eventdata, handles)%refresh the input table, not append
|
---|
407 | return
|
---|
408 | end
|
---|
409 | SubDirCell=InputTable(:,2);
|
---|
410 | oldfile=fullfile(RootPathCell{1},SubDirCell{1});
|
---|
411 |
|
---|
412 | %% use a file name stored in prefdir
|
---|
413 | dir_perso=prefdir;
|
---|
414 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
415 | if exist(profil_perso,'file')
|
---|
416 | h=load (profil_perso);
|
---|
417 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
418 | oldfile=h.RootPath;
|
---|
419 | end
|
---|
420 | end
|
---|
421 |
|
---|
422 | %% launch the browser
|
---|
423 | fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
|
---|
424 | hh=dir(fileinput);
|
---|
425 | if numel(hh)>1
|
---|
426 | msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
427 | else
|
---|
428 | if ~isempty(fileinput)
|
---|
429 | display_file_name(handles,fileinput,'append')
|
---|
430 | end
|
---|
431 | end
|
---|
432 |
|
---|
433 | %------------------------------------------------------------------------
|
---|
434 | % --- fct activated by selecting a previous file under the menu Open
|
---|
435 | %------------------------------------------------------------------------
|
---|
436 | function MenuFile_Callback(hObject, eventdata, handles)
|
---|
437 |
|
---|
438 | errormsg=display_file_name(handles,get(hObject,'Label'),'one');
|
---|
439 | if ~isempty(errormsg)
|
---|
440 | set(hObject,'Label','')
|
---|
441 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
442 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
443 | str_find=strcmp(get(hObject,'Label'),MenuFile);
|
---|
444 | MenuFile(str_find)=[];% suppress the input file to the list
|
---|
445 | for ifile=1:numel(MenuFile)
|
---|
446 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
|
---|
447 | end
|
---|
448 | end
|
---|
449 |
|
---|
450 | %------------------------------------------------------------------------
|
---|
451 | % --- fct activated by selecting a previous file under the menu Open/append
|
---|
452 | %------------------------------------------------------------------------
|
---|
453 | function MenuFile_append_Callback(hObject, eventdata, handles)
|
---|
454 |
|
---|
455 | InputTable=get(handles.InputTable,'Data');
|
---|
456 | if isempty(InputTable{1,1})% no input file in the table
|
---|
457 | display_file_name(handles,get(hObject,'Label'),'one') %refresh the input table, not append
|
---|
458 | else
|
---|
459 | display_file_name(handles,get(hObject,'Label'),'append')% append the selected file to the current list of InputTable
|
---|
460 | end
|
---|
461 |
|
---|
462 | %------------------------------------------------------------------------
|
---|
463 | % --- fct activated by the browser under 'Open campaign/Browse...'
|
---|
464 | %------------------------------------------------------------------------
|
---|
465 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
|
---|
466 |
|
---|
467 | %% look for the previously opened file 'oldfile'
|
---|
468 | InputTable=get(handles.InputTable,'Data');
|
---|
469 | RootPathCell=InputTable(:,1);
|
---|
470 | SubDirCell=InputTable(:,2);
|
---|
471 | oldfile=fullfile(InputTable{1,1},InputTable{1,2});
|
---|
472 | if isempty(oldfile)
|
---|
473 | % use a file name stored in prefdir
|
---|
474 | dir_perso=prefdir;
|
---|
475 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
476 | if exist(profil_perso,'file')
|
---|
477 | h=load (profil_perso);
|
---|
478 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
479 | oldfile=h.RootPath;
|
---|
480 | end
|
---|
481 | end
|
---|
482 | end
|
---|
483 |
|
---|
484 | OutPut=browse_data(oldfile,'on','on');% open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
485 | NbLines=numel(OutPut.Experiment)*numel(OutPut.DataSeries);
|
---|
486 | icount=0;
|
---|
487 | for iexp=1:numel(OutPut.Experiment)
|
---|
488 | for idevice=1:numel(OutPut.DataSeries)
|
---|
489 | icount=icount+1;
|
---|
490 | InputTable{icount,1}=fullfile(OutPut.Campaign,OutPut.Experiment{iexp});
|
---|
491 | InputTable{icount,2}=OutPut.DataSeries{idevice};
|
---|
492 | if isempty(InputTable{icount,3})
|
---|
493 | if icount>1
|
---|
494 | InputTable{icount,3}=InputTable{icount-1,3};
|
---|
495 | else
|
---|
496 | InputTable{icount,3}='';
|
---|
497 | end
|
---|
498 | end
|
---|
499 | if isempty(InputTable{icount,4})
|
---|
500 | if icount>1
|
---|
501 | InputTable{icount,4}=InputTable{icount-1,4};
|
---|
502 | else
|
---|
503 | InputTable{icount,4}='';
|
---|
504 | end
|
---|
505 | end
|
---|
506 | if isempty(InputTable{icount,5})
|
---|
507 | if icount>1
|
---|
508 | InputTable{icount,5}=InputTable{icount-1,5};
|
---|
509 | else
|
---|
510 | InputTable{icount,5}='';
|
---|
511 | end
|
---|
512 | end
|
---|
513 | end
|
---|
514 | end
|
---|
515 | if size(InputTable,1)>icount
|
---|
516 | InputTable(icount+1:size(InputTable,1),:)=[];
|
---|
517 | end
|
---|
518 | set(handles.InputTable,'Data',InputTable)
|
---|
519 | REFRESH_Callback(hObject, eventdata, handles)
|
---|
520 | % DataSeries=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
|
---|
521 | % fileinput=uigetfile_uvmat('pick an input file',DataSeries);
|
---|
522 | % hh=dir(fileinput);
|
---|
523 | % if numel(hh)>1
|
---|
524 | % msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
525 | % return
|
---|
526 | % end
|
---|
527 | %
|
---|
528 | %
|
---|
529 | %
|
---|
530 | % %% launch the browser
|
---|
531 | % fileinput=uigetfile_uvmat('pick an input file in the series',oldfile);
|
---|
532 | % hh=dir(fileinput);
|
---|
533 | % if numel(hh)>1
|
---|
534 | % msgbox_uvmat('ERROR','invalid input, probably a broken link');
|
---|
535 | % else
|
---|
536 | % if ~isempty(fileinput)
|
---|
537 | % display_file_name(handles,fileinput,'one')
|
---|
538 | % end
|
---|
539 | % end
|
---|
540 | % append='one';
|
---|
541 | % set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
|
---|
542 | % drawnow
|
---|
543 | % browse_campaign(handles,append);
|
---|
544 |
|
---|
545 | %------------------------------------------------------------------------
|
---|
546 | % --- fct activated by the browser under 'Open campaign/Browse...'
|
---|
547 | %------------------------------------------------------------------------
|
---|
548 | function MenuBrowseCampaignAppend_Callback(hObject, eventdata, handles)
|
---|
549 | append='append';
|
---|
550 | browse_campaign(handles,append);
|
---|
551 |
|
---|
552 | %------------------------------------------------------------------------
|
---|
553 | function browse_campaign(handles,append);
|
---|
554 |
|
---|
555 | %% look for the previously opened file 'oldfile'
|
---|
556 |
|
---|
557 | %
|
---|
558 | %
|
---|
559 | % InputTable=get(handles.InputTable,'Data');
|
---|
560 | % RootPath=InputTable{1,1};
|
---|
561 | % CampaignPath=fileparts(fileparts(RootPath));
|
---|
562 | % DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
|
---|
563 | % if ~ischar(DirFull)|| ~exist(DirFull,'dir')
|
---|
564 | % return
|
---|
565 | % end
|
---|
566 | OutPut=browse_data(oldfile);% open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
567 | if ~isfield(OutPut,'Campaign')
|
---|
568 | return
|
---|
569 | end
|
---|
570 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
|
---|
571 | ListStruct=dir(DirName); %list files and the dir DataSeries
|
---|
572 | % select the first appropriate file in the dir
|
---|
573 | FileName='';
|
---|
574 | for ilist=1:numel(ListStruct)
|
---|
575 | if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
|
---|
576 | FileName=ListStruct(ilist).name;
|
---|
577 | FileInfo=get_file_info(fullfile(DirName,FileName));
|
---|
578 | switch FileInfo.FileType
|
---|
579 | case {'image','multimage','civx','civdata','netcdf'}
|
---|
580 | break
|
---|
581 | end
|
---|
582 | end
|
---|
583 | end
|
---|
584 | if isempty(FileName)
|
---|
585 | msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
|
---|
586 | return
|
---|
587 | end
|
---|
588 |
|
---|
589 | %% update the list of campaigns in the menubar
|
---|
590 | MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
|
---|
591 | {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
|
---|
592 | check_dir=isempty(find(strcmp(DirName,MenuCampaign)));
|
---|
593 | if check_dir %insert the new campaign in the list if it is not found
|
---|
594 | MenuCampaign(end)=[]; %suppress the last item
|
---|
595 | MenuCampaign=[{DirName};MenuCampaign];%insert the new campaign
|
---|
596 | for ilist=1:numel(MenuCampaign)
|
---|
597 | set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
|
---|
598 | end
|
---|
599 | % save the list for future opening:
|
---|
600 | dir_perso=prefdir;
|
---|
601 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
602 | if exist(profil_perso,'file')
|
---|
603 | save (profil_perso,'MenuCampaign','-append'); %store the file names for future opening of uvmat
|
---|
604 | else
|
---|
605 | save (profil_perso,'MenuCampaign','-V6'); %store the file names for future opening of uvmat
|
---|
606 | end
|
---|
607 | end
|
---|
608 |
|
---|
609 | %% display the selected field and related information
|
---|
610 | if get(handles.CheckAppend,'Value')
|
---|
611 | display_file_name(handles,fullfile(DirName,FileName),'append')
|
---|
612 | else
|
---|
613 | display_file_name(handles,fullfile(DirName,FileName),'one')
|
---|
614 | end
|
---|
615 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
|
---|
616 |
|
---|
617 | % --------------------------------------------------------------------
|
---|
618 | function MenuCampaign_Callback(hObject, eventdata, handles)
|
---|
619 | % --------------------------------------------------------------------
|
---|
620 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
|
---|
621 | OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device
|
---|
622 | if ~isfield(OutPut,'Campaign')
|
---|
623 | return
|
---|
624 | end
|
---|
625 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
|
---|
626 | hdir=dir(DirName); %list files and dirs
|
---|
627 | for ilist=1:numel(hdir)
|
---|
628 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
|
---|
629 | FileName=hdir(ilist).name;
|
---|
630 | FileInfo=get_file_info(fullfile(DirName,FileName));
|
---|
631 | switch FileInfo.FileType
|
---|
632 | case {'image','multimage','civx','civdata','netcdf'}
|
---|
633 | break
|
---|
634 | end
|
---|
635 | end
|
---|
636 | end
|
---|
637 | if get(handles.CheckAppend,'Value')
|
---|
638 | display_file_name(handles,fullfile(DirName,FileName),'append')
|
---|
639 | else
|
---|
640 | display_file_name(handles,fullfile(DirName,FileName),'one')
|
---|
641 | end
|
---|
642 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
|
---|
643 |
|
---|
644 |
|
---|
645 | % --- Executes when selected cell(s) is changed in InputTable.
|
---|
646 | function InputTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
647 | iline=[];
|
---|
648 | if ~isempty(eventdata.Indices)
|
---|
649 | iline=eventdata.Indices(1);
|
---|
650 | end
|
---|
651 | set(handles.InputLine,'String',num2str(iline));
|
---|
652 | % set(handles.InputTable,'UserData',iline);
|
---|
653 |
|
---|
654 | %------------------------------------------------------------------------
|
---|
655 | % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
|
---|
656 | %------------------------------------------------------------------------
|
---|
657 | function InputTable_KeyPressFcn(hObject, eventdata, handles)
|
---|
658 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
|
---|
659 | set(handles.OutputSubDir,'BackgroundColor',[1 0 1])% set edit box OutputSubDir to magenta color to indicate that refresh may be needed
|
---|
660 | xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character
|
---|
661 | if ~isempty(xx)
|
---|
662 | switch xx
|
---|
663 | case 31 %downward arrow
|
---|
664 | InputTable=get(handles.InputTable,'Data');
|
---|
665 | iline=str2double(get(handles.InputLine,'String'));
|
---|
666 | if isequal(iline,size(InputTable,1))% arrow downward
|
---|
667 | InputTable=[InputTable;InputTable(iline,:)];% create a new line as a copy of the last one
|
---|
668 | set(handles.InputTable,'Data',InputTable);
|
---|
669 | end
|
---|
670 | case 127 %key 'Suppress'
|
---|
671 | ClearLine_Callback(hObject, eventdata, handles)
|
---|
672 | end
|
---|
673 | end
|
---|
674 |
|
---|
675 | %------------------------------------------------------------------------
|
---|
676 | % --- Executes on button press in REFRESH.
|
---|
677 | function REFRESH_Callback(hObject, eventdata, handles)
|
---|
678 | %------------------------------------------------------------------------
|
---|
679 | InputTable=get(handles.InputTable,'Data');
|
---|
680 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
681 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
682 | drawnow
|
---|
683 | empty_line=false(size(InputTable,1),1);
|
---|
684 | for iline=1:size(InputTable,1)
|
---|
685 | empty_line(iline)= isempty(cell2mat(InputTable(iline,1:3)));
|
---|
686 | end
|
---|
687 | if ~isempty(find(empty_line));
|
---|
688 | InputTable(empty_line,:)=[];%remove empty lines
|
---|
689 | set(handles.InputTable,'Data',InputTable)
|
---|
690 | ListTable={'MinIndex_i','MaxIndex_i','MinIndex_j','MaxIndex_j','PairString','TimeTable'};
|
---|
691 | for ilist=1:numel(ListTable)
|
---|
692 | Table=get(handles.(ListTable{ilist}),'Data');
|
---|
693 | Table(empty_line,:)=[];%remove empty lines
|
---|
694 | set(handles.(ListTable{ilist}),'Data',Table);
|
---|
695 | end
|
---|
696 | set(handles.series,'UserData',[])%refresh the stored info
|
---|
697 | end
|
---|
698 | nbview=size(InputTable,1);
|
---|
699 | for iview=1:nbview
|
---|
700 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2});
|
---|
701 | if ~exist(RootPath,'dir')
|
---|
702 | i1_series=[];
|
---|
703 | RootFile='';
|
---|
704 | else %scan the input folder
|
---|
705 | [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
|
---|
706 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]);
|
---|
707 | end
|
---|
708 | % if no file is found, open a browser
|
---|
709 | if isempty(RootFile)&& isempty(i1_series)
|
---|
710 | fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
|
---|
711 | if isempty(fileinput)
|
---|
712 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH back to red color
|
---|
713 | return
|
---|
714 | else
|
---|
715 | display_file_name(handles,fileinput,iview)
|
---|
716 | end
|
---|
717 | else
|
---|
718 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview)
|
---|
719 | end
|
---|
720 | end
|
---|
721 |
|
---|
722 | %% update MinIndex_i and MaxIndex_i if the input table content has been reduced in line nbre
|
---|
723 | MinIndex_i_table=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex
|
---|
724 | set(handles.MinIndex_i,'Data',MinIndex_i_table(1:nbview,:));
|
---|
725 | MinIndex_j_table=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex
|
---|
726 | set(handles.MinIndex_j,'Data',MinIndex_j_table(1:nbview,:));
|
---|
727 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
|
---|
728 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table(1:nbview,:));
|
---|
729 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
|
---|
730 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table(1:nbview,:));
|
---|
731 | PairString=get(handles.PairString,'Data');%retrieve the min indices in the table MinIndex
|
---|
732 | set(handles.PairString,'Data',PairString(1:nbview,:));
|
---|
733 | TimeTable=get(handles.TimeTable,'Data');%retrieve the min indices in the table MinIndex
|
---|
734 | set(handles.TimeTable,'Data',TimeTable(1:nbview,:));
|
---|
735 |
|
---|
736 | %% enable field and veltype menus, in accordance with the current action
|
---|
737 | ActionName_Callback([],[], handles)
|
---|
738 |
|
---|
739 | %% set length of waitbar
|
---|
740 | displ_time(handles)
|
---|
741 |
|
---|
742 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (indicate activation finished)
|
---|
743 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch'
|
---|
744 |
|
---|
745 | %------------------------------------------------------------------------
|
---|
746 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser
|
---|
747 | %------------------------------------------------------------------------
|
---|
748 | % INPUT:
|
---|
749 | % handles: handles of elements in the GUI
|
---|
750 | % Param: structure of input parameters, including input file name and path
|
---|
751 | % iview: line index in the input table
|
---|
752 | % or 'one': refresh the list
|
---|
753 | % 'append': add a new line to the input table
|
---|
754 | function errormsg=display_file_name(handles,Param,iview)
|
---|
755 |
|
---|
756 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% set REFRESH button to yellow color (indicate activation)
|
---|
757 | drawnow
|
---|
758 | errormsg='';%default
|
---|
759 | if ischar(Param)
|
---|
760 | fileinput=Param;
|
---|
761 | else% input set when series is opened (called by the GUI uvmat)
|
---|
762 | fileinput=Param.FileName;
|
---|
763 | end
|
---|
764 |
|
---|
765 | %% get the input root name, indices, file extension and nomenclature NomType
|
---|
766 | if ~exist(fileinput,'file')
|
---|
767 | errormsg=['input file ' fileinput ' does not exist'];
|
---|
768 | msgbox_uvmat('ERROR',errormsg)
|
---|
769 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (refresh still needed)
|
---|
770 | return
|
---|
771 | end
|
---|
772 |
|
---|
773 | %% detect root name, nomenclature and indices in the input file name:
|
---|
774 | [FilePath,FileName,FileExt]=fileparts(fileinput);
|
---|
775 | %%%%%%%%%%%%%%%%%%
|
---|
776 | %TODO: case of input by uvmat: do not check agai the input seies %%%%%%%
|
---|
777 | %%%%%%%%%%%%%%%%%%%
|
---|
778 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
779 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
|
---|
780 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
|
---|
781 | FileType=FileInfo.FileType;
|
---|
782 | if isempty(RootFile)&&isempty(i1_series)
|
---|
783 | errormsg='no input file in the series';
|
---|
784 | msgbox_uvmat('ERROR',errormsg)
|
---|
785 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
786 | return
|
---|
787 | end
|
---|
788 | if strcmp(FileType,'txt')
|
---|
789 | edit(fileinput)
|
---|
790 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
791 | return
|
---|
792 | elseif strcmp(FileType,'xml')
|
---|
793 | editxml(fileinput)
|
---|
794 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
795 | return
|
---|
796 | elseif strcmp(FileType,'figure')
|
---|
797 | open(fileinput)
|
---|
798 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color (end of activation)
|
---|
799 | return
|
---|
800 | end
|
---|
801 |
|
---|
802 | %% enable other menus and uicontrols
|
---|
803 | set(handles.MenuOpenCampaign,'Enable','on')
|
---|
804 | set(handles.MenuCampaign_1,'Enable','on')
|
---|
805 | set(handles.MenuCampaign_2,'Enable','on')
|
---|
806 | set(handles.MenuCampaign_3,'Enable','on')
|
---|
807 | set(handles.MenuCampaign_4,'Enable','on')
|
---|
808 | set(handles.MenuCampaign_5,'Enable','on')
|
---|
809 | set(handles.RUN, 'Enable','On')
|
---|
810 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
|
---|
811 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow
|
---|
812 | drawnow
|
---|
813 |
|
---|
814 |
|
---|
815 | %% fill the list of file series
|
---|
816 | InputTable=get(handles.InputTable,'Data');
|
---|
817 | SeriesData=get(handles.series,'UserData');
|
---|
818 | if strcmp(iview,'append') % display the input data as a new line in the table
|
---|
819 | iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line
|
---|
820 | % InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
|
---|
821 | elseif strcmp(iview,'one') % refresh the list of input file series
|
---|
822 | iview=1; %the first line in InputTable becomes the current line
|
---|
823 | InputTable={'','','','',''};
|
---|
824 | % InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
|
---|
825 | set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
|
---|
826 | set(handles.MinIndex_i,'Data',[])
|
---|
827 | set(handles.MaxIndex_i,'Data',[])
|
---|
828 | set(handles.MinIndex_j,'Data',[])
|
---|
829 | set(handles.MaxIndex_j,'Data',[])
|
---|
830 | set(handles.PairString,'Data',{''})
|
---|
831 | SeriesData.CheckPair=0;%reset the list of input lines with pairs
|
---|
832 | SeriesData.i1_series={};
|
---|
833 | SeriesData.i2_series={};
|
---|
834 | SeriesData.j1_series={};
|
---|
835 | SeriesData.j2_series={};
|
---|
836 | SeriesData.FileType={};
|
---|
837 | SeriesData.FileInfo={};
|
---|
838 | SeriesData.Time={};
|
---|
839 | end
|
---|
840 | if isfield(SeriesData,'i1_series')
|
---|
841 | SeriesData.i1_series(iview+1:end)=[];
|
---|
842 | SeriesData.i2_series(iview+1:end)=[];
|
---|
843 | SeriesData.j1_series(iview+1:end)=[];
|
---|
844 | SeriesData.j2_series(iview+1:end)=[];
|
---|
845 | SeriesData.FileType(iview+1:end)=[];
|
---|
846 | SeriesData.FileInfo(iview+1:end)=[];
|
---|
847 | SeriesData.Time(iview+1:end)=[];
|
---|
848 | end
|
---|
849 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
|
---|
850 | if iview >1
|
---|
851 | set(handles.InputLine,'String',num2str(iview))
|
---|
852 | end
|
---|
853 | set(handles.InputTable,'Data',InputTable)
|
---|
854 |
|
---|
855 | %% determine the selected reference field indices for pair display
|
---|
856 | if isempty(i1)
|
---|
857 | i1=1;
|
---|
858 | end
|
---|
859 | if isempty(i2)
|
---|
860 | i2=i1;
|
---|
861 | end
|
---|
862 | ref_i=floor((i1+i2)/2);% reference image number corresponding to the file
|
---|
863 | % set(handles.num_ref_i,'String',num2str(ref_i));
|
---|
864 | if isempty(j1)
|
---|
865 | j1=1;
|
---|
866 | end
|
---|
867 | if isempty(j2)
|
---|
868 | j2=j1;
|
---|
869 | end
|
---|
870 | ref_j=floor((j1+j2)/2);% reference image number corresponding to the file
|
---|
871 | SeriesData.ref_i=ref_i;
|
---|
872 | SeriesData.ref_j=ref_j;
|
---|
873 |
|
---|
874 | %% update first and last indices if they do not exist
|
---|
875 | Param=read_GUI(handles.series);
|
---|
876 | first_j=[];
|
---|
877 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
878 | last_j=[];
|
---|
879 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
880 | PairString='';
|
---|
881 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
882 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
883 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
884 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
885 | if ~exist(FirstFileName,'file')
|
---|
886 | set(handles.num_first_i,'String',num2str(ref_i))
|
---|
887 | set(handles.num_first_j,'String',num2str(ref_j))
|
---|
888 | end
|
---|
889 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
|
---|
890 | LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
891 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
892 | if ~exist(LastFileName,'file')
|
---|
893 | set(handles.num_last_i,'String',num2str(ref_i))
|
---|
894 | set(handles.num_last_j,'String',num2str(ref_j))
|
---|
895 | end
|
---|
896 |
|
---|
897 | %% update the list of recent files in the menubar and save it for future opening
|
---|
898 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
899 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
900 | str_find=strcmp(fileinput,MenuFile);
|
---|
901 | if isempty(find(str_find,1))
|
---|
902 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list
|
---|
903 | end
|
---|
904 | for ifile=1:min(length(MenuFile),5)
|
---|
905 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
|
---|
906 | end
|
---|
907 | dir_perso=prefdir;
|
---|
908 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
909 | if exist(profil_perso,'file')
|
---|
910 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
|
---|
911 | else
|
---|
912 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
|
---|
913 | end
|
---|
914 | % save the opened file to initiate future opening
|
---|
915 | SeriesData.RefFile{iview}=fileinput;% reference opening file for line iview
|
---|
916 | SeriesData.Ref_i1=i1;
|
---|
917 | SeriesData.Ref_i2=i2;
|
---|
918 | SeriesData.Ref_j1=j1;
|
---|
919 | SeriesData.Ref_j2=j2;
|
---|
920 | set(handles.series,'UserData',SeriesData)
|
---|
921 |
|
---|
922 | set(handles.InputTable,'BackgroundColor',[1 1 1])
|
---|
923 |
|
---|
924 | %% initiate input file series and refresh the current field view:
|
---|
925 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,iview);
|
---|
926 | %% enable field and veltype menus, in accordance with the current action
|
---|
927 | ActionName_Callback([],[], handles)
|
---|
928 |
|
---|
929 | %% set length of waitbar
|
---|
930 | displ_time(handles)
|
---|
931 |
|
---|
932 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to red color (end of activation)
|
---|
933 |
|
---|
934 | %------------------------------------------------------------------------
|
---|
935 | % --- Update information about a new field series (indices to scan, timing,
|
---|
936 | % calibration from an xml file
|
---|
937 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,iview)
|
---|
938 | %------------------------------------------------------------------------
|
---|
939 | InputTable=get(handles.InputTable,'Data');
|
---|
940 |
|
---|
941 | %% display the min and max indices for the whole file series
|
---|
942 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
|
---|
943 | MinIndex_j=1;% index j set to 1 by default
|
---|
944 | MaxIndex_j=1;
|
---|
945 | MinIndex_i=find(i1_series(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
|
---|
946 | MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
|
---|
947 | else
|
---|
948 | ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i
|
---|
949 | ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j
|
---|
950 | MinIndex_i=min(find(ref_i))-1;
|
---|
951 | MaxIndex_i=max(find(ref_i))-1;
|
---|
952 | MaxIndex_j=max(find(ref_j))-1;
|
---|
953 | MinIndex_j=min(find(ref_j))-1;
|
---|
954 | diff_j_max=diff(ref_j);
|
---|
955 | diff_i_max=diff(ref_i);
|
---|
956 | if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
|
---|
957 | set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
|
---|
958 | end
|
---|
959 | if ~isempty(diff_j_max) && isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
|
---|
960 | set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
|
---|
961 | end
|
---|
962 | end
|
---|
963 | if isequal(MinIndex_i,-1)
|
---|
964 | MinIndex_i=0;
|
---|
965 | end
|
---|
966 | if isequal(MinIndex_j,-1)
|
---|
967 | MinIndex_j=0;
|
---|
968 | end
|
---|
969 | MinIndex_i_table=get(handles.MinIndex_i,'Data');%retrieve the min indices in the table MinIndex
|
---|
970 | MinIndex_j_table=get(handles.MinIndex_j,'Data');%retrieve the min indices in the table MinIndex
|
---|
971 | MaxIndex_i_table=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
|
---|
972 | MaxIndex_j_table=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
|
---|
973 | if ~isempty(MinIndex_i)&&~isempty(MaxIndex_i)
|
---|
974 | MinIndex_i_table(iview,1)=MinIndex_i;
|
---|
975 | MaxIndex_i_table(iview,1)=MaxIndex_i;
|
---|
976 | end
|
---|
977 | if ~isempty(MinIndex_j)&&~isempty(MaxIndex_j)
|
---|
978 | MinIndex_j_table(iview,1)=MinIndex_j;
|
---|
979 | MaxIndex_j_table(iview,1)=MaxIndex_j;
|
---|
980 | end
|
---|
981 | set(handles.MinIndex_i,'Data',MinIndex_i_table)%display the min indices in the table MinIndex
|
---|
982 | set(handles.MinIndex_j,'Data',MinIndex_j_table)%display the max indices in the table MaxIndex
|
---|
983 | set(handles.MaxIndex_i,'Data',MaxIndex_i_table)%display the min indices in the table MinIndex
|
---|
984 | set(handles.MaxIndex_j,'Data',MaxIndex_j_table)%display the max indices in the table MaxIndex
|
---|
985 | SeriesData=get(handles.series,'UserData');
|
---|
986 |
|
---|
987 | %% adjust the first and last indices for the selected series, only if requested by the bounds
|
---|
988 | % i index, compare input to min index i
|
---|
989 | first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i
|
---|
990 | % ref_i=str2num(get(handles.num_ref_i,'String'));%index i given by the input field
|
---|
991 | ref_i=1;
|
---|
992 | if isfield(SeriesData,'ref_i')
|
---|
993 | ref_i=SeriesData.ref_i;
|
---|
994 | end
|
---|
995 | if isempty(first_i)
|
---|
996 | first_i=ref_i;% first_i updated by the input value
|
---|
997 | elseif first_i < MinIndex_i
|
---|
998 | first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines)
|
---|
999 | elseif first_i >MaxIndex_i
|
---|
1000 | first_i=MaxIndex_i;% first_i set to the max i index (restricted by oter input lines)
|
---|
1001 | end
|
---|
1002 | % j index, compare input to min index j
|
---|
1003 | first_j=str2num(get(handles.num_first_j,'String'));
|
---|
1004 | ref_j=1;
|
---|
1005 | if isfield(SeriesData,'ref_j')
|
---|
1006 | ref_j=SeriesData.ref_j;
|
---|
1007 | end
|
---|
1008 | if isempty(first_j)
|
---|
1009 | first_j=ref_j;% first_j updated by the input value
|
---|
1010 | elseif first_j<MinIndex_j
|
---|
1011 | first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines)
|
---|
1012 | elseif first_j >MaxIndex_j
|
---|
1013 | first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines)
|
---|
1014 | end
|
---|
1015 | % i index, compare input to max index i
|
---|
1016 | last_i=str2num(get(handles.num_last_i,'String'));
|
---|
1017 | if isempty(last_i)
|
---|
1018 | last_i=ref_i;
|
---|
1019 | elseif last_i > MaxIndex_i
|
---|
1020 | last_i=MaxIndex_i;
|
---|
1021 | elseif last_i<first_i
|
---|
1022 | last_i=first_i;
|
---|
1023 | end
|
---|
1024 | % j index, compare input to max index j
|
---|
1025 | last_j=str2num(get(handles.num_last_j,'String'));
|
---|
1026 | if isempty(last_j)
|
---|
1027 | last_j=ref_j;
|
---|
1028 | elseif last_j>MaxIndex_j
|
---|
1029 | last_j=MaxIndex_j;
|
---|
1030 | elseif last_j<first_j
|
---|
1031 | last_j=first_j;
|
---|
1032 | end
|
---|
1033 | set(handles.num_first_i,'String',num2str(first_i));
|
---|
1034 | set(handles.num_first_j,'String',num2str(first_j));
|
---|
1035 | set(handles.num_last_i,'String',num2str(last_i));
|
---|
1036 | set(handles.num_last_j,'String',num2str(last_j));
|
---|
1037 |
|
---|
1038 | %% number of slices set by default
|
---|
1039 | NbSlice=1;%default
|
---|
1040 | % read value set by the first series for the append mode (iwiew >1)
|
---|
1041 | if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
|
---|
1042 | NbSlice=str2num(get(handles.num_NbSlice,'String'));
|
---|
1043 | end
|
---|
1044 |
|
---|
1045 | %% default time settings
|
---|
1046 | TimeUnit='';
|
---|
1047 | % read value set by the first series for the append mode (iwiew >1)
|
---|
1048 | if iview>1
|
---|
1049 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
1050 | end
|
---|
1051 | TimeName='';
|
---|
1052 | Time=[];%default
|
---|
1053 | TimeMin=[];
|
---|
1054 | TimeFirst=[];
|
---|
1055 | TimeLast=[];
|
---|
1056 | TimeMax=[];
|
---|
1057 |
|
---|
1058 | %% read image documentation file if found
|
---|
1059 | XmlData=[];
|
---|
1060 | check_calib=0;
|
---|
1061 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5});
|
---|
1062 | if ~isempty(XmlFileName)
|
---|
1063 | [XmlData,errormsg]=imadoc2struct(XmlFileName);
|
---|
1064 | if ~isempty(errormsg)
|
---|
1065 | msgbox_uvmat('WARNING',['error in reading ' XmlFileName ': ' errormsg]);
|
---|
1066 | end
|
---|
1067 | % read time if available
|
---|
1068 | if isfield(XmlData,'Time')
|
---|
1069 | Time=XmlData.Time;
|
---|
1070 | TimeName='xml';
|
---|
1071 | end
|
---|
1072 | if isfield(XmlData,'Camera')
|
---|
1073 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
1074 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,XmlData.Camera.NbSlice)
|
---|
1075 | msgbox_uvmat('WARNING','inconsistent number of slices with the first field series');
|
---|
1076 | end
|
---|
1077 | NbSlice=XmlData.Camera.NbSlice;% Nbre of slices from camera
|
---|
1078 | end
|
---|
1079 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
1080 | if iview>1 && ~isempty(TimeUnit) && ~strcmp(TimeUnit,XmlData.Camera.TimeUnit)
|
---|
1081 | msgbox_uvmat('WARNING','inconsistent time unit with the first field series');
|
---|
1082 | end
|
---|
1083 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
1084 | end
|
---|
1085 | end
|
---|
1086 | % number of slices
|
---|
1087 | if isfield(XmlData,'GeometryCalib')
|
---|
1088 | check_calib=1;
|
---|
1089 | if isfield(XmlData.GeometryCalib,'SliceCoord')
|
---|
1090 | siz=size(XmlData.GeometryCalib.SliceCoord);
|
---|
1091 | if siz(1)>1
|
---|
1092 | if iview>1 && ~isempty(NbSlice) && ~strcmp(NbSlice,siz(1))
|
---|
1093 | msgbox_uvmat('WARNING','inconsistent number of Z indices with the first field series');
|
---|
1094 | end
|
---|
1095 | NbSlice=siz(1);
|
---|
1096 | end
|
---|
1097 | end
|
---|
1098 | end
|
---|
1099 | set(handles.num_NbSlice,'String',num2str(NbSlice))
|
---|
1100 | end
|
---|
1101 |
|
---|
1102 | %% read timing from the current file (prioritary)
|
---|
1103 | if ~isempty(VideoObject)% case of movies
|
---|
1104 | imainfo=get(VideoObject);
|
---|
1105 | if isempty(j1_series); %frame index along i
|
---|
1106 | Time=zeros(imainfo.NumberOfFrames+1,2);
|
---|
1107 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
|
---|
1108 | else
|
---|
1109 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
|
---|
1110 | end
|
---|
1111 | TimeName='video';
|
---|
1112 | end
|
---|
1113 |
|
---|
1114 |
|
---|
1115 | %% determine the min and max times: case of Netcdf files will be treated later in FieldName_Callback
|
---|
1116 | if ~isempty(TimeName)
|
---|
1117 | TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
|
---|
1118 | if size(Time)>=[first_i+1 first_j+1]
|
---|
1119 | TimeFirst=Time(first_i+1,first_j+1);
|
---|
1120 | end
|
---|
1121 | if size(Time)>=[last_i+1 last_j+1]
|
---|
1122 | TimeLast=Time(last_i+1,last_j+1);
|
---|
1123 | end
|
---|
1124 | if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1];
|
---|
1125 | TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
|
---|
1126 | end
|
---|
1127 | end
|
---|
1128 |
|
---|
1129 | %% update the time table
|
---|
1130 | TimeTable=get(handles.TimeTable,'Data');
|
---|
1131 | TimeTable{iview,1}=TimeName;
|
---|
1132 | TimeTable{iview,2}=TimeMin;
|
---|
1133 | TimeTable{iview,3}=TimeFirst;
|
---|
1134 | TimeTable{iview,4}=TimeLast;
|
---|
1135 | TimeTable{iview,5}=TimeMax;
|
---|
1136 | set(handles.TimeTable,'Data',TimeTable)
|
---|
1137 |
|
---|
1138 | %% update the series info in 'UserData'
|
---|
1139 | SeriesData.i1_series{iview}=i1_series;
|
---|
1140 | SeriesData.i2_series{iview}=i2_series;
|
---|
1141 | SeriesData.j1_series{iview}=j1_series;
|
---|
1142 | SeriesData.j2_series{iview}=j2_series;
|
---|
1143 | SeriesData.FileType{iview}=FileInfo.FileType;
|
---|
1144 | SeriesData.FileInfo{iview}=FileInfo;
|
---|
1145 | SeriesData.Time{iview}=Time;
|
---|
1146 | % if ~isempty(TimeName)
|
---|
1147 | % SeriesData.TimeSource=TimeSource;
|
---|
1148 | % end
|
---|
1149 | if check_calib
|
---|
1150 | SeriesData.GeometryCalib{iview}=XmlData.GeometryCalib;
|
---|
1151 | end
|
---|
1152 | set(handles.series,'UserData',SeriesData)
|
---|
1153 |
|
---|
1154 | %% update pair menus
|
---|
1155 | hset_pair=findobj(allchild(0),'Tag','set_pairs');
|
---|
1156 | if ~isempty(hset_pair), delete(hset_pair); end % delete the GUI set_pair if opened
|
---|
1157 | CheckPair= ~isempty(i2_series)||~isempty(j2_series); % check whether index pairs need to be defined
|
---|
1158 | PairString=get(handles.PairString,'Data');
|
---|
1159 | if CheckPair% if pairs need to be display for line iview
|
---|
1160 | [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series);
|
---|
1161 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),FileInfo);
|
---|
1162 | PairString{iview,1}=Menu{1};
|
---|
1163 | else
|
---|
1164 | PairString{iview,1}='';%no pair for #iview
|
---|
1165 | end
|
---|
1166 | set(handles.PairString,'Data',PairString)
|
---|
1167 | if isempty(find(cellfun('isempty',get(handles.PairString,'Data'))==0, 1))% if all lines of pairs are empty
|
---|
1168 | set(handles.PairString,'Visible','off')
|
---|
1169 | set(handles.SetPairs,'Visible','off')
|
---|
1170 | else
|
---|
1171 | set(handles.PairString,'Visible','on')
|
---|
1172 | set(handles.SetPairs,'Visible','on')
|
---|
1173 | end
|
---|
1174 |
|
---|
1175 |
|
---|
1176 | %% display the set of existing files as an image
|
---|
1177 | set(handles.FileStatus,'Units','pixels')
|
---|
1178 | Position=get(handles.FileStatus,'Position');
|
---|
1179 | set(handles.FileStatus,'Units','normalized')
|
---|
1180 | %xI=0.5:Position(3)-0.5;
|
---|
1181 | nbview=numel(SeriesData.i1_series);
|
---|
1182 | j_max=cell(1,nbview);
|
---|
1183 | MaxIndex_i=ones(1,nbview);%default
|
---|
1184 | MinIndex_i=ones(1,nbview);%default
|
---|
1185 | for iline=1:nbview
|
---|
1186 | pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); %max on pair index
|
---|
1187 | j_max{iline}=max(pair_max,[],1);%max on j index
|
---|
1188 | if ~isempty(j_max{iline})
|
---|
1189 | MaxIndex_i(iline)=max(find(j_max{iline}))-1;% max ref index i
|
---|
1190 | MinIndex_i(iline)=min(find(j_max{iline}))-1;% min ref index i
|
---|
1191 | end
|
---|
1192 | end
|
---|
1193 | MinIndex_i=min(MinIndex_i);
|
---|
1194 | MaxIndex_i=max(MaxIndex_i);
|
---|
1195 | range_index=MaxIndex_i-MinIndex_i+1;
|
---|
1196 | range_y=max(1,floor(Position(4)/nbview));
|
---|
1197 | npx=floor(Position(3));
|
---|
1198 | file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1;
|
---|
1199 | CData=zeros(nbview*range_y,npx);% initiate the image representing the existing files
|
---|
1200 | for iline=1:nbview
|
---|
1201 | ind_y=1+(iline-1)*range_y:iline*range_y;
|
---|
1202 | LineData=zeros(size(file_indices));
|
---|
1203 | file_select=file_indices(file_indices<=numel(j_max{iline}));
|
---|
1204 | ind_select=find(file_indices<=numel(j_max{iline}));
|
---|
1205 | LineData(ind_select)=j_max{iline}(file_select)~=0;
|
---|
1206 | CData(ind_y,:)=ones(size(ind_y'))*LineData;
|
---|
1207 | end
|
---|
1208 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));%make color images r=0,g,b=0
|
---|
1209 | set(handles.FileStatus,'CData',CData);
|
---|
1210 |
|
---|
1211 | %-----------------------------------------------------------guide -------------
|
---|
1212 | %------------------------------------------------------------------------
|
---|
1213 | % III - FUNCTIONS ASSOCIATED TO THE FRAME IndexRange
|
---|
1214 | %------------------------------------------------------------------------
|
---|
1215 |
|
---|
1216 |
|
---|
1217 | % ---- determine the menu to put in mode and advice a default choice
|
---|
1218 | %------------------------------------------------------------------------
|
---|
1219 | function [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series)
|
---|
1220 | %------------------------------------------------------------------------
|
---|
1221 | ModeMenu={''};
|
---|
1222 | if isempty(j2_series)% no j pair
|
---|
1223 | ModeValue=1;
|
---|
1224 | if ~isempty(i2_series)
|
---|
1225 | ModeMenu={'series(Di)'}; % pair menu with only option Di
|
---|
1226 | end
|
---|
1227 | else %existence of j pairs
|
---|
1228 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index
|
---|
1229 | j_max=max(pair_max,[],1);
|
---|
1230 | MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i
|
---|
1231 | MinIndex_i=find(j_max, 1 )-1;% min ref index i
|
---|
1232 | i_max=max(pair_max,[],2);
|
---|
1233 | MaxIndex_j=find(i_max, 1, 'last' )-1;% max ref index i
|
---|
1234 | MinIndex_j=find(i_max, 1 )-1;% min ref index i
|
---|
1235 | if MaxIndex_j==MinIndex_j
|
---|
1236 | ModeValue=1;
|
---|
1237 | ModeMenu={'bursts'};
|
---|
1238 | elseif MaxIndex_i==MinIndex_i
|
---|
1239 | ModeValue=1;
|
---|
1240 | ModeMenu={'series(Dj)'};
|
---|
1241 | else
|
---|
1242 | ModeMenu={'bursts';'series(Dj)'};
|
---|
1243 | if (MaxIndex_j-MinIndex_j)>10
|
---|
1244 | ModeValue=2;%set mode to series(Dj) if more than 10 j values
|
---|
1245 | else
|
---|
1246 | ModeValue=1;
|
---|
1247 | end
|
---|
1248 | end
|
---|
1249 | end
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | %------------------------------------------------------------------------
|
---|
1253 | function displ_pair=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,time,TimeUnit,ref_i,ref_j,TimeName,InputTable,FileInfo)
|
---|
1254 | %------------------------------------------------------------------------
|
---|
1255 | displ_pair={};
|
---|
1256 | if isempty(TimeUnit)
|
---|
1257 | dtunit='e-03';
|
---|
1258 | else
|
---|
1259 | dtunit=['m' TimeUnit];
|
---|
1260 | end
|
---|
1261 | switch mode
|
---|
1262 | case 'series(Di)'
|
---|
1263 | diff_i=i2_series-i1_series;
|
---|
1264 | min_diff=min(diff_i(diff_i>0));
|
---|
1265 | max_diff=max(diff_i(diff_i>0));
|
---|
1266 | for ipair=min_diff:max_diff
|
---|
1267 | if numel(diff_i(diff_i==ipair))>0
|
---|
1268 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
1269 | if ~isempty(time)
|
---|
1270 | if ref_i<=floor(ipair/2)
|
---|
1271 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair
|
---|
1272 | end
|
---|
1273 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j);
|
---|
1274 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
1275 | end
|
---|
1276 | displ_pair=[displ_pair;{pair_string}];
|
---|
1277 | end
|
---|
1278 | end
|
---|
1279 | if ~isempty(displ_pair)
|
---|
1280 | displ_pair=[displ_pair;{'Di=*|*'}];
|
---|
1281 | end
|
---|
1282 | case 'series(Dj)'
|
---|
1283 | if isempty(j2_series)
|
---|
1284 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
1285 | return
|
---|
1286 | end
|
---|
1287 | diff_j=j2_series-j1_series;
|
---|
1288 | min_diff=min(diff_j(diff_j>0));
|
---|
1289 | max_diff=max(diff_j(diff_j>0));
|
---|
1290 | for ipair=min_diff:max_diff
|
---|
1291 | if numel(diff_j(diff_j==ipair))>0
|
---|
1292 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ];
|
---|
1293 | if ~isempty(time)
|
---|
1294 | if ref_j<=floor(ipair/2)
|
---|
1295 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair
|
---|
1296 | end
|
---|
1297 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2));
|
---|
1298 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit];
|
---|
1299 | end
|
---|
1300 | displ_pair=[displ_pair;{pair_string}];
|
---|
1301 | end
|
---|
1302 | end
|
---|
1303 | if ~isempty(displ_pair)
|
---|
1304 | displ_pair=[displ_pair;{'Dj=*|*'}];
|
---|
1305 | end
|
---|
1306 | case 'bursts'
|
---|
1307 | if isempty(j2_series)
|
---|
1308 | msgbox_uvmat('ERROR','no j1-j2 pair available')
|
---|
1309 | return
|
---|
1310 | end
|
---|
1311 | %diff_j=j2_series-j1_series;
|
---|
1312 | min_j1=min(j1_series(j1_series>0));
|
---|
1313 | max_j1=max(j1_series(j1_series>0));
|
---|
1314 | min_j2=min(j2_series(j2_series>0));
|
---|
1315 | max_j2=max(j2_series(j2_series>0));
|
---|
1316 | for pair1=min_j1:min(max_j1,min_j1+20)
|
---|
1317 | for pair2=min_j2:min(max_j2,min_j2+20)
|
---|
1318 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0
|
---|
1319 | pair_string=['j= ' num2str(pair1) '-' num2str(pair2)];
|
---|
1320 | [TimeValue,DtValue]=get_time(ref_i,[],pair_string,InputTable,FileInfo,TimeName,'Dt');
|
---|
1321 | %Dt=time(ref_i,pair2+1)-time(ref_i,pair1+1);
|
---|
1322 | pair_string=[pair_string ', Dt=' num2str(DtValue) ' ' dtunit];
|
---|
1323 | displ_pair=[displ_pair;{pair_string}];
|
---|
1324 | end
|
---|
1325 | end
|
---|
1326 | end
|
---|
1327 | if ~isempty(displ_pair)
|
---|
1328 | displ_pair=[displ_pair;{'j=*-*'}];
|
---|
1329 | end
|
---|
1330 | end
|
---|
1331 |
|
---|
1332 | %------------------------------------------------------------------------
|
---|
1333 | function num_first_i_Callback(hObject, eventdata, handles)
|
---|
1334 | %------------------------------------------------------------------------
|
---|
1335 | num_last_i_Callback(hObject, eventdata, handles)
|
---|
1336 |
|
---|
1337 | %------------------------------------------------------------------------
|
---|
1338 | function num_last_i_Callback(hObject, eventdata, handles)
|
---|
1339 | %------------------------------------------------------------------------
|
---|
1340 | SeriesData=get(handles.series,'UserData');
|
---|
1341 | if ~isfield(SeriesData,'Time')
|
---|
1342 | SeriesData.Time{1}=[];
|
---|
1343 | end
|
---|
1344 | displ_time(handles);
|
---|
1345 |
|
---|
1346 | %------------------------------------------------------------------------
|
---|
1347 | function num_first_j_Callback(hObject, eventdata, handles)
|
---|
1348 | %------------------------------------------------------------------------
|
---|
1349 | num_last_j_Callback(hObject, eventdata, handles)
|
---|
1350 |
|
---|
1351 | %------------------------------------------------------------------------
|
---|
1352 | function num_last_j_Callback(hObject, eventdata, handles)
|
---|
1353 | %------------------------------------------------------------------------
|
---|
1354 | % first_j=str2num(get(handles.num_first_j,'String'));
|
---|
1355 | % last_j=str2num(get(handles.num_last_j,'String'));
|
---|
1356 | % ref_j=ceil((first_j+last_j)/2);
|
---|
1357 | % set(handles.num_ref_j,'String', num2str(ref_j))
|
---|
1358 | % num_ref_j_Callback(hObject, eventdata, handles)
|
---|
1359 | SeriesData=get(handles.series,'UserData');
|
---|
1360 | if ~isfield(SeriesData,'Time')
|
---|
1361 | SeriesData.Time{1}=[];
|
---|
1362 | end
|
---|
1363 | displ_time(handles);
|
---|
1364 |
|
---|
1365 | %------------------------------------------------------------------------
|
---|
1366 | % ---- find the times corresponding to the first and last indices of a series
|
---|
1367 | function displ_time(handles)
|
---|
1368 | %------------------------------------------------------------------------
|
---|
1369 | SeriesData=get(handles.series,'UserData');%
|
---|
1370 | if ~isfield(SeriesData,'Time')
|
---|
1371 | return
|
---|
1372 | end
|
---|
1373 | PairString=get(handles.PairString,'Data');
|
---|
1374 | ref_i_1=str2num(get(handles.num_first_i,'String'));%first reference index
|
---|
1375 | ref_i_2=str2num(get(handles.num_last_i,'String'));%last reference index
|
---|
1376 | ref_j_1=[];ref_j_2=[];
|
---|
1377 | if strcmp(get(handles.num_first_j,'Visible'),'on')
|
---|
1378 | ref_j_1=str2num(get(handles.num_first_j,'String'));
|
---|
1379 | ref_j_2=str2num(get(handles.num_last_j,'String'));
|
---|
1380 | end
|
---|
1381 | [i1_1,i2_1,j1_1,j2_1] = get_file_index(ref_i_1,ref_j_1,PairString);
|
---|
1382 | [i1_2,i2_2,j1_2,j2_2] = get_file_index(ref_i_2,ref_j_2,PairString);
|
---|
1383 | TimeTable=get(handles.TimeTable,'Data');
|
---|
1384 | %%%%%%
|
---|
1385 | %TODO: read time in netcdf file, see ActionName_Callback
|
---|
1386 | %%%%%%%
|
---|
1387 | %Pairs=get(handles.PairString,'Data');
|
---|
1388 | for iview=1:size(TimeTable,1)
|
---|
1389 | if size(SeriesData.Time,1)<iview
|
---|
1390 | break
|
---|
1391 | end
|
---|
1392 | TimeTable{iview,3}=[];
|
---|
1393 | TimeTable{iview,4}=[];
|
---|
1394 | if size(SeriesData.Time{iview},1)>=i2_2+1 && (isempty(ref_j_1)||size(SeriesData.Time{iview},2)>=j2_2+1)
|
---|
1395 | if isempty(ref_j_1)
|
---|
1396 | time_first=(SeriesData.Time{iview}(i1_1+1,2)+SeriesData.Time{iview}(i2_1+1,2))/2;
|
---|
1397 | time_last=(SeriesData.Time{iview}(i1_2+1,2)+SeriesData.Time{iview}(i2_2+1,2))/2;
|
---|
1398 | else
|
---|
1399 | time_first=(SeriesData.Time{iview}(i1_1+1,j1_1+1)+SeriesData.Time{iview}(i2_1+1,j2_1+1))/2;
|
---|
1400 | time_last=(SeriesData.Time{iview}(i1_2+1,j1_2+1)+SeriesData.Time{iview}(i2_2+1,j2_1+1))/2;
|
---|
1401 | end
|
---|
1402 | TimeTable{iview,3}=time_first; %TODO: take into account pairs
|
---|
1403 | TimeTable{iview,4}=time_last; %TODO: take into account pairs
|
---|
1404 | end
|
---|
1405 | end
|
---|
1406 | set(handles.TimeTable,'Data',TimeTable)
|
---|
1407 |
|
---|
1408 | %% set the waitbar position with respect to the min and max in the series
|
---|
1409 | MinIndex_i=min(get(handles.MinIndex_i,'Data'));
|
---|
1410 | MaxIndex_i=max(get(handles.MaxIndex_i,'Data'));
|
---|
1411 | pos_first=(ref_i_1-MinIndex_i)/(MaxIndex_i-MinIndex_i+1);
|
---|
1412 | pos_last=(ref_i_2-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1);
|
---|
1413 | if isempty(pos_first), pos_first=0; end
|
---|
1414 | if isempty(pos_last), pos_last=1; end
|
---|
1415 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height]
|
---|
1416 | Position_status=get(handles.FileStatus,'Position');
|
---|
1417 | Position(1)=Position_status(1)+Position_status(3)*pos_first;
|
---|
1418 | Position(3)=max(Position_status(3)*(pos_last-pos_first),0.001);% width must remain positive
|
---|
1419 | set(handles.Waitbar,'Position',Position)
|
---|
1420 | update_waitbar(handles.Waitbar,0)
|
---|
1421 |
|
---|
1422 | %------------------------------------------------------------------------
|
---|
1423 | % --- Executes when selected cell(s) is changed in PairString.
|
---|
1424 | function PairString_CellSelectionCallback(hObject, eventdata, handles)
|
---|
1425 | %------------------------------------------------------------------------
|
---|
1426 | if numel(eventdata.Indices)>=1
|
---|
1427 | PairString=get(hObject,'Data');
|
---|
1428 | if ~isempty(PairString{eventdata.Indices(1)})
|
---|
1429 | SetPairs_Callback(hObject, eventdata.Indices(1), handles)
|
---|
1430 | end
|
---|
1431 | end
|
---|
1432 |
|
---|
1433 | %-------------------------------------
|
---|
1434 | function enable_i(handles,state)
|
---|
1435 | set(handles.i_txt,'Visible',state)
|
---|
1436 | set(handles.num_first_i,'Visible',state)
|
---|
1437 | set(handles.num_last_i,'Visible',state)
|
---|
1438 | set(handles.num_incr_i,'Visible',state)
|
---|
1439 |
|
---|
1440 | %-----------------------------------
|
---|
1441 | function enable_j(handles,state)
|
---|
1442 | set(handles.j_txt,'Visible',state)
|
---|
1443 | set(handles.num_first_j,'Visible',state)
|
---|
1444 | set(handles.num_last_j,'Visible',state)
|
---|
1445 | set(handles.num_incr_j,'Visible',state)
|
---|
1446 | set(handles.MinIndex_j,'Visible',state)
|
---|
1447 | set(handles.MaxIndex_j,'Visible',state)
|
---|
1448 |
|
---|
1449 |
|
---|
1450 | %%%%%%%%%%%%%%%%%%%%
|
---|
1451 | %% MAIN ActionName FUNCTIONS
|
---|
1452 | %%%%%%%%%%%%%%%%%%%%
|
---|
1453 | %------------------------------------------------------------------------
|
---|
1454 | % --- Executes on button press in RUN.
|
---|
1455 | %------------------------------------------------------------------------
|
---|
1456 | function RUN_Callback(hObject, eventdata, handles)
|
---|
1457 |
|
---|
1458 | %% settings of the button RUN
|
---|
1459 | set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel'
|
---|
1460 | set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished
|
---|
1461 | set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color
|
---|
1462 | drawnow
|
---|
1463 | set(handles.status,'Value',0)% desable status display if relevant
|
---|
1464 | status_Callback([], eventdata, handles)
|
---|
1465 |
|
---|
1466 | %% launch action
|
---|
1467 | errormsg=launch_action(handles);
|
---|
1468 | if ~isempty(errormsg)
|
---|
1469 | msgbox_uvmat('ERROR',errormsg)
|
---|
1470 | end
|
---|
1471 |
|
---|
1472 | %% reset the GUI series
|
---|
1473 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
|
---|
1474 | set(handles.RUN, 'Enable','On')
|
---|
1475 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
1476 | set(handles.RUN, 'Value',0)
|
---|
1477 |
|
---|
1478 | %------------------------------------------------------------------------
|
---|
1479 | % --- called by RUN_Callback
|
---|
1480 | %------------------------------------------------------------------------
|
---|
1481 | function errormsg=launch_action(handles)
|
---|
1482 | errormsg='';%default
|
---|
1483 |
|
---|
1484 | %% read the data on the GUI series
|
---|
1485 | Param=read_GUI_series(handles);%displayed parameters
|
---|
1486 | SeriesData=get(handles.series,'UserData');%hidden parameters
|
---|
1487 | if isfield(SeriesData,'TransformInput')
|
---|
1488 | Param.TransformInput=SeriesData.TransformInput;
|
---|
1489 | end
|
---|
1490 | if ~isfield(SeriesData,'i1_series')
|
---|
1491 | errormsg='The input field series needs to be refreshed: press REFRESH';
|
---|
1492 | return
|
---|
1493 | end
|
---|
1494 | if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...')
|
---|
1495 | errormsg='input field name(s) not defined, select get_field...';
|
---|
1496 | return
|
---|
1497 | end
|
---|
1498 |
|
---|
1499 | %% select the Action mode, 'local', 'background' or 'cluster' (if available)
|
---|
1500 | RunMode='local';%default (needed for first opening of the GUI series)
|
---|
1501 | if isfield(Param.Action,'RunMode')
|
---|
1502 | RunMode=Param.Action.RunMode;
|
---|
1503 | Param.Action=rmfield(Param.Action,'RunMode');%remove from the recorded xml file to avoid interference during ImportConfig
|
---|
1504 | end
|
---|
1505 | ActionExt='.m';%default
|
---|
1506 | if isfield(Param.Action,'ActionExt')
|
---|
1507 | ActionExt=Param.Action.ActionExt;% '.m', '.sh' (compiled) or '.py' (Python)
|
---|
1508 | Param.Action=rmfield(Param.Action,'ActionExt');%remove from the recorded xml file to avoid interference during ImportConfig
|
---|
1509 | end
|
---|
1510 | ActionName=Param.Action.ActionName;
|
---|
1511 | ActionPath=Param.Action.ActionPath;
|
---|
1512 | path_series=fileparts(which('series'));
|
---|
1513 |
|
---|
1514 | %% create the Action fct handle if RunMode option = 'local'
|
---|
1515 | if strcmp(RunMode,'local')
|
---|
1516 | if ~isequal(ActionPath,path_series)
|
---|
1517 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
|
---|
1518 | if ~exist(ActionPath,'dir')
|
---|
1519 | errormsg=['The prescribed function path ' ActionPath ' does not exist'];
|
---|
1520 | return
|
---|
1521 | end
|
---|
1522 | if ~isequal(spath,ActionPath)
|
---|
1523 | addpath(ActionPath)% add the prescribed path if not the current one
|
---|
1524 | end
|
---|
1525 | end
|
---|
1526 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
|
---|
1527 | if ~isequal(ActionPath,path_series)
|
---|
1528 | rmpath(ActionPath)% add the prescribed path if not the current one
|
---|
1529 | end
|
---|
1530 | end
|
---|
1531 |
|
---|
1532 | %% Get PARAM.xml (not used at this stage)
|
---|
1533 | errormsg='';%default error message
|
---|
1534 | xmlfile=fullfile(path_series,'PARAM.xml');
|
---|
1535 | if ~exist(xmlfile,'file')
|
---|
1536 | [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile);
|
---|
1537 | end
|
---|
1538 | if strcmp(ActionExt,'.sh')
|
---|
1539 | if exist(xmlfile,'file')
|
---|
1540 | s=xml2struct(xmlfile);
|
---|
1541 | if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
|
---|
1542 | if isfield(s.BatchParam,'NbCore')
|
---|
1543 | NbCore=s.BatchParam.NbCore;
|
---|
1544 | end
|
---|
1545 | elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam')
|
---|
1546 | if isfield(s.RunParam,'NbCore')
|
---|
1547 | NbCore=s.RunParam.NbCore;
|
---|
1548 | end
|
---|
1549 | end
|
---|
1550 | end
|
---|
1551 | end
|
---|
1552 | ActionFullName=fullfile(get(handles.ActionPath,'String'),ActionName);
|
---|
1553 |
|
---|
1554 | %% If a compiled version has been selected (ext .sh) check wether it needs to be recompiled
|
---|
1555 | if strcmp(ActionExt,'.sh')
|
---|
1556 | TransformPath='';
|
---|
1557 | if ~isempty(get(handles.ActionExt,'UserData'))
|
---|
1558 | TransformPath=get(handles.ActionExt,'UserData');
|
---|
1559 | end
|
---|
1560 | set(handles.series,'Pointer','watch') % set the mouse pointer to 'watch'
|
---|
1561 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1562 | [mcrmajor, mcrminor] = mcrversion;
|
---|
1563 | MCRROOT = ['MCRROOT',int2str(mcrmajor),int2str(mcrminor)];
|
---|
1564 | RunTime = getenv(MCRROOT);
|
---|
1565 | ActionNameVersion=[ActionName '_' MCRROOT];
|
---|
1566 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']);
|
---|
1567 | % compile the .m file if the .sh file does not exist yet
|
---|
1568 | if ~exist(ActionFullName,'file')
|
---|
1569 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
|
---|
1570 | if strcmp(answer,'Yes')
|
---|
1571 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1572 | path_uvmat=fileparts(which('series'));
|
---|
1573 | currentdir=pwd;
|
---|
1574 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
1575 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
1576 | compile(ActionName,TransformPath)
|
---|
1577 | cd(currentdir)
|
---|
1578 | else
|
---|
1579 | errormsg='Action launch interrupted';
|
---|
1580 | return
|
---|
1581 | end
|
---|
1582 | else
|
---|
1583 | sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionNameVersion '.sh']));
|
---|
1584 | m_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.m']));
|
---|
1585 | if isfield(m_file_info,'datenum') && m_file_info.datenum>sh_file_info.datenum
|
---|
1586 | set(handles.ActionExt,'BackgroundColor',[1 1 0])
|
---|
1587 | drawnow
|
---|
1588 | answer=msgbox_uvmat('INPUT_Y-N',[ActionNameVersion '.sh needs to be updated: recompile now?']);
|
---|
1589 | if strcmp(answer,'Yes')
|
---|
1590 | path_uvmat=fileparts(which('series'));
|
---|
1591 | currentdir=pwd;
|
---|
1592 | cd(get(handles.ActionPath,'String'))% go to the directory of Action
|
---|
1593 | addpath(path_uvmat)% add the path to uvmat to run the fct 'compile'
|
---|
1594 | addpath(fullfile(path_uvmat,'transform_field'))% add the path to uvmat to run the fct 'compile'
|
---|
1595 | compile(ActionName,TransformPath)
|
---|
1596 | cd(currentdir)
|
---|
1597 | end
|
---|
1598 | end
|
---|
1599 | end
|
---|
1600 |
|
---|
1601 | set(handles.ActionExt,'BackgroundColor',[1 1 1])
|
---|
1602 | set(handles.series,'Pointer','arrow') % set the mouse pointer to 'watch
|
---|
1603 | end
|
---|
1604 |
|
---|
1605 | %% set nbre of cluster cores and processes:
|
---|
1606 | % NbCore is the number of computer processors used
|
---|
1607 | % NbProcess is the number of independent processes in which the required calculation is split.
|
---|
1608 | switch RunMode
|
---|
1609 | case {'local','background'}
|
---|
1610 | NbCore=1;% no need to split the calculation
|
---|
1611 | case 'cluster_oar'
|
---|
1612 | if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
1613 | NbCore=1;% one core used only (limitation of Matlab licences)
|
---|
1614 | answer=msgbox_uvmat('INPUT_Y-N','Number of cores =1: select the compiled version .sh for multi-core processing. Proceed with the .m version?');
|
---|
1615 | if ~strcmp(answer,'Yes')
|
---|
1616 | errormsg='Action launch interrupted by user';
|
---|
1617 | return
|
---|
1618 | end
|
---|
1619 | extra_oar='';
|
---|
1620 | else
|
---|
1621 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
|
---|
1622 | if isempty(answer)
|
---|
1623 | errormsg='Action launch interrupted by user';
|
---|
1624 | return
|
---|
1625 | end
|
---|
1626 | NbCore=str2double(answer{1});
|
---|
1627 | extra_oar=answer{2};
|
---|
1628 | end
|
---|
1629 | case 'cluster_pbs'
|
---|
1630 | if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled)
|
---|
1631 | NbCore=1;% one core used only (limitation of Matlab licences)
|
---|
1632 | answer=msgbox_uvmat('INPUT_Y-N','Number of cores =1: select the compiled version .sh for multi-core processing. Proceed with the .m version?');
|
---|
1633 | if ~strcmp(answer,'Yes')
|
---|
1634 | errormsg='Action launch interrupted';
|
---|
1635 | return
|
---|
1636 | end
|
---|
1637 | extra_oar='';
|
---|
1638 | else
|
---|
1639 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
|
---|
1640 | NbCore=str2double(answer{1});
|
---|
1641 | %extra_oar=answer{2};%TODO : fix this for LMFA cluster. Maybe
|
---|
1642 | %extrs_oar and extra_pbs are not the best names
|
---|
1643 | end
|
---|
1644 | end
|
---|
1645 | if ~isfield(Param.IndexRange,'NbSlice')
|
---|
1646 | Param.IndexRange.NbSlice=[];
|
---|
1647 | end
|
---|
1648 |
|
---|
1649 | %% create the output data directory if needed
|
---|
1650 | OutputDir='';
|
---|
1651 | if isfield(Param,'OutputSubDir')
|
---|
1652 | SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
|
---|
1653 | SubDirOutNew=SubDirOut;
|
---|
1654 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist
|
---|
1655 | check_create=1; %need to create the result directory by default
|
---|
1656 | CheckOverwrite=1;
|
---|
1657 | if isfield(Param,'CheckOverwrite')
|
---|
1658 | CheckOverwrite=Param.CheckOverwrite;
|
---|
1659 | end
|
---|
1660 | while detect
|
---|
1661 | if CheckOverwrite
|
---|
1662 | comment=', possibly overwrite previous data';
|
---|
1663 | else
|
---|
1664 | comment=', will complement existing result files (no overwriting)';
|
---|
1665 | end
|
---|
1666 | answer=msgbox_uvmat('INPUT_Y-N-Cancel',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) comment]);
|
---|
1667 | if strcmp(answer,'Cancel')
|
---|
1668 | return
|
---|
1669 | elseif strcmp(answer,'Yes')
|
---|
1670 | detect=0;
|
---|
1671 | check_create=0;
|
---|
1672 | else
|
---|
1673 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
|
---|
1674 | if isempty(r)
|
---|
1675 | r(1).root=[SubDirOutNew '_'];
|
---|
1676 | r(1).num1='0';
|
---|
1677 | end
|
---|
1678 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
|
---|
1679 | detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists
|
---|
1680 | check_create=1;
|
---|
1681 | end
|
---|
1682 | end
|
---|
1683 | Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,'');
|
---|
1684 | Param.OutputRootFile=Param.InputTable{1,3};% the first sorted RootFile taken for output
|
---|
1685 | set(handles.OutputDirExt,'String',Param.OutputDirExt)
|
---|
1686 | OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);% full name (with path) of output directory
|
---|
1687 | if check_create % create output directory if it does not exist
|
---|
1688 | [tild,msg1]=mkdir(OutputDir);
|
---|
1689 | if ~strcmp(msg1,'')
|
---|
1690 | errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation
|
---|
1691 | return
|
---|
1692 | end
|
---|
1693 | end
|
---|
1694 |
|
---|
1695 | elseif isfield(Param,'ActionInput')&&isfield(Param.ActionInput,'LogPath')% custom definition of the output dir
|
---|
1696 | OutputDir=Param.ActionInput.LogPath;
|
---|
1697 | end
|
---|
1698 | DirXml=fullfile(OutputDir,'0_XML');
|
---|
1699 | if ~exist(DirXml,'dir')
|
---|
1700 | [tild,msg1]=mkdir(DirXml);
|
---|
1701 | if ~strcmp(msg1,'')
|
---|
1702 | errormsg=['cannot create ' DirXml ': ' msg1];%error message for directory creation
|
---|
1703 | return
|
---|
1704 | end
|
---|
1705 | end
|
---|
1706 | OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files
|
---|
1707 |
|
---|
1708 | %% get the set of reference input field indices
|
---|
1709 | first_i=1;% first i index to process
|
---|
1710 | last_i=1;% last i index to process
|
---|
1711 | incr_i=1;% increment step in i index
|
---|
1712 | first_j=1;% first j index to process
|
---|
1713 | last_j=1;% last j index to process
|
---|
1714 | incr_j=1;% increment step in j index
|
---|
1715 | if isfield(Param.IndexRange,'first_i')
|
---|
1716 | first_i=Param.IndexRange.first_i;
|
---|
1717 | incr_i=Param.IndexRange.incr_i;
|
---|
1718 | last_i=Param.IndexRange.last_i;
|
---|
1719 | end
|
---|
1720 | if isfield(Param.IndexRange,'first_j')
|
---|
1721 | first_j=Param.IndexRange.first_j;
|
---|
1722 | last_j=Param.IndexRange.last_j;
|
---|
1723 | incr_j=Param.IndexRange.incr_j;
|
---|
1724 | end
|
---|
1725 | if last_i < first_i || last_j < first_j
|
---|
1726 | errormsg= 'series/Run_Callback:last field index must be larger or equal to the first one';
|
---|
1727 | return
|
---|
1728 | end
|
---|
1729 | %incr_i must be defined, =1 by default, if NbSlice is active
|
---|
1730 | if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice)
|
---|
1731 | incr_i=1;
|
---|
1732 | set(handles.num_incr_i,'String','1')
|
---|
1733 | end
|
---|
1734 | % case of no increment i defined: processing is done on the available files found in i1_series
|
---|
1735 | if isempty(incr_i)
|
---|
1736 | if isempty(incr_j)
|
---|
1737 | [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1738 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
1739 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
1740 | ref_j=ref_j-1;
|
---|
1741 | ref_i=ref_i-1;
|
---|
1742 | else
|
---|
1743 | ref_j=first_j:incr_j:last_j;
|
---|
1744 | [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1745 | ref_i=ref_i-1;
|
---|
1746 | ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
|
---|
1747 | end
|
---|
1748 | % increment i is defined: processing is done on first_i:incr_i:last_i;
|
---|
1749 | else
|
---|
1750 | ref_i=first_i:incr_i:last_i;
|
---|
1751 | if isempty(incr_j)% automatic finding of the existing j indices
|
---|
1752 | [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
|
---|
1753 | ref_j=ref_j-1;
|
---|
1754 | ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
|
---|
1755 | else
|
---|
1756 | ref_j=first_j:incr_j:last_j;
|
---|
1757 | end
|
---|
1758 | end
|
---|
1759 | CPUTime=1;% job time estimated at 1 min per iteration (on index i and j) by default
|
---|
1760 | if isfield(Param.Action, 'CPUTime') && ~isempty(Param.Action.CPUTime)
|
---|
1761 | CPUTime=Param.Action.CPUTime;%Note: CpUTime for one iteration ref_i has to be multiplied by the number of j indices nbfield_j
|
---|
1762 | end
|
---|
1763 | nbfield_j=numel(ref_j); % number of j indices
|
---|
1764 | BlockLength=numel(ref_i);% by default, job involves the full set of i field indices
|
---|
1765 | NbProcess=1;
|
---|
1766 | switch RunMode
|
---|
1767 | case {'cluster_oar','cluster_pbs'}
|
---|
1768 | if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
|
---|
1769 | BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
|
---|
1770 | BlockLength=max(BlockLength,ceil(numel(ref_i)/500));% possibly increase the BlockLength to have less than 500 jobs
|
---|
1771 | NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
|
---|
1772 | else
|
---|
1773 | NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
|
---|
1774 | NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes
|
---|
1775 | end
|
---|
1776 | otherwise
|
---|
1777 | if ~isempty(Param.IndexRange.NbSlice)
|
---|
1778 | NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
|
---|
1779 | end
|
---|
1780 | end
|
---|
1781 |
|
---|
1782 | %% record nbre of output files and starting time for computation for status
|
---|
1783 | StatusData=get(handles.status,'UserData');
|
---|
1784 | if isfield(StatusData,'OutputFileMode')
|
---|
1785 | switch StatusData.OutputFileMode
|
---|
1786 | case 'NbInput'
|
---|
1787 | StatusData.NbOutputFile=numel(ref_i)*nbfield_j;
|
---|
1788 | case 'NbInput_i'
|
---|
1789 | StatusData.NbOutputFile=numel(ref_i);
|
---|
1790 | case 'NbSlice'
|
---|
1791 | StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
|
---|
1792 | end
|
---|
1793 | end
|
---|
1794 | StatusData.TimeStart=now;
|
---|
1795 | set(handles.status,'UserData',StatusData)
|
---|
1796 |
|
---|
1797 | %% case of a function in Python
|
---|
1798 | if strcmp(ActionExt, '.py (in dev.)')
|
---|
1799 | fprintf([
|
---|
1800 | '\n' ...
|
---|
1801 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' ...
|
---|
1802 | 'The option .py is used. It is still in development.\n' ...
|
---|
1803 | 'Do not use it unless you really know what you do!\n' ...
|
---|
1804 | 'To try it, first install Pyp and the most recent version of FluidDyn.\n' ...
|
---|
1805 | '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
|
---|
1806 | RunMode = 'python';
|
---|
1807 | end
|
---|
1808 |
|
---|
1809 |
|
---|
1810 | %% direct processing on the current Matlab session or creation of command files
|
---|
1811 | filexml=cell(1,NbProcess);% initialisation of the names of the files containing the processing parameters
|
---|
1812 | extxml=cell(1,NbProcess); % initialisation of the set of labels used for the files documenting each process
|
---|
1813 | for iprocess=1:NbProcess
|
---|
1814 | extxml{iprocess}='.xml';
|
---|
1815 | end
|
---|
1816 | for iprocess=1:NbProcess
|
---|
1817 | if ~strcmp(get(handles.RUN,'BusyAction'),'queue')% allow for STOP action
|
---|
1818 | disp('program stopped by user')
|
---|
1819 | return
|
---|
1820 | end
|
---|
1821 | if isempty(Param.IndexRange.NbSlice)
|
---|
1822 | Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
|
---|
1823 | if Param.IndexRange.first_i>last_i
|
---|
1824 | NbProcess=iprocess-1;% leave the loop, we are at the end of the calculation
|
---|
1825 | break
|
---|
1826 | end
|
---|
1827 | Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
|
---|
1828 | else %multislices (then incr_i is not empty)
|
---|
1829 | Param.IndexRange.first_i= first_i+iprocess-1;
|
---|
1830 | Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
|
---|
1831 | end
|
---|
1832 | for ilist=1:size(Param.InputTable,1)
|
---|
1833 | Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/');%correct path name for PCWIN system
|
---|
1834 | end
|
---|
1835 |
|
---|
1836 | if isfield(Param,'OutputSubDir')
|
---|
1837 | t=struct2xml(Param);
|
---|
1838 | t=set(t,1,'name','Series');
|
---|
1839 | extxml{iprocess}=fullfile_uvmat('','',Param.InputTable{1,3},'.xml',OutputNomType,...
|
---|
1840 | Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
|
---|
1841 | filexml{iprocess}=fullfile(OutputDir,'0_XML',extxml{iprocess});
|
---|
1842 | try
|
---|
1843 | save(t, filexml{iprocess});% save the xml file containing the processing parameters
|
---|
1844 | catch ME
|
---|
1845 | if ~strcmp (RunMode,'local')
|
---|
1846 | errormsg=['error writting ' filexml{iprocess} ': ' ME.message];
|
---|
1847 | return
|
---|
1848 | end
|
---|
1849 | end
|
---|
1850 | end
|
---|
1851 | if strcmp (RunMode,'local')
|
---|
1852 | switch ActionExt
|
---|
1853 | case '.m'
|
---|
1854 | h_fun(Param);% direct launching
|
---|
1855 |
|
---|
1856 | case '.sh'
|
---|
1857 | switch computer
|
---|
1858 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
1859 | filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters
|
---|
1860 | system([ActionFullName ' ' RunTime ' ' filexml]);% TODO: adapt to DOS system
|
---|
1861 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
1862 | system([ActionFullName ' ' RunTime ' ' filexml]);
|
---|
1863 | end
|
---|
1864 | end
|
---|
1865 | end
|
---|
1866 | end
|
---|
1867 |
|
---|
1868 | if ~strcmp (RunMode,'local') && ~strcmp(RunMode,'python')
|
---|
1869 | %% processing on a different session of the same computer (background) or cluster, create executable files
|
---|
1870 | batch_file_list=cell(NbProcess,1);% initiate the list of executable files
|
---|
1871 | DirExe=fullfile(OutputDir,'0_EXE');%directory name for executable files
|
---|
1872 | switch computer
|
---|
1873 | case {'PCWIN','PCWIN64'} %Windows system
|
---|
1874 | ExeExt='.bat';
|
---|
1875 | case {'GLNX86','GLNXA64','MACI64'}%Linux system
|
---|
1876 | ExeExt='.sh';
|
---|
1877 | end
|
---|
1878 | %create subdirectory for executable files
|
---|
1879 | if ~exist(DirExe,'dir')
|
---|
1880 | [tild,msg1]=mkdir(DirExe);
|
---|
1881 | if ~strcmp(msg1,'')
|
---|
1882 | errormsg=['cannot create ' DirExe ': ' msg1];%error message for directory creation
|
---|
1883 | return
|
---|
1884 | end
|
---|
1885 | end
|
---|
1886 | %create subdirectory for log files
|
---|
1887 | DirLog=fullfile(OutputDir,'0_LOG');
|
---|
1888 | if ~exist(DirLog,'dir')
|
---|
1889 | [tild,msg1]=mkdir(DirLog);
|
---|
1890 | if ~strcmp(msg1,'')
|
---|
1891 | errormsg=['cannot create ' DirLog ': ' msg1];%error message for directory creation
|
---|
1892 | return
|
---|
1893 | end
|
---|
1894 | end
|
---|
1895 |
|
---|
1896 | %create the executable file
|
---|
1897 | file_exe_global=fullfile_uvmat('','',Param.InputTable{1,3},ExeExt,OutputNomType,...
|
---|
1898 | first_i,last_i,first_j,last_j);
|
---|
1899 | file_exe_global=fullfile(OutputDir,'0_EXE',file_exe_global);
|
---|
1900 | filelog_global=fullfile_uvmat('','',Param.InputTable{1,3},'.log',OutputNomType,...
|
---|
1901 | first_i,last_i,first_j,last_j);
|
---|
1902 | filelog_global=fullfile(OutputDir,'0_LOG',filelog_global);
|
---|
1903 |
|
---|
1904 | for iprocess=1:NbProcess
|
---|
1905 |
|
---|
1906 | %create the executable file
|
---|
1907 |
|
---|
1908 | batch_file_list{iprocess}=fullfile(OutputDir,'0_EXE',regexprep(extxml{iprocess},'.xml$',ExeExt));
|
---|
1909 |
|
---|
1910 | % set the log file name
|
---|
1911 | filelog{iprocess}=fullfile(OutputDir,'0_LOG',regexprep(extxml{iprocess},'.xml$','.log'));
|
---|
1912 |
|
---|
1913 | end
|
---|
1914 | end
|
---|
1915 |
|
---|
1916 | %% launch the executable files for background or cluster processing
|
---|
1917 |
|
---|
1918 | switch RunMode
|
---|
1919 |
|
---|
1920 | case 'background'
|
---|
1921 | [fid,message]=fopen(file_exe_global,'w');
|
---|
1922 | if isequal(fid,-1)
|
---|
1923 | errormsg=['creation of ' file_exe_global ':' message];
|
---|
1924 | return
|
---|
1925 | end
|
---|
1926 | switch ActionExt
|
---|
1927 | case '.m'% Matlab function
|
---|
1928 | switch computer
|
---|
1929 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
1930 | cmd=[...
|
---|
1931 | '#!/bin/bash \n'...
|
---|
1932 | '. /etc/sysprofile \n'...
|
---|
1933 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog_global ''' <<END_MATLAB \n'...
|
---|
1934 | 'addpath(''' path_series '''); \n'...
|
---|
1935 | 'addpath(''' Param.Action.ActionPath '''); \n'];
|
---|
1936 | for iprocess=1:NbProcess
|
---|
1937 | cmd=[cmd '' Param.Action.ActionName '( ''' filexml{iprocess} '''); \n'];
|
---|
1938 | end
|
---|
1939 | cmd=[cmd 'exit \n' 'END_MATLAB \n'];
|
---|
1940 | fprintf(fid,cmd);%fill the executable file with the char string cmd
|
---|
1941 | fclose(fid);% close the executable file
|
---|
1942 | system(['chmod +x ' file_exe_global]);% set the file to executable
|
---|
1943 | case {'PCWIN','PCWIN64'}
|
---|
1944 | cmd=['matlab -automation -logfile ' regexprep(filelog{iprocess},'\\','\\\\')...
|
---|
1945 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
|
---|
1946 | 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'];
|
---|
1947 | for iprocess=1:NbProcess
|
---|
1948 | cmd=[cmd '' Param.Action.ActionName '( ''' regexprep(filexml{iprocess},'\\','\\\\') ''');']
|
---|
1949 | end
|
---|
1950 | cmd=[cmd ';exit"'];
|
---|
1951 | fprintf(fid,cmd);%fill the executable file with the char string cmd
|
---|
1952 | fclose(fid);% close the executable file
|
---|
1953 | end
|
---|
1954 | system([file_exe_global ' &'])% directly execute the command file
|
---|
1955 | case '.sh' % compiled Matlab function
|
---|
1956 | for iprocess=1:NbProcess
|
---|
1957 | switch computer
|
---|
1958 | case {'GLNX86','GLNXA64','MACI64'}
|
---|
1959 | [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
|
---|
1960 | if isequal(fid,-1)
|
---|
1961 | errormsg=['creation of .bat file: ' message];
|
---|
1962 | return
|
---|
1963 | end
|
---|
1964 | cmd=['#!/bin/bash \n '...
|
---|
1965 | '#$ -cwd \n '...
|
---|
1966 | 'hostname && date \n '...
|
---|
1967 | 'umask 002 \n'...
|
---|
1968 | ActionFullName ' ' RunTime ' ' filexml{iprocess}];%allow writting access to created files for user group
|
---|
1969 | fprintf(fid,cmd);%fill the executable file with the char string cmd
|
---|
1970 | fclose(fid);% close the executable file
|
---|
1971 | system(['chmod +x ' batch_file_list{iprocess}]);% set the file to executable
|
---|
1972 | system([batch_file_list{iprocess} ' &'])% directly execute the command file
|
---|
1973 | case {'PCWIN','PCWIN64'}
|
---|
1974 | msgbox_uvmat('ERROR','option for compiled Matlab functions not implemented for Windows system')
|
---|
1975 | return
|
---|
1976 | end
|
---|
1977 | end
|
---|
1978 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched in background: press STATUS to see results'])
|
---|
1979 | end
|
---|
1980 |
|
---|
1981 | case 'cluster_oar' % option 'oar-parexec' used
|
---|
1982 | %create subdirectory for oar commands
|
---|
1983 | for iprocess=1:NbProcess
|
---|
1984 | [fid,message]=fopen(batch_file_list{iprocess},'w');% create the executable file
|
---|
1985 | if isequal(fid,-1)
|
---|
1986 | errormsg=['creation of .bat file: ' message];
|
---|
1987 | return
|
---|
1988 | end
|
---|
1989 | if strcmp(ActionExt,'.sh')
|
---|
1990 | cmd=['#!/bin/bash \n '...
|
---|
1991 | '#$ -cwd \n '...
|
---|
1992 | 'hostname && date \n '...
|
---|
1993 | 'umask 002 \n'...
|
---|
1994 | ActionFullName ' ' RunTime ' ' filexml{iprocess}];%allow writting access to created files for user group
|
---|
1995 | else
|
---|
1996 | cmd=[...
|
---|
1997 | '#!/bin/bash \n'...
|
---|
1998 | '. /etc/sysprofile \n'...
|
---|
1999 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog{iprocess} ''' <<END_MATLAB \n'...
|
---|
2000 | 'addpath(''' path_series '''); \n'...
|
---|
2001 | 'addpath(''' Param.Action.ActionPath '''); \n'...
|
---|
2002 | '' Param.Action.ActionName '( ''' filexml{iprocess} '''); \n'...
|
---|
2003 | 'exit \n'...
|
---|
2004 | 'END_MATLAB \n'];
|
---|
2005 | end
|
---|
2006 | fprintf(fid,cmd);%fill the executable file with the char string cmd
|
---|
2007 | fclose(fid);% close the executable file
|
---|
2008 | system(['chmod +x ' batch_file_list{iprocess}]);% set the file to executable
|
---|
2009 | end
|
---|
2010 | DirOAR=fullfile(OutputDir,'0_OAR');
|
---|
2011 | if exist(DirOAR,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
2012 | curdir=pwd;
|
---|
2013 | cd(DirOAR)
|
---|
2014 | delete('*')
|
---|
2015 | cd(curdir)
|
---|
2016 | else
|
---|
2017 | [tild,msg1]=mkdir(DirOAR);
|
---|
2018 | if ~strcmp(msg1,'')
|
---|
2019 | errormsg=['cannot create ' DirOAR ': ' msg1];%error message for directory creation
|
---|
2020 | return
|
---|
2021 | end
|
---|
2022 | end
|
---|
2023 | % create file containing the list of jobs
|
---|
2024 | filename_joblist=fullfile(DirOAR,'job_list.txt');% name of the file containing the list of executables
|
---|
2025 | fid=fopen(filename_joblist,'w');%open it for writting
|
---|
2026 | for iprocess=1:length(batch_file_list)
|
---|
2027 | fprintf(fid,[batch_file_list{iprocess} '\n']);% write list of exe files
|
---|
2028 | end
|
---|
2029 | fclose(fid);
|
---|
2030 | system(['chmod +x ' filename_joblist]);% set the file to executable
|
---|
2031 |
|
---|
2032 | filename_log=fullfile(DirLog,'job_list.stdout');%file for output messages of the master oar process
|
---|
2033 | filename_errors=fullfile(DirLog,'job_list.stderr');%file for error messages of the master oar process
|
---|
2034 | % the command job_list.txt contains the list of NbProcess independent individual jobs
|
---|
2035 | % in which the total calculation has been split. Those are written as executable files .sh in the folder /O_EXE.
|
---|
2036 | % These individual jobs are grouped by the system as oar jobs on the NbCore processors.
|
---|
2037 | % For each processor, the oar job must stop after the walltime which has been set, which is limited to 24 h.
|
---|
2038 | % However, the oar job is automatically restarted (option 'idempotent') provided the individual jobs are
|
---|
2039 | % shorter than the wall time: in the time interval 'checkpoint' (WallTimeOneJob) before the end of the allowed duration,
|
---|
2040 | % the oar job restarts when an individual job ends.
|
---|
2041 | JobTime=CPUTime*BlockLength*nbfield_j;% estimated time for one individual job (in minutes)
|
---|
2042 | % wall time (in hours ) for each oar job, allowing 10 individual jobs, but limited to 23 h:
|
---|
2043 | WallTimeTotal=min(23,4*JobTime/60);
|
---|
2044 | %disp(['WallTimeTotal: ' num2str(WallTimeTotal) ' hours'])
|
---|
2045 | % estimated time of an individual job (in min), with a margin of error
|
---|
2046 | WallTimeOneJob=min(4*JobTime+10,WallTimeTotal*60/2);% estimated max time of an individual job for checkpoint
|
---|
2047 | disp(['WallTimeOneJob: ' num2str(WallTimeOneJob) ' minutes'])
|
---|
2048 | oar_command=['oarsub -n UVmat_' ActionFullName ' '...
|
---|
2049 | '-t idempotent --checkpoint ' num2str(WallTimeOneJob*60) ' '...
|
---|
2050 | '-l /core=' num2str(NbCore) ','...
|
---|
2051 | 'walltime=' datestr(WallTimeTotal/24,13) ' '...
|
---|
2052 | '-E ' filename_errors ' '...
|
---|
2053 | '-O ' filename_log ' '...
|
---|
2054 | extra_oar ' '...
|
---|
2055 | '"oar-parexec -s -f ' filename_joblist ' '...
|
---|
2056 | '-l ' filename_joblist '.log"'];
|
---|
2057 |
|
---|
2058 | fprintf(oar_command);% display system command on the Matlab command window
|
---|
2059 | [status,result]=system(oar_command)% execute system command and show the result (ID number of the launched job) on the Matlab command window
|
---|
2060 | filename_oarcommand=fullfile(DirOAR,'0_oar_command');% keep track of the command in file '0-OAR/0_oar_command'
|
---|
2061 | fid=fopen(filename_oarcommand,'w');
|
---|
2062 | fprintf(fid,oar_command); % store the command
|
---|
2063 | fprintf(fid,result);% store the result (job ID number)
|
---|
2064 | fclose(fid);
|
---|
2065 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' launched as ' num2str(NbProcess) ' processes in cluster: press STATUS to see results'])
|
---|
2066 |
|
---|
2067 | case 'cluster_pbs' % for LMFA Kepler machine
|
---|
2068 | %create subdirectory for pbs command and log files
|
---|
2069 | DirPBS=fullfile(OutputDir,'0_PBS'); %todo : common name OAR/PBS
|
---|
2070 | if exist(DirPBS,'dir')% delete the content of the dir 0_LOG to allow new input
|
---|
2071 | curdir=pwd;
|
---|
2072 | cd(DirPBS)
|
---|
2073 | delete('*')
|
---|
2074 | cd(curdir)
|
---|
2075 | else
|
---|
2076 | [tild,msg1]=mkdir(DirPBS);
|
---|
2077 | if ~strcmp(msg1,'')
|
---|
2078 | errormsg=['cannot create ' DirPBS ': ' msg1];%error message for directory creation
|
---|
2079 | return
|
---|
2080 | end
|
---|
2081 | end
|
---|
2082 | max_walltime=3600*20; % 20h max total calculation (cannot exceed 24 h)
|
---|
2083 | walltime_onejob=1800; % seconds, max estimated time for asingle file index value
|
---|
2084 | filename_joblist=fullfile(DirPBS,'job_list.txt');%create name of the global executable file
|
---|
2085 | fid=fopen(filename_joblist,'w');
|
---|
2086 | for iprocess=1:length(batch_file_list)
|
---|
2087 | fprintf(fid,[batch_file_list{iprocess} '\n']);% list of exe files
|
---|
2088 | end
|
---|
2089 | fclose(fid);
|
---|
2090 | system(['chmod +x ' filename_joblist]);% set the file to executable
|
---|
2091 | pbs_command=['qstat -n CIVX '...
|
---|
2092 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
|
---|
2093 | '-l /core=' num2str(NbCore) ','...
|
---|
2094 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(NbProcess*BlockLength*nbfield_j,NbCore)/NbCore,max_walltime/86400),13) ' '...
|
---|
2095 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
|
---|
2096 | '-O ' regexprep(filename_joblist,'\.txt\>','.log') ' '...
|
---|
2097 | extra_oar ' '...
|
---|
2098 | '"oar-parexec -s -f ' filename_joblist ' '...
|
---|
2099 | '-l ' filename_joblist '.log"'];
|
---|
2100 | filename_oarcommand=fullfile(DirPBS,'pbs_command');
|
---|
2101 | fid=fopen(filename_oarcommand,'w');
|
---|
2102 | fprintf(fid,pbs_command);
|
---|
2103 | fclose(fid);
|
---|
2104 | fprintf(pbs_command);% display in command line
|
---|
2105 | %system(pbs_command);
|
---|
2106 | msgbox_uvmat('CONFIRMATION',[ActionFullName ' command ready to be launched in cluster'])
|
---|
2107 | case 'python'
|
---|
2108 | command = [
|
---|
2109 | 'LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') | [s for s in p if ''matlab'' not in s] | '':''.join(p)") ' ...
|
---|
2110 | 'python -m fluiddyn.postproc.uvmat ' filexml{iprocess}];
|
---|
2111 | % fprintf(['command:\n' command '\n\n'])
|
---|
2112 | system(command, '-echo');
|
---|
2113 | end
|
---|
2114 | if exist(OutputDir,'dir')
|
---|
2115 | [success,msg] = fileattrib(OutputDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
|
---|
2116 | if success==0
|
---|
2117 | msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation
|
---|
2118 | end
|
---|
2119 | end
|
---|
2120 |
|
---|
2121 | %------------------------------------------------------------------------
|
---|
2122 | function STOP_Callback(hObject, eventdata, handles)
|
---|
2123 | %------------------------------------------------------------------------
|
---|
2124 | set(handles.RUN, 'BusyAction','cancel')
|
---|
2125 | set(handles.RUN,'BackgroundColor',[1 0 0])
|
---|
2126 | set(handles.RUN,'enable','on')
|
---|
2127 | set(handles.RUN, 'Value',0)
|
---|
2128 |
|
---|
2129 | %------------------------------------------------------------------------
|
---|
2130 | % --- read parameters from the GUI series
|
---|
2131 | %------------------------------------------------------------------------
|
---|
2132 | function Param=read_GUI_series(handles)
|
---|
2133 |
|
---|
2134 | %% read raw parameters from the GUI series
|
---|
2135 | Param=read_GUI(handles.series);
|
---|
2136 |
|
---|
2137 | %% clean the output structure by removing unused information
|
---|
2138 | if isfield(Param,'Pairs')
|
---|
2139 | Param=rmfield(Param,'Pairs'); %info Pairs not needed for output
|
---|
2140 | end
|
---|
2141 | if isfield(Param,'InputLine')
|
---|
2142 | Param=rmfield(Param,'InputLine');
|
---|
2143 | end
|
---|
2144 | if isfield(Param,'EditObject')
|
---|
2145 | Param=rmfield(Param,'EditObject');
|
---|
2146 | end
|
---|
2147 | Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1};
|
---|
2148 | Param.IndexRange=rmfield(Param.IndexRange,'TimeTable');
|
---|
2149 | empty_line=false(size(Param.InputTable,1),1);
|
---|
2150 | for iline=1:size(Param.InputTable,1)
|
---|
2151 | empty_line(iline)=isempty(cell2mat(Param.InputTable(iline,1:3)));
|
---|
2152 | end
|
---|
2153 | Param.InputTable(empty_line,:)=[];
|
---|
2154 |
|
---|
2155 | %------------------------------------------------------------------------
|
---|
2156 | % --- Executes on selection change in ActionName.
|
---|
2157 | function ActionName_Callback(hObject, eventdata, handles)
|
---|
2158 | %------------------------------------------------------------------------
|
---|
2159 |
|
---|
2160 | %% stop any ongoing series processing
|
---|
2161 | if isequal(get(handles.RUN,'Value'),1)
|
---|
2162 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
2163 | if strcmp(answer,'Yes')
|
---|
2164 | STOP_Callback(hObject, eventdata, handles)
|
---|
2165 | else
|
---|
2166 | return
|
---|
2167 | end
|
---|
2168 | end
|
---|
2169 | set(handles.ActionName,'BackgroundColor',[1 1 0])
|
---|
2170 | huigetfile=findobj(allchild(0),'tag','status_display');
|
---|
2171 | if ~isempty(huigetfile)
|
---|
2172 | delete(huigetfile)
|
---|
2173 | end
|
---|
2174 | drawnow
|
---|
2175 |
|
---|
2176 | %% get Action name and path
|
---|
2177 | NbBuiltinAction=get(handles.Action,'UserData'); %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series)
|
---|
2178 | ActionList=get(handles.ActionName,'String');% list menu fields
|
---|
2179 | ActionIndex=get(handles.ActionName,'Value');
|
---|
2180 | if ~isequal(ActionIndex,1)% if we are not just opening series
|
---|
2181 | InputTable=get(handles.InputTable,'Data');
|
---|
2182 | if isempty(InputTable{1,4})
|
---|
2183 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar')
|
---|
2184 | return
|
---|
2185 | end
|
---|
2186 | end
|
---|
2187 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
|
---|
2188 | ActionPathList=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ActionName
|
---|
2189 |
|
---|
2190 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName
|
---|
2191 | if isequal(ActionName,'more...')
|
---|
2192 | [FileName, PathName] = uigetfile( ...
|
---|
2193 | {'*.m', ' (*.m)';
|
---|
2194 | '*.m', '.m files '; ...
|
---|
2195 | '*.*', 'All Files (*.*)'}, ...
|
---|
2196 | 'Pick a series processing function ',get(handles.ActionPath,'String'));
|
---|
2197 | if length(FileName)<2
|
---|
2198 | return
|
---|
2199 | end
|
---|
2200 | [tild,ActionName,ActionExt]=fileparts(FileName);
|
---|
2201 |
|
---|
2202 | % insert the choice in the menu ActionName
|
---|
2203 | ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action
|
---|
2204 | PathName=regexprep(PathName,'/$','');
|
---|
2205 | if ~isempty(ActionIndex) && ~strcmp(ActionPathList{ActionIndex},PathName)%compare the path to the existing fct
|
---|
2206 | ActionIndex=[]; % the selected path is different than the recorded one
|
---|
2207 | end
|
---|
2208 | if isempty(ActionIndex)%the qselected fct (with selected path) does not exist in the menu
|
---|
2209 | ActionIndex= length(ActionList);
|
---|
2210 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...'
|
---|
2211 | ActionPathList=[ActionPathList; PathName];
|
---|
2212 | end
|
---|
2213 |
|
---|
2214 | % record the file extension and extend the path list if it is a new extension
|
---|
2215 | ActionExtList=get(handles.ActionExt,'String');
|
---|
2216 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
|
---|
2217 | if isempty(ActionExtIndex)
|
---|
2218 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
|
---|
2219 | end
|
---|
2220 |
|
---|
2221 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5)
|
---|
2222 | if length(ActionList)>NbBuiltinAction+5; %nb_builtin_ACTION=nbre of functions always remaining in the initial menu
|
---|
2223 | nbremove=length(ActionList)-NbBuiltinAction-5;
|
---|
2224 | ActionList(NbBuiltinAction+1:end-5)=[];
|
---|
2225 | ActionPathList(NbBuiltinAction+1:end-4,:)=[];
|
---|
2226 | ActionIndex=ActionIndex-nbremove;
|
---|
2227 | end
|
---|
2228 |
|
---|
2229 | % record action menu, choice and path
|
---|
2230 | set(handles.ActionName,'Value',ActionIndex)
|
---|
2231 | set(handles.ActionName,'String',ActionList)
|
---|
2232 | set(handles.ActionName,'UserData',ActionPathList);
|
---|
2233 | set(handles.ActionExt,'Value',ActionExtIndex)
|
---|
2234 |
|
---|
2235 | %record the user defined menu additions in personal file profil_perso
|
---|
2236 | dir_perso=prefdir;
|
---|
2237 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
2238 | if NbBuiltinAction+1<=numel(ActionList)-1
|
---|
2239 | ActionListUser=ActionList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
2240 | ActionPathListUser=ActionPathList(NbBuiltinAction+1:numel(ActionList)-1);
|
---|
2241 | ActionExtListUser={};
|
---|
2242 | if numel(ActionExtList)>2
|
---|
2243 | ActionExtListUser=ActionExtList(3:end);
|
---|
2244 | end
|
---|
2245 | if exist(profil_perso,'file')
|
---|
2246 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append')
|
---|
2247 | else
|
---|
2248 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6')
|
---|
2249 | end
|
---|
2250 | end
|
---|
2251 | end
|
---|
2252 |
|
---|
2253 | %% check the current ActionPath to the selected function
|
---|
2254 | ActionPath=ActionPathList{ActionIndex};%current recorded path
|
---|
2255 | set(handles.ActionPath,'String',ActionPath); %show the path to the senlected function
|
---|
2256 |
|
---|
2257 | %% reinitialise the waitbar
|
---|
2258 | update_waitbar(handles.Waitbar,0)
|
---|
2259 |
|
---|
2260 | %% create the function handle for Action
|
---|
2261 | if ~exist(ActionPath,'dir')
|
---|
2262 | msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
|
---|
2263 | return
|
---|
2264 | end
|
---|
2265 | current_dir=pwd;%current working dir
|
---|
2266 | cd(ActionPath)
|
---|
2267 | h_fun=str2func(ActionName);
|
---|
2268 | cd(current_dir)
|
---|
2269 |
|
---|
2270 | %
|
---|
2271 | % checkaddpath=0;
|
---|
2272 | % path_series=which('series');
|
---|
2273 | % %eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
|
---|
2274 | % spath=fileparts(which(ActionName)); %spath = current path of the selected function ACTION
|
---|
2275 | % if ~exist(ActionPath,'dir')
|
---|
2276 | % msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
|
---|
2277 | % return
|
---|
2278 | % end
|
---|
2279 | % if ~strcmp(spath,ActionPath)
|
---|
2280 | % if strcmp(pwd,spath)
|
---|
2281 | % msgbox_uvmat('ERROR',[ 'a function called ' ActionName ' on your working space oversets the selected one']);
|
---|
2282 | % return
|
---|
2283 | % else
|
---|
2284 | % addpath(ActionPath)% add the prescribed path if not the current one
|
---|
2285 | % checkaddpath=1;
|
---|
2286 | % end
|
---|
2287 | % end
|
---|
2288 | % eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION
|
---|
2289 | % if checkaddpath && ~isequal(ActionPath,path_series)
|
---|
2290 | % rmpath(ActionPath)% add the prescribed path if not the current one
|
---|
2291 | % end
|
---|
2292 |
|
---|
2293 | %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData
|
---|
2294 | Param=read_GUI_series(handles);% read the parameters from the GUI series
|
---|
2295 | ParamOut=h_fun(Param);%run the selected Action function to get the relevant input
|
---|
2296 |
|
---|
2297 | %% Put the first line of the selected Action fct as tooltip help
|
---|
2298 | try
|
---|
2299 | [fid,errormsg] =fopen([ActionName '.m']);
|
---|
2300 | InputText=textscan(fid,'%s',1,'delimiter','\n');
|
---|
2301 | fclose(fid);
|
---|
2302 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
|
---|
2303 | end
|
---|
2304 |
|
---|
2305 |
|
---|
2306 | %% Visibility of VelType and VelType_1 menus asked by ActionName
|
---|
2307 | VelTypeRequest=1;%VelType requested by default
|
---|
2308 | VelTypeRequest_1=1;%VelType requested by default
|
---|
2309 | if isfield(ParamOut,'VelType')
|
---|
2310 | VelTypeRequest=ismember(ParamOut.VelType,{'on','one','two'});
|
---|
2311 | VelTypeRequest_1=strcmp( ParamOut.VelType,'two');
|
---|
2312 | end
|
---|
2313 | FieldNameRequest=0; %hidden by default
|
---|
2314 | FieldNameRequest_1=0; %hidden by default
|
---|
2315 | if isfield(ParamOut,'FieldName')
|
---|
2316 | FieldNameRequest=ismember(ParamOut.FieldName,{'on','one','two'});
|
---|
2317 | FieldNameRequest_1=strcmp( ParamOut.FieldName,'two');
|
---|
2318 | end
|
---|
2319 |
|
---|
2320 | %% Detect the types of input files and set menus and default options in 'VelType'
|
---|
2321 | SeriesData=get(handles.series,'UserData');% info on the input file series
|
---|
2322 | iview_civ=find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));
|
---|
2323 | iview_netcdf=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ
|
---|
2324 | FieldList=get(handles.FieldName,'String');% previous list as default
|
---|
2325 | if ~iscell(FieldList),FieldList={FieldList};end
|
---|
2326 | FieldList_1=get(handles.FieldName_1,'String');% previous list as default
|
---|
2327 | if ~iscell(FieldList_1),FieldList_1={FieldList_1};end
|
---|
2328 | %CheckList=0;% indicate whether FieldName has been updated
|
---|
2329 | CheckList_1=1;% indicate whether FieldName_1 has been updated
|
---|
2330 | handles_coord=[handles.Coord_x handles.Coord_y handles.Coord_z handles.Coord_x_title handles.Coord_y_title handles.Coord_z_title];
|
---|
2331 | if VelTypeRequest && numel(iview_civ)>=1
|
---|
2332 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(1)}.CivStage,SeriesData.FileType{iview_civ(1)});
|
---|
2333 | set(handles.VelType,'Value',1)% set first choice by default
|
---|
2334 | set(handles.VelType,'String',[{'*'};menu])
|
---|
2335 | set(handles.VelType,'Visible','on')
|
---|
2336 | set(handles.VelType_title,'Visible','on')
|
---|
2337 | FieldList=[set_field_list('U','V');{'C'};{'get_field...'}];%standard menu for civx data
|
---|
2338 | %CheckList=1;
|
---|
2339 | set(handles.FieldName,'Value',1); %velocity vector choice by default
|
---|
2340 | if VelTypeRequest_1 && numel(iview_civ)>=2
|
---|
2341 | menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)});
|
---|
2342 | set(handles.VelType_1,'Value',1)% set first choice by default
|
---|
2343 | set(handles.VelType_1,'String',[{'*'};menu])
|
---|
2344 | set(handles.VelType_1,'Visible','on')
|
---|
2345 | set(handles.VelType_title_1,'Visible','on')
|
---|
2346 | FieldList_1=[set_field_list('U','V');{'C'};{'get_field...'}];%standard menu for civx data
|
---|
2347 | CheckList_1=1;
|
---|
2348 | set(handles.FieldName_1,'Value',1); %velocity vector choice by default
|
---|
2349 | else
|
---|
2350 | set(handles.VelType_1,'Visible','off')
|
---|
2351 | set(handles.VelType_title_1,'Visible','off')
|
---|
2352 | end
|
---|
2353 | else
|
---|
2354 | set(handles.VelType,'Visible','off')
|
---|
2355 | set(handles.VelType_title,'Visible','off')
|
---|
2356 | end
|
---|
2357 |
|
---|
2358 | %% Detect the types of input files and set menus and default options in 'FieldName'
|
---|
2359 | if FieldNameRequest && numel(iview_netcdf)>=1
|
---|
2360 | set(handles.InputFields,'Visible','on')
|
---|
2361 | %if CheckList==0 % not civ input made
|
---|
2362 | if isfield(SeriesData.FileInfo{iview_netcdf(1)},'ListVarName')
|
---|
2363 | ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName;
|
---|
2364 | ind_var=get(handles.FieldName,'Value');%indices of previously selected variables
|
---|
2365 | for ilist=1:numel(ind_var)
|
---|
2366 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName)))
|
---|
2367 | FieldList={};% previous choice not consistent with new input field
|
---|
2368 | set(handles.FieldName,'Value',1)
|
---|
2369 | break
|
---|
2370 | end
|
---|
2371 | end
|
---|
2372 | if ~isempty(FieldList)
|
---|
2373 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||...
|
---|
2374 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName)))
|
---|
2375 | FieldList={};
|
---|
2376 | set(handles.Coord_x,'String','')
|
---|
2377 | set(handles.Coord_y,'String','')
|
---|
2378 | end
|
---|
2379 | Coord_z=get(handles.Coord_z,'String');
|
---|
2380 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName)))
|
---|
2381 | FieldList={};
|
---|
2382 | set(handles.Coord_z,'String','')
|
---|
2383 | end
|
---|
2384 | end
|
---|
2385 | set(handles_coord,'Visible','on')
|
---|
2386 | FieldList=[FieldList;{'get_field...'}];
|
---|
2387 | if FieldNameRequest_1 && numel(iview_netcdf)>=2
|
---|
2388 | set(handles.FieldName_1,'Visible','on')
|
---|
2389 | if CheckList_1==0 % not civ input made
|
---|
2390 | ListVarName=SeriesData.FileInfo{iview_netcdf(2)}.ListVarName;
|
---|
2391 | ind_var=get(handles.FieldName,'Value');%indices of previously selected variables
|
---|
2392 | for ilist=1:numel(ind_var)
|
---|
2393 | if isempty(find(strcmp(FieldList{ind_var(ilist)},ListVarName)))
|
---|
2394 | FieldList_1={};% previous choice not consistent with new input field
|
---|
2395 | set(handles.FieldName_1,'Value',1)
|
---|
2396 | break
|
---|
2397 | end
|
---|
2398 | end
|
---|
2399 | warn_coord=0;
|
---|
2400 | if isempty(find(strcmp(get(handles.Coord_x,'String'),ListVarName)))||...
|
---|
2401 | isempty(find(strcmp(get(handles.Coord_y,'String'),ListVarName)))
|
---|
2402 | warn_coord=1;
|
---|
2403 | end
|
---|
2404 | if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName)))
|
---|
2405 | FieldList_1={};
|
---|
2406 | warn_coord=1;
|
---|
2407 | end
|
---|
2408 | if warn_coord
|
---|
2409 | msgbox_uvmat('WARNING','coordiante names do not exist in the second netcdf input file')
|
---|
2410 | end
|
---|
2411 | set(handles.FieldName,'String',[FieldList;{'get_field...'}])
|
---|
2412 | set(handles.FieldName_1,'Visible','on')
|
---|
2413 | set(handles.FieldName_1,'Value',1)
|
---|
2414 | set(handles.FieldName_1,'String',FieldList_1)
|
---|
2415 | end
|
---|
2416 | else
|
---|
2417 | set(handles.FieldName_1,'Visible','off')
|
---|
2418 | end
|
---|
2419 | end
|
---|
2420 | % else
|
---|
2421 | % set(handles_coord,'Visible','off')% no coord display for civ data
|
---|
2422 | % end
|
---|
2423 | set(handles.FieldName,'String',FieldList)
|
---|
2424 | else
|
---|
2425 | set(handles.InputFields,'Visible','off')
|
---|
2426 | end
|
---|
2427 |
|
---|
2428 | %% Introduce visibility of file overwrite option
|
---|
2429 | if isfield(ParamOut,'CheckOverwriteVisible')&& strcmp(ParamOut.CheckOverwriteVisible,'on')
|
---|
2430 | set(handles.CheckOverwrite,'Visible','on')
|
---|
2431 | else
|
---|
2432 | set(handles.CheckOverwrite,'Visible','off')
|
---|
2433 | end
|
---|
2434 |
|
---|
2435 | %% Check whether alphabetical sorting of input Subdir is allowed by the Action fct (for multiples series entries)
|
---|
2436 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1
|
---|
2437 | [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order
|
---|
2438 | set(handles.InputTable,'Data',InputTable(iview,:));
|
---|
2439 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
2440 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
2441 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
2442 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
2443 | set(handles.MinIndex_i,'Data',MinIndex_i(iview,:));
|
---|
2444 | set(handles.MinIndex_j,'Data',MinIndex_j(iview,:));
|
---|
2445 | set(handles.MaxIndex_i,'Data',MaxIndex_i(iview,:));
|
---|
2446 | set(handles.MaxIndex_j,'Data',MaxIndex_j(iview,:));
|
---|
2447 | TimeTable=get(handles.TimeTable,'Data');
|
---|
2448 | set(handles.TimeTable,'Data',TimeTable(iview,:));
|
---|
2449 | PairString=get(handles.PairString,'Data');
|
---|
2450 | set(handles.PairString,'Data',PairString(iview,:));
|
---|
2451 | end
|
---|
2452 |
|
---|
2453 | %% Impose the whole input file index range if requested
|
---|
2454 | if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on')
|
---|
2455 | MinIndex_i=get(handles.MinIndex_i,'Data');
|
---|
2456 | MinIndex_j=get(handles.MinIndex_j,'Data');
|
---|
2457 | MaxIndex_i=get(handles.MaxIndex_i,'Data');
|
---|
2458 | MaxIndex_j=get(handles.MaxIndex_j,'Data');
|
---|
2459 | set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line)
|
---|
2460 | set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line)
|
---|
2461 | set(handles.num_incr_i,'String','1')
|
---|
2462 | set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line)
|
---|
2463 | set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line)
|
---|
2464 | set(handles.num_incr_j,'String','1')
|
---|
2465 | else % check index ranges
|
---|
2466 | first_i=1;last_i=1;first_j=1;last_j=1;
|
---|
2467 | if isfield(Param.IndexRange,'first_i')
|
---|
2468 | first_i=Param.IndexRange.first_i;
|
---|
2469 | last_i=Param.IndexRange.last_i;
|
---|
2470 | end
|
---|
2471 | if isfield(Param.IndexRange,'first_j')
|
---|
2472 | first_j=Param.IndexRange.first_j;
|
---|
2473 | last_j=Param.IndexRange.last_j;
|
---|
2474 | end
|
---|
2475 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
|
---|
2476 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
|
---|
2477 | end
|
---|
2478 |
|
---|
2479 | %% enable or desable j index visibility
|
---|
2480 | status_j='on';%default
|
---|
2481 | if isfield(ParamOut,'Desable_j_index')&&isequal(ParamOut.Desable_j_index,'on')
|
---|
2482 | status_j='off';
|
---|
2483 | end
|
---|
2484 | if isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)); % case of empty j indices
|
---|
2485 | status_j='off'; % no j index needed
|
---|
2486 | elseif strcmp(get(handles.PairString,'Visible'),'on')
|
---|
2487 | check_burst=cellfun(@isempty,regexp(get(handles.PairString,'Data'),'^j'));%=0 for burst case, 1 otherwise
|
---|
2488 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst)
|
---|
2489 | status_j='off'; % no j index needed for bust case
|
---|
2490 | end
|
---|
2491 | end
|
---|
2492 | enable_j(handles,status_j) % no j index needed
|
---|
2493 |
|
---|
2494 |
|
---|
2495 | %% NbSlice visibility
|
---|
2496 | %NbSliceVisible='off';%default
|
---|
2497 | if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice))
|
---|
2498 | set(handles.num_NbSlice,'Visible','on')
|
---|
2499 | set(handles.NbSlice_title,'Visible','on')
|
---|
2500 | else
|
---|
2501 | set(handles.num_NbSlice,'Visible','off')
|
---|
2502 | set(handles.NbSlice_title,'Visible','off')
|
---|
2503 | % set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices
|
---|
2504 | % else
|
---|
2505 | % set(handles.num_NbProcess,'String','')% free nbre of processes
|
---|
2506 | end
|
---|
2507 | if isnumeric(ParamOut.NbSlice)
|
---|
2508 | set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
|
---|
2509 | set(handles.num_NbSlice,'Enable','off'); % NbSlice set by the activation of the Action function
|
---|
2510 | else
|
---|
2511 | set(handles.num_NbSlice,'Enable','on'); % NbSlice can be modified on the GUI series
|
---|
2512 | end
|
---|
2513 | % set(handles.num_NbSlice,'Visible',NbSliceVisible)
|
---|
2514 | % set(handles.NbSlice_title,'Visible',NbSliceVisible)
|
---|
2515 |
|
---|
2516 |
|
---|
2517 |
|
---|
2518 | %% Visibility of FieldTransform menu
|
---|
2519 | FieldTransformVisible='off'; %hidden by default
|
---|
2520 | if isfield(ParamOut,'FieldTransform')
|
---|
2521 | FieldTransformVisible=ParamOut.FieldTransform;
|
---|
2522 | TransformName_Callback([],[], handles)
|
---|
2523 | end
|
---|
2524 | set(handles.FieldTransform,'Visible',FieldTransformVisible)
|
---|
2525 | if isfield(ParamOut,'TransformPath')
|
---|
2526 | set(handles.ActionExt,'UserData',ParamOut.TransformPath)
|
---|
2527 | else
|
---|
2528 | set(handles.ActionExt,'UserData',[])
|
---|
2529 | end
|
---|
2530 |
|
---|
2531 | %% Visibility of projection object
|
---|
2532 | ProjObjectVisible='off'; %hidden by default
|
---|
2533 | if isfield(ParamOut,'ProjObject')
|
---|
2534 | ProjObjectVisible=ParamOut.ProjObject;
|
---|
2535 | end
|
---|
2536 | set(handles.CheckObject,'Visible',ProjObjectVisible)
|
---|
2537 | if ~get(handles.CheckObject,'Value')
|
---|
2538 | ProjObjectVisible='off';
|
---|
2539 | end
|
---|
2540 | set(handles.ProjObject,'Visible',ProjObjectVisible)
|
---|
2541 | set(handles.DeleteObject,'Visible',ProjObjectVisible)
|
---|
2542 | set(handles.ViewObject,'Visible',ProjObjectVisible)
|
---|
2543 | set(handles.EditObject,'Visible',ProjObjectVisible)
|
---|
2544 |
|
---|
2545 | %% Visibility of mask input
|
---|
2546 | MaskVisible='off'; %hidden by default
|
---|
2547 | if isfield(ParamOut,'Mask')
|
---|
2548 | MaskVisible=ParamOut.Mask;
|
---|
2549 | end
|
---|
2550 | set(handles.CheckMask,'Visible',MaskVisible);
|
---|
2551 |
|
---|
2552 | %% definition of the directory containing the output files
|
---|
2553 | if ~(isfield(SeriesData,'ActionName') && strcmp(ActionName,SeriesData.ActionName))
|
---|
2554 | OutputDirExt='.series'; %default
|
---|
2555 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt)
|
---|
2556 | OutputDirExt=ParamOut.OutputDirExt;
|
---|
2557 | end
|
---|
2558 | set(handles.OutputDirExt,'String',OutputDirExt)
|
---|
2559 | end
|
---|
2560 | OutputDirVisible='off';
|
---|
2561 | OutputSubDirMode='auto';%default
|
---|
2562 | SubDirOut='';
|
---|
2563 | if isfield(ParamOut,'OutputSubDirMode')
|
---|
2564 | OutputSubDirMode=ParamOut.OutputSubDirMode;
|
---|
2565 | end
|
---|
2566 | switch OutputSubDirMode
|
---|
2567 | case 'auto';%default
|
---|
2568 | OutputDirVisible='on';
|
---|
2569 | SubDir=InputTable(1:end,2); %set of subdirectories
|
---|
2570 | SubDirOut=SubDir{1};
|
---|
2571 | if numel(SubDir)>1
|
---|
2572 | for ilist=2:numel(SubDir)
|
---|
2573 | SubDirOut=[SubDirOut '-' regexprep(SubDir{ilist},'^/','')];
|
---|
2574 | end
|
---|
2575 | end
|
---|
2576 | case 'one'
|
---|
2577 | OutputDirVisible='on';
|
---|
2578 | SubDirOut=InputTable{1,2}; %use the first subdir name (+OutputDirExt) as output subdirectory
|
---|
2579 | case 'two'
|
---|
2580 | OutputDirVisible='on';
|
---|
2581 | SubDir=InputTable(1:2,2); %set of subdirectories
|
---|
2582 | SubDirOut=SubDir{1};
|
---|
2583 | if numel(SubDir)>1
|
---|
2584 | SubDirOut=[SubDirOut '-' regexprep(SubDir{2},'^/','')];
|
---|
2585 | end
|
---|
2586 | case 'last'
|
---|
2587 | OutputDirVisible='on';
|
---|
2588 | SubDirOut=InputTable{end,2}; %use the last subdir name (+OutputDirExt) as output subdirectory
|
---|
2589 | end
|
---|
2590 | set(handles.OutputSubDir,'String',SubDirOut)
|
---|
2591 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])% set edit box to white color to indicate refreshment
|
---|
2592 | set(handles.OutputDirExt,'Visible',OutputDirVisible)
|
---|
2593 | set(handles.OutputSubDir,'Visible',OutputDirVisible)
|
---|
2594 | %set(handles.CheckOverwrite,'Visible',OutputDirVisible)
|
---|
2595 | set(handles.OutputDir_title,'Visible',OutputDirVisible)
|
---|
2596 | SeriesData.ActionName=ActionName;%record ActionName for next use
|
---|
2597 |
|
---|
2598 |
|
---|
2599 | %% visibility of the run mode (local or background or cluster)
|
---|
2600 | if strcmp(OutputSubDirMode,'none')
|
---|
2601 | RunModeVisible='off';% only local mode available if no output file is produced
|
---|
2602 | else
|
---|
2603 | RunModeVisible='on';
|
---|
2604 | end
|
---|
2605 | set(handles.RunMode,'Visible',RunModeVisible)
|
---|
2606 | set(handles.ActionExt,'Visible',RunModeVisible)
|
---|
2607 | set(handles.RunMode_title,'Visible',RunModeVisible)
|
---|
2608 | set(handles.ActionExt_title,'Visible',RunModeVisible)
|
---|
2609 |
|
---|
2610 |
|
---|
2611 | %% Expected nbre of output files
|
---|
2612 | if isfield(ParamOut,'OutputFileMode')
|
---|
2613 | StatusData.OutputFileMode=ParamOut.OutputFileMode;
|
---|
2614 | set(handles.status,'UserData',StatusData)
|
---|
2615 | end
|
---|
2616 |
|
---|
2617 | %% definition of an additional parameter set, determined by an ancillary GUI
|
---|
2618 | if isfield(ParamOut,'ActionInput')
|
---|
2619 | set(handles.ActionInput,'Visible','on')
|
---|
2620 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput
|
---|
2621 | SeriesData.ActionInput=ParamOut.ActionInput;
|
---|
2622 | else
|
---|
2623 | set(handles.ActionInput,'Visible','off')
|
---|
2624 | if isfield(SeriesData,'ActionInput')
|
---|
2625 | SeriesData=rmfield(SeriesData,'ActionInput');
|
---|
2626 | end
|
---|
2627 | end
|
---|
2628 | set(handles.series,'UserData',SeriesData)
|
---|
2629 | set(handles.ActionName,'BackgroundColor',[1 1 1])
|
---|
2630 |
|
---|
2631 | %------------------------------------------------------------------------
|
---|
2632 | % --- Executes on selection change in FieldName.
|
---|
2633 | function FieldName_Callback(hObject, eventdata, handles)
|
---|
2634 | %------------------------------------------------------------------------
|
---|
2635 | field_str=get(handles.FieldName,'String');
|
---|
2636 | field_index=get(handles.FieldName,'Value');
|
---|
2637 | field=field_str{field_index(1)};
|
---|
2638 | if isequal(field,'get_field...')
|
---|
2639 | SeriesData=get(handles.series,'UserData');
|
---|
2640 | % input line for which the field choice is relevant
|
---|
2641 | iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'}));% all nc files, icluding civ
|
---|
2642 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2643 | if ~isempty(hget_field)
|
---|
2644 | delete(hget_field)%delete opened versions of get_field
|
---|
2645 | end
|
---|
2646 | Param=read_GUI(handles.series);
|
---|
2647 | InputTable=Param.InputTable(iview,:);
|
---|
2648 | % check the existence of the first file in the series
|
---|
2649 | first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1;%default setting for index j
|
---|
2650 | if isfield(Param.IndexRange,'first_j');% if index j is used
|
---|
2651 | first_j=Param.IndexRange.first_j;
|
---|
2652 | last_j=Param.IndexRange.last_j;
|
---|
2653 | MinIndex_j=Param.IndexRange.MinIndex_j(iview);
|
---|
2654 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview);
|
---|
2655 | end
|
---|
2656 | PairString='';
|
---|
2657 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
|
---|
2658 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
2659 | LineIndex=iview(1);
|
---|
2660 | if numel(iview)>1
|
---|
2661 | answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
|
---|
2662 | LineIndex=str2num(answer);
|
---|
2663 | % InputLine=str2num(get(handles.InputLine,'String'));
|
---|
2664 | % if ismember(InputLine,iview)
|
---|
2665 | % LineIndex=InputLine;
|
---|
2666 | % end
|
---|
2667 | end
|
---|
2668 | FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
|
---|
2669 | InputTable{LineIndex,5},InputTable{LineIndex,4},i1,i2,j1,j2);
|
---|
2670 | if exist(FirstFileName,'file')
|
---|
2671 | ParamIn.Title='get_field: pick input variables and coordinates for series processing';
|
---|
2672 | ParamIn.SeriesInput=1;
|
---|
2673 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
2674 | FieldList={};
|
---|
2675 | if isfield(GetFieldData,'FieldOption')% if a field has been selected
|
---|
2676 | switch GetFieldData.FieldOption
|
---|
2677 | case 'vectors'
|
---|
2678 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
2679 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
2680 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
2681 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
2682 | ['norm(' UName ',' VName ')'];...
|
---|
2683 | UName;VName};
|
---|
2684 | case {'scalar'}
|
---|
2685 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
2686 | YName={GetFieldData.Coordinates.Coord_y};
|
---|
2687 | if ischar(FieldList)
|
---|
2688 | FieldList={FieldList};
|
---|
2689 | end
|
---|
2690 | case 'civdata...'
|
---|
2691 | FieldList=[set_field_list('U','V') ;{'C'}];
|
---|
2692 | set(handles.FieldName,'Value',1) % set menu to 'velocity
|
---|
2693 | XName='X';
|
---|
2694 | YName='y';
|
---|
2695 | end
|
---|
2696 | set(handles.FieldName,'Value',1)
|
---|
2697 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
|
---|
2698 | if ~strcmp(GetFieldData.FieldOption,'civdata...')
|
---|
2699 | if ~isempty(regexp(FieldList{1},'^vec'))
|
---|
2700 | set(handles.FieldName,'Value',1)
|
---|
2701 | else
|
---|
2702 | set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
|
---|
2703 | end
|
---|
2704 | XName=GetFieldData.Coordinates.Coord_x;
|
---|
2705 | YName=GetFieldData.Coordinates.Coord_y;
|
---|
2706 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
|
---|
2707 | % get the time info
|
---|
2708 | TimeTable=get(handles.TimeTable,'Data');
|
---|
2709 | switch TimeNameStr
|
---|
2710 | case 'file index'
|
---|
2711 | TimeName='';
|
---|
2712 | case 'attribute'
|
---|
2713 | TimeName=['att:' GetFieldData.Time.TimeName];
|
---|
2714 | % update the time table
|
---|
2715 | TimeTable{LineIndex,2}=get_time(Param.IndexRange.MinIndex_i(LineIndex),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Min time
|
---|
2716 | TimeTable{LineIndex,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % first time
|
---|
2717 | TimeTable{LineIndex,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % last time
|
---|
2718 | TimeTable{LineIndex,5}=get_time(Param.IndexRange.MaxIndex_i(LineIndex),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName); % Max time
|
---|
2719 | case 'variable'
|
---|
2720 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
|
---|
2721 | set(handles.NomType,'String','*')
|
---|
2722 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
|
---|
2723 | set(handles.FileIndex,'String','')
|
---|
2724 | ParamIn.TimeVarName=GetFieldData.Time.TimeName;
|
---|
2725 | case 'matrix_index'
|
---|
2726 | TimeName=['dim:' GetFieldData.Time.TimeName];
|
---|
2727 | set(handles.NomType,'String','*')
|
---|
2728 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
|
---|
2729 | set(handles.FileIndex,'String','')
|
---|
2730 | ParamIn.TimeDimName=GetFieldData.Time.TimeName;
|
---|
2731 | end
|
---|
2732 | TimeTable{LineIndex,1}=TimeName;
|
---|
2733 | set(handles.TimeTable,'Data',TimeTable);
|
---|
2734 | end
|
---|
2735 | set(handles.Coord_x,'String',XName)
|
---|
2736 | set(handles.Coord_y,'String',YName)
|
---|
2737 | set(handles.Coord_x,'Visible','on')
|
---|
2738 | set(handles.Coord_y,'Visible','on')
|
---|
2739 | end
|
---|
2740 | else
|
---|
2741 | msgbox_uvmat('ERROR',[FirstFileName ' does not exist'])
|
---|
2742 | end
|
---|
2743 | end
|
---|
2744 |
|
---|
2745 | function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName)
|
---|
2746 | [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
|
---|
2747 | FileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},InputTable{5},InputTable{4},i1,i2,j1,j2);
|
---|
2748 | Data=nc2struct(FileName,[]);
|
---|
2749 | TimeValue=[];
|
---|
2750 | DtValue=[];
|
---|
2751 | if isequal(FileInfo.FileType,'civdata')
|
---|
2752 | if ismember(TimeName,{'civ1','filter1'})
|
---|
2753 | TimeValue=Data.Civ1_Time;
|
---|
2754 | DtValue=Data.Civ1_Dt;
|
---|
2755 | else
|
---|
2756 | TimeValue=Data.Civ2_Time;
|
---|
2757 | DtValue=Data.Civ2_Dt;
|
---|
2758 | end
|
---|
2759 | else
|
---|
2760 | if ~isempty(TimeName)&& isfield(Data,TimeName)
|
---|
2761 | TimeValue=Data.(TimeName);
|
---|
2762 | end
|
---|
2763 | if exist('DtName','var') && isfield(Data,DtName)
|
---|
2764 | DtValue=Data.(DtName);
|
---|
2765 | end
|
---|
2766 | end
|
---|
2767 |
|
---|
2768 | %------------------------------------------------------------------------
|
---|
2769 | % --- Executes on selection change in FieldName_1.
|
---|
2770 | function FieldName_1_Callback(hObject, eventdata, handles)
|
---|
2771 | %------------------------------------------------------------------------
|
---|
2772 | field_str=get(handles.FieldName_1,'String');
|
---|
2773 | field_index=get(handles.FieldName_1,'Value');
|
---|
2774 | field=field_str{field_index(1)};
|
---|
2775 | if isequal(field,'get_field...')
|
---|
2776 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2777 | if ~isempty(hget_field)
|
---|
2778 | delete(hget_field)%delete opened versions of get_field
|
---|
2779 | end
|
---|
2780 | Param=read_GUI(handles.series);
|
---|
2781 | Param.InputTable=Param.InputTable(1,:);
|
---|
2782 | % check the existence of the first file in the series
|
---|
2783 | first_j=[];
|
---|
2784 | if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
|
---|
2785 | if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
|
---|
2786 | PairString='';
|
---|
2787 | if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
|
---|
2788 | [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
|
---|
2789 | FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
|
---|
2790 | Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
|
---|
2791 | if exist(FirstFileName,'file')
|
---|
2792 | ParamIn.SeriesInput=1;
|
---|
2793 | GetFieldData=get_field(FirstFileName,ParamIn);
|
---|
2794 | FieldList={};
|
---|
2795 | switch GetFieldData.FieldOption
|
---|
2796 | case 'vectors'
|
---|
2797 | UName=GetFieldData.PanelVectors.vector_x;
|
---|
2798 | VName=GetFieldData.PanelVectors.vector_y;
|
---|
2799 | FieldList={['vec(' UName ',' VName ')'];...
|
---|
2800 | ['norm(' UName ',' VName ')'];...
|
---|
2801 | UName;VName};
|
---|
2802 | case {'scalar','pick variables'}
|
---|
2803 | FieldList=GetFieldData.PanelScalar.scalar;
|
---|
2804 | if ischar(FieldList)
|
---|
2805 | FieldList={FieldList};
|
---|
2806 | end
|
---|
2807 | case '1D plot'
|
---|
2808 |
|
---|
2809 | case 'civdata...'
|
---|
2810 | FieldList=set_field_list('U','V','C');
|
---|
2811 | set(handles.FieldName,'Value',2) % set menu to 'velocity
|
---|
2812 | end
|
---|
2813 | if ~strcmp(GetFieldData.FieldOption,'civdata...')
|
---|
2814 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
|
---|
2815 | switch TimeNameStr
|
---|
2816 | case 'file index'
|
---|
2817 | set(handles.TimeName,'String','');
|
---|
2818 | case 'attribute'
|
---|
2819 | set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]);
|
---|
2820 | case 'variable'
|
---|
2821 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
|
---|
2822 | set(handles.NomType,'String','*')
|
---|
2823 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
|
---|
2824 | set(handles.FileIndex,'String','')
|
---|
2825 | ParamIn.TimeVarName=GetFieldData.Time.TimeName;
|
---|
2826 | case 'matrix_index'
|
---|
2827 | set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
|
---|
2828 | set(handles.NomType,'String','*')
|
---|
2829 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
|
---|
2830 | set(handles.FileIndex,'String','')
|
---|
2831 | ParamIn.TimeDimName=GetFieldData.Time.TimeName;
|
---|
2832 | end
|
---|
2833 | end
|
---|
2834 | set(handles.FieldName_1,'Value',1)
|
---|
2835 | set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]);
|
---|
2836 | end
|
---|
2837 | end
|
---|
2838 |
|
---|
2839 |
|
---|
2840 | %%%%%%%%%%%%%
|
---|
2841 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
|
---|
2842 | indsel=ind_i;
|
---|
2843 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series
|
---|
2844 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds
|
---|
2845 | if ~isempty(indiff)
|
---|
2846 | indiff2=diff(indiff);
|
---|
2847 | indiffp=[indiff2 1];
|
---|
2848 | indiffm=[1 indiff2];
|
---|
2849 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets
|
---|
2850 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets
|
---|
2851 | %for each multiplet, select the most recent file
|
---|
2852 | ind_remove=[];
|
---|
2853 | for i=1:length(ind_multi_m)
|
---|
2854 | ind_pairs=ind_multi_m(i):ind_multi_p(i);
|
---|
2855 | for imulti=1:length(ind_pairs)
|
---|
2856 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation
|
---|
2857 | end
|
---|
2858 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date
|
---|
2859 | ind_s=indsort2(1:end-1);%
|
---|
2860 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one
|
---|
2861 | end
|
---|
2862 | end
|
---|
2863 |
|
---|
2864 | %------------------------------------------------------------------------
|
---|
2865 | % --- determine the list of index pairstring of processing file
|
---|
2866 | 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)
|
---|
2867 | %------------------------------------------------------------------------
|
---|
2868 | num_i1=num_i;% set of first image numbers by default
|
---|
2869 | num_i2=num_i;
|
---|
2870 | num_j1=num_j;
|
---|
2871 | num_j2=num_j;
|
---|
2872 | num_i_out=num_i;
|
---|
2873 | num_j_out=num_j;
|
---|
2874 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2')
|
---|
2875 | if isequal(mode,'series(Di)')
|
---|
2876 | num_i1_line=num_i+ind_shift(3);% set of first image numbers
|
---|
2877 | num_i2_line=num_i+ind_shift(4);
|
---|
2878 | % adjust the first and last field number
|
---|
2879 | indsel=find(num_i1_line >= 1);
|
---|
2880 | num_i_out=num_i(indsel);
|
---|
2881 | num_i1_line=num_i1_line(indsel);
|
---|
2882 | num_i2_line=num_i2_line(indsel);
|
---|
2883 | num_j1=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
2884 | num_j2=meshgrid(num_j,ones(size(num_i1_line)));
|
---|
2885 | [xx,num_i1]=meshgrid(num_j,num_i1_line);
|
---|
2886 | [xx,num_i2]=meshgrid(num_j,num_i2_line);
|
---|
2887 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts')
|
---|
2888 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
|
---|
2889 | num_j1=ind_shift(1)*ones(size(num_i));
|
---|
2890 | num_j2=ind_shift(2)*ones(size(num_i));
|
---|
2891 | else
|
---|
2892 | num_j1_col=num_j+ind_shift(1);% set of first image numbers
|
---|
2893 | num_j2_col=num_j+ind_shift(2);
|
---|
2894 | % adjust the first field number
|
---|
2895 | indsel=find((num_j1_col >= 1));
|
---|
2896 | num_j_out=num_j(indsel);
|
---|
2897 | num_j1_col=num_j1_col(indsel);
|
---|
2898 | num_j2_col=num_j2_col(indsel);
|
---|
2899 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
|
---|
2900 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
|
---|
2901 | end
|
---|
2902 | end
|
---|
2903 |
|
---|
2904 | %------------------------------------------------------------------------
|
---|
2905 | % --- Executes on button press in CheckObject.
|
---|
2906 | function CheckObject_Callback(hObject, eventdata, handles)
|
---|
2907 | %------------------------------------------------------------------------
|
---|
2908 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
|
---|
2909 | if get(handles.CheckObject,'Value')
|
---|
2910 | SeriesData=get(handles.series,'UserData');
|
---|
2911 | if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)
|
---|
2912 | set(handles.ViewObject,'Value',1)
|
---|
2913 | ViewObject_Callback(hObject, eventdata, handles)
|
---|
2914 | else
|
---|
2915 | if ishandle(hset_object)
|
---|
2916 | uistack(hset_object,'top')% show the GUI set_object if opened
|
---|
2917 | else
|
---|
2918 | %get the object file
|
---|
2919 | InputTable=get(handles.InputTable,'Data');
|
---|
2920 | defaultname=InputTable{1,1};
|
---|
2921 | if isempty(defaultname)
|
---|
2922 | defaultname={''};
|
---|
2923 | end
|
---|
2924 | fileinput=uigetfile_uvmat('pick a xml object file (or use uvmat to create it)',defaultname,'.xml');
|
---|
2925 | if isempty(fileinput)% exit if no object file is selected
|
---|
2926 | set(handles.CheckObject,'Value',0)
|
---|
2927 | return
|
---|
2928 | end
|
---|
2929 | %read the file
|
---|
2930 | data=xml2struct(fileinput);
|
---|
2931 | if ~isfield(data,'Type')
|
---|
2932 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
|
---|
2933 | set(handles.CheckObject,'Value',0)
|
---|
2934 | return
|
---|
2935 | end
|
---|
2936 | if ~isfield(data,'ProjMode')
|
---|
2937 | data.ProjMode='none';
|
---|
2938 | end
|
---|
2939 | hset_object=set_object(data);% call the set_object interface
|
---|
2940 | set(hset_object,'Name','set_object_series')% name to distinguish from set_object used with uvmat
|
---|
2941 | end
|
---|
2942 | ProjObject=read_GUI(hset_object);
|
---|
2943 | set(handles.ProjObject,'String',ProjObject.Name);%display the object name
|
---|
2944 | SeriesData=get(handles.series,'UserData');
|
---|
2945 | SeriesData.ProjObject=ProjObject;
|
---|
2946 | set(handles.series,'UserData',SeriesData);
|
---|
2947 | end
|
---|
2948 | set(handles.EditObject,'Visible','on');
|
---|
2949 | set(handles.DeleteObject,'Visible','on');
|
---|
2950 | set(handles.ViewObject,'Visible','on');
|
---|
2951 | set(handles.ProjObject,'Visible','on');
|
---|
2952 | else
|
---|
2953 | set(handles.EditObject,'Visible','off');
|
---|
2954 | set(handles.DeleteObject,'Visible','off');
|
---|
2955 | set(handles.ViewObject,'Visible','off');
|
---|
2956 | if ~ishandle(hset_object)
|
---|
2957 | set(handles.ViewObject,'Value',0);
|
---|
2958 | end
|
---|
2959 | set(handles.ProjObject,'Visible','off');
|
---|
2960 | end
|
---|
2961 |
|
---|
2962 | %------------------------------------------------------------------------
|
---|
2963 | % --- Executes on button press in ViewObject.
|
---|
2964 | %------------------------------------------------------------------------
|
---|
2965 | function ViewObject_Callback(hObject, eventdata, handles)
|
---|
2966 |
|
---|
2967 | UserData=get(handles.series,'UserData');
|
---|
2968 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
2969 | if ~isempty(hset_object)
|
---|
2970 | delete(hset_object)% refresh set_object if already opened
|
---|
2971 | end
|
---|
2972 | hset_object=set_object(UserData.ProjObject);
|
---|
2973 | set(hset_object,'Name','view_object_series')
|
---|
2974 |
|
---|
2975 |
|
---|
2976 | %------------------------------------------------------------------------
|
---|
2977 | % --- Executes on button press in EditObject.
|
---|
2978 | function EditObject_Callback(hObject, eventdata, handles)
|
---|
2979 | %------------------------------------------------------------------------
|
---|
2980 | if get(handles.EditObject,'Value')
|
---|
2981 | set(handles.ViewObject,'Value',0)
|
---|
2982 | UserData=get(handles.series,'UserData');
|
---|
2983 | hset_object=set_object(UserData.ProjObject);
|
---|
2984 | set(hset_object,'Name','edit_object_series')
|
---|
2985 | set(get(hset_object,'Children'),'Enable','on')
|
---|
2986 | else
|
---|
2987 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
2988 | if ~isempty(hset_object)
|
---|
2989 | set(get(hset_object,'Children'),'Enable','off')
|
---|
2990 | end
|
---|
2991 | end
|
---|
2992 |
|
---|
2993 | %------------------------------------------------------------------------
|
---|
2994 | % --- Executes on button press in DeleteObject.
|
---|
2995 | function DeleteObject_Callback(hObject, eventdata, handles)
|
---|
2996 | %------------------------------------------------------------------------
|
---|
2997 | SeriesData=get(handles.series,'UserData');
|
---|
2998 | SeriesData.ProjObject=[];
|
---|
2999 | set(handles.series,'UserData',SeriesData)
|
---|
3000 | set(handles.ProjObject,'String','')
|
---|
3001 | set(handles.ProjObject,'Visible','off')
|
---|
3002 | set(handles.CheckObject,'Value',0)
|
---|
3003 | set(handles.ViewObject,'Visible','off')
|
---|
3004 | set(handles.EditObject,'Visible','off')
|
---|
3005 | hset_object=findobj(allchild(0),'name','set_object_series');
|
---|
3006 | if ~isempty(hset_object)
|
---|
3007 | delete(hset_object)
|
---|
3008 | end
|
---|
3009 | set(handles.DeleteObject,'Visible','off')
|
---|
3010 |
|
---|
3011 | %------------------------------------------------------------------------
|
---|
3012 | % --- Executed when CheckMask is activated
|
---|
3013 | %------------------------------------------------------------------------
|
---|
3014 | function CheckMask_Callback(hObject, eventdata, handles)
|
---|
3015 |
|
---|
3016 | if get(handles.CheckMask,'Value')
|
---|
3017 | InputTable=get(handles.InputTable,'Data');
|
---|
3018 | nbview=size(InputTable,1);
|
---|
3019 | MaskTable=cell(nbview,1);%default
|
---|
3020 | ListMask=cell(nbview,1);%default
|
---|
3021 | MaskData=get(handles.MaskTable,'Data');
|
---|
3022 | MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1);%complement if undefined lines
|
---|
3023 | for iview=1:nbview
|
---|
3024 | ListMask{iview,1}=num2str(iview);
|
---|
3025 | RootPath=InputTable{iview,1};
|
---|
3026 | if ~isempty(RootPath)
|
---|
3027 | if isempty(MaskData{iview})
|
---|
3028 | SubDir=InputTable{iview,2};
|
---|
3029 | MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']);%take the root part of SubDir, before the first dot '.'
|
---|
3030 | if exist(MaskPath,'dir')
|
---|
3031 | ListStruct=dir(MaskPath);%look for a mask file
|
---|
3032 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
|
---|
3033 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
|
---|
3034 | ListFiles=ListCells(1,:);%list of file and dri names
|
---|
3035 | ListFiles=ListFiles(~check_dir);%list of file names (excluding dir)
|
---|
3036 | mdetect=0;
|
---|
3037 | if ~isempty(ListFiles)
|
---|
3038 | for ifile=1:numel(ListFiles)
|
---|
3039 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
|
---|
3040 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
|
---|
3041 | mdetect=1;
|
---|
3042 | MaskName=ListFiles{ifile};
|
---|
3043 | end
|
---|
3044 | if ~strcmp(MaskFile{ifile},MaskFile{1})
|
---|
3045 | mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection
|
---|
3046 | break
|
---|
3047 | end
|
---|
3048 | end
|
---|
3049 | end
|
---|
3050 | if mdetect==1
|
---|
3051 | MaskName=fullfile(MaskPath,'mask_1.png');
|
---|
3052 | else
|
---|
3053 | MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image');
|
---|
3054 | end
|
---|
3055 | else
|
---|
3056 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
|
---|
3057 | end
|
---|
3058 | MaskTable{iview,1}=MaskName ;
|
---|
3059 | ListMask{iview,1}=num2str(iview);
|
---|
3060 | end
|
---|
3061 | end
|
---|
3062 | end
|
---|
3063 | set(handles.MaskTable,'Data',MaskTable)
|
---|
3064 | set(handles.MaskTable,'Visible','on')
|
---|
3065 | set(handles.MaskBrowse,'Visible','on')
|
---|
3066 | set(handles.ListMask,'Visible','on')
|
---|
3067 | set(handles.ListMask,'String',ListMask)
|
---|
3068 | set(handles.ListMask,'Value',1)
|
---|
3069 | else
|
---|
3070 | set(handles.MaskTable,'Visible','off')
|
---|
3071 | set(handles.MaskBrowse,'Visible','off')
|
---|
3072 | set(handles.ListMask,'Visible','off')
|
---|
3073 | end
|
---|
3074 |
|
---|
3075 | %------------------------------------------------------------------------
|
---|
3076 | % --- Executes on button press in MaskBrowse.
|
---|
3077 | %------------------------------------------------------------------------
|
---|
3078 | function MaskBrowse_Callback(hObject, eventdata, handles)
|
---|
3079 |
|
---|
3080 | InputTable=get(handles.InputTable,'Data');
|
---|
3081 | iview=get(handles.ListMask,'Value');
|
---|
3082 | RootPath=InputTable{iview,1};
|
---|
3083 | MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
|
---|
3084 | if ~isempty(MaskName)
|
---|
3085 | MaskTable=get(handles.MaskTable,'Data');
|
---|
3086 | MaskTable{iview,1}=MaskName ;
|
---|
3087 | set(handles.MaskTable,'Data',MaskTable)
|
---|
3088 | end
|
---|
3089 |
|
---|
3090 | %------------------------------------------------------------------------
|
---|
3091 | % --- Executes when selected cell(s) is changed in MaskTable.
|
---|
3092 | %------------------------------------------------------------------------
|
---|
3093 | function MaskTable_CellSelectionCallback(hObject, eventdata, handles)
|
---|
3094 |
|
---|
3095 | if numel(eventdata.Indices)>=1
|
---|
3096 | set(handles.ListMask,'Value',eventdata.Indices(1))
|
---|
3097 | end
|
---|
3098 |
|
---|
3099 | %-------------------------------------------------------------------
|
---|
3100 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
3101 | %-------------------------------------------------------------------
|
---|
3102 |
|
---|
3103 |
|
---|
3104 | % path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
3105 | % pathelp=fileparts(path_to_uvmat);
|
---|
3106 | % helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
3107 | % 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')
|
---|
3108 | % else
|
---|
3109 | % addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
3110 | % web([helpfile '#series'])
|
---|
3111 | % end
|
---|
3112 |
|
---|
3113 | %-------------------------------------------------------------------
|
---|
3114 | % --- Executes on selection change in TransformName.
|
---|
3115 | function TransformName_Callback(hObject, eventdata, handles)
|
---|
3116 | %----------------------------------------------------------------------
|
---|
3117 | TransformList=get(handles.TransformName,'String');
|
---|
3118 | TransformIndex=get(handles.TransformName,'Value');
|
---|
3119 | TransformName=TransformList{TransformIndex};
|
---|
3120 | TransformPathList=get(handles.TransformName,'UserData');
|
---|
3121 | nb_builtin_transform=4;
|
---|
3122 | if isequal(TransformName,'more...');
|
---|
3123 | FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m');
|
---|
3124 | if isempty(FileName)
|
---|
3125 | return %browser closed without choice
|
---|
3126 | end
|
---|
3127 | [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m
|
---|
3128 | if ~strcmp(TransformExt,'.m')
|
---|
3129 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
3130 | return
|
---|
3131 | end
|
---|
3132 | % insert the choice in the menu
|
---|
3133 | TransformIndex=find(strcmp(TransformName,TransformList),1);% look for the selected function in the menu Action
|
---|
3134 | if isempty(TransformIndex)%the input string does not exist in the menu
|
---|
3135 | TransformIndex= length(TransformList);
|
---|
3136 | TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...'
|
---|
3137 | set(handles.TransformName,'String',TransformList)
|
---|
3138 | TransformPathList=[TransformPathList;{TransformPath}];
|
---|
3139 | else% the input function already exist, we update its path (possibly new)
|
---|
3140 | TransformPathList{TransformIndex}=TransformPath;%
|
---|
3141 | set(handles.TransformName,'Value',TransformIndex)
|
---|
3142 | end
|
---|
3143 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
3144 | dir_perso=prefdir;%personal Matalb directory
|
---|
3145 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3146 | if exist(profil_perso,'file')
|
---|
3147 | for ilist=nb_builtin_transform+1:numel(TransformPathList)
|
---|
3148 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist};
|
---|
3149 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist};
|
---|
3150 | end
|
---|
3151 | TransformPathListUser=TransformPathListUser';
|
---|
3152 | TransformListUser=TransformListUser';
|
---|
3153 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat
|
---|
3154 | end
|
---|
3155 | end
|
---|
3156 |
|
---|
3157 | %display the current function path
|
---|
3158 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); %show the path to the senlected function
|
---|
3159 | set(handles.TransformName,'UserData',TransformPathList);
|
---|
3160 |
|
---|
3161 | %% create the function handle of the selected fct
|
---|
3162 | if ~isempty(TransformName)
|
---|
3163 | if ~exist(TransformPathList{TransformIndex},'dir')
|
---|
3164 | msgbox_uvmat('ERROR',['The prescribed transform function path ' TransformPathList{TransformIndex} ' does not exist']);
|
---|
3165 | return
|
---|
3166 | end
|
---|
3167 | current_dir=pwd;%current working dir
|
---|
3168 | cd(TransformPathList{TransformIndex})
|
---|
3169 | transform_handle=str2func(TransformName);
|
---|
3170 | cd(current_dir)
|
---|
3171 | Field.Action.RUN=0;% indicate that the transform fct is called only to get input param
|
---|
3172 | DataOut=feval(transform_handle,Field,[]);% execute the transform fct to get the required conditions
|
---|
3173 | if isfield(DataOut,'TransformInput')% used to add transform parameters at selection of the transform fct
|
---|
3174 | SeriesData=get(handles.series,'UserData');
|
---|
3175 | SeriesData.TransformInput=DataOut.TransformInput;
|
---|
3176 | set(handles.series,'UserData',SeriesData)
|
---|
3177 | end
|
---|
3178 | end
|
---|
3179 |
|
---|
3180 | %------------------------------------------------------------------------
|
---|
3181 | % --- fct activated by the upper bar menu ExportConfig
|
---|
3182 | %------------------------------------------------------------------------
|
---|
3183 | function MenuDisplayConfig_Callback(hObject, eventdata, handles)
|
---|
3184 |
|
---|
3185 | global Param
|
---|
3186 | Param=read_GUI_series(handles);
|
---|
3187 | evalin('base','global Param')%make CurData global in the workspace
|
---|
3188 | display('current series config :')
|
---|
3189 | evalin('base','Param') %display CurData in the workspace
|
---|
3190 | commandwindow; %brings the Matlab command window to the front
|
---|
3191 |
|
---|
3192 | %------------------------------------------------------------------------
|
---|
3193 | % --- fct activated by the upper bar menu InportConfig: import
|
---|
3194 | % menu settings from an xml file (stored in /0_XML for each run)
|
---|
3195 | %------------------------------------------------------------------------
|
---|
3196 | function MenuImportConfig_Callback(hObject, eventdata, handles)
|
---|
3197 |
|
---|
3198 | %% use a browser to choose the xml file containing the processing config
|
---|
3199 | InputTable=get(handles.InputTable,'Data');
|
---|
3200 | oldfile=InputTable{1,1};%current path in InputTable
|
---|
3201 | if isempty(oldfile)
|
---|
3202 | % use a file name stored in prefdir
|
---|
3203 | dir_perso=prefdir;
|
---|
3204 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3205 | if exist(profil_perso,'file')
|
---|
3206 | h=load (profil_perso);
|
---|
3207 | if isfield(h,'RootPath') && ischar(h.RootPath)
|
---|
3208 | oldfile=h.RootPath;
|
---|
3209 | end
|
---|
3210 | end
|
---|
3211 | end
|
---|
3212 | filexml=uigetfile_uvmat('pick a xml parameter file',oldfile,'.xml');% get the xml file containing processing parameters
|
---|
3213 | if isempty(filexml), return, end % quit function if an xml file has not been opened
|
---|
3214 |
|
---|
3215 | %% fill the GUI series with the content of the xml file
|
---|
3216 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure
|
---|
3217 |
|
---|
3218 | % ask to stop current Action if button RUN is in action (another process is already running)
|
---|
3219 | if isequal(get(handles.RUN,'Value'),1)
|
---|
3220 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
|
---|
3221 | if strcmp(answer,'Yes')
|
---|
3222 | STOP_Callback(hObject, eventdata, handles)
|
---|
3223 | else
|
---|
3224 | return
|
---|
3225 | end
|
---|
3226 | end
|
---|
3227 | Param.Action.RUN=0; %desactivate the input RUN=1
|
---|
3228 |
|
---|
3229 | fill_GUI(Param,handles.series)% fill the elements of the GUI series with the input parameters
|
---|
3230 | SeriesData=get(handles.series,'UserData');
|
---|
3231 | if isfield(Param,'InputFields')
|
---|
3232 | ListField=Param.InputFields.FieldName;
|
---|
3233 | if ischar(ListField),ListField={ListField}; end
|
---|
3234 | set(handles.FieldName,'String',[ListField;{'get-field...'}])
|
---|
3235 | set(handles.FieldName,'Value',1:numel(ListField))
|
---|
3236 | set(handles.FieldName,'Visible','on')
|
---|
3237 | end
|
---|
3238 | if isfield(Param,'ActionInput')% introduce parameters specific to an Action fct, for instance PIV parameters
|
---|
3239 | set(handles.ActionInput,'Visible','on')
|
---|
3240 | set(handles.ActionInput,'Value',0)
|
---|
3241 | Param.ActionInput.ConfigSource=filexml;% record the source of config for future info
|
---|
3242 | SeriesData.ActionInput=Param.ActionInput;
|
---|
3243 | end
|
---|
3244 | if isfield(Param,'TransformInput')% introduce parameters specific to a transform fct
|
---|
3245 | SeriesData.TransformInput=Param.TransformInput;
|
---|
3246 | end
|
---|
3247 | if isfield(Param,'ProjObject') %introduce projection object if relevant
|
---|
3248 | SeriesData.ProjObject=Param.ProjObject;
|
---|
3249 | end
|
---|
3250 | set(handles.series,'UserData',SeriesData)
|
---|
3251 | if isfield(Param,'CheckObject') && isequal(Param.CheckObject,1)
|
---|
3252 | set(handles.ProjObject,'String',Param.ProjObject.Name)
|
---|
3253 | set(handles.ViewObject,'Visible','on')
|
---|
3254 | set(handles.EditObject,'Visible','on')
|
---|
3255 | set(handles.DeleteObject,'Visible','on')
|
---|
3256 | else
|
---|
3257 | set(handles.ProjObject,'String','')
|
---|
3258 | set(handles.ProjObject,'Visible','off')
|
---|
3259 | set(handles.ViewObject,'Visible','off')
|
---|
3260 | set(handles.EditObject,'Visible','off')
|
---|
3261 | set(handles.DeleteObject,'Visible','off')
|
---|
3262 | end
|
---|
3263 | set(handles.REFRESH,'BackgroundColor',[1 0 1]); %paint REFRESH button in magenta to indicate that it should be activated
|
---|
3264 |
|
---|
3265 |
|
---|
3266 | %------------------------------------------------------------------------
|
---|
3267 | % --- Executes when the GUI series is resized.
|
---|
3268 | %------------------------------------------------------------------------
|
---|
3269 | function series_ResizeFcn(hObject, eventdata, handles)
|
---|
3270 |
|
---|
3271 | %% input table
|
---|
3272 | set(handles.InputTable,'Unit','pixel')
|
---|
3273 | Pos=get(handles.InputTable,'Position');
|
---|
3274 | set(handles.InputTable,'Unit','normalized')
|
---|
3275 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52));
|
---|
3276 | ColumnWidth=num2cell(ColumnWidth);
|
---|
3277 | set(handles.InputTable,'ColumnWidth',ColumnWidth)
|
---|
3278 |
|
---|
3279 | %% MinIndex_j and MaxIndex_i
|
---|
3280 | unit=get(handles.MinIndex_i,'Unit');
|
---|
3281 | set(handles.MinIndex_i,'Unit','pixel')
|
---|
3282 | Pos=get(handles.MinIndex_i,'Position');
|
---|
3283 | set(handles.MinIndex_i,'Unit',unit)
|
---|
3284 | set(handles.MinIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
3285 | set(handles.MaxIndex_i,'ColumnWidth',{Pos(3)-18})
|
---|
3286 | set(handles.MinIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
3287 | set(handles.MaxIndex_j,'ColumnWidth',{Pos(3)-18})
|
---|
3288 |
|
---|
3289 | %% TimeTable
|
---|
3290 | set(handles.TimeTable,'Unit','pixel')
|
---|
3291 | Pos=get(handles.TimeTable,'Position');
|
---|
3292 | set(handles.TimeTable,'Unit','normalized')
|
---|
3293 | % ColumnWidth=get(handles.TimeTable,'ColumnWidth');
|
---|
3294 | ColumnWidth=num2cell(floor([0.2 0.2 0.2 0.2 0.2]*(Pos(3)-20)));
|
---|
3295 | set(handles.TimeTable,'ColumnWidth',ColumnWidth)
|
---|
3296 |
|
---|
3297 |
|
---|
3298 | %% PairString
|
---|
3299 | set(handles.PairString,'Unit','pixel')
|
---|
3300 | Pos=get(handles.PairString,'Position');
|
---|
3301 | set(handles.PairString,'Unit','normalized')
|
---|
3302 | set(handles.PairString,'ColumnWidth',{Pos(3)-5})
|
---|
3303 |
|
---|
3304 | %% MaskTable
|
---|
3305 | set(handles.MaskTable,'Unit','pixel')
|
---|
3306 | Pos=get(handles.MaskTable,'Position');
|
---|
3307 | set(handles.MaskTable,'Unit','normalized')
|
---|
3308 | set(handles.MaskTable,'ColumnWidth',{Pos(3)-5})
|
---|
3309 |
|
---|
3310 | %------------------------------------------------------------------------
|
---|
3311 | % --- Executes on button press in status.
|
---|
3312 | %------------------------------------------------------------------------
|
---|
3313 | function status_Callback(hObject, eventdata, handles)
|
---|
3314 |
|
---|
3315 | if get(handles.status,'Value')
|
---|
3316 | set(handles.status,'BackgroundColor',[1 1 0])
|
---|
3317 | drawnow
|
---|
3318 | Param=read_GUI(handles.series);
|
---|
3319 | RootPath=Param.InputTable{1,1};
|
---|
3320 | if ~isfield(Param,'OutputSubDir')
|
---|
3321 | msgbox_uvmat('ERROR','no standard sub-directory definition for output files, use a browser to check the output')
|
---|
3322 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3323 | return
|
---|
3324 | end
|
---|
3325 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
|
---|
3326 | OutputDir=fullfile(RootPath,OutputSubDir);
|
---|
3327 | if exist(OutputDir,'dir')
|
---|
3328 | uigetfile_uvmat('status_display',OutputDir)
|
---|
3329 | else
|
---|
3330 | msgbox_uvmat('ERROR','output folder not created yet: calculation did not start')
|
---|
3331 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3332 | end
|
---|
3333 | else
|
---|
3334 | %% delete current display fig if selection is off
|
---|
3335 | set(handles.status,'BackgroundColor',[0 1 0])
|
---|
3336 | hfig=findobj(allchild(0),'name','status_display');
|
---|
3337 | if ~isempty(hfig)
|
---|
3338 | delete(hfig)
|
---|
3339 | end
|
---|
3340 | return
|
---|
3341 | end
|
---|
3342 |
|
---|
3343 |
|
---|
3344 | %------------------------------------------------------------------------
|
---|
3345 | % launched by selecting a file on the list
|
---|
3346 | %------------------------------------------------------------------------
|
---|
3347 | function view_file(hObject, eventdata)
|
---|
3348 |
|
---|
3349 | list=get(hObject,'String');
|
---|
3350 | index=get(hObject,'Value');
|
---|
3351 | rootroot=get(hObject,'UserData');
|
---|
3352 | selectname=list{index};
|
---|
3353 | ind_dot=regexp(selectname,'\.\.\.');
|
---|
3354 | if ~isempty(ind_dot)
|
---|
3355 | selectname=selectname(1:ind_dot-1);
|
---|
3356 | end
|
---|
3357 | FullSelectName=fullfile(rootroot,selectname);
|
---|
3358 | if exist(FullSelectName,'dir')% a directory has been selected
|
---|
3359 | ListFiles=dir(FullSelectName);
|
---|
3360 | ListDisplay=cell(numel(ListFiles),1);
|
---|
3361 | for ilist=2:numel(ListDisplay)% suppress the first line '.'
|
---|
3362 | ListDisplay{ilist-1}=ListFiles(ilist).name;
|
---|
3363 | end
|
---|
3364 | set(hObject,'Value',1)
|
---|
3365 | set(hObject,'String',ListDisplay)
|
---|
3366 | if strcmp(selectname,'..')
|
---|
3367 | FullSelectName=fileparts(fileparts(FullSelectName));
|
---|
3368 | end
|
---|
3369 | set(hObject,'UserData',FullSelectName)
|
---|
3370 | hfig=get(hObject,'parent');
|
---|
3371 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
3372 | set(htitlebox,'String',FullSelectName)
|
---|
3373 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists
|
---|
3374 | FileInfo=get_file_info(FullSelectName);
|
---|
3375 | if strcmp(FileInfo.FileType,'txt')
|
---|
3376 | edit(FullSelectName)
|
---|
3377 | elseif strcmp(FileInfo.FileType,'xml')
|
---|
3378 | editxml(FullSelectName)
|
---|
3379 | else
|
---|
3380 | uvmat(FullSelectName)
|
---|
3381 | end
|
---|
3382 | set(gcbo,'Value',1)
|
---|
3383 | end
|
---|
3384 |
|
---|
3385 |
|
---|
3386 | %------------------------------------------------------------------------
|
---|
3387 | % launched by refreshing the status figure
|
---|
3388 | %------------------------------------------------------------------------
|
---|
3389 | function refresh_GUI(hfig)
|
---|
3390 |
|
---|
3391 | htitlebox=findobj(hfig,'tag','titlebox');
|
---|
3392 | hlist=findobj(hfig,'tag','list');
|
---|
3393 | hseries=findobj(allchild(0),'tag','series');
|
---|
3394 | hstatus=findobj(hseries,'tag','status');
|
---|
3395 | StatusData=get(hstatus,'UserData');
|
---|
3396 | OutputDir=get(htitlebox,'String');
|
---|
3397 | if ischar(OutputDir),OutputDir={OutputDir};end
|
---|
3398 | ListFiles=dir(OutputDir{1});
|
---|
3399 | if numel(ListFiles)<1
|
---|
3400 | return
|
---|
3401 | end
|
---|
3402 | ListFiles(1)=[];%removes the first line ='.'
|
---|
3403 | ListDisplay=cell(numel(ListFiles),1);
|
---|
3404 | testrecent=0;
|
---|
3405 | datnum=zeros(numel(ListDisplay),1);
|
---|
3406 | for ilist=1:numel(ListDisplay)
|
---|
3407 | ListDisplay{ilist}=ListFiles(ilist).name;
|
---|
3408 | if ~ListFiles(ilist).isdir && isfield(ListFiles(ilist),'datenum')
|
---|
3409 | datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions
|
---|
3410 | testrecent=1;
|
---|
3411 | end
|
---|
3412 | end
|
---|
3413 | set(hlist,'String',ListDisplay)
|
---|
3414 |
|
---|
3415 | %% Look at date of creation
|
---|
3416 | ListDisplay=ListDisplay(datnum~=0);
|
---|
3417 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
|
---|
3418 | NbOutputFile=[];
|
---|
3419 | if isempty(datnum)
|
---|
3420 | if testrecent
|
---|
3421 | message='no civ result created yet';
|
---|
3422 | else
|
---|
3423 | message='';
|
---|
3424 | end
|
---|
3425 | else
|
---|
3426 | [first,indfirst]=min(datnum);
|
---|
3427 | [last,indlast]=max(datnum);
|
---|
3428 | NbOutputFile_str='?';
|
---|
3429 | NbOutputFile=[];
|
---|
3430 | if isfield(StatusData,'NbOutputFile')
|
---|
3431 | NbOutputFile=StatusData.NbOutputFile;
|
---|
3432 | NbOutputFile_str=num2str(NbOutputFile);
|
---|
3433 | end
|
---|
3434 | message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];...
|
---|
3435 | ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]};
|
---|
3436 | end
|
---|
3437 | set(htitlebox,'String', [OutputDir{1};message])
|
---|
3438 |
|
---|
3439 | %% update the waitbar
|
---|
3440 | hwaitbar=findobj(hfig,'tag','waitbar');
|
---|
3441 | if ~isempty(NbOutputFile)
|
---|
3442 | BarPosition=get(hwaitbar,'Position');
|
---|
3443 | BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
|
---|
3444 | set(hwaitbar,'Position',BarPosition)
|
---|
3445 | end
|
---|
3446 |
|
---|
3447 | %------------------------------------------------------------------------
|
---|
3448 | % --- Executes on selection change in ActionExt.
|
---|
3449 | %------------------------------------------------------------------------
|
---|
3450 | function ActionExt_Callback(hObject, eventdata, handles)
|
---|
3451 |
|
---|
3452 | ActionExtList=get(handles.ActionExt,'String');
|
---|
3453 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
|
---|
3454 | if strcmp(ActionExt,'.py (in dev.)')
|
---|
3455 | set(handles.RunMode,'Value',2)
|
---|
3456 | end
|
---|
3457 |
|
---|
3458 | %function num_NbProcess_Callback(hObject, eventdata, handles)
|
---|
3459 |
|
---|
3460 |
|
---|
3461 | function num_NbSlice_Callback(hObject, eventdata, handles)
|
---|
3462 | NbSlice=str2num(get(handles.num_NbSlice,'String'));
|
---|
3463 | %set(handles.num_NbProcess,'String',num2str(NbSlice))
|
---|
3464 |
|
---|
3465 | %------------------------------------------------------------------------
|
---|
3466 | % --- set the visibility of relevant velocity type menus:
|
---|
3467 | function menu=set_veltype_display(Civ,FileType)
|
---|
3468 | %------------------------------------------------------------------------
|
---|
3469 | if ~exist('FileType','var')
|
---|
3470 | FileType='civx';
|
---|
3471 | end
|
---|
3472 | switch FileType
|
---|
3473 | case 'civx'
|
---|
3474 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
3475 | if isequal(Civ,0)
|
---|
3476 | imax=0;
|
---|
3477 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3478 | imax=1;
|
---|
3479 | elseif isequal(Civ,3)
|
---|
3480 | imax=3;
|
---|
3481 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3482 | imax=4;
|
---|
3483 | elseif isequal(Civ,6) %patch2
|
---|
3484 | imax=6;
|
---|
3485 | end
|
---|
3486 | case 'civdata'
|
---|
3487 | menu={'civ1';'filter1';'civ2';'filter2'};
|
---|
3488 | if isequal(Civ,0)
|
---|
3489 | imax=0;
|
---|
3490 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3491 | imax=1;
|
---|
3492 | elseif isequal(Civ,3)
|
---|
3493 | imax=2;
|
---|
3494 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3495 | imax=3;
|
---|
3496 | else%if isequal(Civ,6) %patch2
|
---|
3497 | imax=4;
|
---|
3498 | end
|
---|
3499 | end
|
---|
3500 | menu=menu(1:imax);
|
---|
3501 |
|
---|
3502 |
|
---|
3503 | % --- Executes on mouse motion over figure - except title and menu.
|
---|
3504 | function series_WindowButtonMotionFcn(hObject, eventdata, handles)
|
---|
3505 | set(hObject,'Pointer','arrow');
|
---|
3506 |
|
---|
3507 |
|
---|
3508 | % --- Executes on button press in SetPairs.
|
---|
3509 | function SetPairs_Callback(hObject, iview, handles)
|
---|
3510 |
|
---|
3511 | %% delete previous occurrence of 'set_pairs'
|
---|
3512 | hfig=findobj(allchild(0),'Tag','set_pairs');
|
---|
3513 | if ~isempty(hfig)
|
---|
3514 | delete(hfig)
|
---|
3515 | end
|
---|
3516 |
|
---|
3517 | %% create the GUI set_pairs
|
---|
3518 | set(0,'Unit','points')
|
---|
3519 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
|
---|
3520 | Width=220;% fig width in points (1/72 inch)
|
---|
3521 | Height=min(0.8*ScreenSize(4),300);
|
---|
3522 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
|
---|
3523 | Bottom=ScreenSize(4)-Height-40; %put fig at top right
|
---|
3524 | hfig=findobj(allchild(0),'Tag','set_slice');
|
---|
3525 | if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
|
---|
3526 | hfig=figure('name','set_pairs','tag','set_pairs','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]);
|
---|
3527 | BackgroundColor=get(hfig,'Color');
|
---|
3528 | SeriesData=get(handles.series,'UserData');
|
---|
3529 | TimeUnit=get(handles.TimeUnit,'String');
|
---|
3530 | PairString=get(handles.PairString,'Data');
|
---|
3531 | ListViewLines=find(cellfun('isempty',PairString)==0);%find list of non empty pairs
|
---|
3532 | ListViewMenu=cell(numel(ListViewLines),1);
|
---|
3533 | for ilist=1:numel(ListViewLines)
|
---|
3534 | ListViewMenu{ilist}=num2str(ListViewLines(ilist));
|
---|
3535 | end
|
---|
3536 | if isempty(iview)
|
---|
3537 | ListViewValue=numel(ListViewLines);% we work by default on the pair option for the last line which requires pairs
|
---|
3538 | iview=ListViewLines(end);
|
---|
3539 | else
|
---|
3540 | ListViewValue=find(ListViewLines==iview);
|
---|
3541 | end
|
---|
3542 | ref_i=str2num(get(handles.num_first_i,'String'));
|
---|
3543 | ref_j=1;%default
|
---|
3544 | if strcmp(get(handles.num_first_j,'String'),'Visible')
|
---|
3545 | ref_j=str2num(get(handles.num_first_j,'String'));
|
---|
3546 | end
|
---|
3547 | [ModeMenu,ModeValue]=update_mode(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j2_series{iview});
|
---|
3548 | displ_pair=update_listpair(SeriesData.i1_series{iview},SeriesData.i2_series{iview},SeriesData.j1_series{iview},SeriesData.j2_series{iview},ModeMenu{ModeValue},...
|
---|
3549 | SeriesData.Time{iview},TimeUnit,ref_i,ref_j,SeriesData.FileInfo{iview});
|
---|
3550 | % first raw of the GUI
|
---|
3551 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.88 0.5 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3552 | 'String','row to edit #','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
|
---|
3553 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.54 0.8 0.3 0.2],'BackgroundColor',[1 1 1],...
|
---|
3554 | 'Callback',@(hObject,eventdata)ListView_Callback(hObject,eventdata),'String',ListViewMenu,'Value',ListViewValue,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3555 | 'Tag','ListView','TooltipString','''ListView'':choice of the file series w for pair display');
|
---|
3556 | % second raw of the GUI
|
---|
3557 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.79 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3558 | 'String','mode of index pairing:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title
|
---|
3559 | uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.05 0.62 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
3560 | 'Callback',@(hObject,eventdata)Mode_Callback(hObject,eventdata),'String',ModeMenu,'Value',ModeValue,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3561 | 'Tag','Mode','TooltipString','''Mode'': choice of the image pair mode');
|
---|
3562 | % third raw
|
---|
3563 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.6 0.7 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3564 | 'String','pair choice:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');%title
|
---|
3565 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.42 0.9 0.2],'BackgroundColor',[1 1 1],...
|
---|
3566 | 'Callback',@(hObject,eventdata)ListPair_Callback(hObject,eventdata),'String',displ_pair,'Value',1,'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3567 | 'Tag','ListPair','TooltipString','''ListPair'': menu for selecting the image pair');
|
---|
3568 | uicontrol('Style','text','Units','normalized', 'Position', [0.1 0.22 0.8 0.1],'BackgroundColor',BackgroundColor,...
|
---|
3569 | 'String','ref_i ref_j','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
|
---|
3570 | uicontrol('Style','edit','Units','normalized', 'Position', [0.15 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
3571 | 'Callback',@(hObject,eventdata)num_ref_i_Callback(hObject,eventdata),'String',num2str(ref_i),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3572 | 'Tag','num_ref_i','TooltipString','''num_ref_i'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
3573 | uicontrol('Style','edit','Units','normalized', 'Position', [0.55 0.17 0.3 0.08],'BackgroundColor',[1 1 1],...
|
---|
3574 | 'Callback',@(hObject,eventdata)num_ref_j_Callback(hObject,eventdata),'String',num2str(ref_j),'FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3575 | 'Tag','num_ref_j','TooltipString','''num_ref_j'': reference field index i used to display dt in ''list_pair_civ''');
|
---|
3576 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.01 0.01 0.3 0.12],'BackgroundColor',[0 1 0],...
|
---|
3577 | 'Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),'String','OK','FontUnits','points','FontSize',12,'FontWeight','bold',...
|
---|
3578 | 'Tag','OK','TooltipString','''OK'': validate the choice');
|
---|
3579 | % last raw of the GUI: pushbuttons
|
---|
3580 | % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.01 0.3 0.15],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),...
|
---|
3581 | % 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''OK'': apply the output to the current field series in uvmat');
|
---|
3582 | drawnow
|
---|
3583 |
|
---|
3584 | %------------------------------------------------------------------------
|
---|
3585 | function ListView_Callback(hObject,eventdata)
|
---|
3586 | Mode_Callback(hObject,eventdata)
|
---|
3587 |
|
---|
3588 | %------------------------------------------------------------------------
|
---|
3589 | function Mode_Callback(hObject,eventdata)
|
---|
3590 | %% get input info
|
---|
3591 | hseries=findobj(allchild(0),'tag','series');%handles of the GUI series
|
---|
3592 | hhseries=guidata(hseries);%handles of the elements in the GUI series
|
---|
3593 | TimeUnit=get(hhseries.TimeUnit,'String');
|
---|
3594 | SeriesData=get(hseries,'UserData');
|
---|
3595 | mode_list=get(hObject,'String');
|
---|
3596 | mode=mode_list{get(hObject,'Value')};
|
---|
3597 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
3598 | iview=get(hListView,'Value');
|
---|
3599 | i1_series=SeriesData.i1_series{iview};
|
---|
3600 | i2_series=SeriesData.i2_series{iview};
|
---|
3601 | j1_series=SeriesData.j1_series{iview};
|
---|
3602 | j2_series=SeriesData.j2_series{iview};
|
---|
3603 |
|
---|
3604 | %% enable j index visibility after the new choice
|
---|
3605 | status_j='on';%default
|
---|
3606 | if isempty(find(~cellfun(@isempty,SeriesData.j1_series), 1)); % case of empty j indices
|
---|
3607 | status_j='off'; % no j index needed
|
---|
3608 | elseif strcmp(get(handles.PairString,'Visible'),'on')
|
---|
3609 | check_burst=cellfun(@isempty,regexp(PairString,'^j'));%=0 for burst case, 1 otherwise
|
---|
3610 | if isempty(find(check_burst, 1))% if all pair string begins by j (burst)
|
---|
3611 | status_j='off'; % no j index needed for bust case
|
---|
3612 | end
|
---|
3613 | end
|
---|
3614 | enable_j(handles,status_j) % no j index needed
|
---|
3615 |
|
---|
3616 | %% get the reference indices for the time interval Dt
|
---|
3617 | href_i=findobj(get(hObject,'parent'),'Tag','ref_i');
|
---|
3618 | ref_i=[];ref_j=[];
|
---|
3619 | if strcmp(get(href_i,'Visible'),'on')
|
---|
3620 | ref_i=str2num(get(href_i,'String'));
|
---|
3621 | end
|
---|
3622 | if isempty(ref_i)
|
---|
3623 | ref_i=1;
|
---|
3624 | end
|
---|
3625 | if isempty(ref_j)
|
---|
3626 | ref_j=1;
|
---|
3627 | end
|
---|
3628 |
|
---|
3629 | %% update the menu ListPair
|
---|
3630 | Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,mode,SeriesData.Time{iview},TimeUnit,ref_i,ref_j,FileInfo);
|
---|
3631 | hlist_pairs=findobj(get(hObject,'parent'),'Tag','ListPair');
|
---|
3632 | set(hlist_pairs,'Value',1)% set the first choice by default in ListPair
|
---|
3633 | set(hlist_pairs,'String',Menu)% set the menu in ListPair
|
---|
3634 | ListPair_Callback(hlist_pairs,[])% apply the default choice in ListPair
|
---|
3635 |
|
---|
3636 | %-------------------------------------------------------------
|
---|
3637 | % --- Executes on selection in ListPair.
|
---|
3638 | function ListPair_Callback(hObject,eventdata)
|
---|
3639 | %------------------------------------------------------------
|
---|
3640 | list_pair=get(hObject,'String');%get the menu of image pairs
|
---|
3641 | if isempty(list_pair)
|
---|
3642 | string='';
|
---|
3643 | else
|
---|
3644 | string=list_pair{get(hObject,'Value')};
|
---|
3645 | % string=regexprep(string,',.*','');%removes time indication (after ',')
|
---|
3646 | end
|
---|
3647 | hseries=findobj(allchild(0),'tag','series');
|
---|
3648 | hPairString=findobj(hseries,'tag','PairString');
|
---|
3649 | PairString=get(hPairString,'Data');
|
---|
3650 | hListView=findobj(get(hObject,'parent'),'Tag','ListView');
|
---|
3651 | iview=get(hListView,'Value');
|
---|
3652 | PairString{iview,1}=string;
|
---|
3653 | % report the selected pair string to the table PairString
|
---|
3654 | set(hPairString,'Data',PairString)
|
---|
3655 |
|
---|
3656 |
|
---|
3657 | %------------------------------------------------------------------------
|
---|
3658 | function num_ref_i_Callback(hObject, eventdata)
|
---|
3659 | %------------------------------------------------------------------------
|
---|
3660 | Mode_Callback([],[])
|
---|
3661 |
|
---|
3662 | %------------------------------------------------------------------------
|
---|
3663 | function num_ref_j_Callback(hObject, eventdata)
|
---|
3664 | %------------------------------------------------------------------------
|
---|
3665 | Mode_Callback([],[])
|
---|
3666 |
|
---|
3667 | %------------------------------------------------------------------------
|
---|
3668 | function OK_Callback(hObject, eventdata)
|
---|
3669 | %------------------------------------------------------------------------
|
---|
3670 | delete(get(hObject,'parent'))
|
---|
3671 |
|
---|
3672 |
|
---|
3673 | %------------------------------------------------------------------------
|
---|
3674 | % --- Executes on button press in ClearLine.
|
---|
3675 | %------------------------------------------------------------------------
|
---|
3676 | function ClearLine_Callback(hObject, eventdata, handles)
|
---|
3677 | InputTable=get(handles.InputTable,'Data');
|
---|
3678 | iline=str2double(get(handles.InputLine,'String'));
|
---|
3679 | if size(InputTable,1)>1
|
---|
3680 | InputTable(iline,:)=[];% suppress the current line if not the first
|
---|
3681 | set(handles.InputTable,'Data',InputTable);
|
---|
3682 | end
|
---|
3683 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refr
|
---|
3684 |
|
---|
3685 |
|
---|
3686 | % --- Executes on button press in MonitorCluster.
|
---|
3687 | function MonitorCluster_Callback(hObject, eventdata, handles)
|
---|
3688 | web('https://www.legi.grenoble-inp.fr/servload/monika')
|
---|
3689 |
|
---|
3690 |
|
---|
3691 |
|
---|
3692 | function OutputSubDir_Callback(hObject, eventdata, handles)
|
---|
3693 | set(handles.OutputSubDir,'BackgroundColor',[1 1 1])
|
---|
3694 |
|
---|
3695 |
|
---|
3696 | % --- Executes on button press in CheckOverwrite.
|
---|
3697 | function CheckOverwrite_Callback(hObject, eventdata, handles)
|
---|
3698 |
|
---|
3699 |
|
---|
3700 |
|
---|
3701 | % --- Executes on button press in TestCPUTime.
|
---|
3702 | function TestCPUTime_Callback(hObject, eventdata, handles)
|
---|
3703 | % hObject handle to TestCPUTime (see GCBO)
|
---|
3704 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
3705 | % handles structure with handles and user data (see GUIDATA)
|
---|
3706 |
|
---|
3707 |
|
---|
3708 |
|
---|
3709 |
|
---|
3710 |
|
---|