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