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