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