[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 |
---|
[156] | 69 | drawnow |
---|
[244] | 70 | set(hObject,'Units','pixels') |
---|
[526] | 71 | set(handles.PairString,'ColumnName',{'pairs'}) |
---|
[598] | 72 | set(handles.PairString,'ColumnEditable',false) |
---|
[408] | 73 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
| 74 | set(handles.PairString,'Data',{''}) |
---|
[526] | 75 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size |
---|
[332] | 76 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
[591] | 77 | % check default input data |
---|
| 78 | if ~exist('Param','var') |
---|
| 79 | Param=[]; %default |
---|
| 80 | end |
---|
| 81 | |
---|
| 82 | %% default list of functions in the mebu ActionName |
---|
| 83 | ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback |
---|
| 84 | [path_series,name,ext]=fileparts(which('series'));% path to the GUI series |
---|
| 85 | path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series' |
---|
[598] | 86 | %path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled) |
---|
[591] | 87 | ActionPathList=regexprep(ActionList,'^.+$',path_series_fct);% set path=path_series to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string) |
---|
[598] | 88 | ActionPathList=[ActionPathList ActionPathList];% set path to .sh commands for compiled functions |
---|
[591] | 89 | ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh) |
---|
| 90 | RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh) |
---|
| 91 | [s,w]=system('oarstat');% look for cluster system 'oar' |
---|
| 92 | if isequal(s,0) |
---|
| 93 | RunModeList=[RunModeList;{'cluster_oar'}]; |
---|
| 94 | end |
---|
| 95 | [s,w]=system('qstat');% look for cluster system 'sge' |
---|
| 96 | if isequal(s,0) |
---|
| 97 | RunModeList=[RunModeList;{'cluster_sge'}]; |
---|
| 98 | end |
---|
| 99 | set(handles.RunMode,'String',RunModeList) |
---|
| 100 | |
---|
| 101 | %% default list of functions in the mebu TransformName |
---|
| 102 | TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in TransformName_callback |
---|
| 103 | path_transform_fct=fullfile(path_series,'transform_field'); |
---|
| 104 | TransformPathList=regexprep(TransformList,'^.+$',path_transform_fct);% set path=path_transform_fct to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string) |
---|
| 105 | |
---|
| 106 | %% load the personal file uvmat_perso.mat |
---|
[2] | 107 | dir_perso=prefdir; |
---|
| 108 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 109 | if exist(profil_perso,'file') |
---|
[591] | 110 | h=load (profil_perso); |
---|
| 111 | %get the list of previous input files in the upper bar menu Open |
---|
| 112 | if isfield(h,'MenuFile') |
---|
| 113 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 114 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 115 | end |
---|
| 116 | end |
---|
| 117 | %get the menu of actions |
---|
| 118 | if isfield(h,'ActionExtListUser') && iscell(h.ActionExtListUser) |
---|
| 119 | ActionExtList=[ActionExtList; h.ActionExtListUser]; |
---|
| 120 | end |
---|
| 121 | if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser) |
---|
| 122 | ActionList=[ActionList;h.ActionListUser]; |
---|
| 123 | ActionPathList=[ActionPathList;h.ActionPathListUser]; |
---|
| 124 | end |
---|
| 125 | %get the menu of transform fct |
---|
| 126 | if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser) |
---|
| 127 | TransformList=[TransformList;h.TransformListUser]; |
---|
| 128 | TransformPathList=[TransformPathList;h.TransformPathListUser]; |
---|
| 129 | end |
---|
[2] | 130 | end |
---|
| 131 | |
---|
[591] | 132 | %% selection of the input Action fct |
---|
| 133 | ActionCheckExist=false(size(ActionList)); |
---|
| 134 | for ilist=1:numel(ActionList) |
---|
| 135 | ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file'); |
---|
[2] | 136 | end |
---|
[591] | 137 | ActionPathList=ActionPathList(ActionCheckExist,:); |
---|
| 138 | ActionList=ActionList(ActionCheckExist); |
---|
| 139 | set(handles.ActionName,'String',[ActionList;{'more...'}]) |
---|
| 140 | set(handles.ActionName,'UserData',ActionPathList) |
---|
| 141 | ActionIndex=[]; |
---|
| 142 | if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat |
---|
| 143 | ActionIndex=find(strcmp(Param.ActionName,ActionList),1); |
---|
[2] | 144 | end |
---|
[591] | 145 | if isempty(ActionIndex) |
---|
| 146 | ActionIndex=1; |
---|
[2] | 147 | end |
---|
[591] | 148 | set(handles.ActionName,'Value',ActionIndex) |
---|
| 149 | set(handles.ActionPath,'String',ActionPathList{ActionIndex}) |
---|
| 150 | set(handles.ActionExt,'Value',1) |
---|
| 151 | set(handles.ActionExt,'String',ActionExtList) |
---|
[2] | 152 | |
---|
[591] | 153 | %% selection of the input transform fct |
---|
| 154 | TransformCheckExist=false(size(TransformList)); |
---|
| 155 | TransformCheckExist(1)=1;%the first option is blank: no transform, always allowed |
---|
| 156 | for ilist=2:numel(TransformList) |
---|
| 157 | TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file'); |
---|
[2] | 158 | end |
---|
[591] | 159 | TransformPathList=TransformPathList(TransformCheckExist); |
---|
| 160 | TransformList=TransformList(TransformCheckExist); |
---|
| 161 | set(handles.TransformName,'String',[TransformList;{'more...'}]) |
---|
| 162 | set(handles.TransformName,'UserData',TransformPathList) |
---|
| 163 | TransformIndex=[]; |
---|
| 164 | if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat |
---|
| 165 | TransformIndex=find(strcmp(Param.TransformName,TransformList),1); |
---|
[526] | 166 | end |
---|
[591] | 167 | if isempty(TransformIndex) |
---|
| 168 | TransformIndex=1; |
---|
[526] | 169 | end |
---|
[591] | 170 | set(handles.TransformName,'Value',TransformIndex) |
---|
| 171 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}) |
---|
| 172 | |
---|
| 173 | %% fields input initialisation |
---|
| 174 | if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields) |
---|
| 175 | set(handles.FieldName,'String',Param.list_fields);% list menu fields |
---|
| 176 | set(handles.FieldName,'Value',Param.index_fields);% selected string index |
---|
[2] | 177 | end |
---|
[591] | 178 | if isfield(Param,'Coord_x_str')&& isfield(Param,'Coord_x_val') |
---|
| 179 | set(handles.Coord_x,'String',Param.Coord_x_str);% list menu fields |
---|
| 180 | set(handles.Coord_x,'Value',Param.Coord_x_val);% selected string index |
---|
[38] | 181 | end |
---|
[591] | 182 | if isfield(Param,'Coord_y_str')&& isfield(Param,'Coord_y_val') |
---|
| 183 | set(handles.Coord_y,'String',Param.Coord_y_str);% list menu fields |
---|
| 184 | set(handles.Coord_y,'Value',Param.Coord_y_val);% selected string index |
---|
[2] | 185 | end |
---|
[39] | 186 | |
---|
[472] | 187 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
[594] | 188 | % path_uvmat=fileparts(which('uvmat')); %path to civ |
---|
| 189 | % addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
| 190 | % errormsg=[];%default error message |
---|
| 191 | % xmlfile='PARAM.xml'; |
---|
| 192 | % if exist(xmlfile,'file') |
---|
| 193 | % try |
---|
| 194 | % t=xmltree(xmlfile); |
---|
| 195 | % sparam=convert(t); |
---|
| 196 | % catch ME |
---|
| 197 | % errormsg={' Unable to read the file PARAM.xml defining the binaries:';ME.message}; |
---|
| 198 | % end |
---|
| 199 | % else |
---|
| 200 | % errormsg=[xmlfile ' not found: path to binaries undefined']; |
---|
| 201 | % end |
---|
| 202 | % if ~isempty(errormsg) |
---|
| 203 | % msgbox_uvmat('WARNING',errormsg); |
---|
| 204 | % end |
---|
| 205 | % test_batch=0;%default: ,no batch mode available |
---|
| 206 | % if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 207 | % test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 208 | % end |
---|
| 209 | % RUNVal=get(handles.RunMode,'Value'); |
---|
| 210 | % if test_batch==0 |
---|
| 211 | % if RUNVal>2 |
---|
| 212 | % set(handles.RunMode,'Value',1) |
---|
| 213 | % end |
---|
| 214 | % set(handles.RunMode,'String',{'local';'background'}) |
---|
| 215 | % else |
---|
| 216 | % set(handles.RunMode,'String',{'local';'background';'cluster'}) |
---|
| 217 | % end |
---|
[2] | 218 | |
---|
[591] | 219 | %% introduce the input file name(s) if defined from input Param |
---|
| 220 | if isfield(Param,'FileName') |
---|
| 221 | InputTable={'','','','',''}; % refresh the file input table |
---|
| 222 | set(handles.InputTable,'Data',InputTable) |
---|
| 223 | if isfield(Param,'FileName_1') |
---|
| 224 | display_file_name(handles,Param.FileName_1,0) |
---|
| 225 | display_file_name(handles,Param.FileName,1) |
---|
| 226 | else |
---|
| 227 | display_file_name(handles,Param.FileName,0) |
---|
| 228 | end |
---|
| 229 | end |
---|
| 230 | if isfield(Param,'incr_i') |
---|
| 231 | set(handles.num_incr_i,'String',num2str(Param.incr_i)) |
---|
| 232 | end |
---|
| 233 | if isfield(Param,'incr_j') |
---|
| 234 | set(handles.num_incr_j,'String',num2str(Param.incr_j)) |
---|
| 235 | end |
---|
| 236 | |
---|
| 237 | |
---|
[408] | 238 | %------------------------------------------------------------------------ |
---|
[2] | 239 | % --- Outputs from this function are returned to the command line. |
---|
| 240 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
[408] | 241 | %------------------------------------------------------------------------ |
---|
[2] | 242 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 243 | % hObject handle to figure |
---|
| 244 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 245 | % handles structure with handles and user data (see GUIDATA) |
---|
| 246 | % Get default command line output from handles structure |
---|
| 247 | varargout{1} = handles.output; |
---|
| 248 | |
---|
[408] | 249 | %------------------------------------------------------------------------ |
---|
| 250 | %------------------------------------------------------------------------ |
---|
| 251 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 252 | % automatically sets the global properties when the rootfile name is introduced |
---|
[446] | 253 | % then activate the view-field actionname if selected |
---|
[408] | 254 | % it is activated either by clicking on the RootPath window or by the |
---|
| 255 | % browser |
---|
| 256 | %------------------------------------------------------------------------ |
---|
| 257 | %------------------------------------------------------------------------ |
---|
[2] | 258 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
[408] | 259 | %------------------------------------------------------------------------ |
---|
[350] | 260 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 261 | if isempty(InputTable) |
---|
| 262 | RootPathCell={}; |
---|
| 263 | else |
---|
| 264 | RootPathCell=InputTable(:,1); |
---|
| 265 | end |
---|
[2] | 266 | oldfile=''; %default |
---|
[329] | 267 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 268 | dir_perso=prefdir; |
---|
| 269 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 270 | if exist(profil_perso,'file') |
---|
| 271 | h=load (profil_perso); |
---|
[329] | 272 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
[2] | 273 | oldfile=h.filebase; |
---|
| 274 | end |
---|
[329] | 275 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
[2] | 276 | oldfile=h.RootPath; |
---|
| 277 | end |
---|
| 278 | end |
---|
[472] | 279 | else |
---|
| 280 | SubDirCell=InputTable(:,2); |
---|
| 281 | RootFileCell=InputTable(:,3); |
---|
[2] | 282 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
| 283 | end |
---|
| 284 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 285 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 286 | '*.xml', '.xml files '; ... |
---|
| 287 | '*.xls', '.xls files '; ... |
---|
| 288 | '*.png','.png image files'; ... |
---|
| 289 | '*.tif','.tif image files'; ... |
---|
| 290 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 291 | '*.nc','.netcdf files'; ... |
---|
| 292 | '*.*', 'All Files (*.*)'}, ... |
---|
| 293 | 'Pick a file',oldfile); |
---|
| 294 | fileinput=[PathName FileName];%complete file name |
---|
[472] | 295 | if isempty(fileinput),return;end %abandon if no file is introduced by the browser |
---|
[2] | 296 | [path,name,ext]=fileparts(fileinput); |
---|
| 297 | if isequal(ext,'.xml') |
---|
[472] | 298 | [Param,Heading]=xml2struct(fileinput); |
---|
| 299 | if ~strcmp(Heading,'Series') |
---|
| 300 | msg_box_uvmat('ERROR','xml file heading is not <Series>') |
---|
| 301 | else |
---|
[591] | 302 | fill_GUI(Param,handles.series);%fill the GUI with the parameters retrieved from the xml file |
---|
[472] | 303 | if isfield(Param,'CheckObject')&& Param.CheckObject |
---|
| 304 | set_object(Param.ProjObject) |
---|
| 305 | end |
---|
| 306 | set(handles.REFRESH,'UserData',[1:size(Param.InputTable,1)]) |
---|
| 307 | REFRESH_Callback([],[], handles) |
---|
| 308 | return |
---|
[463] | 309 | end |
---|
[2] | 310 | elseif isequal(ext,'.xls') |
---|
[408] | 311 | msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 312 | else |
---|
[408] | 313 | display_file_name(handles,fileinput,0) |
---|
[2] | 314 | end |
---|
| 315 | |
---|
| 316 | % -------------------------------------------------------------------- |
---|
| 317 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 318 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[408] | 319 | display_file_name(handles,fileinput,0) |
---|
[2] | 320 | |
---|
| 321 | % -------------------------------------------------------------------- |
---|
| 322 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 323 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[408] | 324 | display_file_name(handles,fileinput,0) |
---|
[2] | 325 | |
---|
| 326 | % -------------------------------------------------------------------- |
---|
| 327 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 328 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[408] | 329 | display_file_name( handles,fileinput,0) |
---|
[2] | 330 | |
---|
| 331 | % -------------------------------------------------------------------- |
---|
| 332 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 333 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[408] | 334 | display_file_name(handles,fileinput,0) |
---|
[2] | 335 | |
---|
| 336 | % -------------------------------------------------------------------- |
---|
| 337 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 338 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[408] | 339 | display_file_name(handles,fileinput,0) |
---|
[2] | 340 | |
---|
| 341 | % -------------------------------------------------------------------- |
---|
| 342 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
[350] | 343 | InputTable=get(handles.InputTable,'Data'); |
---|
| 344 | RootPathCell=InputTable(:,1); |
---|
| 345 | SubDirCell=InputTable(:,3); |
---|
| 346 | RootFileCell=InputTable(:,2); |
---|
[2] | 347 | oldfile=''; %default |
---|
[206] | 348 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 349 | dir_perso=prefdir; |
---|
| 350 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 351 | if exist(profil_perso,'file') |
---|
| 352 | h=load (profil_perso); |
---|
| 353 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 354 | oldfile=h.filebase; |
---|
| 355 | end |
---|
| 356 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 357 | oldfile=h.RootPath; |
---|
| 358 | end |
---|
| 359 | end |
---|
| 360 | else |
---|
| 361 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
| 362 | end |
---|
| 363 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 364 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
| 365 | '*.xml', '.xml files '; ... |
---|
| 366 | '*.xls', '.xls files '; ... |
---|
| 367 | '*.png','.png image files'; ... |
---|
| 368 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 369 | '*.nc','.netcdf files'; ... |
---|
| 370 | '*.*', 'All Files (*.*)'}, ... |
---|
| 371 | 'Pick a file',oldfile); |
---|
| 372 | fileinput=[PathName FileName];%complete file name |
---|
| 373 | sizf=size(fileinput); |
---|
| 374 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 375 | [path,name,ext]=fileparts(fileinput); |
---|
| 376 | if isequal(ext,'.xml') |
---|
[206] | 377 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 378 | elseif isequal(ext,'.xls') |
---|
[206] | 379 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 380 | else |
---|
[472] | 381 | display_file_name(handles,fileinput,'append') |
---|
[2] | 382 | end |
---|
| 383 | |
---|
| 384 | % -------------------------------------------------------------------- |
---|
| 385 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
[408] | 386 | % -------------------------------------------------------------------- |
---|
[2] | 387 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
[472] | 388 | display_file_name(handles,fileinput,'append') |
---|
[2] | 389 | |
---|
| 390 | % -------------------------------------------------------------------- |
---|
| 391 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
[408] | 392 | % -------------------------------------------------------------------- |
---|
[2] | 393 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
[472] | 394 | display_file_name(handles,fileinput,'append') |
---|
[2] | 395 | |
---|
| 396 | % -------------------------------------------------------------------- |
---|
| 397 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
[408] | 398 | % -------------------------------------------------------------------- |
---|
[2] | 399 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
[472] | 400 | display_file_name( handles,fileinput,'append') |
---|
[2] | 401 | |
---|
| 402 | % -------------------------------------------------------------------- |
---|
| 403 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
[408] | 404 | % -------------------------------------------------------------------- |
---|
[2] | 405 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
[472] | 406 | display_file_name( handles,fileinput,'append') |
---|
[2] | 407 | |
---|
| 408 | % -------------------------------------------------------------------- |
---|
| 409 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
[408] | 410 | % -------------------------------------------------------------------- |
---|
[2] | 411 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
[472] | 412 | display_file_name(handles,fileinput,'append') |
---|
[2] | 413 | |
---|
[89] | 414 | %------------------------------------------------------------------------ |
---|
[408] | 415 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
| 416 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
| 417 | %------------------------------------------------------------------------ |
---|
[472] | 418 | set(handles.REFRESH,'Visible','on') |
---|
[408] | 419 | iview=eventdata.Indices(1); |
---|
[472] | 420 | view_set=get(handles.REFRESH,'UserData'); |
---|
| 421 | if isempty(find(view_set==iview)) |
---|
| 422 | set(handles.REFRESH,'UserData',[view_set iview]) |
---|
| 423 | end |
---|
| 424 | %% enable other menus and uicontrols |
---|
| 425 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 426 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 427 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 428 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 429 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 430 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 431 | set(handles.RUN, 'Enable','On') |
---|
| 432 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
| 433 | |
---|
| 434 | %update the output dir |
---|
| 435 | % SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
| 436 | % SubDirOut=SubDir{1}; |
---|
| 437 | % if numel(SubDir)>1 |
---|
| 438 | % for ilist=2:numel(SubDir) |
---|
| 439 | % SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 440 | % end |
---|
| 441 | % end |
---|
| 442 | % set(handles.OutputSubDir,'String',SubDirOut) |
---|
| 443 | |
---|
| 444 | %------------------------------------------------------------------------ |
---|
| 445 | % --- Executes on button press in REFRESH. |
---|
| 446 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
| 447 | %------------------------------------------------------------------------ |
---|
[408] | 448 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 449 | view_set=get(handles.REFRESH,'UserData'); |
---|
| 450 | set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])% set REFRESH button to grey color |
---|
| 451 | drawnow |
---|
| 452 | for iview=view_set |
---|
| 453 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2}); |
---|
| 454 | if ~exist(RootPath,'dir') |
---|
| 455 | i1_series=[]; |
---|
| 456 | RootPath=fileparts(RootPath); %will try the upped forldr |
---|
| 457 | else |
---|
| 458 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=... |
---|
| 459 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
[446] | 460 | end |
---|
[472] | 461 | if isempty(i1_series) |
---|
| 462 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 463 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 464 | '*.xml', '.xml files '; ... |
---|
| 465 | '*.xls', '.xls files '; ... |
---|
| 466 | '*.png','.png image files'; ... |
---|
| 467 | '*.tif','.tif image files'; ... |
---|
| 468 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 469 | '*.nc','.netcdf files'; ... |
---|
| 470 | '*.*', 'All Files (*.*)'}, ... |
---|
| 471 | ['unvalid entry at line ' num2str(iview) ', pick a file'],RootPath); |
---|
| 472 | fileinput=[PathName FileName];%complete file name |
---|
| 473 | if isempty(fileinput),return;end %abandon if the operation has been cancelled: no input from browser |
---|
| 474 | [path,name,ext]=fileparts(fileinput); |
---|
| 475 | display_file_name(handles,fileinput,iview) |
---|
| 476 | else |
---|
| 477 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview) |
---|
| 478 | end |
---|
[446] | 479 | end |
---|
[472] | 480 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to grey color |
---|
| 481 | set(handles.REFRESH,'Visible','off') |
---|
| 482 | set(handles.REFRESH,'UserData',[]) |
---|
[408] | 483 | |
---|
| 484 | %------------------------------------------------------------------------ |
---|
[472] | 485 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser |
---|
| 486 | function display_file_name(handles,fileinput,iview) |
---|
| 487 | %------------------------------------------------------------------------ |
---|
| 488 | % |
---|
[332] | 489 | % INPUT: |
---|
[472] | 490 | % handles: handles of elements in the GUI |
---|
| 491 | % fielinput: input file name, including path |
---|
| 492 | % append =0 (refresh the Input table with the new file), ='append' append a new line in the table |
---|
[332] | 493 | |
---|
[408] | 494 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
| 495 | if ~exist(fileinput,'file') |
---|
| 496 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 497 | return |
---|
| 498 | end |
---|
| 499 | |
---|
[332] | 500 | %% enable other menus and uicontrols |
---|
| 501 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 502 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 503 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 504 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 505 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 506 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 507 | set(handles.RUN, 'Enable','On') |
---|
| 508 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
[350] | 509 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
[332] | 510 | drawnow |
---|
| 511 | |
---|
[408] | 512 | %% detect root name, nomenclature and indices in the input file name: |
---|
| 513 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
| 514 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 515 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 516 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
| 517 | if isempty(RootFile)&&isempty(i1_series) |
---|
| 518 | errormsg='no input file in the series'; |
---|
[29] | 519 | return |
---|
| 520 | end |
---|
[89] | 521 | |
---|
[376] | 522 | %% fill the list of file series |
---|
| 523 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 524 | if strcmp(iview,'append') % display the input data as a new line in the table |
---|
| 525 | iview=size(InputTable,1); |
---|
| 526 | InputTable(iview+1,:)={'','','','',''}; |
---|
| 527 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
| 528 | elseif iview==0 % or re-initialise the list of input file series |
---|
| 529 | iview=1; |
---|
| 530 | InputTable=[{'','','','',''};{'','','','',''}]; |
---|
| 531 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
[376] | 532 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
| 533 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
| 534 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
[408] | 535 | set(handles.ListView,'Value',1) |
---|
| 536 | set(handles.ListView,'String',{'1'}) |
---|
[376] | 537 | end |
---|
[472] | 538 | nbview=size(InputTable,1); |
---|
| 539 | set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1))) |
---|
| 540 | set(handles.ListView,'Value',iview) |
---|
[376] | 541 | set(handles.InputTable,'Data',InputTable) |
---|
| 542 | |
---|
[472] | 543 | %% determine the selected reference field indices for pair display |
---|
| 544 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
| 545 | if ~isempty(i1) |
---|
| 546 | ref_i=i1; |
---|
| 547 | if ~isempty(i2) |
---|
| 548 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
| 549 | end |
---|
| 550 | end |
---|
| 551 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
| 552 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
| 553 | if ~isempty(j1) |
---|
| 554 | ref_j=j1; |
---|
| 555 | if ~isempty(j2) |
---|
| 556 | ref_j=floor((j1+j2)/2); |
---|
| 557 | end |
---|
| 558 | end |
---|
| 559 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
| 560 | |
---|
| 561 | %% update the list of recent files in the menubar and save it for future opening |
---|
| 562 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 563 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 564 | str_find=strcmp(fileinput,MenuFile); |
---|
| 565 | if isempty(find(str_find,1)) |
---|
| 566 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
| 567 | end |
---|
| 568 | for ifile=1:min(length(MenuFile),5) |
---|
| 569 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 570 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 571 | end |
---|
| 572 | dir_perso=prefdir; |
---|
| 573 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 574 | if exist(profil_perso,'file') |
---|
| 575 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 576 | else |
---|
| 577 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
| 578 | end |
---|
| 579 | |
---|
| 580 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
| 581 | |
---|
| 582 | %% initiate input file series and refresh the current field view: |
---|
| 583 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview); |
---|
| 584 | |
---|
| 585 | %------------------------------------------------------------------------ |
---|
| 586 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 587 | % calibration from an xml file |
---|
| 588 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
| 589 | %------------------------------------------------------------------------ |
---|
| 590 | %% update the output dir |
---|
| 591 | InputTable=get(handles.InputTable,'Data'); |
---|
| 592 | SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order |
---|
| 593 | SubDirOut=SubDir{1}; |
---|
| 594 | if numel(SubDir)>1 |
---|
| 595 | for ilist=2:numel(SubDir) |
---|
| 596 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 597 | end |
---|
| 598 | end |
---|
| 599 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
| 600 | |
---|
[521] | 601 | %% display the min and max indices for the file series |
---|
[554] | 602 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 |
---|
[526] | 603 | MinIndex_j=1; |
---|
[554] | 604 | MaxIndex_j=1; |
---|
| 605 | MinIndex_i=find(i1_series(:,2,:), 1 )-1; |
---|
| 606 | MaxIndex_i=find(i1_series(:,2,:), 1, 'last' )-1; |
---|
[526] | 607 | else |
---|
[554] | 608 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
| 609 | j_max=max(pair_max,[],1); |
---|
| 610 | %i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index |
---|
| 611 | MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i |
---|
| 612 | MinIndex_i=find(j_max, 1 )-1;% min ref index i |
---|
| 613 | diff_i_max=diff(j_max); |
---|
[526] | 614 | if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) |
---|
| 615 | set(handles.num_incr_i,'String',num2str(diff_i_max(1))) |
---|
| 616 | end |
---|
[554] | 617 | i_max=max(pair_max,[],2); |
---|
| 618 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
| 619 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
| 620 | diff_j_max=diff(i_max); |
---|
[526] | 621 | if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) |
---|
| 622 | set(handles.num_incr_j,'String',num2str(diff_j_max(1))) |
---|
| 623 | end |
---|
| 624 | end |
---|
[460] | 625 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
| 626 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
[554] | 627 | if isequal(MinIndex_i,-1) |
---|
| 628 | MinIndex_i=0; |
---|
| 629 | end |
---|
| 630 | if isequal(MinIndex_j,-1) |
---|
| 631 | MinIndex_j=0; |
---|
| 632 | end |
---|
[472] | 633 | MinIndex{iview,1}=MinIndex_i; |
---|
| 634 | MinIndex{iview,2}=MinIndex_j; |
---|
| 635 | MaxIndex{iview,1}=MaxIndex_i; |
---|
| 636 | MaxIndex{iview,2}=MaxIndex_j; |
---|
[460] | 637 | |
---|
| 638 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
| 639 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
| 640 | |
---|
| 641 | %% adjust the first and last indices if requested by the bounds |
---|
| 642 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 643 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 644 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 645 | if isempty(first_i) |
---|
| 646 | first_i=ref_i; |
---|
| 647 | elseif first_i < MinIndex_i |
---|
| 648 | first_i=MinIndex_i; |
---|
[526] | 649 | elseif first_i >MaxIndex_i |
---|
| 650 | first_i=MinIndex_i; |
---|
[460] | 651 | end |
---|
| 652 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 653 | if isempty(first_j) |
---|
| 654 | first_j=ref_j; |
---|
| 655 | elseif first_j<MinIndex_j |
---|
| 656 | first_j=MinIndex_j; |
---|
[526] | 657 | elseif first_j >MaxIndex_j |
---|
| 658 | first_j=MinIndex_j; |
---|
[460] | 659 | end |
---|
| 660 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 661 | if isempty(last_i) |
---|
| 662 | last_i=ref_i; |
---|
| 663 | elseif last_i > MaxIndex_i |
---|
| 664 | last_i=MaxIndex_i; |
---|
[526] | 665 | elseif last_i<first_i |
---|
| 666 | last_i=first_i; |
---|
[460] | 667 | end |
---|
| 668 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
| 669 | if isempty(last_j) |
---|
| 670 | last_j=ref_j; |
---|
| 671 | elseif last_j>MaxIndex_j |
---|
| 672 | last_j=MaxIndex_j; |
---|
[526] | 673 | elseif last_i<first_i |
---|
| 674 | last_i=first_i; |
---|
[460] | 675 | end |
---|
| 676 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
| 677 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
| 678 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
| 679 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
| 680 | |
---|
[526] | 681 | %% read timing and total frame number from the current file (movie files) may be overrid by xml file |
---|
[408] | 682 | InputTable=get(handles.InputTable,'Data'); |
---|
| 683 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
| 684 | time=[];%default |
---|
| 685 | % case of movies |
---|
| 686 | if strcmp(InputTable{iview,4},'*') |
---|
| 687 | if ~isempty(VideoObject) |
---|
| 688 | imainfo=get(VideoObject); |
---|
| 689 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
[526] | 690 | % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
[408] | 691 | ColorType='truecolor'; |
---|
| 692 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
| 693 | if ~isempty(InputTable{iview,2}) |
---|
| 694 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
| 695 | else |
---|
| 696 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
| 697 | end |
---|
| 698 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 699 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 700 | nbfield=length(imainfo); |
---|
| 701 | nbfield_j=1; |
---|
| 702 | end |
---|
| 703 | end |
---|
| 704 | end |
---|
| 705 | |
---|
| 706 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 707 | XmlData=[]; |
---|
| 708 | NbSlice_calib={}; |
---|
[525] | 709 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); |
---|
| 710 | if ~isempty(XmlFileName) |
---|
| 711 | [XmlData,warntext]=imadoc2struct(XmlFileName); |
---|
[408] | 712 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
| 713 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 714 | end |
---|
| 715 | if isfield(XmlData,'Time') |
---|
| 716 | time=XmlData.Time; |
---|
| 717 | end |
---|
| 718 | if isfield(XmlData,'Camera') |
---|
| 719 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 720 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 721 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 722 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 723 | end |
---|
| 724 | end |
---|
| 725 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 726 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 727 | end |
---|
| 728 | end |
---|
| 729 | if ~isempty(warntext) |
---|
| 730 | msgbox_uvmat('WARNING',warntext) |
---|
| 731 | end |
---|
| 732 | end |
---|
| 733 | |
---|
| 734 | %% update time table |
---|
[456] | 735 | if ~isempty(time) |
---|
[523] | 736 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 737 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 738 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 739 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 740 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 741 | MinIndexTable=get(handles.MinIndex,'Data'); |
---|
| 742 | MinIndex_i=MinIndexTable{iview,1}; |
---|
| 743 | MinIndex_j=MinIndexTable{iview,2}; |
---|
| 744 | MaxIndexTable=get(handles.MaxIndex,'Data'); |
---|
| 745 | MaxIndex_i=MaxIndexTable{iview,1}; |
---|
| 746 | MaxIndex_j=MaxIndexTable{iview,2}; |
---|
[553] | 747 | if isempty(MinIndex_j)% only i index |
---|
[523] | 748 | if MinIndex_i>0 |
---|
| 749 | TimeTable{iview,1}=time(MinIndex_i); |
---|
| 750 | end |
---|
| 751 | TimeTable{iview,2}=time(first_i); |
---|
| 752 | TimeTable{iview,3}=time(last_i); |
---|
| 753 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
| 754 | elseif ~isempty(time) |
---|
| 755 | if MinIndex_i>0 |
---|
| 756 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
| 757 | end |
---|
[554] | 758 | if size(time)>=[last_i last_j] |
---|
| 759 | TimeTable{iview,2}=time(first_i,first_j); |
---|
| 760 | TimeTable{iview,3}=time(last_i,last_j); |
---|
| 761 | end |
---|
[553] | 762 | if size(time)>=[MaxIndex_i MaxIndex_j]; |
---|
[554] | 763 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
[553] | 764 | end |
---|
[456] | 765 | end |
---|
[523] | 766 | set(handles.TimeTable,'Data',TimeTable) |
---|
[408] | 767 | end |
---|
| 768 | |
---|
| 769 | %% number of slices |
---|
[460] | 770 | NbSlice=1;%default |
---|
[408] | 771 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 772 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 773 | if siz(1)>1 |
---|
| 774 | NbSlice=siz(1); |
---|
| 775 | end |
---|
| 776 | end |
---|
[450] | 777 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 778 | |
---|
[408] | 779 | %% update pair menus |
---|
[441] | 780 | set(handles.Pairs,'Visible','on') |
---|
| 781 | set(handles.PairString,'Visible','on') |
---|
[408] | 782 | ListView=get(handles.ListView,'String'); |
---|
| 783 | ListView{iview}=num2str(iview); |
---|
[472] | 784 | set(handles.ListView,'String',ListView); |
---|
[408] | 785 | set(handles.ListView,'Value',iview) |
---|
| 786 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 787 | |
---|
[472] | 788 | %% update the series info in 'UserData' |
---|
[408] | 789 | SeriesData=get(handles.series,'UserData'); |
---|
| 790 | SeriesData.i1_series{iview}=i1_series; |
---|
| 791 | SeriesData.i2_series{iview}=i2_series; |
---|
| 792 | SeriesData.j1_series{iview}=j1_series; |
---|
| 793 | SeriesData.j2_series{iview}=j2_series; |
---|
| 794 | SeriesData.FileType{iview}=FileType; |
---|
| 795 | SeriesData.Time{iview}=time; |
---|
| 796 | set(handles.series,'UserData',SeriesData) |
---|
| 797 | |
---|
[521] | 798 | %% enable j index visibilitycellfun(@isempty,regexp(PairString,'^j')) |
---|
[553] | 799 | % state='off'; |
---|
[472] | 800 | check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices |
---|
| 801 | if isempty(find(check_jindex)) |
---|
| 802 | enable_j(handles,'off') % no j index needed |
---|
| 803 | else |
---|
[521] | 804 | PairString=get(handles.PairString,'Data'); |
---|
| 805 | if isempty(find(cellfun(@isempty,regexp(PairString,'^j'))))% if all pair string begins by j (burst) |
---|
| 806 | enable_j(handles,'off') % no j index needed |
---|
| 807 | else |
---|
| 808 | enable_j(handles,'on') |
---|
| 809 | end |
---|
[472] | 810 | end |
---|
| 811 | |
---|
[477] | 812 | %% display the set of existing files as an image |
---|
| 813 | set(handles.FileStatus,'Units','pixels') |
---|
| 814 | Position=get(handles.FileStatus,'Position'); |
---|
| 815 | set(handles.FileStatus,'Units','normalized') |
---|
| 816 | xI=0.5:Position(3)-0.5; |
---|
| 817 | nbview=numel(SeriesData.i1_series); |
---|
[523] | 818 | pair_max=cell(1,nbview); |
---|
[477] | 819 | for iview=1:nbview |
---|
[523] | 820 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
[526] | 821 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
[525] | 822 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
| 823 | end |
---|
[523] | 824 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
| 825 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
[477] | 826 | end |
---|
| 827 | index_min=min(index_min); |
---|
| 828 | index_max=max(index_max); |
---|
| 829 | range_index=index_max-index_min+1; |
---|
| 830 | scale_y=Position(4)/nbview; |
---|
| 831 | scale_x=Position(3)/range_index; |
---|
| 832 | x=(0.5:range_index-0.5)*Position(3)/range_index; |
---|
| 833 | % y=(0.5:nbview-0.5)*Position(4)/nbview; |
---|
| 834 | range_y=max(1,floor(Position(4)/nbview)); |
---|
| 835 | CData=zeros(nbview*range_y,Position(3)); |
---|
| 836 | for iview=1:nbview |
---|
| 837 | ind_y=1+(iview-1)*range_y:iview*range_y; |
---|
| 838 | LineData=zeros(1,range_index); |
---|
[523] | 839 | x_index=find(pair_max{iview}>0)-index_min+1; |
---|
[477] | 840 | LineData(x_index)=1; |
---|
[591] | 841 | if numel(x)>1 |
---|
[477] | 842 | LineData=interp1(x,LineData,xI,'nearest'); |
---|
| 843 | CData(ind_y,:)=ones(size(ind_y'))*LineData; |
---|
[591] | 844 | end |
---|
[477] | 845 | end |
---|
| 846 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); |
---|
| 847 | set(handles.FileStatus,'CData',CData); |
---|
| 848 | |
---|
| 849 | |
---|
[472] | 850 | %% enable field and veltype menus, in accordance with the current action |
---|
| 851 | ActionName_Callback([],[], handles) |
---|
| 852 | |
---|
[441] | 853 | %% check for pair display |
---|
| 854 | check_pairs=0; |
---|
| 855 | for iview=1:numel(SeriesData.i2_series) |
---|
| 856 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
| 857 | check_pairs=1; |
---|
| 858 | end |
---|
| 859 | end |
---|
| 860 | if check_pairs |
---|
| 861 | set(handles.Pairs,'Visible','on') |
---|
| 862 | set(handles.PairString,'Visible','on') |
---|
| 863 | else |
---|
| 864 | set(handles.Pairs,'Visible','off') |
---|
| 865 | set(handles.PairString,'Visible','off') |
---|
| 866 | end |
---|
[408] | 867 | |
---|
[477] | 868 | %% set length of waitbar |
---|
| 869 | displ_time(handles) |
---|
| 870 | |
---|
| 871 | |
---|
[525] | 872 | %% set default options in menu 'Fields' |
---|
| 873 | switch FileType |
---|
| 874 | case {'civx','civdata'} |
---|
[596] | 875 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
[525] | 876 | set(handles.FieldName,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 877 | set(handles.FieldName,'Value',2) % set menu to 'velocity |
---|
| 878 | set(handles.Coord_x,'Value',1); |
---|
| 879 | set(handles.Coord_x,'String',{'X'}); |
---|
| 880 | set(handles.Coord_y,'Value',1); |
---|
| 881 | set(handles.Coord_y,'String',{'Y'}); |
---|
| 882 | case 'netcdf' |
---|
[526] | 883 | set(handles.FieldName,'Value',1) |
---|
| 884 | set(handles.FieldName,'String',{'get_field...'}) |
---|
| 885 | if isempty(i2_series) |
---|
| 886 | i2=[]; |
---|
| 887 | else |
---|
| 888 | i2=i2_series(1,ref_j+1,ref_i+1); |
---|
| 889 | end |
---|
| 890 | if isempty(j1_series) |
---|
| 891 | j1=[];j2=[]; |
---|
| 892 | else |
---|
| 893 | j1=j1_series(1,ref_j+1,ref_i+1); |
---|
| 894 | if isempty(j2_series) |
---|
| 895 | j2=[]; |
---|
| 896 | else |
---|
| 897 | j2=j2_series(1,ref_j+1,ref_i+1); |
---|
| 898 | end |
---|
| 899 | end |
---|
| 900 | 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] | 901 | % hget_field=get_field(FileName); |
---|
| 902 | % hhget_field=guidata(hget_field); |
---|
| 903 | % get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
[525] | 904 | otherwise |
---|
[526] | 905 | set(handles.FieldName,'Value',1) % set menu to 'image' |
---|
| 906 | set(handles.FieldName,'String',{'image'}) |
---|
[525] | 907 | set(handles.Coord_x,'Value',1); |
---|
| 908 | set(handles.Coord_x,'String',{'AX'}); |
---|
| 909 | set(handles.Coord_y,'Value',1); |
---|
| 910 | set(handles.Coord_y,'String',{'AY'}); |
---|
| 911 | end |
---|
[408] | 912 | |
---|
[446] | 913 | %------------------------------------------------------------------------ |
---|
| 914 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
| 915 | %------------------------------------------------------------------------ |
---|
| 916 | num_last_i_Callback(hObject, eventdata, handles) |
---|
[408] | 917 | |
---|
| 918 | %------------------------------------------------------------------------ |
---|
[446] | 919 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
| 920 | %------------------------------------------------------------------------ |
---|
| 921 | SeriesData=get(handles.series,'UserData'); |
---|
| 922 | if ~isfield(SeriesData,'Time') |
---|
| 923 | SeriesData.Time{1}=[]; |
---|
| 924 | end |
---|
| 925 | displ_time(handles); |
---|
| 926 | |
---|
| 927 | %------------------------------------------------------------------------ |
---|
| 928 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
| 929 | %------------------------------------------------------------------------ |
---|
| 930 | num_last_j_Callback(hObject, eventdata, handles) |
---|
| 931 | |
---|
| 932 | %------------------------------------------------------------------------ |
---|
| 933 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
| 934 | %------------------------------------------------------------------------ |
---|
| 935 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 936 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 937 | ref_j=ceil((first_j+last_j)/2); |
---|
| 938 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
| 939 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 940 | SeriesData=get(handles.series,'UserData'); |
---|
| 941 | if ~isfield(SeriesData,'Time') |
---|
| 942 | SeriesData.Time{1}=[]; |
---|
| 943 | end |
---|
| 944 | displ_time(handles); |
---|
| 945 | |
---|
[477] | 946 | |
---|
[446] | 947 | %------------------------------------------------------------------------ |
---|
| 948 | % ---- find the times corresponding to the first and last indices of a series |
---|
| 949 | function displ_time(handles) |
---|
| 950 | %------------------------------------------------------------------------ |
---|
| 951 | SeriesData=get(handles.series,'UserData');% |
---|
| 952 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
| 953 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
| 954 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 955 | Pairs=get(handles.PairString,'Data'); |
---|
| 956 | for iview=1:size(TimeTable,1) |
---|
| 957 | if size(SeriesData.Time,1)<iview |
---|
| 958 | break |
---|
| 959 | end |
---|
| 960 | i1=ref_i; |
---|
| 961 | j1=ref_j; |
---|
| 962 | i2=ref_i; |
---|
| 963 | j2=ref_j; |
---|
| 964 | % case of pairs |
---|
| 965 | if ~isempty(Pairs{iview,1}) |
---|
| 966 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 967 | if isempty(r) |
---|
| 968 | r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 969 | end |
---|
| 970 | switch r.mode |
---|
| 971 | case 'Di=' % case 'series(Di)') |
---|
| 972 | i1=ref_i-str2num(r.num1); |
---|
| 973 | i2=ref_i+str2num(r.num2); |
---|
| 974 | case 'Dj=' % case 'series(Dj)' |
---|
| 975 | j1=ref_j-str2num(r.num1); |
---|
| 976 | j2=ref_j+str2num(r.num2); |
---|
| 977 | case '-' % case 'bursts' |
---|
| 978 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
| 979 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
| 980 | end |
---|
| 981 | end |
---|
| 982 | TimeTable{iview,2}=[]; |
---|
| 983 | TimeTable{iview,3}=[]; |
---|
| 984 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
| 985 | if isempty(ref_j) |
---|
| 986 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
| 987 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
| 988 | else |
---|
| 989 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
| 990 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
| 991 | end |
---|
| 992 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
| 993 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
| 994 | end |
---|
| 995 | end |
---|
| 996 | set(handles.TimeTable,'Data',TimeTable) |
---|
| 997 | |
---|
[477] | 998 | %% set the waitbar position with respect to the min and max in the series |
---|
| 999 | for iview=1:numel(SeriesData.i1_series) |
---|
[526] | 1000 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
| 1001 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
| 1002 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
| 1003 | end |
---|
| 1004 | pair_max{iview}=reshape(pair_max{iview},1,[]); |
---|
| 1005 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
| 1006 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
[477] | 1007 | end |
---|
| 1008 | [index_min,iview_min]=min(index_min); |
---|
| 1009 | [index_max,iview_max]=min(index_max); |
---|
[526] | 1010 | if size(SeriesData.i1_series{iview_min},2)==1% movie |
---|
[533] | 1011 | index_first=ref_i(1); |
---|
| 1012 | index_last=ref_i(2); |
---|
[526] | 1013 | else |
---|
[533] | 1014 | index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; |
---|
| 1015 | index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; |
---|
[526] | 1016 | end |
---|
[477] | 1017 | range=index_max-index_min+1; |
---|
| 1018 | coeff_min=(index_first-index_min)/range; |
---|
| 1019 | coeff_max=(index_last-index_min+1)/range; |
---|
[533] | 1020 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] |
---|
[477] | 1021 | Position_status=get(handles.FileStatus,'Position'); |
---|
| 1022 | Position(1)=coeff_min*Position_status(3)+Position_status(1); |
---|
| 1023 | Position(3)=Position_status(3)*(coeff_max-coeff_min); |
---|
| 1024 | set(handles.Waitbar,'Position',Position) |
---|
| 1025 | update_waitbar(handles.Waitbar,0) |
---|
| 1026 | |
---|
[446] | 1027 | %------------------------------------------------------------------------ |
---|
[408] | 1028 | % --- Executes when selected cell(s) is changed in PairString. |
---|
| 1029 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
| 1030 | %------------------------------------------------------------------------ |
---|
| 1031 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
| 1032 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
| 1033 | |
---|
| 1034 | %------------------------------------------------------------------------ |
---|
| 1035 | %------------------------------------------------------------------------ |
---|
| 1036 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
| 1037 | %------------------------------------------------------------------------ |
---|
| 1038 | %------------------------------------------------------------------------ |
---|
| 1039 | % --- Executes on selection change in ListView. |
---|
| 1040 | function ListView_Callback(hObject, eventdata, handles) |
---|
| 1041 | %------------------------------------------------------------------------ |
---|
| 1042 | SeriesData=get(handles.series,'UserData'); |
---|
| 1043 | i2_series=[]; |
---|
| 1044 | j2_series=[]; |
---|
| 1045 | iview=get(handles.ListView,'Value'); |
---|
| 1046 | if ~isempty(SeriesData.i2_series{iview}) |
---|
| 1047 | i2_series=SeriesData.i2_series{iview}; |
---|
| 1048 | end |
---|
| 1049 | if ~isempty(SeriesData.j2_series{iview}) |
---|
| 1050 | j2_series=SeriesData.j2_series{iview}; |
---|
| 1051 | end |
---|
| 1052 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1053 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1054 | |
---|
| 1055 | %------------------------------------------------------------------------ |
---|
[2] | 1056 | % --- Executes on button press in mode. |
---|
[376] | 1057 | function mode_Callback(hObject, eventdata, handles) |
---|
[408] | 1058 | %------------------------------------------------------------------------ |
---|
[376] | 1059 | SeriesData=get(handles.series,'UserData'); |
---|
[408] | 1060 | iview=get(handles.ListView,'Value'); |
---|
[376] | 1061 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1062 | mode=mode_list{get(handles.mode,'Value')}; |
---|
[376] | 1063 | if isequal(mode,'bursts') |
---|
| 1064 | enable_i(handles,'On') |
---|
| 1065 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1066 | else |
---|
| 1067 | enable_i(handles,'On') |
---|
| 1068 | enable_j(handles,'Off') |
---|
| 1069 | end |
---|
[408] | 1070 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1071 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1072 | ListPairs_Callback([],[],handles) |
---|
[339] | 1073 | |
---|
[408] | 1074 | %------------------------------------------------------------- |
---|
| 1075 | % --- Executes on selection in ListPairs. |
---|
| 1076 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
| 1077 | %------------------------------------------------------------ |
---|
| 1078 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
[441] | 1079 | if isempty(list_pair) |
---|
| 1080 | string=''; |
---|
| 1081 | else |
---|
| 1082 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
| 1083 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
| 1084 | end |
---|
[408] | 1085 | PairString=get(handles.PairString,'Data'); |
---|
| 1086 | iview=get(handles.ListView,'Value'); |
---|
| 1087 | PairString{iview,1}=string; |
---|
| 1088 | % report the selected pair string to the table PairString |
---|
| 1089 | set(handles.PairString,'Data',PairString) |
---|
[2] | 1090 | |
---|
[408] | 1091 | %------------------------------------------------------------------------ |
---|
| 1092 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
| 1093 | %------------------------------------------------------------------------ |
---|
| 1094 | mode_list=get(handles.mode,'String'); |
---|
| 1095 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1096 | SeriesData=get(handles.series,'UserData'); |
---|
| 1097 | iview=get(handles.ListView,'Value'); |
---|
| 1098 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
[446] | 1099 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
[408] | 1100 | ListPairs_Callback([],[],handles) |
---|
[2] | 1101 | |
---|
[408] | 1102 | %------------------------------------------------------------------------ |
---|
| 1103 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 1104 | %------------------------------------------------------------------------ |
---|
| 1105 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
[2] | 1106 | |
---|
[408] | 1107 | %------------------------------------------------------------------------ |
---|
| 1108 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1109 | %------------------------------------------------------------------------ |
---|
[521] | 1110 | % check_burst=0; |
---|
| 1111 | if isempty(j2_series)% no j pair |
---|
[408] | 1112 | if isempty(i2_series) |
---|
| 1113 | set(handles.mode,'Value',1) |
---|
[521] | 1114 | set(handles.mode,'String',{''})% no pair menu to display |
---|
| 1115 | else |
---|
| 1116 | set(handles.mode,'Value',1) |
---|
| 1117 | set(handles.mode,'String',{'series(Di)'}) % pair menu with only option Di |
---|
[408] | 1118 | end |
---|
[521] | 1119 | else %existence of j pairs |
---|
| 1120 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
| 1121 | j_max=max(pair_max,[],1); |
---|
| 1122 | MaxIndex_i=max(find(j_max))-1;% max ref index i |
---|
| 1123 | MinIndex_i=min(find(j_max))-1;% min ref index i |
---|
| 1124 | i_max=max(pair_max,[],2); |
---|
| 1125 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
| 1126 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
| 1127 | if MaxIndex_j==MinIndex_j |
---|
[408] | 1128 | set(handles.mode,'Value',1); |
---|
[521] | 1129 | set(handles.mode,'String',{'bursts'}) |
---|
| 1130 | % check_burst=1; |
---|
| 1131 | elseif MaxIndex_i==MinIndex_i |
---|
| 1132 | set(handles.mode,'Value',1); |
---|
| 1133 | set(handles.mode,'String',{'series(Dj)'}) |
---|
[456] | 1134 | else |
---|
[521] | 1135 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
| 1136 | if (MaxIndex_j-MinIndex_j)>10 |
---|
| 1137 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
| 1138 | else |
---|
| 1139 | set(handles.mode,'Value',1); |
---|
| 1140 | % check_burst=1; |
---|
| 1141 | end |
---|
[456] | 1142 | end |
---|
[408] | 1143 | end |
---|
[521] | 1144 | % if check_burst |
---|
| 1145 | % enable_i(handles,'On') |
---|
| 1146 | % enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1147 | % else |
---|
| 1148 | % enable_i(handles,'On') |
---|
| 1149 | % if isempty(j1_series) |
---|
| 1150 | % enable_j(handles,'Off') |
---|
| 1151 | % else |
---|
| 1152 | % enable_j(handles,'On') |
---|
| 1153 | % end |
---|
| 1154 | % end |
---|
[408] | 1155 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1156 | ListPairs_Callback([],[],handles) |
---|
[2] | 1157 | |
---|
| 1158 | %-------------------------------------------------------------- |
---|
[408] | 1159 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
| 1160 | % with the reference indices num_ref_i and num_ref_j |
---|
[2] | 1161 | %---------------------------------------------------------------- |
---|
[408] | 1162 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1163 | |
---|
[2] | 1164 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1165 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1166 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 1167 | if isempty(ref_i) |
---|
| 1168 | ref_i=1; |
---|
| 1169 | end |
---|
[472] | 1170 | if strcmp(get(handles.num_ref_j,'Visible'),'on') |
---|
| 1171 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 1172 | if isempty(ref_j) |
---|
| 1173 | ref_j=1; |
---|
| 1174 | end |
---|
| 1175 | else |
---|
[408] | 1176 | ref_j=1; |
---|
| 1177 | end |
---|
[2] | 1178 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1179 | if length(TimeUnit)>=1 |
---|
| 1180 | dtunit=['m' TimeUnit]; |
---|
| 1181 | else |
---|
| 1182 | dtunit='e-03'; |
---|
| 1183 | end |
---|
[339] | 1184 | |
---|
| 1185 | displ_pair={}; |
---|
[118] | 1186 | if strcmp(mode,'series(Di)') |
---|
[339] | 1187 | if isempty(i2_series) |
---|
| 1188 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
| 1189 | return |
---|
| 1190 | end |
---|
| 1191 | diff_i=i2_series-i1_series; |
---|
| 1192 | min_diff=min(diff_i(diff_i>0)); |
---|
| 1193 | max_diff=max(diff_i(diff_i>0)); |
---|
| 1194 | for ipair=min_diff:max_diff |
---|
| 1195 | if numel(diff_i(diff_i==ipair))>0 |
---|
[408] | 1196 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1197 | if ~isempty(time) |
---|
[472] | 1198 | if ref_i<=floor(ipair/2) |
---|
| 1199 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
| 1200 | end |
---|
[408] | 1201 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
| 1202 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1203 | end |
---|
| 1204 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1205 | end |
---|
| 1206 | end |
---|
| 1207 | if ~isempty(displ_pair) |
---|
| 1208 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
| 1209 | end |
---|
| 1210 | elseif strcmp(mode,'series(Dj)') |
---|
| 1211 | if isempty(j2_series) |
---|
| 1212 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1213 | return |
---|
| 1214 | end |
---|
| 1215 | diff_j=j2_series-j1_series; |
---|
| 1216 | min_diff=min(diff_j(diff_j>0)); |
---|
| 1217 | max_diff=max(diff_j(diff_j>0)); |
---|
| 1218 | for ipair=min_diff:max_diff |
---|
| 1219 | if numel(diff_j(diff_j==ipair))>0 |
---|
[408] | 1220 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1221 | if ~isempty(time) |
---|
[472] | 1222 | if ref_j<=floor(ipair/2) |
---|
| 1223 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
| 1224 | end |
---|
[408] | 1225 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
| 1226 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1227 | end |
---|
| 1228 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1229 | end |
---|
| 1230 | end |
---|
| 1231 | if ~isempty(displ_pair) |
---|
| 1232 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
| 1233 | end |
---|
| 1234 | elseif strcmp(mode,'bursts') |
---|
| 1235 | if isempty(j2_series) |
---|
| 1236 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1237 | return |
---|
| 1238 | end |
---|
| 1239 | diff_j=j2_series-j1_series; |
---|
| 1240 | min_j1=min(j1_series(j1_series>0)); |
---|
| 1241 | max_j1=max(j1_series(j1_series>0)); |
---|
| 1242 | min_j2=min(j2_series(j2_series>0)); |
---|
| 1243 | max_j2=max(j2_series(j2_series>0)); |
---|
| 1244 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
| 1245 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
| 1246 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
| 1247 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
| 1248 | end |
---|
| 1249 | end |
---|
| 1250 | end |
---|
| 1251 | if ~isempty(displ_pair) |
---|
| 1252 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
| 1253 | end |
---|
| 1254 | end |
---|
[472] | 1255 | set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j |
---|
| 1256 | set(handles.num_ref_j,'String',num2str(ref_j)) |
---|
[408] | 1257 | |
---|
| 1258 | %% display list of pairstring |
---|
| 1259 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
[339] | 1260 | NewVal=[]; |
---|
| 1261 | if ~isempty(displ_pair_list) |
---|
[408] | 1262 | Val=get(handles.ListPairs,'Value'); |
---|
[419] | 1263 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pï¿œir |
---|
[339] | 1264 | end |
---|
| 1265 | if ~isempty(NewVal) |
---|
[408] | 1266 | set(handles.ListPairs,'Value',NewVal) |
---|
[339] | 1267 | else |
---|
[408] | 1268 | set(handles.ListPairs,'Value',1) |
---|
[339] | 1269 | end |
---|
[408] | 1270 | set(handles.ListPairs,'String',displ_pair) |
---|
[339] | 1271 | |
---|
[408] | 1272 | %------------------------------------- |
---|
| 1273 | function enable_i(handles,state) |
---|
| 1274 | set(handles.i_txt,'Visible',state) |
---|
| 1275 | set(handles.num_first_i,'Visible',state) |
---|
| 1276 | set(handles.num_last_i,'Visible',state) |
---|
| 1277 | set(handles.num_incr_i,'Visible',state) |
---|
| 1278 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
| 1279 | set(handles.num_ref_i,'Visible',state) |
---|
| 1280 | set(handles.ref_i_text,'Visible',state) |
---|
[2] | 1281 | |
---|
[408] | 1282 | %----------------------------------- |
---|
| 1283 | function enable_j(handles,state) |
---|
| 1284 | set(handles.j_txt,'Visible',state) |
---|
| 1285 | set(handles.num_first_j,'Visible',state) |
---|
| 1286 | set(handles.num_last_j,'Visible',state) |
---|
| 1287 | set(handles.num_incr_j,'Visible',state) |
---|
| 1288 | set(handles.num_ref_j,'Visible',state) |
---|
| 1289 | set(handles.ref_j_text,'Visible',state) |
---|
[526] | 1290 | % if strcmp(state,'off') |
---|
| 1291 | % set(handles.MinIndex,'ColumnName',{'imax'}) |
---|
| 1292 | % set(handles.MinIndex,'ColumnEditable',logical(0)) |
---|
| 1293 | % else |
---|
| 1294 | % set(handles.MinIndex,'ColumnName',{'imax','jmax'}) |
---|
| 1295 | % end |
---|
[41] | 1296 | |
---|
[408] | 1297 | |
---|
[446] | 1298 | %%%%%%%%%%%%%%%%%%%% |
---|
| 1299 | %% MAIN ActionName FUNCTIONS |
---|
| 1300 | %%%%%%%%%%%%%%%%%%%% |
---|
[41] | 1301 | %------------------------------------------------------------------------ |
---|
[2] | 1302 | % --- Executes on button press in RUN. |
---|
| 1303 | function RUN_Callback(hObject, eventdata, handles) |
---|
[41] | 1304 | %------------------------------------------------------------------------ |
---|
[595] | 1305 | |
---|
[2] | 1306 | set(handles.RUN,'BusyAction','queue'); |
---|
[332] | 1307 | set(0,'CurrentFigure',handles.series) |
---|
[446] | 1308 | set(handles.RUN, 'Enable','Off') |
---|
| 1309 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[456] | 1310 | drawnow |
---|
[595] | 1311 | |
---|
| 1312 | %% read the input parameters and set the output dir and nomenclature |
---|
| 1313 | [Series,OutputDir,errormsg]=prepare_jobs(handles);% get parameters form the GUI series |
---|
[446] | 1314 | if ~isempty(errormsg) |
---|
| 1315 | msgbox_uvmat('ERROR',errormsg) |
---|
[472] | 1316 | return |
---|
[2] | 1317 | end |
---|
[595] | 1318 | OutputNomType=nomtype2pair(Series.InputTable{1,4});% nomenclature for output files |
---|
| 1319 | DirXml=fullfile(OutputDir,'0_XML'); |
---|
| 1320 | if ~exist(DirXml,'dir') |
---|
| 1321 | [tild,msg1]=mkdir(DirXml); |
---|
| 1322 | if ~strcmp(msg1,'') |
---|
| 1323 | msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation |
---|
| 1324 | return |
---|
| 1325 | end |
---|
| 1326 | end |
---|
| 1327 | |
---|
| 1328 | %% select the Action modes |
---|
[472] | 1329 | RunModeList=get(handles.RunMode,'String'); |
---|
| 1330 | RunMode=RunModeList{get(handles.RunMode,'Value')}; |
---|
[595] | 1331 | ActionExt='.m';%default |
---|
| 1332 | if isfield(Series.Action,'ActionExt') |
---|
| 1333 | ActionExt=Series.Action.ActionExt;% '.m' or '.sh' (compiled) |
---|
| 1334 | end |
---|
| 1335 | ActionName=Series.Action.ActionName; |
---|
| 1336 | ActionPath=Series.Action.ActionPath; |
---|
[594] | 1337 | path_series=fileparts(which('series')); |
---|
[472] | 1338 | |
---|
[595] | 1339 | %% create the Action fct handle if RunMode option = 'local' |
---|
[594] | 1340 | if strcmp(RunMode,'local') |
---|
| 1341 | if ~isequal(ActionPath,path_series) |
---|
| 1342 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
| 1343 | if ~exist(ActionPath,'dir') |
---|
| 1344 | msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']); |
---|
| 1345 | return |
---|
| 1346 | end |
---|
| 1347 | if ~isequal(spath,ActionPath) |
---|
| 1348 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
| 1349 | end |
---|
| 1350 | end |
---|
| 1351 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
| 1352 | if ~isequal(ActionPath,path_series) |
---|
| 1353 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
| 1354 | end |
---|
| 1355 | end |
---|
| 1356 | |
---|
| 1357 | %% Get RunTime code from the file PARAM.xml (needed to run compiled functions) |
---|
| 1358 | errormsg='';%default error message |
---|
| 1359 | xmlfile=fullfile(path_series,'PARAM.xml'); |
---|
| 1360 | test_batch=0;%default: ,no batch mode available |
---|
| 1361 | if ~exist(xmlfile,'file') |
---|
| 1362 | [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile); |
---|
| 1363 | end |
---|
| 1364 | RunTime=''; |
---|
| 1365 | if strcmp(ActionExt,'.sh') |
---|
| 1366 | if exist(xmlfile,'file') |
---|
| 1367 | s=xml2struct(xmlfile); |
---|
[598] | 1368 | if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam') |
---|
[594] | 1369 | if isfield(s.BatchParam,'RunTime') |
---|
| 1370 | RunTime=s.BatchParam.RunTime; |
---|
| 1371 | end |
---|
| 1372 | if isfield(s.BatchParam,'NbCore') |
---|
| 1373 | NbCore=s.BatchParam.NbCore; |
---|
| 1374 | end |
---|
| 1375 | elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam') |
---|
| 1376 | if isfield(s.RunParam,'RunTime') |
---|
| 1377 | RunTime=s.RunParam.RunTime; |
---|
| 1378 | end |
---|
| 1379 | if isfield(s.RunParam,'NbCore') |
---|
| 1380 | NbCore=s.RunParam.NbCore; |
---|
| 1381 | end |
---|
| 1382 | end |
---|
| 1383 | end |
---|
[598] | 1384 | if isempty(RunTime) && strcmp(RunMode,'cluster_oar') |
---|
[594] | 1385 | msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster') |
---|
| 1386 | return |
---|
| 1387 | end |
---|
[598] | 1388 | % Series.RunTime=RunTime; |
---|
[594] | 1389 | end |
---|
[595] | 1390 | |
---|
| 1391 | %% set nbre of cluster cores and processes |
---|
| 1392 | switch RunMode |
---|
| 1393 | case {'local','background'} |
---|
| 1394 | NbCore=1;% no need to split the calculation |
---|
| 1395 | case 'cluster_oar' |
---|
| 1396 | if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled) |
---|
| 1397 | NbCore=1;% one core used only (limitation of Matlab licences) |
---|
| 1398 | msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); |
---|
| 1399 | extra_oar=''; |
---|
| 1400 | else |
---|
[591] | 1401 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
| 1402 | NbCore=str2double(answer{1}); |
---|
[595] | 1403 | extra_oar=answer{2}; |
---|
| 1404 | end |
---|
| 1405 | end |
---|
| 1406 | if ~isfield(Series.IndexRange,'NbSlice') |
---|
| 1407 | Series.IndexRange.NbSlice=[]; |
---|
| 1408 | end |
---|
| 1409 | if isempty(Series.IndexRange.NbSlice) |
---|
[591] | 1410 | NbProcess=NbCore;% choose one process per core |
---|
[594] | 1411 | else |
---|
[595] | 1412 | NbProcess=Series.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices |
---|
| 1413 | NbCore=min(NbCore,NbProcess);% at least one process per core |
---|
[591] | 1414 | end |
---|
[594] | 1415 | |
---|
| 1416 | %% read index ranges |
---|
| 1417 | first_i=1; |
---|
| 1418 | last_i=1; |
---|
| 1419 | incr_i=1; |
---|
| 1420 | first_j=1; |
---|
| 1421 | last_j=1; |
---|
| 1422 | if isfield(Series.IndexRange,'first_i') |
---|
| 1423 | first_i=Series.IndexRange.first_i; |
---|
| 1424 | incr_i=Series.IndexRange.incr_i; |
---|
| 1425 | last_i=Series.IndexRange.last_i; |
---|
| 1426 | end |
---|
| 1427 | if isfield(Series.IndexRange,'first_j') |
---|
| 1428 | first_j=Series.IndexRange.first_j; |
---|
| 1429 | last_j=Series.IndexRange.last_j; |
---|
| 1430 | end |
---|
| 1431 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[595] | 1432 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return |
---|
[594] | 1433 | else |
---|
| 1434 | BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess); |
---|
| 1435 | end |
---|
| 1436 | |
---|
[595] | 1437 | %% direct processing on the current Matlab session |
---|
| 1438 | if strcmp (RunMode,'local') |
---|
| 1439 | Series.RUNHandle=handles.RUN; |
---|
| 1440 | Series.WaitbarHandle=handles.Waitbar; |
---|
| 1441 | for iprocess=1:NbProcess |
---|
| 1442 | if isempty(Series.IndexRange.NbSlice) |
---|
| 1443 | Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength; |
---|
[598] | 1444 | if Series.IndexRange.first_i>last_i |
---|
| 1445 | break |
---|
| 1446 | end |
---|
| 1447 | Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength-1,last_i); |
---|
[595] | 1448 | else |
---|
| 1449 | Series.IndexRange.first_i= first_i+iprocess-1; |
---|
| 1450 | Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice; |
---|
| 1451 | end |
---|
| 1452 | t=struct2xml(Series); |
---|
| 1453 | t=set(t,1,'name','Series'); |
---|
| 1454 | filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,... |
---|
| 1455 | Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); |
---|
| 1456 | save(t,filexml); |
---|
| 1457 | switch ActionExt |
---|
| 1458 | case '.m' |
---|
| 1459 | h_fun(Series); |
---|
| 1460 | case '.sh' |
---|
| 1461 | switch computer |
---|
| 1462 | case {'PCWIN','PCWIN64'} %Windows system |
---|
| 1463 | filexml=regexprep(filexml,'\\','\\\\');% add '\' so that '\' are left as characters |
---|
[598] | 1464 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]);% TODO: adapt to DOS system |
---|
[595] | 1465 | case {'GLNX86','GLNXA64','MACI64'}%Linux system |
---|
[598] | 1466 | system([fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml]); |
---|
[591] | 1467 | end |
---|
[472] | 1468 | end |
---|
[595] | 1469 | end |
---|
| 1470 | elseif strcmp(get(handles.OutputDirExt,'Visible'),'off') |
---|
| 1471 | msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option |
---|
| 1472 | return |
---|
| 1473 | else |
---|
| 1474 | %% processing on a different session of the same computer (background) or cluster, create executable files |
---|
| 1475 | batch_file_list=cell(NbProcess,1);% initiate the list of executable files |
---|
| 1476 | DirBat=fullfile(OutputDir,'0_BAT'); |
---|
| 1477 | %create subdirectory for executable files |
---|
| 1478 | if ~exist(DirBat,'dir') |
---|
| 1479 | [tild,msg1]=mkdir(DirBat); |
---|
| 1480 | if ~strcmp(msg1,'') |
---|
| 1481 | msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation |
---|
| 1482 | return |
---|
[472] | 1483 | end |
---|
[595] | 1484 | end |
---|
| 1485 | %create subdirectory for log files |
---|
| 1486 | DirLog=fullfile(OutputDir,'0_LOG'); |
---|
| 1487 | if ~exist(DirLog,'dir') |
---|
| 1488 | [tild,msg1]=mkdir(DirLog); |
---|
| 1489 | if ~strcmp(msg1,'') |
---|
| 1490 | msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation |
---|
| 1491 | return |
---|
| 1492 | end |
---|
| 1493 | end |
---|
| 1494 | for iprocess=1:NbProcess |
---|
| 1495 | if isempty(Series.IndexRange.NbSlice)% process by blocks of i index |
---|
| 1496 | Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength; |
---|
[598] | 1497 | if Series.IndexRange.first_i>last_i |
---|
| 1498 | NbProcess=iprocess-1; |
---|
| 1499 | break% leave the loop, we are at the end of the calculation |
---|
| 1500 | end |
---|
| 1501 | Series.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength-1); |
---|
[595] | 1502 | else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1 |
---|
| 1503 | Series.IndexRange.first_i= first_i+iprocess-1; |
---|
| 1504 | Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice; |
---|
| 1505 | end |
---|
| 1506 | |
---|
| 1507 | % create, fill and save the xml parameter file |
---|
| 1508 | t=struct2xml(Series); |
---|
| 1509 | t=set(t,1,'name','Series'); |
---|
| 1510 | filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,... |
---|
| 1511 | Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); |
---|
| 1512 | save(t,filexml);% save the parameter file |
---|
| 1513 | |
---|
| 1514 | %create the executable file |
---|
[598] | 1515 | % filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.bat',OutputNomType,... |
---|
| 1516 | % Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); |
---|
| 1517 | filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.sh',OutputNomType,... |
---|
| 1518 | Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); |
---|
[595] | 1519 | batch_file_list{iprocess}=filebat; |
---|
| 1520 | [fid,message]=fopen(filebat,'w');% create the executable file |
---|
| 1521 | if isequal(fid,-1) |
---|
| 1522 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
| 1523 | return |
---|
| 1524 | end |
---|
| 1525 | |
---|
| 1526 | % set the log file name |
---|
| 1527 | filelog=fullfile_uvmat(DirLog,'',Series.InputTable{1,3},'.log',OutputNomType,... |
---|
| 1528 | Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); |
---|
| 1529 | |
---|
| 1530 | % fill and save the executable file |
---|
| 1531 | switch ActionExt |
---|
| 1532 | case '.m'% Matlab function |
---|
| 1533 | switch computer |
---|
| 1534 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1535 | cmd=[... |
---|
| 1536 | '#!/bin/bash \n'... |
---|
| 1537 | '. /etc/sysprofile \n'... |
---|
| 1538 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... |
---|
| 1539 | 'addpath(''' path_series '''); \n'... |
---|
| 1540 | 'addpath(''' Series.Action.ActionPath '''); \n'... |
---|
| 1541 | '' Series.Action.ActionName '( ''' filexml '''); \n'... |
---|
| 1542 | 'exit \n'... |
---|
| 1543 | 'END_MATLAB \n']; |
---|
| 1544 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
| 1545 | fclose(fid);% close the executable file |
---|
| 1546 | system(['chmod +x ' filebat]);% set the file to executable |
---|
| 1547 | case {'PCWIN','PCWIN64'} |
---|
| 1548 | text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
| 1549 | ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... |
---|
| 1550 | 'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'... |
---|
| 1551 | '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
| 1552 | fprintf(fid,text_matlabscript);%fill the executable file with the char string cmd |
---|
| 1553 | fclose(fid);% close the executable file |
---|
[591] | 1554 | end |
---|
[595] | 1555 | case '.sh' % compiled Matlab function |
---|
| 1556 | switch computer |
---|
| 1557 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1558 | cmd=['#!/bin/bash \n '... |
---|
| 1559 | '#$ -cwd \n '... |
---|
| 1560 | 'hostname && date \n '... |
---|
| 1561 | 'umask 002 \n'... |
---|
[598] | 1562 | fullfile(ActionPath,[ActionName '.sh']) ' ' RunTime ' ' filexml];%allow writting access to created files for user group |
---|
[595] | 1563 | fprintf(fid,cmd);%fill the executable file with the char string cmd |
---|
| 1564 | fclose(fid);% close the executable file |
---|
| 1565 | system(['chmod +x ' filebat]);% set the file to executable |
---|
[591] | 1566 | |
---|
[595] | 1567 | case {'PCWIN','PCWIN64'} % TODO: adapt to Windows system |
---|
| 1568 | % cmd=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
| 1569 | % ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... |
---|
| 1570 | % 'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'... |
---|
| 1571 | % '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
| 1572 | fprintf(fid,cmd); |
---|
[591] | 1573 | fclose(fid); |
---|
[595] | 1574 | % dos([filebat ' &']); |
---|
[591] | 1575 | end |
---|
| 1576 | end |
---|
[595] | 1577 | end |
---|
[472] | 1578 | end |
---|
| 1579 | |
---|
[595] | 1580 | %% launch the executable files for background or cluster processing |
---|
| 1581 | switch RunMode |
---|
| 1582 | case 'background' |
---|
| 1583 | for iprocess=1:NbProcess |
---|
| 1584 | system(batch_file_list{iprocess})% directly execute the command file for each process |
---|
| 1585 | end |
---|
| 1586 | case 'cluster_oar' % option 'oar-parexec' used |
---|
| 1587 | %create subdirectory for oar command and log files |
---|
| 1588 | DirOAR=fullfile(OutputDir,'0_OAR'); |
---|
| 1589 | if ~exist(DirOAR,'dir') |
---|
| 1590 | [tild,msg1]=mkdir(DirOAR); |
---|
| 1591 | if ~strcmp(msg1,'') |
---|
| 1592 | msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation |
---|
| 1593 | return |
---|
| 1594 | end |
---|
| 1595 | end |
---|
| 1596 | max_walltime=3600*12; % 12h max |
---|
| 1597 | walltime_onejob=600;%seconds |
---|
| 1598 | filename_joblist=fullfile(DirOAR,'job_list.txt');%create name of the global executable file |
---|
| 1599 | fid=fopen(filename_joblist,'w'); |
---|
| 1600 | for p=1:length(batch_file_list) |
---|
[598] | 1601 | fprintf(fid,[batch_file_list{p} '\n']);% list of exe files |
---|
[595] | 1602 | end |
---|
| 1603 | fclose(fid); |
---|
| 1604 | system(['chmod +x ' filename_joblist]);% set the file to executable |
---|
| 1605 | oar_command=['oarsub -n CIVX '... |
---|
| 1606 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
| 1607 | '-l /core=' num2str(NbCore) ','... |
---|
| 1608 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),NbCore)/NbCore,max_walltime/86400),13) ' '... |
---|
| 1609 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1610 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1611 | extra_oar ' '... |
---|
| 1612 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
| 1613 | '-l ' filename_joblist '.log"\n']; |
---|
| 1614 | filename_oarcommand=fullfile(DirOAR,'oar_command'); |
---|
| 1615 | fid=fopen(filename_oarcommand,'w'); |
---|
| 1616 | fprintf(fid,oar_command); |
---|
| 1617 | fclose(fid); |
---|
| 1618 | fprintf(oar_command);% display in command line |
---|
| 1619 | %system(['chmod +x ' oar_command]);% set the file to executable |
---|
| 1620 | system(oar_command); |
---|
| 1621 | end |
---|
| 1622 | |
---|
| 1623 | %% reset the GUI series |
---|
| 1624 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished |
---|
[446] | 1625 | set(handles.RUN, 'Enable','On') |
---|
| 1626 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[591] | 1627 | set(handles.RUN, 'Value',0) |
---|
[2] | 1628 | |
---|
[446] | 1629 | %------------------------------------------------------------------------ |
---|
| 1630 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1631 | %------------------------------------------------------------------------ |
---|
| 1632 | set(handles.RUN, 'BusyAction','cancel') |
---|
| 1633 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1634 | set(handles.RUN,'enable','on') |
---|
[591] | 1635 | set(handles.RUN, 'Value',0) |
---|
[446] | 1636 | |
---|
[472] | 1637 | % %------------------------------------------------------------------------ |
---|
| 1638 | % % --- Executes on button press in BIN. |
---|
| 1639 | % function BIN_Callback(hObject, eventdata, handles) |
---|
| 1640 | % %------------------------------------------------------------------------ |
---|
| 1641 | % cmd=['#!/bin/bash \n '... |
---|
| 1642 | % '#$ -cwd \n '... |
---|
| 1643 | % 'hostname && date \n '... |
---|
| 1644 | % 'umask 002 \n'... |
---|
| 1645 | % Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; |
---|
| 1646 | % |
---|
[446] | 1647 | %------------------------------------------------------------------------ |
---|
[456] | 1648 | % --- Main launch command, called by RUN and BATCH |
---|
[591] | 1649 | |
---|
[595] | 1650 | function [Series,OutputDir,errormsg]=prepare_jobs(handles) |
---|
[472] | 1651 | %INPUT: |
---|
| 1652 | % handles: handles of graphic objects on the GUI series |
---|
| 1653 | |
---|
[446] | 1654 | %------------------------------------------------------------------------ |
---|
[595] | 1655 | OutputDir=''; |
---|
[446] | 1656 | errormsg=''; |
---|
[594] | 1657 | |
---|
[446] | 1658 | %% Read parameters from series |
---|
| 1659 | Series=read_GUI(handles.series); |
---|
| 1660 | |
---|
| 1661 | %% get_field GUI |
---|
[595] | 1662 | % if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') |
---|
| 1663 | % if strcmp(Series.InputFields.Field,'get_field...') |
---|
| 1664 | % hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1665 | % Series.GetField=read_GUI(hget_field); |
---|
[594] | 1666 | % end |
---|
| 1667 | % end |
---|
[26] | 1668 | |
---|
[595] | 1669 | %% create the output data directory |
---|
[446] | 1670 | %determine the root file corresponding to the first sub dir |
---|
[591] | 1671 | if get(handles.RUN,'value') && isfield(Series,'OutputSubDir') |
---|
| 1672 | SubDirOut=[get(handles.OutputSubDir,'String') Series.OutputDirExt]; |
---|
[446] | 1673 | SubDirOutNew=SubDirOut; |
---|
| 1674 | SeriesData=get(handles.series,'UserData'); |
---|
[591] | 1675 | if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort |
---|
[446] | 1676 | [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
| 1677 | Series.InputTable=Series.InputTable(iview,:); |
---|
[421] | 1678 | end |
---|
[448] | 1679 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
[450] | 1680 | check_create=1; %need to create the result directory by default |
---|
[446] | 1681 | while detect |
---|
[448] | 1682 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
| 1683 | if isequal(answer,'Yes') |
---|
| 1684 | detect=0; |
---|
| 1685 | check_create=0; |
---|
| 1686 | else |
---|
| 1687 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1688 | if isempty(r) |
---|
| 1689 | r(1).root=[SubDirOutNew '_']; |
---|
| 1690 | r(1).num1='0'; |
---|
| 1691 | end |
---|
| 1692 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1693 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
| 1694 | check_create=1; |
---|
[408] | 1695 | end |
---|
| 1696 | end |
---|
[448] | 1697 | Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); |
---|
[446] | 1698 | Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output |
---|
[448] | 1699 | set(handles.OutputDirExt,'String',Series.OutputDirExt) |
---|
[595] | 1700 | OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);% full name (with path) of output directory |
---|
| 1701 | if check_create % create output directory if it does not exist |
---|
[472] | 1702 | [tild,msg1]=mkdir(OutputDir); |
---|
[446] | 1703 | if ~strcmp(msg1,'') |
---|
[472] | 1704 | errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation |
---|
[446] | 1705 | return |
---|
[421] | 1706 | end |
---|
[408] | 1707 | end |
---|
[595] | 1708 | % RootOut=fullfile(OutputDir,Series.InputTable{1,3});% name of the parameter xml file set in this directory |
---|
[408] | 1709 | end |
---|
[595] | 1710 | |
---|
| 1711 | %% removes unused information on Series |
---|
| 1712 | if isfield(Series,'Pairs') |
---|
| 1713 | Series=rmfield(Series,'Pairs'); %info Pairs not needed for output |
---|
| 1714 | end |
---|
[472] | 1715 | Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); |
---|
[598] | 1716 | % Series.IndexRange=rmfield(Series.IndexRange,'MinIndex'); |
---|
| 1717 | % Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex'); |
---|
[591] | 1718 | empty_line=false(size(Series.InputTable,1),1); |
---|
[472] | 1719 | for iline=1:size(Series.InputTable,1) |
---|
| 1720 | empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''}); |
---|
| 1721 | end |
---|
[591] | 1722 | Series.InputTable(empty_line,:)=[]; |
---|
[408] | 1723 | |
---|
[41] | 1724 | %------------------------------------------------------------------------ |
---|
[446] | 1725 | % --- Executes on selection change in ActionName. |
---|
| 1726 | function ActionName_Callback(hObject, eventdata, handles) |
---|
[41] | 1727 | %------------------------------------------------------------------------ |
---|
[591] | 1728 | %% stop any ongoing series processing |
---|
| 1729 | if isequal(get(handles.RUN,'Value'),1) |
---|
| 1730 | answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?'); |
---|
| 1731 | if strcmp(answer,'Yes') |
---|
| 1732 | STOP_Callback(hObject, eventdata, handles) |
---|
| 1733 | else |
---|
| 1734 | return |
---|
| 1735 | end |
---|
| 1736 | end |
---|
[598] | 1737 | set(handles.ActionName,'BackgroundColor',[1 1 0]) |
---|
| 1738 | drawnow |
---|
[591] | 1739 | |
---|
| 1740 | %% get Action name and path |
---|
| 1741 | nb_builtin_ACTION=4; %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series) |
---|
| 1742 | ActionList=get(handles.ActionName,'String');% list menu fields |
---|
| 1743 | ActionIndex=get(handles.ActionName,'Value'); |
---|
| 1744 | if ~isequal(ActionIndex,1) |
---|
| 1745 | InputTable=get(handles.InputTable,'Data'); |
---|
| 1746 | if isempty(InputTable{1,4}) |
---|
| 1747 | msgbox_uvmat('ERROR','no input file available: use Open in the menu bar') |
---|
| 1748 | return |
---|
| 1749 | end |
---|
| 1750 | end |
---|
| 1751 | ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name |
---|
| 1752 | ActionPathList=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ActionName |
---|
| 1753 | |
---|
| 1754 | %% add a new function to the menu if 'more...' has been selected in the menu ActionName |
---|
| 1755 | if isequal(ActionName,'more...') |
---|
| 1756 | [FileName, PathName] = uigetfile( ... |
---|
| 1757 | {'*.m', ' (*.m)'; |
---|
[2] | 1758 | '*.m', '.m files '; ... |
---|
| 1759 | '*.*', 'All Files (*.*)'}, ... |
---|
[591] | 1760 | 'Pick a series processing function ',get(handles.ActionPath,'String')); |
---|
[2] | 1761 | if length(FileName)<2 |
---|
| 1762 | return |
---|
| 1763 | end |
---|
[591] | 1764 | [ActionPath,ActionName,ActionExt]=fileparts(FileName); |
---|
[598] | 1765 | |
---|
| 1766 | % insert the choice in the menu ActionName |
---|
[591] | 1767 | ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action |
---|
| 1768 | if isempty(ActionIndex)%the input string does not exist in the menu |
---|
| 1769 | ActionIndex= length(ActionList); |
---|
| 1770 | ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
| 1771 | set(handles.ActionName,'String',ActionList) |
---|
| 1772 | end |
---|
[2] | 1773 | |
---|
[598] | 1774 | % record the file extension and extend the path list if it is a new extension |
---|
[591] | 1775 | ActionExtList=get(handles.ActionExt,'String'); |
---|
| 1776 | ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1); |
---|
| 1777 | if isempty(ActionExtIndex) |
---|
| 1778 | set(handles.ActionExt,'String',[ActionExtList;{ActionExt}]) |
---|
[598] | 1779 | ActionExtIndex=numel(ActionExtList)+1; |
---|
[591] | 1780 | ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath |
---|
| 1781 | ActionPathList=[ActionPathList ActionPathNew]; |
---|
| 1782 | end |
---|
| 1783 | set(handles.ActionName,'UserData',ActionPathList); |
---|
[598] | 1784 | |
---|
| 1785 | % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5) |
---|
| 1786 | if length(ActionList)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
| 1787 | nbremove=length(ActionList)-nb_builtin_ACTION-5; |
---|
| 1788 | ActionList(nb_builtin_ACTION+1:end-5)=[]; |
---|
| 1789 | ActionPathList(nb_builtin_ACTION+1:end-4,:)=[]; |
---|
| 1790 | ActionIndex=ActionIndex-nbremove; |
---|
| 1791 | end |
---|
[591] | 1792 | |
---|
[598] | 1793 | % record action menu, choice and path |
---|
| 1794 | set(handles.ActionName,'Value',ActionIndex) |
---|
| 1795 | set(handles.ActionName,'String',ActionList) |
---|
| 1796 | set(handles.ActionExt,'Value',ActionExtIndex) |
---|
| 1797 | ActionPathList{ActionIndex,ActionExtIndex}=PathName; |
---|
| 1798 | |
---|
| 1799 | %record the user defined menu additions in personal file profil_perso |
---|
[591] | 1800 | dir_perso=prefdir; |
---|
| 1801 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
[598] | 1802 | if nb_builtin_ACTION+1<=numel(ActionList)-1 |
---|
[591] | 1803 | ActionListUser=ActionList(nb_builtin_ACTION+1:numel(ActionList)-1); |
---|
| 1804 | ActionPathListUser=ActionPathList(nb_builtin_ACTION+1:numel(ActionList)-1,:); |
---|
| 1805 | ActionExtListUser={}; |
---|
| 1806 | if numel(ActionExtList)>2 |
---|
| 1807 | ActionExtListUser=ActionExtList(3:end); |
---|
| 1808 | end |
---|
| 1809 | if exist(profil_perso,'file') |
---|
| 1810 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append') |
---|
| 1811 | else |
---|
| 1812 | save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6') |
---|
| 1813 | end |
---|
| 1814 | end |
---|
[2] | 1815 | end |
---|
| 1816 | |
---|
[591] | 1817 | %% check the current ActionPath to the selected function |
---|
[594] | 1818 | ActionPath=ActionPathList{ActionIndex};%current recorded path |
---|
| 1819 | set(handles.ActionPath,'String',ActionPath); %show the path to the senlected function |
---|
[2] | 1820 | |
---|
[591] | 1821 | %% reinitialise the waitbar |
---|
[477] | 1822 | update_waitbar(handles.Waitbar,0) |
---|
| 1823 | |
---|
[591] | 1824 | %% default setting for the visibility of the GUI elements |
---|
[598] | 1825 | % set(handles.FieldTransform,'Visible','off') |
---|
| 1826 | % set(handles.CheckObject,'Visible','off'); |
---|
| 1827 | % set(handles.ProjObject,'Visible','off'); |
---|
| 1828 | % set(handles.CheckMask,'Visible','off') |
---|
| 1829 | % set(handles.Mask,'Visible','off') |
---|
[591] | 1830 | |
---|
[594] | 1831 | %% create the function handle for Action |
---|
| 1832 | path_series=which('series'); |
---|
| 1833 | if ~isequal(ActionPath,path_series) |
---|
| 1834 | eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION |
---|
| 1835 | if ~exist(ActionPath,'dir') |
---|
| 1836 | errormsg=['The prescribed function path ' ActionPath ' does not exist']; |
---|
| 1837 | return |
---|
| 1838 | end |
---|
| 1839 | if ~isequal(spath,ActionPath) |
---|
| 1840 | addpath(ActionPath)% add the prescribed path if not the current one |
---|
| 1841 | end |
---|
| 1842 | end |
---|
| 1843 | eval(['h_fun=@' ActionName ';'])%create a function handle for ACTION |
---|
| 1844 | if ~isequal(ActionPath,path_series) |
---|
| 1845 | rmpath(ActionPath)% add the prescribed path if not the current one |
---|
| 1846 | end |
---|
| 1847 | |
---|
[598] | 1848 | %% Activate the Action fct |
---|
| 1849 | [Series,tild,errormsg]=prepare_jobs(handles);% read the parameters from the GUI series |
---|
[591] | 1850 | if ~isempty(errormsg) |
---|
| 1851 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1852 | return |
---|
[29] | 1853 | end |
---|
[591] | 1854 | ParamOut=h_fun(Series); |
---|
| 1855 | |
---|
[598] | 1856 | %% Put the first line of the selected Action fct as tooltip help |
---|
[244] | 1857 | try |
---|
[591] | 1858 | [fid,errormsg] =fopen([ActionName '.m']); |
---|
[244] | 1859 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
[553] | 1860 | fclose(fid); |
---|
[456] | 1861 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
[244] | 1862 | end |
---|
[2] | 1863 | |
---|
[591] | 1864 | %% Detect the types of input files |
---|
[472] | 1865 | SeriesData=get(handles.series,'UserData'); |
---|
[591] | 1866 | nb_civ=0;nb_netcdf=0; |
---|
| 1867 | if ~isempty(SeriesData) |
---|
| 1868 | nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType))); |
---|
| 1869 | nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); |
---|
| 1870 | end |
---|
| 1871 | |
---|
| 1872 | %% Check whether alphabetical sorting of input Subdir is alowed by the Action fct (for multiples series entries) |
---|
| 1873 | SeriesData.AllowInputSort=0;%default |
---|
| 1874 | if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on') |
---|
| 1875 | SeriesData.AllowInputSort=1; |
---|
| 1876 | end |
---|
| 1877 | |
---|
| 1878 | %% Impose the whole input file index range if requested |
---|
| 1879 | if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on') |
---|
| 1880 | MinIndex=get(handles.MinIndex,'Data'); |
---|
| 1881 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
| 1882 | if ~isempty(MinIndex) |
---|
| 1883 | set(handles.num_first_i,'String',num2str(MinIndex{1})) |
---|
| 1884 | set(handles.num_last_i,'String',num2str(MaxIndex{1})) |
---|
| 1885 | set(handles.num_incr_i,'String','1') |
---|
| 1886 | if size(MinIndex,2)>=2 |
---|
| 1887 | set(handles.num_first_j,'String',num2str(MinIndex{1,2})) |
---|
| 1888 | set(handles.num_last_j,'String',num2str(MaxIndex{1,2})) |
---|
| 1889 | set(handles.num_incr_j,'String','1') |
---|
| 1890 | end |
---|
[2] | 1891 | end |
---|
[594] | 1892 | else |
---|
| 1893 | % check index ranges |
---|
| 1894 | first_i=1;last_i=1;first_j=1;last_j=1; |
---|
| 1895 | if isfield(Series.IndexRange,'first_i') |
---|
| 1896 | first_i=Series.IndexRange.first_i; |
---|
| 1897 | last_i=Series.IndexRange.last_i; |
---|
[2] | 1898 | end |
---|
[594] | 1899 | if isfield(Series.IndexRange,'first_j') |
---|
| 1900 | first_j=Series.IndexRange.first_j; |
---|
| 1901 | last_j=Series.IndexRange.last_j; |
---|
| 1902 | end |
---|
| 1903 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
| 1904 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1905 | end |
---|
[591] | 1906 | |
---|
| 1907 | %% NbSlice visibility |
---|
| 1908 | NbSliceVisible='off';%default |
---|
| 1909 | if isfield(ParamOut,'NbSlice') && isequal(ParamOut.NbSlice,'on') |
---|
| 1910 | NbSliceVisible='on'; |
---|
| 1911 | set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices |
---|
| 1912 | else |
---|
| 1913 | set(handles.num_NbProcess,'String','')% free nbre of processes |
---|
[2] | 1914 | end |
---|
[591] | 1915 | set(handles.num_NbSlice,'Visible',NbSliceVisible) |
---|
| 1916 | set(handles.NbSlice_title,'Visible',NbSliceVisible) |
---|
[2] | 1917 | |
---|
[591] | 1918 | %% Visibility of VelType and VelType_1 menus |
---|
| 1919 | VelTypeVisible='off'; %hidden by default |
---|
| 1920 | VelType_1Visible='off'; |
---|
| 1921 | InputFieldsVisible='off';%visibility of the frame Fields |
---|
| 1922 | if isfield(ParamOut,'VelType') |
---|
| 1923 | if strcmp( ParamOut.VelType,'one')||strcmp( ParamOut.VelType,'two') |
---|
| 1924 | if nb_civ>=1 |
---|
| 1925 | VelTypeVisible='on'; |
---|
| 1926 | InputFieldsVisible='on'; |
---|
| 1927 | end |
---|
| 1928 | end |
---|
| 1929 | if strcmp( ParamOut.VelType,'two') |
---|
| 1930 | if nb_civ>=2 |
---|
| 1931 | VelType_1Visible='on'; |
---|
| 1932 | end |
---|
| 1933 | end |
---|
| 1934 | end |
---|
| 1935 | set(handles.VelType,'Visible',VelTypeVisible) |
---|
| 1936 | set(handles.VelType_text,'Visible',VelTypeVisible); |
---|
| 1937 | set(handles.VelType_1,'Visible',VelType_1Visible) |
---|
| 1938 | set(handles.VelType_text_1,'Visible',VelType_1Visible); |
---|
| 1939 | |
---|
| 1940 | %% Visibility of FieldName and FieldName_1 menus |
---|
| 1941 | FieldNameVisible='off'; %hidden by default |
---|
| 1942 | FieldName_1Visible='off'; %hidden by default |
---|
| 1943 | if isfield(ParamOut,'FieldName') |
---|
| 1944 | if strcmp( ParamOut.FieldName,'one')||strcmp( ParamOut.FieldName,'two') |
---|
| 1945 | if (nb_civ+nb_netcdf)>=1 |
---|
| 1946 | InputFieldsVisible='on'; |
---|
| 1947 | FieldNameVisible='on'; |
---|
| 1948 | end |
---|
| 1949 | end |
---|
| 1950 | if strcmp( ParamOut.FieldName,'two') |
---|
| 1951 | if (nb_civ+nb_netcdf)>=1 |
---|
| 1952 | FieldName_1Visible='on'; |
---|
| 1953 | end |
---|
| 1954 | end |
---|
| 1955 | end |
---|
| 1956 | set(handles.InputFields,'Visible',InputFieldsVisible) |
---|
| 1957 | set(handles.FieldName,'Visible',FieldNameVisible) % test for MenuBorser |
---|
| 1958 | set(handles.FieldName_1,'Visible',FieldName_1Visible) |
---|
| 1959 | |
---|
| 1960 | %% Visibility of FieldTransform menu |
---|
| 1961 | FieldTransformVisible='off'; %hidden by default |
---|
| 1962 | if isfield(ParamOut,'FieldTransform') |
---|
| 1963 | FieldTransformVisible=ParamOut.FieldTransform; |
---|
| 1964 | TransformName_Callback([],[], handles) |
---|
| 1965 | end |
---|
| 1966 | set(handles.FieldTransform,'Visible',FieldTransformVisible) |
---|
| 1967 | |
---|
| 1968 | %% Visibility of projection object |
---|
| 1969 | ProjObjectVisible='off'; %hidden by default |
---|
| 1970 | if isfield(ParamOut,'ProjObject') |
---|
| 1971 | ProjObjectVisible=ParamOut.ProjObject; |
---|
| 1972 | end |
---|
| 1973 | set(handles.CheckObject,'Visible',ProjObjectVisible) |
---|
| 1974 | if ~get(handles.CheckObject,'Value') |
---|
| 1975 | ProjObjectVisible='off'; |
---|
| 1976 | end |
---|
| 1977 | set(handles.ProjObject,'Visible',ProjObjectVisible) |
---|
| 1978 | set(handles.DeleteObject,'Visible',ProjObjectVisible) |
---|
| 1979 | set(handles.ViewObject,'Visible',ProjObjectVisible) |
---|
| 1980 | |
---|
| 1981 | |
---|
| 1982 | %% Visibility of mask input |
---|
| 1983 | MaskVisible='off'; %hidden by default |
---|
| 1984 | if isfield(ParamOut,'Mask') |
---|
| 1985 | MaskVisible=ParamOut.Mask; |
---|
| 1986 | end |
---|
| 1987 | set(handles.Mask,'Visible',MaskVisible) |
---|
| 1988 | set(handles.CheckMask,'Visible',MaskVisible); |
---|
| 1989 | |
---|
| 1990 | %% definition of the directory containing the output files |
---|
| 1991 | OutputDirVisible='off'; |
---|
| 1992 | if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt) |
---|
| 1993 | set(handles.OutputDirExt,'String',ParamOut.OutputDirExt) |
---|
| 1994 | OutputDirVisible='on'; |
---|
| 1995 | end |
---|
| 1996 | set(handles.OutputDirExt,'Visible',OutputDirVisible) |
---|
| 1997 | set(handles.OutputSubDir,'Visible',OutputDirVisible) |
---|
| 1998 | set(handles.OutputDir_title,'Visible',OutputDirVisible) |
---|
| 1999 | set(handles.RunMode,'Visible',OutputDirVisible) |
---|
| 2000 | set(handles.ActionExt,'Visible',OutputDirVisible) |
---|
| 2001 | set(handles.RunMode_title,'Visible',OutputDirVisible) |
---|
| 2002 | set(handles.ActionExt_title,'Visible',OutputDirVisible) |
---|
| 2003 | |
---|
| 2004 | %% definition of an additional parameter set, determined by an ancillary GUI |
---|
| 2005 | if isfield(ParamOut,'ActionInput') |
---|
| 2006 | set(handles.ActionInput,'Visible','on') |
---|
| 2007 | set(handles.ActionInput_title,'Visible','on') |
---|
[598] | 2008 | set(handles.ActionInputView,'Visible','on') |
---|
| 2009 | set(handles.ActionInputView,'Value',0) |
---|
[591] | 2010 | set(handles.ActionInput,'String',ActionName) |
---|
[598] | 2011 | ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput |
---|
[591] | 2012 | SeriesData.ActionInput=ParamOut.ActionInput; |
---|
| 2013 | else |
---|
| 2014 | set(handles.ActionInput,'Visible','off') |
---|
| 2015 | set(handles.ActionInput_title,'Visible','off') |
---|
[598] | 2016 | set(handles.ActionInputView,'Visible','off') |
---|
[591] | 2017 | if isfield(SeriesData,'ActionInput') |
---|
| 2018 | SeriesData=rmfield(SeriesData,'ActionInput'); |
---|
| 2019 | end |
---|
| 2020 | end |
---|
| 2021 | set(handles.series,'UserData',SeriesData) |
---|
[598] | 2022 | set(handles.ActionName,'BackgroundColor',[1 1 1]) |
---|
[591] | 2023 | |
---|
[41] | 2024 | %------------------------------------------------------------------------ |
---|
[598] | 2025 | % --- Executes on button press in ActionInputView. |
---|
| 2026 | function ActionInputView_Callback(hObject, eventdata, handles) |
---|
| 2027 | %------------------------------------------------------------------------ |
---|
| 2028 | if get(handles.ActionInputView,'Value') |
---|
| 2029 | ActionName_Callback(hObject, eventdata, handles) |
---|
| 2030 | end |
---|
| 2031 | |
---|
| 2032 | %------------------------------------------------------------------------ |
---|
[446] | 2033 | % --- Executes on selection change in FieldName. |
---|
| 2034 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[41] | 2035 | %------------------------------------------------------------------------ |
---|
[446] | 2036 | field_str=get(handles.FieldName,'String'); |
---|
| 2037 | field_index=get(handles.FieldName,'Value'); |
---|
[2] | 2038 | field=field_str{field_index(1)}; |
---|
[595] | 2039 | if isequal(field,'get_field...') |
---|
| 2040 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 2041 | if ~isempty(hget_field) |
---|
| 2042 | delete(hget_field)%delete opened versions of get_field |
---|
| 2043 | end |
---|
| 2044 | Series=read_GUI(handles.series); |
---|
| 2045 | Series.InputTable=Series.InputTable(1,:); |
---|
| 2046 | filecell=get_file_series(Series); |
---|
| 2047 | if exist(filecell{1,1},'file') |
---|
| 2048 | GetFieldData=get_field(filecell{1,1}); |
---|
| 2049 | FieldList={}; |
---|
| 2050 | XName=GetFieldData.XVarName; |
---|
| 2051 | if GetFieldData.CheckVector |
---|
| 2052 | UName=GetFieldData.PanelVectors.vector_x; |
---|
| 2053 | VName=GetFieldData.PanelVectors.vector_y; |
---|
| 2054 | XName=GetFieldData.XVarName; |
---|
| 2055 | YName=GetFieldData.YVarName; |
---|
| 2056 | CName=GetFieldData.PanelVectors.vec_color; |
---|
| 2057 | [FieldList,VecColorList]=set_field_list(UName,VName,CName); |
---|
| 2058 | elseif GetFieldData.CheckScalar |
---|
| 2059 | AName=GetFieldData.PanelScalar.scalar; |
---|
| 2060 | XName=GetFieldData.XVarName; |
---|
| 2061 | YName=GetFieldData.YVarName; |
---|
| 2062 | FieldList={AName}; |
---|
| 2063 | elseif GetFieldData.CheckPlot1D; |
---|
| 2064 | YName=GetFieldData.CheckPlot1D.ordinate; |
---|
| 2065 | end |
---|
| 2066 | set(handles.Coord_x,'String',{XName}) |
---|
| 2067 | set(handles.Coord_y,'String',{YName}) |
---|
| 2068 | set(handles.FieldName,'Value',1) |
---|
| 2069 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
| 2070 | % set(handles.ColorScalar,'Value',1) |
---|
| 2071 | % set(handles.ColorScalar,'String',VecColorList); |
---|
| 2072 | % UvData.FileType{1}='netcdf'; |
---|
| 2073 | % set(handles.uvmat,'UserData',UvData) |
---|
| 2074 | end |
---|
| 2075 | % elseif isequal(field,'more...') |
---|
| 2076 | % str=calc_field; |
---|
| 2077 | % [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 2078 | % 'SelectionMode','single',... |
---|
| 2079 | % 'ListString',str); |
---|
| 2080 | % % edit the choice in the fields and actionname menu |
---|
| 2081 | % scalar=cell2mat(str(ind_answer)); |
---|
| 2082 | % update_menu(handles.FieldName,scalar) |
---|
[2] | 2083 | end |
---|
| 2084 | |
---|
[41] | 2085 | %------------------------------------------------------------------------ |
---|
[446] | 2086 | % --- Executes on selection change in FieldName_1. |
---|
| 2087 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[41] | 2088 | %------------------------------------------------------------------------ |
---|
[446] | 2089 | field_str=get(handles.FieldName_1,'String'); |
---|
| 2090 | field_index=get(handles.FieldName_1,'Value'); |
---|
[2] | 2091 | field=field_str{field_index}; |
---|
| 2092 | if isequal(field,'get_field...') |
---|
| 2093 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 2094 | if ~isempty(hget_field) |
---|
| 2095 | delete(hget_field) |
---|
| 2096 | end |
---|
[332] | 2097 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 2098 | filename=SeriesData.CurrentInputFile_1; |
---|
| 2099 | if exist(filename,'file') |
---|
| 2100 | hget_field=get_field(filename); |
---|
| 2101 | set(hget_field,'name','get_field_1') |
---|
| 2102 | end |
---|
[595] | 2103 | % elseif isequal(field,'more...') |
---|
| 2104 | % str=calc_field; |
---|
| 2105 | % [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 2106 | % 'SelectionMode','single',... |
---|
| 2107 | % 'ListString',str); |
---|
| 2108 | % % edit the choice in the fields and actionname menu |
---|
| 2109 | % scalar=cell2mat(str(ind_answer)); |
---|
| 2110 | % update_menu(handles.FieldName_1,scalar) |
---|
[2] | 2111 | end |
---|
[29] | 2112 | |
---|
[244] | 2113 | |
---|
[2] | 2114 | %%%%%%%%%%%%% |
---|
| 2115 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
[339] | 2116 | indsel=ind_i; |
---|
| 2117 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
| 2118 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
| 2119 | if ~isempty(indiff) |
---|
| 2120 | indiff2=diff(indiff); |
---|
| 2121 | indiffp=[indiff2 1]; |
---|
| 2122 | indiffm=[1 indiff2]; |
---|
| 2123 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
| 2124 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
| 2125 | %for each multiplet, select the most recent file |
---|
| 2126 | ind_remove=[]; |
---|
| 2127 | for i=1:length(ind_multi_m) |
---|
| 2128 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
| 2129 | for imulti=1:length(ind_pairs) |
---|
| 2130 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
[2] | 2131 | end |
---|
[339] | 2132 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
| 2133 | ind_s=indsort2(1:end-1);% |
---|
| 2134 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
| 2135 | end |
---|
| 2136 | end |
---|
[2] | 2137 | |
---|
[89] | 2138 | %------------------------------------------------------------------------ |
---|
[408] | 2139 | % --- determine the list of index pairstring of processing file |
---|
[32] | 2140 | 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] | 2141 | %------------------------------------------------------------------------ |
---|
[32] | 2142 | num_i1=num_i;% set of first image numbers by default |
---|
| 2143 | num_i2=num_i; |
---|
| 2144 | num_j1=num_j; |
---|
| 2145 | num_j2=num_j; |
---|
| 2146 | num_i_out=num_i; |
---|
| 2147 | num_j_out=num_j; |
---|
[339] | 2148 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
| 2149 | if isequal(mode,'series(Di)') |
---|
[32] | 2150 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
| 2151 | num_i2_line=num_i+ind_shift(4); |
---|
| 2152 | % adjust the first and last field number |
---|
| 2153 | indsel=find(num_i1_line >= 1); |
---|
| 2154 | num_i_out=num_i(indsel); |
---|
| 2155 | num_i1_line=num_i1_line(indsel); |
---|
| 2156 | num_i2_line=num_i2_line(indsel); |
---|
| 2157 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 2158 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 2159 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
| 2160 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
[339] | 2161 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
[32] | 2162 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
| 2163 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
| 2164 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
| 2165 | else |
---|
| 2166 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
| 2167 | num_j2_col=num_j+ind_shift(2); |
---|
| 2168 | % adjust the first field number |
---|
| 2169 | indsel=find((num_j1_col >= 1)); |
---|
| 2170 | num_j_out=num_j(indsel); |
---|
| 2171 | num_j1_col=num_j1_col(indsel); |
---|
| 2172 | num_j2_col=num_j2_col(indsel); |
---|
| 2173 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
| 2174 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
| 2175 | end |
---|
| 2176 | end |
---|
[2] | 2177 | |
---|
[41] | 2178 | %------------------------------------------------------------------------ |
---|
[446] | 2179 | % --- Executes on button press in CheckObject. |
---|
| 2180 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
[41] | 2181 | %------------------------------------------------------------------------ |
---|
[446] | 2182 | value=get(handles.CheckObject,'Value'); |
---|
[2] | 2183 | if value |
---|
[595] | 2184 | % set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
[76] | 2185 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
[2] | 2186 | if ishandle(hset_object) |
---|
[421] | 2187 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
[2] | 2188 | else |
---|
[41] | 2189 | %get the object file |
---|
[376] | 2190 | InputTable=get(handles.InputTable,'Data'); |
---|
| 2191 | defaultname=InputTable{1,1}; |
---|
[106] | 2192 | if isempty(defaultname) |
---|
| 2193 | defaultname={''}; |
---|
| 2194 | end |
---|
[595] | 2195 | [FileName, PathName] = uigetfile( ... |
---|
[41] | 2196 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 2197 | '*.xml', '.xml files '; ... |
---|
| 2198 | '*.mat', '.mat matlab files '}, ... |
---|
[427] | 2199 | 'Pick an xml object file (or use uvmat to create it)',defaultname); |
---|
[41] | 2200 | fileinput=[PathName FileName];%complete file name |
---|
| 2201 | sizf=size(fileinput); |
---|
| 2202 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 2203 | %read the file |
---|
[427] | 2204 | data=xml2struct(fileinput); |
---|
[446] | 2205 | if ~isfield(data,'Type') |
---|
| 2206 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
| 2207 | return |
---|
[41] | 2208 | end |
---|
| 2209 | if ~isfield(data,'ProjMode') |
---|
[446] | 2210 | data.ProjMode='none'; |
---|
[41] | 2211 | end |
---|
[446] | 2212 | hset_object=set_object(data);% call the set_object interface |
---|
[2] | 2213 | end |
---|
[591] | 2214 | ProjObject=read_GUI(hset_object); |
---|
| 2215 | set(handles.ProjObject,'String',ProjObject.Name);%display the object name |
---|
| 2216 | SeriesData=get(handles.series,'UserData'); |
---|
| 2217 | SeriesData.ProjObject=ProjObject; |
---|
| 2218 | set(handles.series,'UserData',SeriesData); |
---|
| 2219 | set(handles.DeleteObject,'Visible','on'); |
---|
| 2220 | set(handles.ViewObject,'Visible','on'); |
---|
[595] | 2221 | set(handles.ProjObject,'Visible','on'); |
---|
[2] | 2222 | else |
---|
[595] | 2223 | set(handles.DeleteObject,'Visible','off'); |
---|
| 2224 | set(handles.ViewObject,'Visible','off'); |
---|
| 2225 | set(handles.ProjObject,'Visible','off'); |
---|
| 2226 | % set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
[2] | 2227 | end |
---|
[446] | 2228 | %set(handles.series,'UserData',SeriesData) |
---|
[2] | 2229 | |
---|
| 2230 | %-------------------------------------------------------------- |
---|
[446] | 2231 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 2232 | value=get(handles.CheckMask,'Value'); |
---|
[2] | 2233 | if value |
---|
[41] | 2234 | msgbox_uvmat('ERROR','not implemented yet') |
---|
[2] | 2235 | end |
---|
| 2236 | %-------------------------------------------------------------- |
---|
| 2237 | |
---|
[41] | 2238 | %------------------------------------------------------------------- |
---|
[2] | 2239 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
| 2240 | function ncbrowser_uvmat(hObject, eventdata) |
---|
[41] | 2241 | %------------------------------------------------------------------- |
---|
[2] | 2242 | bla=get(gcbo,'String'); |
---|
| 2243 | ind=get(gcbo,'Value'); |
---|
| 2244 | filename=cell2mat(bla(ind)); |
---|
| 2245 | blank=find(filename==' '); |
---|
| 2246 | filename=filename(1:blank-1); |
---|
| 2247 | get_field(filename) |
---|
| 2248 | |
---|
[41] | 2249 | % ------------------------------------------------------------------ |
---|
[2] | 2250 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[41] | 2251 | %------------------------------------------------------------------- |
---|
[2] | 2252 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 2253 | pathelp=fileparts(path_to_uvmat); |
---|
[36] | 2254 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 2255 | 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] | 2256 | else |
---|
[36] | 2257 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 2258 | web([helpfile '#series']) |
---|
[2] | 2259 | end |
---|
| 2260 | |
---|
[41] | 2261 | %------------------------------------------------------------------- |
---|
[446] | 2262 | % --- Executes on selection change in TransformName. |
---|
| 2263 | function TransformName_Callback(hObject, eventdata, handles) |
---|
[591] | 2264 | %---------------------------------------------------------------------- |
---|
| 2265 | TransformList=get(handles.TransformName,'String'); |
---|
| 2266 | TransformIndex=get(handles.TransformName,'Value'); |
---|
| 2267 | TransformName=TransformList{TransformIndex}; |
---|
| 2268 | TransformPathList=get(handles.TransformName,'UserData'); |
---|
| 2269 | nb_builtin_transform=4; |
---|
| 2270 | % ff=functions(list_transform{end}); |
---|
| 2271 | if isequal(TransformName,'more...'); |
---|
| 2272 | % coord_fct=''; |
---|
| 2273 | % prompt = {'Enter the name of the transform function'}; |
---|
| 2274 | % dlg_title = 'user defined transform'; |
---|
| 2275 | % num_lines= 1; |
---|
| 2276 | [FileName, PathName] = uigetfile( ... |
---|
[39] | 2277 | {'*.m', ' (*.m)'; |
---|
| 2278 | '*.m', '.m files '; ... |
---|
| 2279 | '*.*', 'All Files (*.*)'}, ... |
---|
[591] | 2280 | 'Pick a transform function',get(handles.TransformPath,'String')); |
---|
| 2281 | if isequal(FileName,0) |
---|
| 2282 | return %browser closed without choice |
---|
| 2283 | end |
---|
[39] | 2284 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 2285 | PathName(end)=[]; |
---|
| 2286 | end |
---|
[591] | 2287 | [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m |
---|
| 2288 | if ~strcmp(TransformExt,'.m') |
---|
[39] | 2289 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 2290 | return |
---|
| 2291 | end |
---|
[591] | 2292 | % insert the choice in the menu |
---|
| 2293 | TransformIndex=find(strcmp(TransformName,TransformList),1);% look for the selected function in the menu Action |
---|
| 2294 | if isempty(TransformIndex)%the input string does not exist in the menu |
---|
| 2295 | TransformIndex= length(TransformList); |
---|
| 2296 | TransformList=[TransformList(1:end-1);{TransformnName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...' |
---|
| 2297 | set(handles.TransformName,'String',TransformList) |
---|
| 2298 | TransformPathList=[TransformPathList;{TransformPath}]; |
---|
| 2299 | end |
---|
[39] | 2300 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 2301 | dir_perso=prefdir;%personal Matalb directory |
---|
| 2302 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2303 | if exist(profil_perso,'file') |
---|
[591] | 2304 | for ilist=nb_builtin_transform+1:numel(TransformPathList) |
---|
| 2305 | TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist}; |
---|
| 2306 | TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist}; |
---|
[39] | 2307 | end |
---|
[591] | 2308 | save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat |
---|
[39] | 2309 | end |
---|
| 2310 | end |
---|
[2] | 2311 | |
---|
[591] | 2312 | %display the current function path |
---|
| 2313 | set(handles.TransformPath,'String',TransformPathList{TransformIndex}); %show the path to the senlected function |
---|
| 2314 | set(handles.TransformName,'UserData',TransformPathList); |
---|
[350] | 2315 | |
---|
| 2316 | |
---|
[446] | 2317 | % -------------------------------------------------------------------- |
---|
| 2318 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
| 2319 | global Series |
---|
[596] | 2320 | [Series,errormsg]=prepare_jobs(handles); |
---|
[358] | 2321 | |
---|
[446] | 2322 | evalin('base','global Series')%make CurData global in the workspace |
---|
| 2323 | display('current series config :') |
---|
| 2324 | evalin('base','Series') %display CurData in the workspace |
---|
| 2325 | commandwindow; %brings the Matlab command window to the front |
---|
[472] | 2326 | |
---|
| 2327 | |
---|
| 2328 | % --- Executes on selection change in RunMode. |
---|
| 2329 | function RunMode_Callback(hObject, eventdata, handles) |
---|
[525] | 2330 | |
---|
[526] | 2331 | % --- Executes on selection change in Coord_x. |
---|
| 2332 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[525] | 2333 | |
---|
| 2334 | |
---|
[526] | 2335 | % --- Executes on selection change in Coord_y. |
---|
| 2336 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
[525] | 2337 | |
---|
| 2338 | |
---|
| 2339 | |
---|
[526] | 2340 | % --- Executes when series is resized. |
---|
| 2341 | function series_ResizeFcn(hObject, eventdata, handles) |
---|
| 2342 | %% input table |
---|
| 2343 | set(handles.InputTable,'Unit','pixel') |
---|
| 2344 | Pos=get(handles.InputTable,'Position'); |
---|
| 2345 | set(handles.InputTable,'Unit','normalized') |
---|
| 2346 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52)); |
---|
| 2347 | ColumnWidth=num2cell(ColumnWidth); |
---|
| 2348 | set(handles.InputTable,'ColumnWidth',ColumnWidth) |
---|
| 2349 | |
---|
| 2350 | %% MinIndex and MaxIndex |
---|
| 2351 | set(handles.MinIndex,'Unit','pixel') |
---|
| 2352 | Pos=get(handles.MinIndex,'Position'); |
---|
| 2353 | set(handles.MinIndex,'Unit','normalized') |
---|
| 2354 | ColumnWidth=get(handles.MinIndex,'ColumnWidth'); |
---|
| 2355 | if numel(ColumnWidth)==2 |
---|
| 2356 | ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20))); |
---|
| 2357 | else |
---|
| 2358 | ColumnWidth={Pos(3)-5}; |
---|
| 2359 | end |
---|
| 2360 | set(handles.MinIndex,'ColumnWidth',ColumnWidth) |
---|
| 2361 | set(handles.MaxIndex,'ColumnWidth',ColumnWidth) |
---|
| 2362 | |
---|
| 2363 | %% TimeTable |
---|
| 2364 | set(handles.TimeTable,'Unit','pixel') |
---|
| 2365 | Pos=get(handles.TimeTable,'Position'); |
---|
| 2366 | set(handles.TimeTable,'Unit','normalized') |
---|
| 2367 | ColumnWidth=get(handles.TimeTable,'ColumnWidth'); |
---|
| 2368 | ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20))); |
---|
| 2369 | set(handles.TimeTable,'ColumnWidth',ColumnWidth) |
---|
| 2370 | |
---|
| 2371 | |
---|
| 2372 | %% PairString |
---|
| 2373 | set(handles.PairString,'Unit','pixel') |
---|
| 2374 | Pos=get(handles.PairString,'Position'); |
---|
| 2375 | set(handles.PairString,'Unit','normalized') |
---|
| 2376 | set(handles.PairString,'ColumnWidth',{Pos(3)-5}) |
---|
[586] | 2377 | |
---|
| 2378 | |
---|
| 2379 | % --- Executes on button press in status. |
---|
| 2380 | function status_Callback(hObject, eventdata, handles) |
---|
[591] | 2381 | |
---|
[595] | 2382 | if get(handles.status,'Value') |
---|
| 2383 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 2384 | drawnow |
---|
| 2385 | StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch |
---|
| 2386 | Param=read_GUI(handles.series); |
---|
| 2387 | RootPath=Param.InputTable{1,1}; |
---|
| 2388 | OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files |
---|
| 2389 | OutputDir=fullfile(RootPath,OutputSubDir); |
---|
| 2390 | hfig=findobj(allchild(0),'name','series_status'); |
---|
| 2391 | if isempty(hfig) |
---|
| 2392 | hfig=figure('DeleteFcn',@stop_status); |
---|
| 2393 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 2394 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
| 2395 | set(hfig,'name','series_status') |
---|
| 2396 | set(hfig,'tag','series_status') |
---|
| 2397 | uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @view_file,'tag','list','UserData',OutputDir); |
---|
| 2398 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',OutputDir); |
---|
| 2399 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
| 2400 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status); |
---|
| 2401 | hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI); |
---|
| 2402 | set(hrefresh,'UserData',StatusData) |
---|
| 2403 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 2404 | uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 2405 | drawnow |
---|
| 2406 | end |
---|
| 2407 | refresh_GUI(hrefresh,[]) |
---|
| 2408 | else |
---|
| 2409 | %% delete current display fig if selection is off |
---|
[586] | 2410 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
| 2411 | hfig=findobj(allchild(0),'name','series_status'); |
---|
| 2412 | if ~isempty(hfig) |
---|
| 2413 | delete(hfig) |
---|
| 2414 | end |
---|
| 2415 | return |
---|
| 2416 | end |
---|
[595] | 2417 | |
---|
| 2418 | |
---|
| 2419 | %------------------------------------------------------------------------ |
---|
| 2420 | % launched by selecting a file on the list |
---|
| 2421 | function view_file(hObject, eventdata) |
---|
| 2422 | list=get(hObject,'String'); |
---|
| 2423 | index=get(hObject,'Value'); |
---|
| 2424 | rootroot=get(hObject,'UserData'); |
---|
| 2425 | selectname=list{index}; |
---|
| 2426 | ind_dot=regexp(selectname,'\.\.\.'); |
---|
| 2427 | if ~isempty(ind_dot) |
---|
| 2428 | selectname=selectname(1:ind_dot-1); |
---|
[586] | 2429 | end |
---|
[595] | 2430 | FullSelectName=fullfile(rootroot,selectname); |
---|
| 2431 | if exist(FullSelectName,'dir')% a directory has been selected |
---|
| 2432 | ListFiles=dir(FullSelectName); |
---|
| 2433 | ListDisplay=cell(numel(ListFiles),1); |
---|
| 2434 | for ilist=2:numel(ListDisplay)% suppress the first line '.' |
---|
| 2435 | ListDisplay{ilist-1}=ListFiles(ilist).name; |
---|
| 2436 | end |
---|
| 2437 | set(hObject,'Value',1) |
---|
| 2438 | set(hObject,'String',ListDisplay) |
---|
| 2439 | if strcmp(selectname,'..') |
---|
| 2440 | FullSelectName=fileparts(fileparts(FullSelectName)); |
---|
| 2441 | end |
---|
| 2442 | set(hObject,'UserData',FullSelectName) |
---|
| 2443 | hfig=get(hObject,'parent'); |
---|
| 2444 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
| 2445 | set(htitlebox,'String',FullSelectName) |
---|
| 2446 | elseif exist(FullSelectName,'file')%visualise the vel field if it exists |
---|
| 2447 | FileType=get_file_type(FullSelectName); |
---|
| 2448 | if strcmp(FileType,'txt') |
---|
| 2449 | edit(FullSelectName) |
---|
[598] | 2450 | elseif strcmp(FileType,'xml') |
---|
| 2451 | editxml(FullSelectName) |
---|
[595] | 2452 | else |
---|
| 2453 | uvmat(FullSelectName) |
---|
| 2454 | end |
---|
| 2455 | set(gcbo,'Value',1) |
---|
| 2456 | end |
---|
[591] | 2457 | |
---|
[595] | 2458 | |
---|
| 2459 | %------------------------------------------------------------------------ |
---|
| 2460 | |
---|
[591] | 2461 | %------------------------------------------------------------------------ |
---|
| 2462 | % launched by refreshing the status figure |
---|
| 2463 | function refresh_GUI(hObject, eventdata) |
---|
| 2464 | %------------------------------------------------------------------------ |
---|
| 2465 | hfig=get(hObject,'parent'); |
---|
[595] | 2466 | htitlebox=findobj(hfig,'tag','titlebox'); |
---|
[591] | 2467 | hlist=findobj(hfig,'tag','list'); |
---|
[595] | 2468 | OutputDir=get(htitlebox,'String'); |
---|
[591] | 2469 | ListFiles=dir(OutputDir); |
---|
| 2470 | ListDisplay=cell(numel(ListFiles),1); |
---|
[595] | 2471 | for ilist=2:numel(ListDisplay) |
---|
| 2472 | ListDisplay{ilist-1}=ListFiles(ilist).name; |
---|
[591] | 2473 | end |
---|
| 2474 | set(hlist,'String',ListDisplay) |
---|
| 2475 | % civ_files=get(hfig,'UserData'); |
---|
| 2476 | |
---|
| 2477 | % [filepath,filename,ext]=fileparts(civ_files{1}); |
---|
| 2478 | % [tild,SubDir,extdir]=fileparts(filepath); |
---|
| 2479 | % SubDir=[SubDir extdir]; |
---|
| 2480 | % option_civ=StatusData.option_civ; |
---|
| 2481 | % nbfiles=numel(civ_files); |
---|
| 2482 | % testrecent=0; |
---|
| 2483 | % count=0; |
---|
| 2484 | % datnum=zeros(1,nbfiles); |
---|
| 2485 | % filefound=cell(1,nbfiles); |
---|
| 2486 | % for ifile=1:nbfiles |
---|
| 2487 | % detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
| 2488 | % option=0; |
---|
| 2489 | % if detect==0 |
---|
| 2490 | % option_str='not created'; |
---|
| 2491 | % else |
---|
| 2492 | % datfile=dir(civ_files{ifile}); |
---|
| 2493 | % if isfield(datfile,'datenum') |
---|
| 2494 | % datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 2495 | % testrecent=1; |
---|
| 2496 | % end |
---|
| 2497 | % filefound(ifile)={datfile.name}; |
---|
| 2498 | % |
---|
| 2499 | % % check the content netcdf file |
---|
| 2500 | % Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); |
---|
| 2501 | % option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 2502 | % if ~isempty(Data.CivStage) |
---|
| 2503 | % option=Data.CivStage;%case of Matlab civ |
---|
| 2504 | % else |
---|
| 2505 | % if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 2506 | % option=6; |
---|
| 2507 | % elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 2508 | % option=5; |
---|
| 2509 | % elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 2510 | % option=4; |
---|
| 2511 | % elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 2512 | % option=3; |
---|
| 2513 | % elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 2514 | % option=2; |
---|
| 2515 | % else |
---|
| 2516 | % option=1; |
---|
| 2517 | % end |
---|
| 2518 | % end |
---|
| 2519 | % option_str=option_list{option}; |
---|
| 2520 | % if datnum(ifile)<StatusData.time_ref |
---|
| 2521 | % option_str=[option_str ' --OLD--']; |
---|
| 2522 | % end |
---|
| 2523 | % end |
---|
| 2524 | % if option >= option_civ |
---|
| 2525 | % count=count+1; |
---|
| 2526 | % end |
---|
| 2527 | % [filepath,filename,ext]=fileparts(civ_files{ifile}); |
---|
| 2528 | % Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; |
---|
| 2529 | % end |
---|
| 2530 | % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 2531 | % if isempty(datnum) |
---|
| 2532 | % if testrecent |
---|
| 2533 | % message='no civ result created yet'; |
---|
| 2534 | % else |
---|
| 2535 | % message=''; |
---|
| 2536 | % end |
---|
| 2537 | % else |
---|
| 2538 | % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 2539 | % [first,ind]=min(datnum); |
---|
| 2540 | % [last,indlast]=max(datnum); |
---|
| 2541 | % message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 2542 | % ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 2543 | % end |
---|
| 2544 | % hlist=findobj(hfig,'tag','list'); |
---|
[595] | 2545 | % htitlebox=findobj(hfig,'tag','titlebox'); |
---|
[591] | 2546 | % hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 2547 | % set(hlist,'String',Tabchar) |
---|
[595] | 2548 | % set(htitlebox,'String', message) |
---|
[591] | 2549 | % if count>0 %&& ~test_new |
---|
| 2550 | % BarPosition(3)=0.9*count/nbfiles; |
---|
| 2551 | % set(hwaitbar,'Position',BarPosition) |
---|
| 2552 | % end |
---|
| 2553 | %------------------------------------------------------------------------ |
---|
| 2554 | % launched by deleting the status figure |
---|
| 2555 | function stop_status(hObject, eventdata) |
---|
| 2556 | %------------------------------------------------------------------------ |
---|
| 2557 | hciv=findobj(allchild(0),'tag','series'); |
---|
| 2558 | hhciv=guidata(hciv); |
---|
| 2559 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 2560 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
| 2561 | delete(gcbf) |
---|
| 2562 | |
---|
| 2563 | % --- Executes on selection change in ActionExt. |
---|
| 2564 | function ActionExt_Callback(hObject, eventdata, handles) |
---|
| 2565 | ActionExtList=get(handles.ActionExt,'String'); |
---|
| 2566 | ActionExt=ActionExtList{get(handles.ActionExt,'Value')}; |
---|
| 2567 | ActionList=get(handles.ActionName,'String'); |
---|
| 2568 | ActionName=ActionList{get(handles.ActionName,'Value')}; |
---|
| 2569 | if strcmp(ActionExt,'.sh') |
---|
[594] | 2570 | ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']); |
---|
[591] | 2571 | if ~exist(ActionFullName,'file') |
---|
| 2572 | answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?'); |
---|
| 2573 | if strcmp(answer,'Yes') |
---|
| 2574 | currentdir=pwd; |
---|
| 2575 | cd(get(handles.ActionPath,'String')) |
---|
| 2576 | compile(ActionName) |
---|
| 2577 | cd(currentdir) |
---|
| 2578 | end |
---|
| 2579 | end |
---|
[594] | 2580 | currentdir=pwd; |
---|
| 2581 | cd(get(handles.ActionPath,'String')) |
---|
| 2582 | sh_file=dir([ActionName '.sh']); |
---|
| 2583 | m_file=dir([ActionName '.m']); |
---|
| 2584 | if isfield(m_file,'datenum') && m_file.datenum>sh_file.datenum |
---|
| 2585 | set(handles.ActionExt,'BackgroundColor',[1 1 0]) |
---|
[595] | 2586 | drawnow |
---|
[594] | 2587 | answer=msgbox_uvmat('INPUT_Y-N',[ActionName '.sh needs to be updated: recompile now?']); |
---|
| 2588 | if strcmp(answer,'Yes') |
---|
| 2589 | compile(ActionName) |
---|
| 2590 | end |
---|
| 2591 | set(handles.ActionExt,'BackgroundColor',[1 1 1]) |
---|
| 2592 | end |
---|
| 2593 | cd(currentdir) |
---|
[591] | 2594 | end |
---|
| 2595 | |
---|
| 2596 | |
---|
| 2597 | function ActionInput_Callback(hObject, eventdata, handles) |
---|
| 2598 | |
---|
| 2599 | |
---|
| 2600 | % --- Executes on button press in DeleteObject. |
---|
| 2601 | function DeleteObject_Callback(hObject, eventdata, handles) |
---|
| 2602 | if get(handles.DeleteObject,'Value') |
---|
| 2603 | SeriesData=get(handles.series,'UserData'); |
---|
| 2604 | SeriesData.ProjObject=[]; |
---|
| 2605 | set(handles.series,'UserData',SeriesData) |
---|
| 2606 | set(handles.ProjObject,'String','') |
---|
| 2607 | set(handles.CheckObject,'Value',0) |
---|
| 2608 | set(handles.DeleteObject,'Visible','off') |
---|
| 2609 | set(handles.ViewObject,'Visible','off') |
---|
| 2610 | end |
---|
| 2611 | |
---|
| 2612 | % --- Executes on button press in ViewObject. |
---|
| 2613 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
| 2614 | if get(handles.ViewObject,'Value') |
---|
| 2615 | UserData=get(handles.series,'UserData'); |
---|
| 2616 | set_object(UserData.ProjObject) |
---|
| 2617 | else |
---|
| 2618 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 2619 | if ~isempty(hset_object) |
---|
| 2620 | delete(hset_object) |
---|
| 2621 | end |
---|
| 2622 | end |
---|
| 2623 | |
---|
| 2624 | |
---|
| 2625 | function num_NbProcess_Callback(hObject, eventdata, handles) |
---|
| 2626 | |
---|
| 2627 | |
---|
| 2628 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
| 2629 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
| 2630 | set(handles.num_NbProcess,'String',num2str(NbSlice)) |
---|
[598] | 2631 | |
---|
| 2632 | |
---|