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