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