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