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