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