[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 | %-------------------------------------------------------------------------- |
---|
| 61 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
[205] | 62 | global nb_builtin_ACTION nb_builtin_transform |
---|
[2] | 63 | % Choose default command line output for series |
---|
| 64 | handles.output = hObject; |
---|
| 65 | % Update handles structure |
---|
| 66 | guidata(hObject, handles); |
---|
| 67 | %default initial parameters |
---|
[156] | 68 | drawnow |
---|
[244] | 69 | set(hObject,'Units','pixels') |
---|
[526] | 70 | set(handles.PairString,'ColumnName',{'pairs'}) |
---|
[408] | 71 | set(handles.PairString,'ColumnEditable',logical(0)) |
---|
| 72 | set(handles.PairString,'ColumnFormat',{'char'}) |
---|
| 73 | set(handles.PairString,'Data',{''}) |
---|
[526] | 74 | series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size |
---|
[332] | 75 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
[2] | 76 | dir_perso=prefdir; |
---|
[205] | 77 | test_profil_perso=0; |
---|
[2] | 78 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 79 | if exist(profil_perso,'file') |
---|
| 80 | h=load (profil_perso); |
---|
[460] | 81 | if isfield(h,'MenuFile') |
---|
| 82 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 83 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 84 | end |
---|
| 85 | end |
---|
[205] | 86 | test_profil_perso=1; |
---|
[2] | 87 | end |
---|
| 88 | |
---|
| 89 | %check default input data |
---|
| 90 | if ~exist('param','var') |
---|
| 91 | param=[]; %default |
---|
| 92 | end |
---|
| 93 | |
---|
[376] | 94 | %% file name and browser initialisation |
---|
[526] | 95 | if isfield(param,'transform_str') |
---|
| 96 | set(handles.TransformName,'String',param.transform_str) |
---|
[2] | 97 | end |
---|
[526] | 98 | if isfield(param,'transform_val') |
---|
| 99 | set(handles.TransformName,'Value',param.transform_val); |
---|
[2] | 100 | else |
---|
[446] | 101 | set(handles.TransformName,'Value',1);%default |
---|
[2] | 102 | end |
---|
| 103 | if isfield(param,'FileName') |
---|
[476] | 104 | InputTable={'','','','',''}; |
---|
| 105 | set(handles.InputTable,'Data',InputTable) |
---|
[2] | 106 | if isfield(param,'FileName_1') |
---|
[408] | 107 | display_file_name(handles,param.FileName_1,0) |
---|
| 108 | display_file_name(handles,param.FileName,1) |
---|
[2] | 109 | else |
---|
[408] | 110 | display_file_name(handles,param.FileName,0) |
---|
[2] | 111 | end |
---|
| 112 | end |
---|
[523] | 113 | if isfield(param,'incr_i') |
---|
| 114 | set(handles.num_incr_i,'String',num2str(param.incr_i)) |
---|
| 115 | end |
---|
| 116 | if isfield(param,'incr_j') |
---|
| 117 | set(handles.num_incr_j,'String',num2str(param.incr_j)) |
---|
| 118 | end |
---|
[2] | 119 | |
---|
[376] | 120 | %% fields input initialisation |
---|
[2] | 121 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
[446] | 122 | set(handles.FieldName,'String',param.list_fields);% list menu fields |
---|
| 123 | set(handles.FieldName,'Value',param.index_fields);% selected string index |
---|
[2] | 124 | end |
---|
[526] | 125 | if isfield(param,'Coord_x_str')&& isfield(param,'Coord_x_val') |
---|
| 126 | set(handles.Coord_x,'String',param.Coord_x_str);% list menu fields |
---|
| 127 | set(handles.Coord_x,'Value',param.Coord_x_val);% selected string index |
---|
| 128 | end |
---|
| 129 | if isfield(param,'Coord_y_str')&& isfield(param,'Coord_y_val') |
---|
| 130 | set(handles.Coord_y,'String',param.Coord_y_str);% list menu fields |
---|
| 131 | set(handles.Coord_y,'Value',param.Coord_y_val);% selected string index |
---|
| 132 | end |
---|
[376] | 133 | |
---|
[446] | 134 | %loads the information stored in prefdir to initiate the list of ActionName functions |
---|
[329] | 135 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
[38] | 136 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
[205] | 137 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
[38] | 138 | nb_transform=numel(transform_menu); |
---|
[26] | 139 | [path_series,name,ext]=fileparts(which('series')); |
---|
[34] | 140 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
[332] | 141 | addpath (path_series) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[276] | 142 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
[38] | 143 | for ilist=1:length(fct_menu) |
---|
[2] | 144 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
| 145 | end |
---|
[39] | 146 | |
---|
[376] | 147 | %% TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
[523] | 148 | menu_str={'';'sub_field';'phys';'phys_polar'}; |
---|
[205] | 149 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
[39] | 150 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
| 151 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
| 152 | fct_handle{1,1}=[]; |
---|
| 153 | testexist(1)=1; |
---|
| 154 | for ilist=2:length(menu_str) |
---|
| 155 | if exist(menu_str{ilist},'file') |
---|
| 156 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
| 157 | testexist(ilist)=1; |
---|
| 158 | else |
---|
| 159 | testexist(ilist)=0; |
---|
| 160 | end |
---|
[38] | 161 | end |
---|
[39] | 162 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
| 163 | |
---|
[523] | 164 | %% read the list of transform functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
[205] | 165 | if test_profil_perso |
---|
[2] | 166 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
| 167 | for ilist=1:length(h.series_fct) |
---|
| 168 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
| 169 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
[205] | 170 | fct_menu=[fct_menu; {file}]; |
---|
[2] | 171 | end |
---|
| 172 | end |
---|
[38] | 173 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
[39] | 174 | for ilist=1:length(h.transform_fct); |
---|
[38] | 175 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
[39] | 176 | addpath(path) |
---|
| 177 | if exist(file,'file') |
---|
| 178 | h_func=str2func(file); |
---|
| 179 | testexist=[testexist 1]; |
---|
| 180 | else |
---|
| 181 | h_func=[]; |
---|
| 182 | testexist=[testexist 0]; |
---|
| 183 | end |
---|
| 184 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
| 185 | rmpath(path) |
---|
| 186 | menu_str=[menu_str; {file}]; |
---|
| 187 | end |
---|
[38] | 188 | end |
---|
[2] | 189 | end |
---|
[38] | 190 | fct_menu=[fct_menu;{'more...'}]; |
---|
[446] | 191 | set(handles.ActionName,'String',fct_menu) |
---|
| 192 | set(handles.ActionName,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
[39] | 193 | menu_str=menu_str(find(testexist)); |
---|
| 194 | fct_handle=fct_handle(find(testexist)); |
---|
| 195 | menu_str=[menu_str;{'more...'}]; |
---|
[446] | 196 | set(handles.TransformName,'String',menu_str) |
---|
| 197 | set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
[39] | 198 | |
---|
[472] | 199 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
| 200 | path_uvmat=fileparts(which('uvmat')); %path to civ |
---|
| 201 | 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) |
---|
| 202 | errormsg=[];%default error message |
---|
| 203 | xmlfile='PARAM.xml'; |
---|
| 204 | if exist(xmlfile,'file') |
---|
| 205 | try |
---|
| 206 | t=xmltree(xmlfile); |
---|
| 207 | sparam=convert(t); |
---|
| 208 | catch ME |
---|
| 209 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; |
---|
| 210 | end |
---|
| 211 | else |
---|
| 212 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
| 213 | end |
---|
| 214 | if ~isempty(errormsg) |
---|
| 215 | msgbox_uvmat('WARNING',errormsg); |
---|
| 216 | end |
---|
| 217 | test_batch=0;%default: ,no batch mode available |
---|
| 218 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 219 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 220 | end |
---|
| 221 | RUNVal=get(handles.RunMode,'Value'); |
---|
| 222 | if test_batch==0 |
---|
| 223 | if RUNVal>2 |
---|
| 224 | set(handles.RunMode,'Value',1) |
---|
| 225 | end |
---|
| 226 | set(handles.RunMode,'String',{'local';'background'}) |
---|
| 227 | else |
---|
| 228 | set(handles.RunMode,'String',{'local';'background';'cluster'}) |
---|
| 229 | end |
---|
[2] | 230 | |
---|
[408] | 231 | %------------------------------------------------------------------------ |
---|
[2] | 232 | % --- Outputs from this function are returned to the command line. |
---|
| 233 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
[408] | 234 | %------------------------------------------------------------------------ |
---|
[2] | 235 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 236 | % hObject handle to figure |
---|
| 237 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 238 | % handles structure with handles and user data (see GUIDATA) |
---|
| 239 | % Get default command line output from handles structure |
---|
| 240 | varargout{1} = handles.output; |
---|
| 241 | |
---|
[408] | 242 | %------------------------------------------------------------------------ |
---|
| 243 | %------------------------------------------------------------------------ |
---|
| 244 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 245 | % automatically sets the global properties when the rootfile name is introduced |
---|
[446] | 246 | % then activate the view-field actionname if selected |
---|
[408] | 247 | % it is activated either by clicking on the RootPath window or by the |
---|
| 248 | % browser |
---|
| 249 | %------------------------------------------------------------------------ |
---|
| 250 | %------------------------------------------------------------------------ |
---|
[2] | 251 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
[408] | 252 | %------------------------------------------------------------------------ |
---|
[350] | 253 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 254 | if isempty(InputTable) |
---|
| 255 | RootPathCell={}; |
---|
| 256 | else |
---|
| 257 | RootPathCell=InputTable(:,1); |
---|
| 258 | end |
---|
[2] | 259 | oldfile=''; %default |
---|
[329] | 260 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 261 | dir_perso=prefdir; |
---|
| 262 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 263 | if exist(profil_perso,'file') |
---|
| 264 | h=load (profil_perso); |
---|
[329] | 265 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
[2] | 266 | oldfile=h.filebase; |
---|
| 267 | end |
---|
[329] | 268 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
[2] | 269 | oldfile=h.RootPath; |
---|
| 270 | end |
---|
| 271 | end |
---|
[472] | 272 | else |
---|
| 273 | SubDirCell=InputTable(:,2); |
---|
| 274 | RootFileCell=InputTable(:,3); |
---|
[2] | 275 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
| 276 | end |
---|
| 277 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 278 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 279 | '*.xml', '.xml files '; ... |
---|
| 280 | '*.xls', '.xls files '; ... |
---|
| 281 | '*.png','.png image files'; ... |
---|
| 282 | '*.tif','.tif image files'; ... |
---|
| 283 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 284 | '*.nc','.netcdf files'; ... |
---|
| 285 | '*.*', 'All Files (*.*)'}, ... |
---|
| 286 | 'Pick a file',oldfile); |
---|
| 287 | fileinput=[PathName FileName];%complete file name |
---|
[472] | 288 | if isempty(fileinput),return;end %abandon if no file is introduced by the browser |
---|
[2] | 289 | [path,name,ext]=fileparts(fileinput); |
---|
| 290 | if isequal(ext,'.xml') |
---|
[472] | 291 | [Param,Heading]=xml2struct(fileinput); |
---|
| 292 | if ~strcmp(Heading,'Series') |
---|
| 293 | msg_box_uvmat('ERROR','xml file heading is not <Series>') |
---|
| 294 | else |
---|
| 295 | fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file |
---|
| 296 | if isfield(Param,'CheckObject')&& Param.CheckObject |
---|
| 297 | set_object(Param.ProjObject) |
---|
| 298 | end |
---|
| 299 | set(handles.REFRESH,'UserData',[1:size(Param.InputTable,1)]) |
---|
| 300 | REFRESH_Callback([],[], handles) |
---|
| 301 | return |
---|
[463] | 302 | end |
---|
[2] | 303 | elseif isequal(ext,'.xls') |
---|
[408] | 304 | msg_box_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 305 | else |
---|
[408] | 306 | display_file_name(handles,fileinput,0) |
---|
[2] | 307 | end |
---|
| 308 | |
---|
| 309 | % -------------------------------------------------------------------- |
---|
| 310 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 311 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[408] | 312 | display_file_name(handles,fileinput,0) |
---|
[2] | 313 | |
---|
| 314 | % -------------------------------------------------------------------- |
---|
| 315 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 316 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[408] | 317 | display_file_name(handles,fileinput,0) |
---|
[2] | 318 | |
---|
| 319 | % -------------------------------------------------------------------- |
---|
| 320 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 321 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[408] | 322 | display_file_name( handles,fileinput,0) |
---|
[2] | 323 | |
---|
| 324 | % -------------------------------------------------------------------- |
---|
| 325 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 326 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[408] | 327 | display_file_name(handles,fileinput,0) |
---|
[2] | 328 | |
---|
| 329 | % -------------------------------------------------------------------- |
---|
| 330 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 331 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[408] | 332 | display_file_name(handles,fileinput,0) |
---|
[2] | 333 | |
---|
| 334 | % -------------------------------------------------------------------- |
---|
| 335 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
[350] | 336 | InputTable=get(handles.InputTable,'Data'); |
---|
| 337 | RootPathCell=InputTable(:,1); |
---|
| 338 | SubDirCell=InputTable(:,3); |
---|
| 339 | RootFileCell=InputTable(:,2); |
---|
[2] | 340 | oldfile=''; %default |
---|
[206] | 341 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 342 | dir_perso=prefdir; |
---|
| 343 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 344 | if exist(profil_perso,'file') |
---|
| 345 | h=load (profil_perso); |
---|
| 346 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 347 | oldfile=h.filebase; |
---|
| 348 | end |
---|
| 349 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 350 | oldfile=h.RootPath; |
---|
| 351 | end |
---|
| 352 | end |
---|
| 353 | else |
---|
| 354 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
| 355 | end |
---|
| 356 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 357 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
| 358 | '*.xml', '.xml files '; ... |
---|
| 359 | '*.xls', '.xls files '; ... |
---|
| 360 | '*.png','.png image files'; ... |
---|
| 361 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 362 | '*.nc','.netcdf files'; ... |
---|
| 363 | '*.*', 'All Files (*.*)'}, ... |
---|
| 364 | 'Pick a file',oldfile); |
---|
| 365 | fileinput=[PathName FileName];%complete file name |
---|
| 366 | sizf=size(fileinput); |
---|
| 367 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 368 | [path,name,ext]=fileparts(fileinput); |
---|
| 369 | if isequal(ext,'.xml') |
---|
[206] | 370 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 371 | elseif isequal(ext,'.xls') |
---|
[206] | 372 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 373 | else |
---|
[472] | 374 | display_file_name(handles,fileinput,'append') |
---|
[2] | 375 | end |
---|
| 376 | |
---|
| 377 | % -------------------------------------------------------------------- |
---|
| 378 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
[408] | 379 | % -------------------------------------------------------------------- |
---|
[2] | 380 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
[472] | 381 | display_file_name(handles,fileinput,'append') |
---|
[2] | 382 | |
---|
| 383 | % -------------------------------------------------------------------- |
---|
| 384 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
[408] | 385 | % -------------------------------------------------------------------- |
---|
[2] | 386 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
[472] | 387 | display_file_name(handles,fileinput,'append') |
---|
[2] | 388 | |
---|
| 389 | % -------------------------------------------------------------------- |
---|
| 390 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
[408] | 391 | % -------------------------------------------------------------------- |
---|
[2] | 392 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
[472] | 393 | display_file_name( handles,fileinput,'append') |
---|
[2] | 394 | |
---|
| 395 | % -------------------------------------------------------------------- |
---|
| 396 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
[408] | 397 | % -------------------------------------------------------------------- |
---|
[2] | 398 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
[472] | 399 | display_file_name( handles,fileinput,'append') |
---|
[2] | 400 | |
---|
| 401 | % -------------------------------------------------------------------- |
---|
| 402 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
[408] | 403 | % -------------------------------------------------------------------- |
---|
[2] | 404 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
[472] | 405 | display_file_name(handles,fileinput,'append') |
---|
[2] | 406 | |
---|
[89] | 407 | %------------------------------------------------------------------------ |
---|
[408] | 408 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
| 409 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
| 410 | %------------------------------------------------------------------------ |
---|
[472] | 411 | set(handles.REFRESH,'Visible','on') |
---|
[408] | 412 | iview=eventdata.Indices(1); |
---|
[472] | 413 | view_set=get(handles.REFRESH,'UserData'); |
---|
| 414 | if isempty(find(view_set==iview)) |
---|
| 415 | set(handles.REFRESH,'UserData',[view_set iview]) |
---|
| 416 | end |
---|
| 417 | %% enable other menus and uicontrols |
---|
| 418 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 419 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 420 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 421 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 422 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 423 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 424 | set(handles.RUN, 'Enable','On') |
---|
| 425 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
| 426 | |
---|
| 427 | %update the output dir |
---|
| 428 | % SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order |
---|
| 429 | % SubDirOut=SubDir{1}; |
---|
| 430 | % if numel(SubDir)>1 |
---|
| 431 | % for ilist=2:numel(SubDir) |
---|
| 432 | % SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 433 | % end |
---|
| 434 | % end |
---|
| 435 | % set(handles.OutputSubDir,'String',SubDirOut) |
---|
| 436 | |
---|
| 437 | %------------------------------------------------------------------------ |
---|
| 438 | % --- Executes on button press in REFRESH. |
---|
| 439 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
| 440 | %------------------------------------------------------------------------ |
---|
[408] | 441 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 442 | view_set=get(handles.REFRESH,'UserData'); |
---|
| 443 | set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])% set REFRESH button to grey color |
---|
| 444 | drawnow |
---|
| 445 | for iview=view_set |
---|
| 446 | RootPath=fullfile(InputTable{iview,1},InputTable{iview,2}); |
---|
| 447 | if ~exist(RootPath,'dir') |
---|
| 448 | i1_series=[]; |
---|
| 449 | RootPath=fileparts(RootPath); %will try the upped forldr |
---|
| 450 | else |
---|
| 451 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=... |
---|
| 452 | find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]); |
---|
[446] | 453 | end |
---|
[472] | 454 | if isempty(i1_series) |
---|
| 455 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 456 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 457 | '*.xml', '.xml files '; ... |
---|
| 458 | '*.xls', '.xls files '; ... |
---|
| 459 | '*.png','.png image files'; ... |
---|
| 460 | '*.tif','.tif image files'; ... |
---|
| 461 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 462 | '*.nc','.netcdf files'; ... |
---|
| 463 | '*.*', 'All Files (*.*)'}, ... |
---|
| 464 | ['unvalid entry at line ' num2str(iview) ', pick a file'],RootPath); |
---|
| 465 | fileinput=[PathName FileName];%complete file name |
---|
| 466 | if isempty(fileinput),return;end %abandon if the operation has been cancelled: no input from browser |
---|
| 467 | [path,name,ext]=fileparts(fileinput); |
---|
| 468 | display_file_name(handles,fileinput,iview) |
---|
| 469 | else |
---|
| 470 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview) |
---|
| 471 | end |
---|
[446] | 472 | end |
---|
[472] | 473 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set REFRESH button to grey color |
---|
| 474 | set(handles.REFRESH,'Visible','off') |
---|
| 475 | set(handles.REFRESH,'UserData',[]) |
---|
[408] | 476 | |
---|
| 477 | %------------------------------------------------------------------------ |
---|
[472] | 478 | % --- Function called when a new file is opened, either by series_OpeningFcn or by the browser |
---|
| 479 | function display_file_name(handles,fileinput,iview) |
---|
| 480 | %------------------------------------------------------------------------ |
---|
| 481 | % |
---|
[332] | 482 | % INPUT: |
---|
[472] | 483 | % handles: handles of elements in the GUI |
---|
| 484 | % fielinput: input file name, including path |
---|
| 485 | % append =0 (refresh the Input table with the new file), ='append' append a new line in the table |
---|
[332] | 486 | |
---|
[408] | 487 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
| 488 | if ~exist(fileinput,'file') |
---|
| 489 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 490 | return |
---|
| 491 | end |
---|
| 492 | |
---|
[332] | 493 | %% enable other menus and uicontrols |
---|
| 494 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 495 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 496 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 497 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 498 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 499 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 500 | set(handles.RUN, 'Enable','On') |
---|
| 501 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
[350] | 502 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
[332] | 503 | drawnow |
---|
| 504 | |
---|
[408] | 505 | %% detect root name, nomenclature and indices in the input file name: |
---|
| 506 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
| 507 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 508 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 509 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
| 510 | if isempty(RootFile)&&isempty(i1_series) |
---|
| 511 | errormsg='no input file in the series'; |
---|
[29] | 512 | return |
---|
| 513 | end |
---|
[89] | 514 | |
---|
[376] | 515 | %% fill the list of file series |
---|
| 516 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 517 | if strcmp(iview,'append') % display the input data as a new line in the table |
---|
| 518 | iview=size(InputTable,1); |
---|
| 519 | InputTable(iview+1,:)={'','','','',''}; |
---|
| 520 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
| 521 | elseif iview==0 % or re-initialise the list of input file series |
---|
| 522 | iview=1; |
---|
| 523 | InputTable=[{'','','','',''};{'','','','',''}]; |
---|
| 524 | InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; |
---|
[376] | 525 | set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) |
---|
| 526 | set(handles.MinIndex,'Data',[{[]},{[]}]) |
---|
| 527 | set(handles.MaxIndex,'Data',[{[]},{[]}]) |
---|
[408] | 528 | set(handles.ListView,'Value',1) |
---|
| 529 | set(handles.ListView,'String',{'1'}) |
---|
[376] | 530 | end |
---|
[472] | 531 | nbview=size(InputTable,1); |
---|
| 532 | set(handles.ListView,'String',mat2cell((1:nbview)',ones(nbview,1))) |
---|
| 533 | set(handles.ListView,'Value',iview) |
---|
[376] | 534 | set(handles.InputTable,'Data',InputTable) |
---|
| 535 | |
---|
[472] | 536 | %% determine the selected reference field indices for pair display |
---|
| 537 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
| 538 | if ~isempty(i1) |
---|
| 539 | ref_i=i1; |
---|
| 540 | if ~isempty(i2) |
---|
| 541 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
| 542 | end |
---|
| 543 | end |
---|
| 544 | set(handles.num_ref_i,'String',num2str(ref_i)); |
---|
| 545 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
| 546 | if ~isempty(j1) |
---|
| 547 | ref_j=j1; |
---|
| 548 | if ~isempty(j2) |
---|
| 549 | ref_j=floor((j1+j2)/2); |
---|
| 550 | end |
---|
| 551 | end |
---|
| 552 | set(handles.num_ref_j,'String',num2str(ref_j)); |
---|
| 553 | |
---|
| 554 | %% update the list of recent files in the menubar and save it for future opening |
---|
| 555 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 556 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 557 | str_find=strcmp(fileinput,MenuFile); |
---|
| 558 | if isempty(find(str_find,1)) |
---|
| 559 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
| 560 | end |
---|
| 561 | for ifile=1:min(length(MenuFile),5) |
---|
| 562 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 563 | eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 564 | end |
---|
| 565 | dir_perso=prefdir; |
---|
| 566 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 567 | if exist(profil_perso,'file') |
---|
| 568 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 569 | else |
---|
| 570 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
| 571 | end |
---|
| 572 | |
---|
| 573 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
| 574 | |
---|
| 575 | %% initiate input file series and refresh the current field view: |
---|
| 576 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,iview); |
---|
| 577 | |
---|
| 578 | %------------------------------------------------------------------------ |
---|
| 579 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 580 | % calibration from an xml file |
---|
| 581 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,iview) |
---|
| 582 | %------------------------------------------------------------------------ |
---|
| 583 | %% update the output dir |
---|
| 584 | InputTable=get(handles.InputTable,'Data'); |
---|
| 585 | SubDir=sort(InputTable(1:end-1,2)); %set of subdirectories sorted in alphabetical order |
---|
| 586 | SubDirOut=SubDir{1}; |
---|
| 587 | if numel(SubDir)>1 |
---|
| 588 | for ilist=2:numel(SubDir) |
---|
| 589 | SubDirOut=[SubDirOut '-' SubDir{ilist}]; |
---|
| 590 | end |
---|
| 591 | end |
---|
| 592 | set(handles.OutputSubDir,'String',SubDirOut) |
---|
| 593 | |
---|
[521] | 594 | %% display the min and max indices for the file series |
---|
[554] | 595 | if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0 |
---|
[526] | 596 | MinIndex_j=1; |
---|
[554] | 597 | MaxIndex_j=1; |
---|
| 598 | MinIndex_i=find(i1_series(:,2,:), 1 )-1; |
---|
| 599 | MaxIndex_i=find(i1_series(:,2,:), 1, 'last' )-1; |
---|
[526] | 600 | else |
---|
[554] | 601 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
| 602 | j_max=max(pair_max,[],1); |
---|
| 603 | %i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index |
---|
| 604 | MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i |
---|
| 605 | MinIndex_i=find(j_max, 1 )-1;% min ref index i |
---|
| 606 | diff_i_max=diff(j_max); |
---|
[526] | 607 | if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) |
---|
| 608 | set(handles.num_incr_i,'String',num2str(diff_i_max(1))) |
---|
| 609 | end |
---|
[554] | 610 | i_max=max(pair_max,[],2); |
---|
| 611 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
| 612 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
| 613 | diff_j_max=diff(i_max); |
---|
[526] | 614 | if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) |
---|
| 615 | set(handles.num_incr_j,'String',num2str(diff_j_max(1))) |
---|
| 616 | end |
---|
| 617 | end |
---|
[460] | 618 | MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex |
---|
| 619 | MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex |
---|
[554] | 620 | if isequal(MinIndex_i,-1) |
---|
| 621 | MinIndex_i=0; |
---|
| 622 | end |
---|
| 623 | if isequal(MinIndex_j,-1) |
---|
| 624 | MinIndex_j=0; |
---|
| 625 | end |
---|
[472] | 626 | MinIndex{iview,1}=MinIndex_i; |
---|
| 627 | MinIndex{iview,2}=MinIndex_j; |
---|
| 628 | MaxIndex{iview,1}=MaxIndex_i; |
---|
| 629 | MaxIndex{iview,2}=MaxIndex_j; |
---|
[460] | 630 | |
---|
| 631 | set(handles.MinIndex,'Data',MinIndex)%display the min indices in the table MinIndex |
---|
| 632 | set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex |
---|
| 633 | |
---|
| 634 | %% adjust the first and last indices if requested by the bounds |
---|
| 635 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 636 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 637 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 638 | if isempty(first_i) |
---|
| 639 | first_i=ref_i; |
---|
| 640 | elseif first_i < MinIndex_i |
---|
| 641 | first_i=MinIndex_i; |
---|
[526] | 642 | elseif first_i >MaxIndex_i |
---|
| 643 | first_i=MinIndex_i; |
---|
[460] | 644 | end |
---|
| 645 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 646 | if isempty(first_j) |
---|
| 647 | first_j=ref_j; |
---|
| 648 | elseif first_j<MinIndex_j |
---|
| 649 | first_j=MinIndex_j; |
---|
[526] | 650 | elseif first_j >MaxIndex_j |
---|
| 651 | first_j=MinIndex_j; |
---|
[460] | 652 | end |
---|
| 653 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 654 | if isempty(last_i) |
---|
| 655 | last_i=ref_i; |
---|
| 656 | elseif last_i > MaxIndex_i |
---|
| 657 | last_i=MaxIndex_i; |
---|
[526] | 658 | elseif last_i<first_i |
---|
| 659 | last_i=first_i; |
---|
[460] | 660 | end |
---|
| 661 | last_j=str2num(get(handles.num_first_j,'String')); |
---|
| 662 | if isempty(last_j) |
---|
| 663 | last_j=ref_j; |
---|
| 664 | elseif last_j>MaxIndex_j |
---|
| 665 | last_j=MaxIndex_j; |
---|
[526] | 666 | elseif last_i<first_i |
---|
| 667 | last_i=first_i; |
---|
[460] | 668 | end |
---|
| 669 | set(handles.num_first_i,'String',num2str(first_i)); |
---|
| 670 | set(handles.num_first_j,'String',num2str(first_j)); |
---|
| 671 | set(handles.num_last_i,'String',num2str(last_i)); |
---|
| 672 | set(handles.num_last_j,'String',num2str(last_j)); |
---|
| 673 | |
---|
[526] | 674 | %% read timing and total frame number from the current file (movie files) may be overrid by xml file |
---|
[408] | 675 | InputTable=get(handles.InputTable,'Data'); |
---|
| 676 | FileBase=fullfile(InputTable{iview,1},InputTable{iview,3}); |
---|
| 677 | time=[];%default |
---|
| 678 | % case of movies |
---|
| 679 | if strcmp(InputTable{iview,4},'*') |
---|
| 680 | if ~isempty(VideoObject) |
---|
| 681 | imainfo=get(VideoObject); |
---|
| 682 | time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
[526] | 683 | % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
[408] | 684 | ColorType='truecolor'; |
---|
| 685 | elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image |
---|
| 686 | if ~isempty(InputTable{iview,2}) |
---|
| 687 | imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}])); |
---|
| 688 | else |
---|
| 689 | imainfo=imfinfo([FileBase InputTable{iview,5}]); |
---|
| 690 | end |
---|
| 691 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 692 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 693 | nbfield=length(imainfo); |
---|
| 694 | nbfield_j=1; |
---|
| 695 | end |
---|
| 696 | end |
---|
| 697 | end |
---|
| 698 | |
---|
| 699 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 700 | XmlData=[]; |
---|
| 701 | NbSlice_calib={}; |
---|
[525] | 702 | XmlFileName=find_imadoc(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5}); |
---|
| 703 | if ~isempty(XmlFileName) |
---|
| 704 | [XmlData,warntext]=imadoc2struct(XmlFileName); |
---|
[408] | 705 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
| 706 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 707 | end |
---|
| 708 | if isfield(XmlData,'Time') |
---|
| 709 | time=XmlData.Time; |
---|
| 710 | end |
---|
| 711 | if isfield(XmlData,'Camera') |
---|
| 712 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 713 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 714 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 715 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 716 | end |
---|
| 717 | end |
---|
| 718 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 719 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 720 | end |
---|
| 721 | end |
---|
| 722 | if ~isempty(warntext) |
---|
| 723 | msgbox_uvmat('WARNING',warntext) |
---|
| 724 | end |
---|
| 725 | end |
---|
| 726 | |
---|
| 727 | %% update time table |
---|
[456] | 728 | if ~isempty(time) |
---|
[523] | 729 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 730 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 731 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 732 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 733 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 734 | MinIndexTable=get(handles.MinIndex,'Data'); |
---|
| 735 | MinIndex_i=MinIndexTable{iview,1}; |
---|
| 736 | MinIndex_j=MinIndexTable{iview,2}; |
---|
| 737 | MaxIndexTable=get(handles.MaxIndex,'Data'); |
---|
| 738 | MaxIndex_i=MaxIndexTable{iview,1}; |
---|
| 739 | MaxIndex_j=MaxIndexTable{iview,2}; |
---|
[553] | 740 | if isempty(MinIndex_j)% only i index |
---|
[523] | 741 | if MinIndex_i>0 |
---|
| 742 | TimeTable{iview,1}=time(MinIndex_i); |
---|
| 743 | end |
---|
| 744 | TimeTable{iview,2}=time(first_i); |
---|
| 745 | TimeTable{iview,3}=time(last_i); |
---|
| 746 | TimeTable{iview,4}=time(MaxIndex_i); |
---|
| 747 | elseif ~isempty(time) |
---|
| 748 | if MinIndex_i>0 |
---|
| 749 | TimeTable{iview,1}=time(MinIndex_i,MinIndex_j); |
---|
| 750 | end |
---|
[554] | 751 | if size(time)>=[last_i last_j] |
---|
| 752 | TimeTable{iview,2}=time(first_i,first_j); |
---|
| 753 | TimeTable{iview,3}=time(last_i,last_j); |
---|
| 754 | end |
---|
[553] | 755 | if size(time)>=[MaxIndex_i MaxIndex_j]; |
---|
[554] | 756 | TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j); |
---|
[553] | 757 | end |
---|
[456] | 758 | end |
---|
[523] | 759 | set(handles.TimeTable,'Data',TimeTable) |
---|
[408] | 760 | end |
---|
| 761 | |
---|
| 762 | %% number of slices |
---|
[460] | 763 | NbSlice=1;%default |
---|
[408] | 764 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 765 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 766 | if siz(1)>1 |
---|
| 767 | NbSlice=siz(1); |
---|
| 768 | end |
---|
| 769 | end |
---|
[450] | 770 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 771 | |
---|
[408] | 772 | %% update pair menus |
---|
[441] | 773 | set(handles.Pairs,'Visible','on') |
---|
| 774 | set(handles.PairString,'Visible','on') |
---|
[408] | 775 | ListView=get(handles.ListView,'String'); |
---|
| 776 | ListView{iview}=num2str(iview); |
---|
[472] | 777 | set(handles.ListView,'String',ListView); |
---|
[408] | 778 | set(handles.ListView,'Value',iview) |
---|
| 779 | update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 780 | |
---|
[472] | 781 | %% update the series info in 'UserData' |
---|
[408] | 782 | SeriesData=get(handles.series,'UserData'); |
---|
| 783 | SeriesData.i1_series{iview}=i1_series; |
---|
| 784 | SeriesData.i2_series{iview}=i2_series; |
---|
| 785 | SeriesData.j1_series{iview}=j1_series; |
---|
| 786 | SeriesData.j2_series{iview}=j2_series; |
---|
| 787 | SeriesData.FileType{iview}=FileType; |
---|
| 788 | SeriesData.Time{iview}=time; |
---|
| 789 | set(handles.series,'UserData',SeriesData) |
---|
| 790 | |
---|
[521] | 791 | %% enable j index visibilitycellfun(@isempty,regexp(PairString,'^j')) |
---|
[553] | 792 | % state='off'; |
---|
[472] | 793 | check_jindex=~cellfun(@isempty,SeriesData.j1_series); %look for non empty j indices |
---|
| 794 | if isempty(find(check_jindex)) |
---|
| 795 | enable_j(handles,'off') % no j index needed |
---|
| 796 | else |
---|
[521] | 797 | PairString=get(handles.PairString,'Data'); |
---|
| 798 | if isempty(find(cellfun(@isempty,regexp(PairString,'^j'))))% if all pair string begins by j (burst) |
---|
| 799 | enable_j(handles,'off') % no j index needed |
---|
| 800 | else |
---|
| 801 | enable_j(handles,'on') |
---|
| 802 | end |
---|
[472] | 803 | end |
---|
| 804 | |
---|
[477] | 805 | %% display the set of existing files as an image |
---|
| 806 | set(handles.FileStatus,'Units','pixels') |
---|
| 807 | Position=get(handles.FileStatus,'Position'); |
---|
| 808 | set(handles.FileStatus,'Units','normalized') |
---|
| 809 | xI=0.5:Position(3)-0.5; |
---|
| 810 | nbview=numel(SeriesData.i1_series); |
---|
[523] | 811 | pair_max=cell(1,nbview); |
---|
[477] | 812 | for iview=1:nbview |
---|
[523] | 813 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
[526] | 814 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
[525] | 815 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
| 816 | end |
---|
[523] | 817 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
| 818 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
[477] | 819 | end |
---|
| 820 | index_min=min(index_min); |
---|
| 821 | index_max=max(index_max); |
---|
| 822 | range_index=index_max-index_min+1; |
---|
| 823 | scale_y=Position(4)/nbview; |
---|
| 824 | scale_x=Position(3)/range_index; |
---|
| 825 | x=(0.5:range_index-0.5)*Position(3)/range_index; |
---|
| 826 | % y=(0.5:nbview-0.5)*Position(4)/nbview; |
---|
| 827 | range_y=max(1,floor(Position(4)/nbview)); |
---|
| 828 | CData=zeros(nbview*range_y,Position(3)); |
---|
| 829 | for iview=1:nbview |
---|
| 830 | ind_y=1+(iview-1)*range_y:iview*range_y; |
---|
| 831 | LineData=zeros(1,range_index); |
---|
[523] | 832 | x_index=find(pair_max{iview}>0)-index_min+1; |
---|
[477] | 833 | LineData(x_index)=1; |
---|
| 834 | LineData=interp1(x,LineData,xI,'nearest'); |
---|
| 835 | CData(ind_y,:)=ones(size(ind_y'))*LineData; |
---|
| 836 | end |
---|
| 837 | CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); |
---|
| 838 | set(handles.FileStatus,'CData',CData); |
---|
| 839 | |
---|
| 840 | |
---|
[472] | 841 | %% enable field and veltype menus, in accordance with the current action |
---|
| 842 | ActionName_Callback([],[], handles) |
---|
| 843 | |
---|
[441] | 844 | %% check for pair display |
---|
| 845 | check_pairs=0; |
---|
| 846 | for iview=1:numel(SeriesData.i2_series) |
---|
| 847 | if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview}) |
---|
| 848 | check_pairs=1; |
---|
| 849 | end |
---|
| 850 | end |
---|
| 851 | if check_pairs |
---|
| 852 | set(handles.Pairs,'Visible','on') |
---|
| 853 | set(handles.PairString,'Visible','on') |
---|
| 854 | else |
---|
| 855 | set(handles.Pairs,'Visible','off') |
---|
| 856 | set(handles.PairString,'Visible','off') |
---|
| 857 | end |
---|
[408] | 858 | |
---|
[477] | 859 | %% set length of waitbar |
---|
| 860 | displ_time(handles) |
---|
| 861 | |
---|
| 862 | |
---|
[525] | 863 | %% set default options in menu 'Fields' |
---|
| 864 | switch FileType |
---|
| 865 | case {'civx','civdata'} |
---|
| 866 | [FieldList,ColorList]=calc_field; |
---|
| 867 | set(handles.FieldName,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 868 | set(handles.FieldName,'Value',2) % set menu to 'velocity |
---|
| 869 | set(handles.Coord_x,'Value',1); |
---|
| 870 | set(handles.Coord_x,'String',{'X'}); |
---|
| 871 | set(handles.Coord_y,'Value',1); |
---|
| 872 | set(handles.Coord_y,'String',{'Y'}); |
---|
| 873 | case 'netcdf' |
---|
[526] | 874 | set(handles.FieldName,'Value',1) |
---|
| 875 | set(handles.FieldName,'String',{'get_field...'}) |
---|
| 876 | if isempty(i2_series) |
---|
| 877 | i2=[]; |
---|
| 878 | else |
---|
| 879 | i2=i2_series(1,ref_j+1,ref_i+1); |
---|
| 880 | end |
---|
| 881 | if isempty(j1_series) |
---|
| 882 | j1=[];j2=[]; |
---|
| 883 | else |
---|
| 884 | j1=j1_series(1,ref_j+1,ref_i+1); |
---|
| 885 | if isempty(j2_series) |
---|
| 886 | j2=[]; |
---|
| 887 | else |
---|
| 888 | j2=j2_series(1,ref_j+1,ref_i+1); |
---|
| 889 | end |
---|
| 890 | end |
---|
| 891 | 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); |
---|
[525] | 892 | hget_field=get_field(FileName); |
---|
| 893 | hhget_field=guidata(hget_field); |
---|
| 894 | get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
| 895 | otherwise |
---|
[526] | 896 | set(handles.FieldName,'Value',1) % set menu to 'image' |
---|
| 897 | set(handles.FieldName,'String',{'image'}) |
---|
[525] | 898 | set(handles.Coord_x,'Value',1); |
---|
| 899 | set(handles.Coord_x,'String',{'AX'}); |
---|
| 900 | set(handles.Coord_y,'Value',1); |
---|
| 901 | set(handles.Coord_y,'String',{'AY'}); |
---|
| 902 | end |
---|
[408] | 903 | |
---|
[446] | 904 | %------------------------------------------------------------------------ |
---|
| 905 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
| 906 | %------------------------------------------------------------------------ |
---|
| 907 | num_last_i_Callback(hObject, eventdata, handles) |
---|
[408] | 908 | |
---|
| 909 | %------------------------------------------------------------------------ |
---|
[446] | 910 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
| 911 | %------------------------------------------------------------------------ |
---|
| 912 | SeriesData=get(handles.series,'UserData'); |
---|
| 913 | if ~isfield(SeriesData,'Time') |
---|
| 914 | SeriesData.Time{1}=[]; |
---|
| 915 | end |
---|
| 916 | displ_time(handles); |
---|
| 917 | |
---|
| 918 | %------------------------------------------------------------------------ |
---|
| 919 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
| 920 | %------------------------------------------------------------------------ |
---|
| 921 | num_last_j_Callback(hObject, eventdata, handles) |
---|
| 922 | |
---|
| 923 | %------------------------------------------------------------------------ |
---|
| 924 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
| 925 | %------------------------------------------------------------------------ |
---|
| 926 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 927 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 928 | ref_j=ceil((first_j+last_j)/2); |
---|
| 929 | set(handles.num_ref_j,'String', num2str(ref_j)) |
---|
| 930 | num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 931 | SeriesData=get(handles.series,'UserData'); |
---|
| 932 | if ~isfield(SeriesData,'Time') |
---|
| 933 | SeriesData.Time{1}=[]; |
---|
| 934 | end |
---|
| 935 | displ_time(handles); |
---|
| 936 | |
---|
[477] | 937 | |
---|
[446] | 938 | %------------------------------------------------------------------------ |
---|
| 939 | % ---- find the times corresponding to the first and last indices of a series |
---|
| 940 | function displ_time(handles) |
---|
| 941 | %------------------------------------------------------------------------ |
---|
| 942 | SeriesData=get(handles.series,'UserData');% |
---|
| 943 | ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))]; |
---|
| 944 | ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))]; |
---|
| 945 | TimeTable=get(handles.TimeTable,'Data'); |
---|
| 946 | Pairs=get(handles.PairString,'Data'); |
---|
| 947 | for iview=1:size(TimeTable,1) |
---|
| 948 | if size(SeriesData.Time,1)<iview |
---|
| 949 | break |
---|
| 950 | end |
---|
| 951 | i1=ref_i; |
---|
| 952 | j1=ref_j; |
---|
| 953 | i2=ref_i; |
---|
| 954 | j2=ref_j; |
---|
| 955 | % case of pairs |
---|
| 956 | if ~isempty(Pairs{iview,1}) |
---|
| 957 | r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 958 | if isempty(r) |
---|
| 959 | r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 960 | end |
---|
| 961 | switch r.mode |
---|
| 962 | case 'Di=' % case 'series(Di)') |
---|
| 963 | i1=ref_i-str2num(r.num1); |
---|
| 964 | i2=ref_i+str2num(r.num2); |
---|
| 965 | case 'Dj=' % case 'series(Dj)' |
---|
| 966 | j1=ref_j-str2num(r.num1); |
---|
| 967 | j2=ref_j+str2num(r.num2); |
---|
| 968 | case '-' % case 'bursts' |
---|
| 969 | j1=str2num(r.num1)*ones(size(ref_i)); |
---|
| 970 | j2=str2num(r.num2)*ones(size(ref_i)); |
---|
| 971 | end |
---|
| 972 | end |
---|
| 973 | TimeTable{iview,2}=[]; |
---|
| 974 | TimeTable{iview,3}=[]; |
---|
| 975 | if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2) |
---|
| 976 | if isempty(ref_j) |
---|
| 977 | time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2; |
---|
| 978 | time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2; |
---|
| 979 | else |
---|
| 980 | time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2; |
---|
| 981 | time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2; |
---|
| 982 | end |
---|
| 983 | TimeTable{iview,2}=time_first; %TODO: take into account pairs |
---|
| 984 | TimeTable{iview,3}=time_last; %TODO: take into account pairs |
---|
| 985 | end |
---|
| 986 | end |
---|
| 987 | set(handles.TimeTable,'Data',TimeTable) |
---|
| 988 | |
---|
[477] | 989 | %% set the waitbar position with respect to the min and max in the series |
---|
| 990 | for iview=1:numel(SeriesData.i1_series) |
---|
[526] | 991 | pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index |
---|
| 992 | if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) |
---|
| 993 | pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index |
---|
| 994 | end |
---|
| 995 | pair_max{iview}=reshape(pair_max{iview},1,[]); |
---|
| 996 | index_min(iview)=find(pair_max{iview}>0, 1 ); |
---|
| 997 | index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); |
---|
[477] | 998 | end |
---|
| 999 | [index_min,iview_min]=min(index_min); |
---|
| 1000 | [index_max,iview_max]=min(index_max); |
---|
[526] | 1001 | if size(SeriesData.i1_series{iview_min},2)==1% movie |
---|
[533] | 1002 | index_first=ref_i(1); |
---|
| 1003 | index_last=ref_i(2); |
---|
[526] | 1004 | else |
---|
[533] | 1005 | index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; |
---|
| 1006 | index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; |
---|
[526] | 1007 | end |
---|
[477] | 1008 | range=index_max-index_min+1; |
---|
| 1009 | coeff_min=(index_first-index_min)/range; |
---|
| 1010 | coeff_max=(index_last-index_min+1)/range; |
---|
[533] | 1011 | Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] |
---|
[477] | 1012 | Position_status=get(handles.FileStatus,'Position'); |
---|
| 1013 | Position(1)=coeff_min*Position_status(3)+Position_status(1); |
---|
| 1014 | Position(3)=Position_status(3)*(coeff_max-coeff_min); |
---|
| 1015 | set(handles.Waitbar,'Position',Position) |
---|
| 1016 | update_waitbar(handles.Waitbar,0) |
---|
| 1017 | |
---|
[446] | 1018 | %------------------------------------------------------------------------ |
---|
[408] | 1019 | % --- Executes when selected cell(s) is changed in PairString. |
---|
| 1020 | function PairString_CellSelectionCallback(hObject, eventdata, handles) |
---|
| 1021 | %------------------------------------------------------------------------ |
---|
| 1022 | set(handles.ListView,'Value',eventdata.Indices(1))% detect the selected raw index |
---|
| 1023 | ListView_Callback ([],[],handles) % update the list of available pairs |
---|
| 1024 | |
---|
| 1025 | %------------------------------------------------------------------------ |
---|
| 1026 | %------------------------------------------------------------------------ |
---|
| 1027 | % III - FUNCTIONS ASSOCIATED TO THE FRAME SET PAIRS |
---|
| 1028 | %------------------------------------------------------------------------ |
---|
| 1029 | %------------------------------------------------------------------------ |
---|
| 1030 | % --- Executes on selection change in ListView. |
---|
| 1031 | function ListView_Callback(hObject, eventdata, handles) |
---|
| 1032 | %------------------------------------------------------------------------ |
---|
| 1033 | SeriesData=get(handles.series,'UserData'); |
---|
| 1034 | i2_series=[]; |
---|
| 1035 | j2_series=[]; |
---|
| 1036 | iview=get(handles.ListView,'Value'); |
---|
| 1037 | if ~isempty(SeriesData.i2_series{iview}) |
---|
| 1038 | i2_series=SeriesData.i2_series{iview}; |
---|
| 1039 | end |
---|
| 1040 | if ~isempty(SeriesData.j2_series{iview}) |
---|
| 1041 | j2_series=SeriesData.j2_series{iview}; |
---|
| 1042 | end |
---|
| 1043 | update_mode(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1044 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1045 | |
---|
| 1046 | %------------------------------------------------------------------------ |
---|
[2] | 1047 | % --- Executes on button press in mode. |
---|
[376] | 1048 | function mode_Callback(hObject, eventdata, handles) |
---|
[408] | 1049 | %------------------------------------------------------------------------ |
---|
[376] | 1050 | SeriesData=get(handles.series,'UserData'); |
---|
[408] | 1051 | iview=get(handles.ListView,'Value'); |
---|
[376] | 1052 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1053 | mode=mode_list{get(handles.mode,'Value')}; |
---|
[376] | 1054 | if isequal(mode,'bursts') |
---|
| 1055 | enable_i(handles,'On') |
---|
| 1056 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1057 | else |
---|
| 1058 | enable_i(handles,'On') |
---|
| 1059 | enable_j(handles,'Off') |
---|
| 1060 | end |
---|
[408] | 1061 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
| 1062 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview}) |
---|
| 1063 | ListPairs_Callback([],[],handles) |
---|
[339] | 1064 | |
---|
[408] | 1065 | %------------------------------------------------------------- |
---|
| 1066 | % --- Executes on selection in ListPairs. |
---|
| 1067 | function ListPairs_Callback(hObject,eventdata,handles) |
---|
| 1068 | %------------------------------------------------------------ |
---|
| 1069 | list_pair=get(handles.ListPairs,'String');%get the menu of image pairs |
---|
[441] | 1070 | if isempty(list_pair) |
---|
| 1071 | string=''; |
---|
| 1072 | else |
---|
| 1073 | string=list_pair{get(handles.ListPairs,'Value')}; |
---|
| 1074 | string=regexprep(string,',.*','');%removes time indication (after ',') |
---|
| 1075 | end |
---|
[408] | 1076 | PairString=get(handles.PairString,'Data'); |
---|
| 1077 | iview=get(handles.ListView,'Value'); |
---|
| 1078 | PairString{iview,1}=string; |
---|
| 1079 | % report the selected pair string to the table PairString |
---|
| 1080 | set(handles.PairString,'Data',PairString) |
---|
[2] | 1081 | |
---|
[408] | 1082 | %------------------------------------------------------------------------ |
---|
| 1083 | function num_ref_i_Callback(hObject, eventdata, handles) |
---|
| 1084 | %------------------------------------------------------------------------ |
---|
| 1085 | mode_list=get(handles.mode,'String'); |
---|
| 1086 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1087 | SeriesData=get(handles.series,'UserData'); |
---|
| 1088 | iview=get(handles.ListView,'Value'); |
---|
| 1089 | fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},... |
---|
[446] | 1090 | SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files |
---|
[408] | 1091 | ListPairs_Callback([],[],handles) |
---|
[2] | 1092 | |
---|
[408] | 1093 | %------------------------------------------------------------------------ |
---|
| 1094 | function num_ref_j_Callback(hObject, eventdata, handles) |
---|
| 1095 | %------------------------------------------------------------------------ |
---|
| 1096 | num_ref_i_Callback(hObject, eventdata, handles) |
---|
[2] | 1097 | |
---|
[408] | 1098 | %------------------------------------------------------------------------ |
---|
| 1099 | function update_mode(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1100 | %------------------------------------------------------------------------ |
---|
[521] | 1101 | % check_burst=0; |
---|
| 1102 | if isempty(j2_series)% no j pair |
---|
[408] | 1103 | if isempty(i2_series) |
---|
| 1104 | set(handles.mode,'Value',1) |
---|
[521] | 1105 | set(handles.mode,'String',{''})% no pair menu to display |
---|
| 1106 | else |
---|
| 1107 | set(handles.mode,'Value',1) |
---|
| 1108 | set(handles.mode,'String',{'series(Di)'}) % pair menu with only option Di |
---|
[408] | 1109 | end |
---|
[521] | 1110 | else %existence of j pairs |
---|
| 1111 | pair_max=squeeze(max(i1_series,[],1)); %max on pair index |
---|
| 1112 | j_max=max(pair_max,[],1); |
---|
| 1113 | MaxIndex_i=max(find(j_max))-1;% max ref index i |
---|
| 1114 | MinIndex_i=min(find(j_max))-1;% min ref index i |
---|
| 1115 | i_max=max(pair_max,[],2); |
---|
| 1116 | MaxIndex_j=max(find(i_max))-1;% max ref index i |
---|
| 1117 | MinIndex_j=min(find(i_max))-1;% min ref index i |
---|
| 1118 | if MaxIndex_j==MinIndex_j |
---|
[408] | 1119 | set(handles.mode,'Value',1); |
---|
[521] | 1120 | set(handles.mode,'String',{'bursts'}) |
---|
| 1121 | % check_burst=1; |
---|
| 1122 | elseif MaxIndex_i==MinIndex_i |
---|
| 1123 | set(handles.mode,'Value',1); |
---|
| 1124 | set(handles.mode,'String',{'series(Dj)'}) |
---|
[456] | 1125 | else |
---|
[521] | 1126 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
| 1127 | if (MaxIndex_j-MinIndex_j)>10 |
---|
| 1128 | set(handles.mode,'Value',2);%set mode to series(Dj) if more than 10 j values |
---|
| 1129 | else |
---|
| 1130 | set(handles.mode,'Value',1); |
---|
| 1131 | % check_burst=1; |
---|
| 1132 | end |
---|
[456] | 1133 | end |
---|
[408] | 1134 | end |
---|
[521] | 1135 | % if check_burst |
---|
| 1136 | % enable_i(handles,'On') |
---|
| 1137 | % enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 1138 | % else |
---|
| 1139 | % enable_i(handles,'On') |
---|
| 1140 | % if isempty(j1_series) |
---|
| 1141 | % enable_j(handles,'Off') |
---|
| 1142 | % else |
---|
| 1143 | % enable_j(handles,'On') |
---|
| 1144 | % end |
---|
| 1145 | % end |
---|
[408] | 1146 | fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1147 | ListPairs_Callback([],[],handles) |
---|
[2] | 1148 | |
---|
| 1149 | %-------------------------------------------------------------- |
---|
[408] | 1150 | % determine the menu for civ1 pairstring depending on existing netcdf files |
---|
| 1151 | % with the reference indices num_ref_i and num_ref_j |
---|
[2] | 1152 | %---------------------------------------------------------------- |
---|
[408] | 1153 | function fill_ListPair(handles,i1_series,i2_series,j1_series,j2_series,time) |
---|
| 1154 | |
---|
[2] | 1155 | mode_list=get(handles.mode,'String'); |
---|
[408] | 1156 | mode=mode_list{get(handles.mode,'Value')}; |
---|
| 1157 | ref_i=str2num(get(handles.num_ref_i,'String')); |
---|
| 1158 | if isempty(ref_i) |
---|
| 1159 | ref_i=1; |
---|
| 1160 | end |
---|
[472] | 1161 | if strcmp(get(handles.num_ref_j,'Visible'),'on') |
---|
| 1162 | ref_j=str2num(get(handles.num_ref_j,'String')); |
---|
| 1163 | if isempty(ref_j) |
---|
| 1164 | ref_j=1; |
---|
| 1165 | end |
---|
| 1166 | else |
---|
[408] | 1167 | ref_j=1; |
---|
| 1168 | end |
---|
[2] | 1169 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1170 | if length(TimeUnit)>=1 |
---|
| 1171 | dtunit=['m' TimeUnit]; |
---|
| 1172 | else |
---|
| 1173 | dtunit='e-03'; |
---|
| 1174 | end |
---|
[339] | 1175 | |
---|
| 1176 | displ_pair={}; |
---|
[118] | 1177 | if strcmp(mode,'series(Di)') |
---|
[339] | 1178 | if isempty(i2_series) |
---|
| 1179 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
| 1180 | return |
---|
| 1181 | end |
---|
| 1182 | diff_i=i2_series-i1_series; |
---|
| 1183 | min_diff=min(diff_i(diff_i>0)); |
---|
| 1184 | max_diff=max(diff_i(diff_i>0)); |
---|
| 1185 | for ipair=min_diff:max_diff |
---|
| 1186 | if numel(diff_i(diff_i==ipair))>0 |
---|
[408] | 1187 | pair_string=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1188 | if ~isempty(time) |
---|
[472] | 1189 | if ref_i<=floor(ipair/2) |
---|
| 1190 | ref_i=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
| 1191 | end |
---|
[408] | 1192 | Dt=time(ref_i+ceil(ipair/2),ref_j)-time(ref_i-floor(ipair/2),ref_j); |
---|
| 1193 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1194 | end |
---|
| 1195 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1196 | end |
---|
| 1197 | end |
---|
| 1198 | if ~isempty(displ_pair) |
---|
| 1199 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
| 1200 | end |
---|
| 1201 | elseif strcmp(mode,'series(Dj)') |
---|
| 1202 | if isempty(j2_series) |
---|
| 1203 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1204 | return |
---|
| 1205 | end |
---|
| 1206 | diff_j=j2_series-j1_series; |
---|
| 1207 | min_diff=min(diff_j(diff_j>0)); |
---|
| 1208 | max_diff=max(diff_j(diff_j>0)); |
---|
| 1209 | for ipair=min_diff:max_diff |
---|
| 1210 | if numel(diff_j(diff_j==ipair))>0 |
---|
[408] | 1211 | pair_string=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]; |
---|
| 1212 | if ~isempty(time) |
---|
[472] | 1213 | if ref_j<=floor(ipair/2) |
---|
| 1214 | ref_j=floor(ipair/2)+1;% shift ref_i to get the first pair |
---|
| 1215 | end |
---|
[408] | 1216 | Dt=time(ref_i,ref_j+ceil(ipair/2))-time(ref_i,ref_j-floor(ipair/2)); |
---|
| 1217 | pair_string=[pair_string ', Dt=' num2str(Dt) ' ' dtunit]; |
---|
| 1218 | end |
---|
| 1219 | displ_pair=[displ_pair;{pair_string}]; |
---|
[339] | 1220 | end |
---|
| 1221 | end |
---|
| 1222 | if ~isempty(displ_pair) |
---|
| 1223 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
| 1224 | end |
---|
| 1225 | elseif strcmp(mode,'bursts') |
---|
| 1226 | if isempty(j2_series) |
---|
| 1227 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 1228 | return |
---|
| 1229 | end |
---|
| 1230 | diff_j=j2_series-j1_series; |
---|
| 1231 | min_j1=min(j1_series(j1_series>0)); |
---|
| 1232 | max_j1=max(j1_series(j1_series>0)); |
---|
| 1233 | min_j2=min(j2_series(j2_series>0)); |
---|
| 1234 | max_j2=max(j2_series(j2_series>0)); |
---|
| 1235 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
| 1236 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
| 1237 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
| 1238 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
| 1239 | end |
---|
| 1240 | end |
---|
| 1241 | end |
---|
| 1242 | if ~isempty(displ_pair) |
---|
| 1243 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
| 1244 | end |
---|
| 1245 | end |
---|
[472] | 1246 | set(handles.num_ref_i,'String',num2str(ref_i)) % update ref_i and ref_j |
---|
| 1247 | set(handles.num_ref_j,'String',num2str(ref_j)) |
---|
[408] | 1248 | |
---|
| 1249 | %% display list of pairstring |
---|
| 1250 | displ_pair_list=get(handles.ListPairs,'String'); |
---|
[339] | 1251 | NewVal=[]; |
---|
| 1252 | if ~isempty(displ_pair_list) |
---|
[408] | 1253 | Val=get(handles.ListPairs,'Value'); |
---|
[419] | 1254 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pᅵir |
---|
[339] | 1255 | end |
---|
| 1256 | if ~isempty(NewVal) |
---|
[408] | 1257 | set(handles.ListPairs,'Value',NewVal) |
---|
[339] | 1258 | else |
---|
[408] | 1259 | set(handles.ListPairs,'Value',1) |
---|
[339] | 1260 | end |
---|
[408] | 1261 | set(handles.ListPairs,'String',displ_pair) |
---|
[339] | 1262 | |
---|
[408] | 1263 | %------------------------------------- |
---|
| 1264 | function enable_i(handles,state) |
---|
| 1265 | set(handles.i_txt,'Visible',state) |
---|
| 1266 | set(handles.num_first_i,'Visible',state) |
---|
| 1267 | set(handles.num_last_i,'Visible',state) |
---|
| 1268 | set(handles.num_incr_i,'Visible',state) |
---|
| 1269 | % set(handles.num_MaxIndex_i,'Visible',state) |
---|
| 1270 | set(handles.num_ref_i,'Visible',state) |
---|
| 1271 | set(handles.ref_i_text,'Visible',state) |
---|
[2] | 1272 | |
---|
[408] | 1273 | %----------------------------------- |
---|
| 1274 | function enable_j(handles,state) |
---|
| 1275 | set(handles.j_txt,'Visible',state) |
---|
| 1276 | set(handles.num_first_j,'Visible',state) |
---|
| 1277 | set(handles.num_last_j,'Visible',state) |
---|
| 1278 | set(handles.num_incr_j,'Visible',state) |
---|
| 1279 | set(handles.num_ref_j,'Visible',state) |
---|
| 1280 | set(handles.ref_j_text,'Visible',state) |
---|
[526] | 1281 | % if strcmp(state,'off') |
---|
| 1282 | % set(handles.MinIndex,'ColumnName',{'imax'}) |
---|
| 1283 | % set(handles.MinIndex,'ColumnEditable',logical(0)) |
---|
| 1284 | % else |
---|
| 1285 | % set(handles.MinIndex,'ColumnName',{'imax','jmax'}) |
---|
| 1286 | % end |
---|
[41] | 1287 | |
---|
[408] | 1288 | |
---|
[446] | 1289 | %%%%%%%%%%%%%%%%%%%% |
---|
| 1290 | %% MAIN ActionName FUNCTIONS |
---|
| 1291 | %%%%%%%%%%%%%%%%%%%% |
---|
[41] | 1292 | %------------------------------------------------------------------------ |
---|
[2] | 1293 | % --- Executes on button press in RUN. |
---|
| 1294 | function RUN_Callback(hObject, eventdata, handles) |
---|
[41] | 1295 | %------------------------------------------------------------------------ |
---|
[2] | 1296 | set(handles.RUN,'BusyAction','queue'); |
---|
[332] | 1297 | set(0,'CurrentFigure',handles.series) |
---|
[446] | 1298 | set(handles.RUN, 'Enable','Off') |
---|
| 1299 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[456] | 1300 | drawnow |
---|
[453] | 1301 | [h_fun,Series,filexml,errormsg]=prepare_jobs(handles); |
---|
[446] | 1302 | if ~isempty(errormsg) |
---|
| 1303 | msgbox_uvmat('ERROR',errormsg) |
---|
[472] | 1304 | return |
---|
[2] | 1305 | end |
---|
[472] | 1306 | RunModeList=get(handles.RunMode,'String'); |
---|
| 1307 | RunMode=RunModeList{get(handles.RunMode,'Value')}; |
---|
| 1308 | |
---|
| 1309 | switch RunMode |
---|
| 1310 | case 'local' |
---|
| 1311 | Series=h_fun(Series); |
---|
| 1312 | if ~isempty(filexml) |
---|
| 1313 | t=struct2xml(Series); |
---|
| 1314 | t=set(t,1,'name','Series'); |
---|
| 1315 | save(t,filexml); |
---|
| 1316 | end |
---|
| 1317 | case 'background' |
---|
| 1318 | if isempty(filexml) |
---|
| 1319 | Series=h_fun(Series);% no background in the absence of output file |
---|
| 1320 | else |
---|
[477] | 1321 | % update the xml file after interactive input with the function |
---|
| 1322 | Series.Specific='?'; |
---|
| 1323 | Series=h_fun(Series); |
---|
| 1324 | t=struct2xml(Series); |
---|
| 1325 | t=set(t,1,'name','Series'); |
---|
| 1326 | save(t,filexml); |
---|
| 1327 | path_uvmat=fileparts(which('uvmat')); |
---|
| 1328 | |
---|
| 1329 | filename_bat=regexprep(filexml,'.xml$','.bat'); |
---|
| 1330 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1331 | if isequal(fid,-1) |
---|
| 1332 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]); |
---|
| 1333 | return |
---|
| 1334 | end |
---|
| 1335 | path_fct=get(handles.ActionPath,'String'); |
---|
| 1336 | filelog=regexprep(filexml,'.xml$','.log'); |
---|
[495] | 1337 | |
---|
| 1338 | switch computer |
---|
| 1339 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1340 | text_matlabscript=[... |
---|
| 1341 | '#!/bin/bash \n'... |
---|
| 1342 | '. /etc/sysprofile \n'... |
---|
| 1343 | 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... |
---|
| 1344 | 'addpath(''' path_uvmat '''); \n'... |
---|
| 1345 | 'addpath(''' Series.Action.ActionPath '''); \n'... |
---|
| 1346 | '' Series.Action.ActionName '( ''' filexml '''); \n'... |
---|
| 1347 | 'exit \n'... |
---|
| 1348 | 'END_MATLAB \n']; |
---|
| 1349 | fprintf(fid,text_matlabscript); |
---|
| 1350 | fclose(fid); |
---|
| 1351 | system(['chmod +x ' filename_bat]);% set the file to executable |
---|
| 1352 | system(['. ' filename_bat ' &']);%execute fct |
---|
| 1353 | |
---|
| 1354 | case {'PCWIN','PCWIN64'} |
---|
| 1355 | text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... |
---|
| 1356 | ' -r "addpath(''' regexprep(path_uvmat,'\\','\\\\') ''');'... |
---|
| 1357 | 'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'... |
---|
| 1358 | '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; |
---|
| 1359 | fprintf(fid,text_matlabscript); |
---|
| 1360 | fclose(fid); |
---|
| 1361 | dos([filename_bat ' &']); |
---|
[477] | 1362 | end |
---|
[472] | 1363 | end |
---|
[477] | 1364 | update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate lounching is finished |
---|
[472] | 1365 | end |
---|
| 1366 | |
---|
[446] | 1367 | set(handles.RUN, 'Enable','On') |
---|
| 1368 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[2] | 1369 | |
---|
[446] | 1370 | %------------------------------------------------------------------------ |
---|
| 1371 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1372 | %------------------------------------------------------------------------ |
---|
| 1373 | set(handles.RUN, 'BusyAction','cancel') |
---|
| 1374 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1375 | set(handles.RUN,'enable','on') |
---|
[472] | 1376 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1377 | % set(handles.BATCH,'enable','on') |
---|
[446] | 1378 | |
---|
| 1379 | %------------------------------------------------------------------------ |
---|
| 1380 | % --- Executes on button press in BATCH. |
---|
| 1381 | function BATCH_Callback(hObject, eventdata, handles) |
---|
| 1382 | %------------------------------------------------------------------------ |
---|
[456] | 1383 | |
---|
[472] | 1384 | |
---|
| 1385 | % %------------------------------------------------------------------------ |
---|
| 1386 | % % --- Executes on button press in BIN. |
---|
| 1387 | % function BIN_Callback(hObject, eventdata, handles) |
---|
| 1388 | % %------------------------------------------------------------------------ |
---|
| 1389 | % cmd=['#!/bin/bash \n '... |
---|
| 1390 | % '#$ -cwd \n '... |
---|
| 1391 | % 'hostname && date \n '... |
---|
| 1392 | % 'umask 002 \n'... |
---|
| 1393 | % Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc']; |
---|
| 1394 | % |
---|
[446] | 1395 | %------------------------------------------------------------------------ |
---|
[456] | 1396 | % --- Main launch command, called by RUN and BATCH |
---|
[461] | 1397 | function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles,run) |
---|
[472] | 1398 | %INPUT: |
---|
| 1399 | % handles: handles of graphic objects on the GUI series |
---|
| 1400 | % run=0, just to display parameters for MenuExport/GUI config |
---|
| 1401 | % run=1 (default) prepare the computation |
---|
| 1402 | |
---|
[446] | 1403 | %------------------------------------------------------------------------ |
---|
[461] | 1404 | h_fun=[]; |
---|
[456] | 1405 | filexml=''; |
---|
[446] | 1406 | errormsg=''; |
---|
[461] | 1407 | if ~exist('run','var') |
---|
| 1408 | run=1; |
---|
| 1409 | end |
---|
[446] | 1410 | %% Read parameters from series |
---|
| 1411 | Series=read_GUI(handles.series); |
---|
| 1412 | if isfield(Series,'Pairs') |
---|
| 1413 | Series=rmfield(Series,'Pairs'); %info Pairs not needed for output |
---|
| 1414 | end |
---|
| 1415 | |
---|
[456] | 1416 | %% read index ranges |
---|
[446] | 1417 | first_i=1; |
---|
| 1418 | last_i=1; |
---|
| 1419 | incr_i=1; |
---|
| 1420 | first_j=1; |
---|
| 1421 | last_j=1; |
---|
| 1422 | incr_j=1; |
---|
[339] | 1423 | if isfield(Series.IndexRange,'first_i') |
---|
| 1424 | first_i=Series.IndexRange.first_i; |
---|
| 1425 | incr_i=Series.IndexRange.incr_i; |
---|
| 1426 | last_i=Series.IndexRange.last_i; |
---|
| 1427 | end |
---|
| 1428 | if isfield(Series.IndexRange,'first_j') |
---|
| 1429 | first_j=Series.IndexRange.first_j; |
---|
| 1430 | incr_j=Series.IndexRange.incr_j; |
---|
| 1431 | last_j=Series.IndexRange.last_j; |
---|
| 1432 | end |
---|
| 1433 | |
---|
| 1434 | %% read input file parameters and set menus |
---|
[446] | 1435 | menu_coord_state=get(handles.TransformName,'Visible'); |
---|
[2] | 1436 | if isequal(menu_coord_state,'on') |
---|
[446] | 1437 | menu_index=get(handles.TransformName,'Value'); |
---|
| 1438 | transform_list=get(handles.TransformName,'UserData'); |
---|
| 1439 | Series.FieldTransform.TransformHandle=transform_list{menu_index};% transform function handles |
---|
[2] | 1440 | end |
---|
| 1441 | |
---|
| 1442 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
| 1443 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1444 | |
---|
[446] | 1445 | %% projection object |
---|
| 1446 | if isfield(Series,'CheckObject') |
---|
| 1447 | if Series.CheckObject |
---|
| 1448 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 1449 | Series.ProjObject=read_GUI(hset_object); |
---|
[458] | 1450 | CheckObject_Callback([], [], handles) |
---|
[446] | 1451 | end |
---|
| 1452 | else |
---|
| 1453 | Series.CheckObject=0; |
---|
| 1454 | end |
---|
[2] | 1455 | |
---|
[446] | 1456 | %% get_field GUI |
---|
| 1457 | if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') |
---|
| 1458 | if strcmp(Series.InputFields.Field,'get_field...') |
---|
| 1459 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1460 | Series.GetField=read_GUI(hget_field); |
---|
| 1461 | end |
---|
| 1462 | end |
---|
[2] | 1463 | |
---|
[461] | 1464 | if ~run |
---|
| 1465 | return |
---|
| 1466 | end |
---|
| 1467 | |
---|
[446] | 1468 | %% defining the ActionName function handle |
---|
| 1469 | list_action=get(handles.ActionName,'String');% list menu action |
---|
| 1470 | index=get(handles.ActionName,'Value'); |
---|
| 1471 | action= list_action{index}; % selected string |
---|
[461] | 1472 | %Series.Action=action;%name of the processing programme |
---|
[446] | 1473 | Series.hseries=handles.series; % handles to the series GUI |
---|
[2] | 1474 | path_series=which('series'); |
---|
[446] | 1475 | list_path=get(handles.ActionName,'UserData'); |
---|
[2] | 1476 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
| 1477 | if ~isequal(fct_path,path_series) |
---|
| 1478 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
[41] | 1479 | if ~exist(fct_path,'dir') |
---|
[461] | 1480 | errormsg=['The prescribed function path ' fct_path ' does not exist']; |
---|
[41] | 1481 | return |
---|
| 1482 | end |
---|
| 1483 | if ~isequal(spath,fct_path) |
---|
[2] | 1484 | addpath(fct_path)% add the prescribed path if not the current one |
---|
| 1485 | end |
---|
| 1486 | end |
---|
[41] | 1487 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
[26] | 1488 | if ~isequal(fct_path,path_series) |
---|
| 1489 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
| 1490 | end |
---|
| 1491 | |
---|
[446] | 1492 | %% create the output data directory and write in it the xml file from the GUI config |
---|
| 1493 | %determine the root file corresponding to the first sub dir |
---|
| 1494 | if isfield(Series,'OutputSubDir') |
---|
| 1495 | SubDirOut=[Series.OutputSubDir Series.OutputDirExt]; |
---|
| 1496 | SubDirOutNew=SubDirOut; |
---|
| 1497 | iview=1; |
---|
| 1498 | SeriesData=get(handles.series,'UserData'); |
---|
| 1499 | if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort) |
---|
| 1500 | [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order |
---|
| 1501 | Series.InputTable=Series.InputTable(iview,:); |
---|
[421] | 1502 | end |
---|
[448] | 1503 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist |
---|
[450] | 1504 | check_create=1; %need to create the result directory by default |
---|
[446] | 1505 | while detect |
---|
[448] | 1506 | answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); |
---|
| 1507 | if isequal(answer,'Yes') |
---|
| 1508 | detect=0; |
---|
| 1509 | check_create=0; |
---|
| 1510 | else |
---|
| 1511 | r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1512 | if isempty(r) |
---|
| 1513 | r(1).root=[SubDirOutNew '_']; |
---|
| 1514 | r(1).num1='0'; |
---|
| 1515 | end |
---|
| 1516 | SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1517 | detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists |
---|
| 1518 | check_create=1; |
---|
[408] | 1519 | end |
---|
| 1520 | end |
---|
[448] | 1521 | Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); |
---|
[472] | 1522 | % Series.OutputSubDir=SubDirOutNew; |
---|
| 1523 | % Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results |
---|
[446] | 1524 | Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output |
---|
[448] | 1525 | set(handles.OutputDirExt,'String',Series.OutputDirExt) |
---|
[446] | 1526 | % create output directory |
---|
[472] | 1527 | OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]); |
---|
[448] | 1528 | if check_create |
---|
[472] | 1529 | [tild,msg1]=mkdir(OutputDir); |
---|
[446] | 1530 | if ~strcmp(msg1,'') |
---|
[472] | 1531 | errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation |
---|
[446] | 1532 | return |
---|
[421] | 1533 | end |
---|
[408] | 1534 | end |
---|
[472] | 1535 | filexml=fullfile(OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory |
---|
[408] | 1536 | end |
---|
[472] | 1537 | %removes redondant information |
---|
| 1538 | Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); |
---|
| 1539 | Series.IndexRange=rmfield(Series.IndexRange,'MinIndex'); |
---|
| 1540 | Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex'); |
---|
| 1541 | %removes empty lines of InputTable |
---|
| 1542 | empty_line=zeros(size(Series.InputTable,1),1); |
---|
| 1543 | for iline=1:size(Series.InputTable,1) |
---|
| 1544 | empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''}); |
---|
| 1545 | end |
---|
| 1546 | Series.InputTable(find(empty_line),:)=[]; |
---|
[408] | 1547 | |
---|
[41] | 1548 | %------------------------------------------------------------------------ |
---|
[446] | 1549 | % --- Executes on selection change in ActionName. |
---|
| 1550 | function ActionName_Callback(hObject, eventdata, handles) |
---|
[41] | 1551 | %------------------------------------------------------------------------ |
---|
[205] | 1552 | global nb_builtin_ACTION |
---|
[446] | 1553 | list_ACTION=get(handles.ActionName,'String');% list menu fields |
---|
| 1554 | index_ACTION=get(handles.ActionName,'Value');% selected string index |
---|
[2] | 1555 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
| 1556 | path_series=which('series');%path to series.m |
---|
[446] | 1557 | list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION |
---|
[39] | 1558 | default_file=fullfile(list_path{end},ACTION); |
---|
[29] | 1559 | % add a new function to the menu if the selected item is 'more...' |
---|
[2] | 1560 | if isequal(ACTION,'more...') |
---|
| 1561 | pathfct=fileparts(path_series); |
---|
| 1562 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1563 | {'*.m', ' (*.m)'; |
---|
| 1564 | '*.m', '.m files '; ... |
---|
| 1565 | '*.*', 'All Files (*.*)'}, ... |
---|
[39] | 1566 | 'Pick a file',default_file); |
---|
[2] | 1567 | if length(FileName)<2 |
---|
| 1568 | return |
---|
[29] | 1569 | end |
---|
| 1570 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
[2] | 1571 | if ~isequal(ext_fct,'.m') |
---|
| 1572 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1573 | return |
---|
| 1574 | end |
---|
| 1575 | |
---|
[446] | 1576 | % insert the choice in the actionname menu |
---|
| 1577 | menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed |
---|
| 1578 | index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list |
---|
[2] | 1579 | list_path{index_ACTION}=PathName; |
---|
[205] | 1580 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
| 1581 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
| 1582 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
| 1583 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
[2] | 1584 | index_ACTION=index_ACTION-nbremove; |
---|
[446] | 1585 | set(handles.ActionName,'Value',index_ACTION) |
---|
| 1586 | set(handles.ActionName,'String',menu_str) |
---|
[2] | 1587 | end |
---|
| 1588 | list_path{index_ACTION}=PathName; |
---|
[446] | 1589 | set(handles.ActionName,'UserData',list_path); |
---|
| 1590 | set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
[2] | 1591 | |
---|
| 1592 | %record the current menu in personal file profil_perso |
---|
| 1593 | dir_perso=prefdir; |
---|
| 1594 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
[205] | 1595 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
| 1596 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
[2] | 1597 | end |
---|
[206] | 1598 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
| 1599 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
| 1600 | save(profil_perso,'series_fct','-append') |
---|
| 1601 | else |
---|
| 1602 | txt=ver('MATLAB'); |
---|
| 1603 | Release=txt.Release; |
---|
| 1604 | relnumb=str2num(Release(3:4)); |
---|
| 1605 | if relnumb >= 14%recent relaese of Matlab |
---|
| 1606 | save(profil_perso,'series_fct','-V6') |
---|
| 1607 | else |
---|
| 1608 | save(profil_perso, 'series_fct') |
---|
| 1609 | end |
---|
| 1610 | end |
---|
[2] | 1611 | end |
---|
| 1612 | end |
---|
| 1613 | |
---|
[446] | 1614 | %check the current ActionPath to the selected function |
---|
[2] | 1615 | PathName=list_path{index_ACTION};%current recorded path |
---|
[446] | 1616 | set(handles.ActionPath,'String',PathName); %show the path to the senlected function |
---|
[2] | 1617 | |
---|
[477] | 1618 | %reinitialise the waitbar |
---|
| 1619 | update_waitbar(handles.Waitbar,0) |
---|
| 1620 | |
---|
[2] | 1621 | %default setting for the visibility of the GUI elements |
---|
[339] | 1622 | set(handles.num_NbSlice,'Visible','off') |
---|
[2] | 1623 | set(handles.NbSlice_title,'Visible','off') |
---|
[446] | 1624 | set(handles.VelType,'Visible','off'); |
---|
[2] | 1625 | set(handles.VelType_text,'Visible','off'); |
---|
[446] | 1626 | set(handles.VelType_1,'Visible','off'); |
---|
[2] | 1627 | set(handles.VelType_text_1,'Visible','off'); |
---|
[472] | 1628 | set(handles.InputFields,'Visible','off') |
---|
| 1629 | set(handles.FieldName_1,'Visible','off') |
---|
| 1630 | %view_FieldMenu_1(handles,'off') |
---|
[339] | 1631 | set(handles.FieldTransform,'Visible','off') |
---|
[446] | 1632 | set(handles.CheckObject,'Visible','off'); |
---|
| 1633 | set(handles.ProjObject,'Visible','off'); |
---|
| 1634 | set(handles.CheckMask,'Visible','off') |
---|
[2] | 1635 | set(handles.Mask,'Visible','off') |
---|
[446] | 1636 | set(handles.OutputDirExt,'Visible','off') |
---|
| 1637 | set(handles.OutputSubDir,'Visible','off') |
---|
| 1638 | set(handles.OutputDir_title,'Visible','off') |
---|
[2] | 1639 | %set the displayed GUI item needed for input parameters |
---|
[29] | 1640 | if ~isequal(path_series,PathName) |
---|
| 1641 | addpath(PathName) |
---|
| 1642 | end |
---|
| 1643 | eval(['h_function=@' ACTION ';']); |
---|
[244] | 1644 | try |
---|
| 1645 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
| 1646 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
[553] | 1647 | fclose(fid); |
---|
[456] | 1648 | set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help |
---|
[244] | 1649 | end |
---|
[29] | 1650 | if ~isequal(path_series,PathName) |
---|
| 1651 | rmpath(PathName) |
---|
| 1652 | end |
---|
| 1653 | varargout=h_function(); |
---|
[2] | 1654 | Param_list={}; |
---|
| 1655 | |
---|
[372] | 1656 | InputTable=get(handles.InputTable,'Data'); |
---|
[472] | 1657 | nbview=size(InputTable,1); |
---|
| 1658 | SeriesData=get(handles.series,'UserData'); |
---|
| 1659 | nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType))); |
---|
| 1660 | nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType))); |
---|
[2] | 1661 | for ilist=1:length(varargout)-1 |
---|
| 1662 | switch varargout{ilist} |
---|
[446] | 1663 | case 'AllowInputSort' |
---|
| 1664 | if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir |
---|
| 1665 | SeriesData.AllowInputSort=1; |
---|
| 1666 | set(handles.series,'UserData',SeriesData) |
---|
[456] | 1667 | end |
---|
| 1668 | case 'WholeIndexRange' |
---|
[472] | 1669 | if isequal(lower(varargout{ilist+1}),'on')% set by default the input index range from min to max |
---|
[456] | 1670 | MinIndex=get(handles.MinIndex,'Data'); |
---|
| 1671 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
| 1672 | if ~isempty(MinIndex) |
---|
| 1673 | set(handles.num_first_i,'String',num2str(MinIndex{1})) |
---|
| 1674 | set(handles.num_last_i,'String',num2str(MaxIndex{1})) |
---|
| 1675 | set(handles.num_incr_i,'String','1') |
---|
| 1676 | if size(MinIndex,2)>=2 |
---|
| 1677 | set(handles.num_first_j,'String',num2str(MinIndex{1,2})) |
---|
| 1678 | set(handles.num_last_j,'String',num2str(MaxIndex{1,2})) |
---|
| 1679 | set(handles.num_incr_j,'String','1') |
---|
| 1680 | end |
---|
| 1681 | end |
---|
| 1682 | end |
---|
[2] | 1683 | case 'NbSlice' %hidden by default |
---|
| 1684 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[339] | 1685 | set(handles.num_NbSlice,'Visible','on') |
---|
[2] | 1686 | set(handles.NbSlice_title,'Visible','on') |
---|
| 1687 | end |
---|
[446] | 1688 | case 'VelType' %hidden by default |
---|
[372] | 1689 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
[472] | 1690 | if nb_civ>=1 |
---|
[446] | 1691 | set(handles.VelType,'Visible','on') |
---|
[2] | 1692 | set(handles.VelType_text,'Visible','on'); |
---|
| 1693 | end |
---|
[372] | 1694 | end |
---|
[2] | 1695 | if isequal(lower(varargout{ilist+1}),'two') |
---|
[472] | 1696 | if nb_civ>=2 |
---|
[446] | 1697 | set(handles.VelType_1,'Visible','on') |
---|
[2] | 1698 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 1699 | end |
---|
| 1700 | end |
---|
[446] | 1701 | case 'FieldName' %hidden by default |
---|
[2] | 1702 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
[472] | 1703 | if (nb_civ+nb_netcdf)>=1 |
---|
| 1704 | set(handles.FieldName,'Visible','on') % test for MenuBorser |
---|
| 1705 | set(handles.InputFields,'Visible','on') |
---|
[2] | 1706 | end |
---|
| 1707 | end |
---|
| 1708 | if isequal(lower(varargout{ilist+1}),'two') |
---|
[472] | 1709 | if (nb_civ+nb_netcdf)>=1 |
---|
| 1710 | set(handles.FieldName_1,'Visible','on') |
---|
[2] | 1711 | end |
---|
| 1712 | end |
---|
[446] | 1713 | case 'FieldTransform' %hidden by default |
---|
[2] | 1714 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1715 | set(handles.TransformName,'Enable','on') |
---|
[339] | 1716 | set(handles.FieldTransform,'Visible','on') |
---|
[494] | 1717 | TransformName_Callback([],[], handles) |
---|
[2] | 1718 | end |
---|
[446] | 1719 | case 'ProjObject' %hidden by default |
---|
[2] | 1720 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1721 | set(handles.CheckObject,'Visible','on') |
---|
| 1722 | set(handles.ProjObject,'Visible','on') |
---|
[2] | 1723 | end |
---|
| 1724 | case 'Mask' %hidden by default |
---|
| 1725 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[446] | 1726 | set(handles.Mask,'Visible','on') |
---|
| 1727 | set(handles.CheckMask,'Visible','on'); |
---|
[472] | 1728 | end |
---|
[446] | 1729 | case 'OutputDirExt' |
---|
| 1730 | if ~isempty(varargout{ilist+1}) |
---|
| 1731 | set(handles.OutputDirExt,'String',varargout{ilist+1}) |
---|
| 1732 | set(handles.OutputDirExt,'Visible','on') |
---|
| 1733 | set(handles.OutputSubDir,'Visible','on') |
---|
| 1734 | set(handles.OutputDir_title,'Visible','on') |
---|
| 1735 | end |
---|
[2] | 1736 | end |
---|
| 1737 | end |
---|
| 1738 | if ~isempty(Param_list) |
---|
| 1739 | set(handles.ParamKey,'String',Param_list) |
---|
| 1740 | set(handles.ParamVal,'Visible','on') |
---|
| 1741 | end |
---|
| 1742 | |
---|
[41] | 1743 | %------------------------------------------------------------------------ |
---|
[446] | 1744 | % --- Executes on selection change in FieldName. |
---|
| 1745 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[41] | 1746 | %------------------------------------------------------------------------ |
---|
[446] | 1747 | field_str=get(handles.FieldName,'String'); |
---|
| 1748 | field_index=get(handles.FieldName,'Value'); |
---|
[2] | 1749 | field=field_str{field_index(1)}; |
---|
| 1750 | if isequal(field,'get_field...') |
---|
| 1751 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1752 | if ~isempty(hget_field) |
---|
| 1753 | delete(hget_field)%delete opened versions of get_field |
---|
| 1754 | end |
---|
[453] | 1755 | filecell=get_file_series(read_GUI(handles.series)); |
---|
[428] | 1756 | if exist(filecell{1,1},'file') |
---|
| 1757 | get_field(filecell{1,1}) |
---|
[2] | 1758 | end |
---|
| 1759 | elseif isequal(field,'more...') |
---|
| 1760 | str=calc_field; |
---|
| 1761 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1762 | 'SelectionMode','single',... |
---|
| 1763 | 'ListString',str); |
---|
[446] | 1764 | % edit the choice in the fields and actionname menu |
---|
[2] | 1765 | scalar=cell2mat(str(ind_answer)); |
---|
[446] | 1766 | update_menu(handles.FieldName,scalar) |
---|
[2] | 1767 | end |
---|
| 1768 | |
---|
[41] | 1769 | %------------------------------------------------------------------------ |
---|
[446] | 1770 | % --- Executes on selection change in FieldName_1. |
---|
| 1771 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[41] | 1772 | %------------------------------------------------------------------------ |
---|
[446] | 1773 | field_str=get(handles.FieldName_1,'String'); |
---|
| 1774 | field_index=get(handles.FieldName_1,'Value'); |
---|
[2] | 1775 | field=field_str{field_index}; |
---|
| 1776 | if isequal(field,'get_field...') |
---|
| 1777 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 1778 | if ~isempty(hget_field) |
---|
| 1779 | delete(hget_field) |
---|
| 1780 | end |
---|
[332] | 1781 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1782 | filename=SeriesData.CurrentInputFile_1; |
---|
| 1783 | if exist(filename,'file') |
---|
| 1784 | hget_field=get_field(filename); |
---|
| 1785 | set(hget_field,'name','get_field_1') |
---|
| 1786 | end |
---|
| 1787 | elseif isequal(field,'more...') |
---|
| 1788 | str=calc_field; |
---|
| 1789 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1790 | 'SelectionMode','single',... |
---|
| 1791 | 'ListString',str); |
---|
[446] | 1792 | % edit the choice in the fields and actionname menu |
---|
[2] | 1793 | scalar=cell2mat(str(ind_answer)); |
---|
[446] | 1794 | update_menu(handles.FieldName_1,scalar) |
---|
[2] | 1795 | end |
---|
[29] | 1796 | |
---|
[244] | 1797 | |
---|
[2] | 1798 | %%%%%%%%%%%%% |
---|
| 1799 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
[339] | 1800 | indsel=ind_i; |
---|
| 1801 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
| 1802 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
| 1803 | if ~isempty(indiff) |
---|
| 1804 | indiff2=diff(indiff); |
---|
| 1805 | indiffp=[indiff2 1]; |
---|
| 1806 | indiffm=[1 indiff2]; |
---|
| 1807 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
| 1808 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
| 1809 | %for each multiplet, select the most recent file |
---|
| 1810 | ind_remove=[]; |
---|
| 1811 | for i=1:length(ind_multi_m) |
---|
| 1812 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
| 1813 | for imulti=1:length(ind_pairs) |
---|
| 1814 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
[2] | 1815 | end |
---|
[339] | 1816 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
| 1817 | ind_s=indsort2(1:end-1);% |
---|
| 1818 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
| 1819 | end |
---|
| 1820 | end |
---|
[2] | 1821 | |
---|
[89] | 1822 | %------------------------------------------------------------------------ |
---|
[408] | 1823 | % --- determine the list of index pairstring of processing file |
---|
[32] | 1824 | 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] | 1825 | %------------------------------------------------------------------------ |
---|
[32] | 1826 | num_i1=num_i;% set of first image numbers by default |
---|
| 1827 | num_i2=num_i; |
---|
| 1828 | num_j1=num_j; |
---|
| 1829 | num_j2=num_j; |
---|
| 1830 | num_i_out=num_i; |
---|
| 1831 | num_j_out=num_j; |
---|
[339] | 1832 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
| 1833 | if isequal(mode,'series(Di)') |
---|
[32] | 1834 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
| 1835 | num_i2_line=num_i+ind_shift(4); |
---|
| 1836 | % adjust the first and last field number |
---|
| 1837 | indsel=find(num_i1_line >= 1); |
---|
| 1838 | num_i_out=num_i(indsel); |
---|
| 1839 | num_i1_line=num_i1_line(indsel); |
---|
| 1840 | num_i2_line=num_i2_line(indsel); |
---|
| 1841 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1842 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1843 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
| 1844 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
[339] | 1845 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
[32] | 1846 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
| 1847 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
| 1848 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
| 1849 | else |
---|
| 1850 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
| 1851 | num_j2_col=num_j+ind_shift(2); |
---|
| 1852 | % adjust the first field number |
---|
| 1853 | indsel=find((num_j1_col >= 1)); |
---|
| 1854 | num_j_out=num_j(indsel); |
---|
| 1855 | num_j1_col=num_j1_col(indsel); |
---|
| 1856 | num_j2_col=num_j2_col(indsel); |
---|
| 1857 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
| 1858 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
| 1859 | end |
---|
| 1860 | end |
---|
[2] | 1861 | |
---|
[41] | 1862 | %------------------------------------------------------------------------ |
---|
[446] | 1863 | % --- Executes on button press in CheckObject. |
---|
| 1864 | function CheckObject_Callback(hObject, eventdata, handles) |
---|
[41] | 1865 | %------------------------------------------------------------------------ |
---|
[446] | 1866 | value=get(handles.CheckObject,'Value'); |
---|
[2] | 1867 | if value |
---|
[446] | 1868 | set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
[76] | 1869 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
[2] | 1870 | if ishandle(hset_object) |
---|
[421] | 1871 | uistack(hset_object,'top')% show the GUI set_object if opened |
---|
[2] | 1872 | else |
---|
[41] | 1873 | %get the object file |
---|
[376] | 1874 | InputTable=get(handles.InputTable,'Data'); |
---|
| 1875 | defaultname=InputTable{1,1}; |
---|
[106] | 1876 | if isempty(defaultname) |
---|
| 1877 | defaultname={''}; |
---|
| 1878 | end |
---|
[41] | 1879 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1880 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 1881 | '*.xml', '.xml files '; ... |
---|
| 1882 | '*.mat', '.mat matlab files '}, ... |
---|
[427] | 1883 | 'Pick an xml object file (or use uvmat to create it)',defaultname); |
---|
[41] | 1884 | fileinput=[PathName FileName];%complete file name |
---|
| 1885 | sizf=size(fileinput); |
---|
| 1886 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 1887 | %read the file |
---|
[427] | 1888 | data=xml2struct(fileinput); |
---|
[446] | 1889 | if ~isfield(data,'Type') |
---|
| 1890 | msgbox_uvmat('ERROR',[fileinput ' is not an object xml file']) |
---|
| 1891 | return |
---|
[41] | 1892 | end |
---|
| 1893 | if ~isfield(data,'ProjMode') |
---|
[446] | 1894 | data.ProjMode='none'; |
---|
[41] | 1895 | end |
---|
[446] | 1896 | hset_object=set_object(data);% call the set_object interface |
---|
[2] | 1897 | end |
---|
[446] | 1898 | Object=read_GUI(hset_object); |
---|
| 1899 | set(handles.ProjObject,'String',Object.Name);%display the object name |
---|
[2] | 1900 | else |
---|
[446] | 1901 | set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
[2] | 1902 | end |
---|
[446] | 1903 | %set(handles.series,'UserData',SeriesData) |
---|
[2] | 1904 | |
---|
| 1905 | %-------------------------------------------------------------- |
---|
[446] | 1906 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1907 | value=get(handles.CheckMask,'Value'); |
---|
[2] | 1908 | if value |
---|
[41] | 1909 | msgbox_uvmat('ERROR','not implemented yet') |
---|
[2] | 1910 | end |
---|
| 1911 | %-------------------------------------------------------------- |
---|
| 1912 | |
---|
[41] | 1913 | %------------------------------------------------------------------- |
---|
[2] | 1914 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
| 1915 | function ncbrowser_uvmat(hObject, eventdata) |
---|
[41] | 1916 | %------------------------------------------------------------------- |
---|
[2] | 1917 | bla=get(gcbo,'String'); |
---|
| 1918 | ind=get(gcbo,'Value'); |
---|
| 1919 | filename=cell2mat(bla(ind)); |
---|
| 1920 | blank=find(filename==' '); |
---|
| 1921 | filename=filename(1:blank-1); |
---|
| 1922 | get_field(filename) |
---|
| 1923 | |
---|
[41] | 1924 | % ------------------------------------------------------------------ |
---|
[2] | 1925 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[41] | 1926 | %------------------------------------------------------------------- |
---|
[2] | 1927 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 1928 | pathelp=fileparts(path_to_uvmat); |
---|
[36] | 1929 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 1930 | 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] | 1931 | else |
---|
[36] | 1932 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 1933 | web([helpfile '#series']) |
---|
[2] | 1934 | end |
---|
| 1935 | |
---|
[41] | 1936 | %------------------------------------------------------------------- |
---|
[446] | 1937 | % --- Executes on selection change in TransformName. |
---|
| 1938 | function TransformName_Callback(hObject, eventdata, handles) |
---|
[41] | 1939 | %------------------------------------------------------------------- |
---|
[39] | 1940 | global nb_transform |
---|
[2] | 1941 | |
---|
[446] | 1942 | menu=get(handles.TransformName,'String'); |
---|
| 1943 | ind_coord=get(handles.TransformName,'Value'); |
---|
[39] | 1944 | coord_option=menu{ind_coord}; |
---|
[446] | 1945 | list_transform=get(handles.TransformName,'UserData'); |
---|
[39] | 1946 | ff=functions(list_transform{end}); |
---|
| 1947 | if isequal(coord_option,'more...'); |
---|
| 1948 | coord_fct=''; |
---|
| 1949 | prompt = {'Enter the name of the transform function'}; |
---|
| 1950 | dlg_title = 'user defined transform'; |
---|
| 1951 | num_lines= 1; |
---|
| 1952 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1953 | {'*.m', ' (*.m)'; |
---|
| 1954 | '*.m', '.m files '; ... |
---|
| 1955 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1956 | 'Pick a file', ff.file); |
---|
| 1957 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 1958 | PathName(end)=[]; |
---|
| 1959 | end |
---|
| 1960 | transform_selected =fullfile(PathName,FileName); |
---|
| 1961 | if ~exist(transform_selected,'file') |
---|
| 1962 | return |
---|
| 1963 | end |
---|
| 1964 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
| 1965 | if ~isequal(ext_fct,'.m') |
---|
| 1966 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1967 | return |
---|
| 1968 | end |
---|
[446] | 1969 | menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu |
---|
| 1970 | ind_coord=get(handles.TransformName,'Value'); |
---|
[39] | 1971 | addpath(PathName) |
---|
| 1972 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
[446] | 1973 | set(handles.TransformName,'UserData',list_transform) |
---|
[39] | 1974 | rmpath(PathName) |
---|
| 1975 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 1976 | dir_perso=prefdir;%personal Matalb directory |
---|
| 1977 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1978 | if exist(profil_perso,'file') |
---|
| 1979 | for ilist=nb_transform+1:numel(list_transform) |
---|
[55] | 1980 | ff=functions(list_transform{ilist}); |
---|
[39] | 1981 | transform_fct{ilist-nb_transform}=ff.file; |
---|
| 1982 | end |
---|
| 1983 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
| 1984 | end |
---|
| 1985 | end |
---|
[2] | 1986 | |
---|
[446] | 1987 | %check the current ActionPath to the selected function |
---|
[248] | 1988 | if ~isempty(list_transform{ind_coord}) |
---|
[494] | 1989 | func=functions(list_transform{ind_coord}); |
---|
| 1990 | set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function |
---|
[248] | 1991 | else |
---|
[494] | 1992 | set(handles.TransformPath,'String',''); %show the path to the senlected function |
---|
[248] | 1993 | end |
---|
[350] | 1994 | |
---|
| 1995 | |
---|
| 1996 | |
---|
[446] | 1997 | % -------------------------------------------------------------------- |
---|
| 1998 | function MenuExportConfig_Callback(hObject, eventdata, handles) |
---|
| 1999 | global Series |
---|
[461] | 2000 | [tild,Series,errormsg]=prepare_jobs(handles,0); |
---|
[446] | 2001 | % Series=read_GUI(handles.series); |
---|
[358] | 2002 | |
---|
[446] | 2003 | evalin('base','global Series')%make CurData global in the workspace |
---|
| 2004 | display('current series config :') |
---|
| 2005 | evalin('base','Series') %display CurData in the workspace |
---|
| 2006 | commandwindow; %brings the Matlab command window to the front |
---|
[472] | 2007 | |
---|
| 2008 | |
---|
| 2009 | % --- Executes on selection change in RunMode. |
---|
| 2010 | function RunMode_Callback(hObject, eventdata, handles) |
---|
[525] | 2011 | |
---|
[526] | 2012 | % --- Executes on selection change in Coord_x. |
---|
| 2013 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[525] | 2014 | |
---|
| 2015 | |
---|
[526] | 2016 | % --- Executes on selection change in Coord_y. |
---|
| 2017 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
[525] | 2018 | |
---|
| 2019 | |
---|
| 2020 | |
---|
[526] | 2021 | % --- Executes when series is resized. |
---|
| 2022 | function series_ResizeFcn(hObject, eventdata, handles) |
---|
| 2023 | %% input table |
---|
| 2024 | set(handles.InputTable,'Unit','pixel') |
---|
| 2025 | Pos=get(handles.InputTable,'Position'); |
---|
| 2026 | set(handles.InputTable,'Unit','normalized') |
---|
| 2027 | ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52)); |
---|
| 2028 | ColumnWidth=num2cell(ColumnWidth); |
---|
| 2029 | set(handles.InputTable,'ColumnWidth',ColumnWidth) |
---|
| 2030 | |
---|
| 2031 | %% MinIndex and MaxIndex |
---|
| 2032 | set(handles.MinIndex,'Unit','pixel') |
---|
| 2033 | Pos=get(handles.MinIndex,'Position'); |
---|
| 2034 | set(handles.MinIndex,'Unit','normalized') |
---|
| 2035 | ColumnWidth=get(handles.MinIndex,'ColumnWidth'); |
---|
| 2036 | if numel(ColumnWidth)==2 |
---|
| 2037 | ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20))); |
---|
| 2038 | else |
---|
| 2039 | ColumnWidth={Pos(3)-5}; |
---|
| 2040 | end |
---|
| 2041 | set(handles.MinIndex,'ColumnWidth',ColumnWidth) |
---|
| 2042 | set(handles.MaxIndex,'ColumnWidth',ColumnWidth) |
---|
| 2043 | |
---|
| 2044 | %% TimeTable |
---|
| 2045 | set(handles.TimeTable,'Unit','pixel') |
---|
| 2046 | Pos=get(handles.TimeTable,'Position'); |
---|
| 2047 | set(handles.TimeTable,'Unit','normalized') |
---|
| 2048 | ColumnWidth=get(handles.TimeTable,'ColumnWidth'); |
---|
| 2049 | ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20))); |
---|
| 2050 | set(handles.TimeTable,'ColumnWidth',ColumnWidth) |
---|
| 2051 | |
---|
| 2052 | |
---|
| 2053 | %% PairString |
---|
| 2054 | set(handles.PairString,'Unit','pixel') |
---|
| 2055 | Pos=get(handles.PairString,'Position'); |
---|
| 2056 | set(handles.PairString,'Unit','normalized') |
---|
| 2057 | set(handles.PairString,'ColumnWidth',{Pos(3)-5}) |
---|