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