[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) |
---|
[39] | 8 | % .menu_coord_str: string for the transform_fct (menu for coordinate transforms) |
---|
| 9 | % .menu_coord_val: value for transform_fct (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 | |
---|
| 32 | function varargout = series(varargin) |
---|
| 33 | |
---|
| 34 | % Begin initialization code - DO NOT EDIT |
---|
| 35 | gui_Singleton = 1; |
---|
| 36 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 37 | 'gui_Singleton', gui_Singleton, ... |
---|
| 38 | 'gui_OpeningFcn', @series_OpeningFcn, ... |
---|
| 39 | 'gui_OutputFcn', @series_OutputFcn, ... |
---|
| 40 | 'gui_LayoutFcn', [] , ... |
---|
| 41 | 'gui_Callback', []); |
---|
| 42 | if nargin && ischar(varargin{1}) |
---|
| 43 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 44 | end |
---|
| 45 | |
---|
| 46 | if nargout |
---|
| 47 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 48 | else |
---|
| 49 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 50 | end |
---|
| 51 | % End initialization code - DO NOT EDIT |
---|
| 52 | |
---|
| 53 | %-------------------------------------------------------------------------- |
---|
| 54 | % --- Executes just before series is made visible. |
---|
| 55 | %-------------------------------------------------------------------------- |
---|
| 56 | function series_OpeningFcn(hObject, eventdata, handles,param) |
---|
[205] | 57 | global nb_builtin_ACTION nb_builtin_transform |
---|
[2] | 58 | % Choose default command line output for series |
---|
| 59 | handles.output = hObject; |
---|
| 60 | % Update handles structure |
---|
| 61 | guidata(hObject, handles); |
---|
| 62 | %default initial parameters |
---|
[156] | 63 | drawnow |
---|
[244] | 64 | set(hObject,'Units','pixels') |
---|
| 65 | % set(0,'Units','pixels') |
---|
| 66 | % screensize=get(0,'ScreenSize'); %screen size in pixels |
---|
[332] | 67 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) |
---|
| 68 | %set(hObject,'Position',[150 100 1000 600] );%position and size in pixels (get adjusted to the screen size in case of excess) |
---|
[2] | 69 | %load the list of previously browsed files in menus Open and Open_1 |
---|
| 70 | dir_perso=prefdir; |
---|
[205] | 71 | test_profil_perso=0; |
---|
[2] | 72 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 73 | if exist(profil_perso,'file') |
---|
| 74 | h=load (profil_perso); |
---|
[205] | 75 | test_profil_perso=1; |
---|
[2] | 76 | if isfield(h,'MenuFile_1') |
---|
| 77 | set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
| 78 | set(handles.MenuFile_insert_1,'Label',h.MenuFile_1); |
---|
| 79 | end |
---|
| 80 | if isfield(h,'MenuFile_1') |
---|
| 81 | set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
| 82 | set(handles.MenuFile_insert_2,'Label',h.MenuFile_2); |
---|
| 83 | end |
---|
| 84 | if isfield(h,'MenuFile_1') |
---|
| 85 | set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
| 86 | set(handles.MenuFile_insert_3,'Label',h.MenuFile_3); |
---|
| 87 | end |
---|
| 88 | if isfield(h,'MenuFile_1') |
---|
| 89 | set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
| 90 | set(handles.MenuFile_insert_4,'Label',h.MenuFile_4); |
---|
| 91 | end |
---|
| 92 | if isfield(h,'MenuFile_1') |
---|
| 93 | set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
| 94 | set(handles.MenuFile_insert_5,'Label',h.MenuFile_5); |
---|
| 95 | end |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | %check default input data |
---|
| 99 | if ~exist('param','var') |
---|
| 100 | param=[]; %default |
---|
| 101 | end |
---|
| 102 | |
---|
| 103 | %file name and browser initialisation |
---|
| 104 | if isfield(param,'menu_coord_str') |
---|
[39] | 105 | set(handles.transform_fct,'String',param.menu_coord_str) |
---|
[2] | 106 | end |
---|
| 107 | if isfield(param,'menu_coord_val') |
---|
[39] | 108 | set(handles.transform_fct,'Value',param.menu_coord_val); |
---|
[2] | 109 | else |
---|
[39] | 110 | set(handles.transform_fct,'Value',1);%default |
---|
[2] | 111 | end |
---|
| 112 | |
---|
| 113 | if isfield(param,'FileName') |
---|
| 114 | if isfield(param,'FileName_1') |
---|
[350] | 115 | update_rootfile(handles,param.FileName_1,0) |
---|
| 116 | update_rootfile(handles,param.FileName,1) |
---|
[2] | 117 | else |
---|
[350] | 118 | update_rootfile(handles,param.FileName,0) |
---|
[2] | 119 | end |
---|
| 120 | end |
---|
| 121 | |
---|
| 122 | %fields input initialisation |
---|
| 123 | if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields) |
---|
| 124 | set(handles.FieldMenu,'String',param.list_fields);% list menu fields |
---|
| 125 | set(handles.FieldMenu,'Value',param.index_fields);% selected string index |
---|
| 126 | FieldCell{1}=param.list_fields{param.index_fields}; |
---|
| 127 | end |
---|
[350] | 128 | % NomType_Callback(hObject, eventdata, handles) |
---|
| 129 | REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
[39] | 130 | %loads the information stored in prefdir to initiate the list of ACTION functions |
---|
[329] | 131 | fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
[38] | 132 | transform_menu={'';'phys';'px';'phys_polar'}; |
---|
[205] | 133 | nb_builtin_ACTION=numel(fct_menu); %number of functions |
---|
[38] | 134 | nb_transform=numel(transform_menu); |
---|
[26] | 135 | [path_series,name,ext]=fileparts(which('series')); |
---|
[34] | 136 | path_series=fullfile(path_series,'series');%path of the function 'series' |
---|
[332] | 137 | 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] | 138 | path_transform=fullfile(path_series,'transform_field');%path to the field transform functions |
---|
[38] | 139 | for ilist=1:length(fct_menu) |
---|
[2] | 140 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
| 141 | end |
---|
[39] | 142 | |
---|
| 143 | %TRANSFORM menu: loads the information stored in prefdir to initiate the list of field transform functions |
---|
| 144 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
[205] | 145 | nb_builtin_transform=numel(menu_str); %number of functions |
---|
[39] | 146 | [path_uvmat,name,ext]=fileparts(which('uvmat')); |
---|
| 147 | addpath(fullfile(path_uvmat,'transform_field')) |
---|
| 148 | fct_handle{1,1}=[]; |
---|
| 149 | testexist(1)=1; |
---|
| 150 | for ilist=2:length(menu_str) |
---|
| 151 | if exist(menu_str{ilist},'file') |
---|
| 152 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
| 153 | testexist(ilist)=1; |
---|
| 154 | else |
---|
| 155 | testexist(ilist)=0; |
---|
| 156 | end |
---|
[38] | 157 | end |
---|
[39] | 158 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
| 159 | |
---|
[34] | 160 | % read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir |
---|
[205] | 161 | if test_profil_perso |
---|
[2] | 162 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
| 163 | for ilist=1:length(h.series_fct) |
---|
| 164 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
| 165 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
[205] | 166 | fct_menu=[fct_menu; {file}]; |
---|
[2] | 167 | end |
---|
| 168 | end |
---|
[38] | 169 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
[39] | 170 | for ilist=1:length(h.transform_fct); |
---|
[38] | 171 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
[39] | 172 | addpath(path) |
---|
| 173 | if exist(file,'file') |
---|
| 174 | h_func=str2func(file); |
---|
| 175 | testexist=[testexist 1]; |
---|
| 176 | else |
---|
| 177 | h_func=[]; |
---|
| 178 | testexist=[testexist 0]; |
---|
| 179 | end |
---|
| 180 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths |
---|
| 181 | rmpath(path) |
---|
| 182 | menu_str=[menu_str; {file}]; |
---|
| 183 | end |
---|
[38] | 184 | end |
---|
[2] | 185 | end |
---|
[38] | 186 | fct_menu=[fct_menu;{'more...'}]; |
---|
| 187 | set(handles.ACTION,'String',fct_menu) |
---|
[2] | 188 | set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
| 189 | |
---|
[39] | 190 | menu_str=menu_str(find(testexist)); |
---|
| 191 | fct_handle=fct_handle(find(testexist)); |
---|
| 192 | menu_str=[menu_str;{'more...'}]; |
---|
| 193 | set(handles.transform_fct,'String',menu_str) |
---|
| 194 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
| 195 | |
---|
[329] | 196 | % display the GUI for the default action 'check_data_files' |
---|
[2] | 197 | ACTION_Callback(hObject, eventdata, handles) |
---|
| 198 | |
---|
| 199 | %-------------------------------------------------------------- |
---|
| 200 | % --- Outputs from this function are returned to the command line. |
---|
| 201 | %----------------------------------------------------------------- |
---|
| 202 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
| 203 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 204 | % hObject handle to figure |
---|
| 205 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 206 | % handles structure with handles and user data (see GUIDATA) |
---|
| 207 | % Get default command line output from handles structure |
---|
| 208 | varargout{1} = handles.output; |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | % -------------------------------------------------------------------- |
---|
| 212 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
[350] | 213 | InputTable=get(handles.InputTable,'Data'); |
---|
| 214 | RootPathCell=InputTable(:,1); |
---|
| 215 | SubDirCell=InputTable(:,1); |
---|
| 216 | RootFileCell=InputTable(:,1); |
---|
| 217 | %RootPathCell=get(handles.RootPath,'String'); |
---|
| 218 | %SubDirCell=get(handles.SubDir,'String'); |
---|
| 219 | %RootFileCell=get(handles.RootFile,'String'); |
---|
[2] | 220 | oldfile=''; %default |
---|
[329] | 221 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 222 | dir_perso=prefdir; |
---|
| 223 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 224 | if exist(profil_perso,'file') |
---|
| 225 | h=load (profil_perso); |
---|
[329] | 226 | if isfield(h,'filebase')&&ischar(h.filebase) |
---|
[2] | 227 | oldfile=h.filebase; |
---|
| 228 | end |
---|
[329] | 229 | if isfield(h,'RootPath')&&ischar(h.RootPath) |
---|
[2] | 230 | oldfile=h.RootPath; |
---|
| 231 | end |
---|
| 232 | end |
---|
| 233 | else |
---|
| 234 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
| 235 | end |
---|
| 236 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 237 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 238 | '*.xml', '.xml files '; ... |
---|
| 239 | '*.xls', '.xls files '; ... |
---|
| 240 | '*.png','.png image files'; ... |
---|
| 241 | '*.tif','.tif image files'; ... |
---|
| 242 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 243 | '*.nc','.netcdf files'; ... |
---|
| 244 | '*.*', 'All Files (*.*)'}, ... |
---|
| 245 | 'Pick a file',oldfile); |
---|
| 246 | fileinput=[PathName FileName];%complete file name |
---|
[206] | 247 | %testblank=findstr(fileinput,' ');%look for blanks |
---|
| 248 | % if ~isempty(testblank) |
---|
| 249 | % errordlg('forbidden input file name: contain blanks') |
---|
| 250 | % return |
---|
| 251 | % end |
---|
[2] | 252 | sizf=size(fileinput); |
---|
| 253 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 254 | [path,name,ext]=fileparts(fileinput); |
---|
| 255 | SeriesData=[];%dfault |
---|
| 256 | if isequal(ext,'.xml') |
---|
[205] | 257 | warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 258 | elseif isequal(ext,'.xls') |
---|
[205] | 259 | warndlg_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 260 | else |
---|
[350] | 261 | update_rootfile(handles,fileinput,0) |
---|
[2] | 262 | %update list of recent files in the menubar |
---|
| 263 | MenuFile_1=fileinput; |
---|
| 264 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 265 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 266 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 267 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 268 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 269 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 270 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 271 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 272 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 273 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
| 274 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
| 275 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
| 276 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
| 277 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
| 278 | dir_perso=prefdir; |
---|
| 279 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 280 | if exist(profil_perso,'file') |
---|
| 281 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 282 | else |
---|
[147] | 283 | txt=ver('MATLAB'); |
---|
| 284 | Release=txt.Release; |
---|
[2] | 285 | relnumb=str2num(Release(3:4)); |
---|
| 286 | if relnumb >= 14 |
---|
| 287 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 288 | else |
---|
| 289 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 290 | end |
---|
| 291 | end |
---|
| 292 | end |
---|
| 293 | |
---|
| 294 | |
---|
| 295 | % -------------------------------------------------------------------- |
---|
| 296 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 297 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[350] | 298 | update_rootfile(handles,fileinput,0) |
---|
[2] | 299 | |
---|
| 300 | % -------------------------------------------------------------------- |
---|
| 301 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 302 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[350] | 303 | update_rootfile(handles,fileinput,0) |
---|
[2] | 304 | |
---|
| 305 | % -------------------------------------------------------------------- |
---|
| 306 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 307 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[350] | 308 | update_rootfile( handles,fileinput,0) |
---|
[2] | 309 | |
---|
| 310 | % -------------------------------------------------------------------- |
---|
| 311 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 312 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[350] | 313 | update_rootfile(handles,fileinput,0) |
---|
[2] | 314 | |
---|
| 315 | % -------------------------------------------------------------------- |
---|
| 316 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 317 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[350] | 318 | update_rootfile(handles,fileinput,0) |
---|
[2] | 319 | |
---|
| 320 | % -------------------------------------------------------------------- |
---|
| 321 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
[350] | 322 | InputTable=get(handles.InputTable,'Data'); |
---|
| 323 | RootPathCell=InputTable(:,1); |
---|
| 324 | SubDirCell=InputTable(:,3); |
---|
| 325 | RootFileCell=InputTable(:,2); |
---|
| 326 | % RootPathCell=get(handles.RootPath,'String'); |
---|
| 327 | % RootFileCell=get(handles.RootFile,'String'); |
---|
[2] | 328 | oldfile=''; %default |
---|
[206] | 329 | if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 330 | dir_perso=prefdir; |
---|
| 331 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 332 | if exist(profil_perso,'file') |
---|
| 333 | h=load (profil_perso); |
---|
| 334 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 335 | oldfile=h.filebase; |
---|
| 336 | end |
---|
| 337 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 338 | oldfile=h.RootPath; |
---|
| 339 | end |
---|
| 340 | end |
---|
| 341 | else |
---|
| 342 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
| 343 | end |
---|
| 344 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 345 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
| 346 | '*.xml', '.xml files '; ... |
---|
| 347 | '*.xls', '.xls files '; ... |
---|
| 348 | '*.png','.png image files'; ... |
---|
| 349 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 350 | '*.nc','.netcdf files'; ... |
---|
| 351 | '*.*', 'All Files (*.*)'}, ... |
---|
| 352 | 'Pick a file',oldfile); |
---|
| 353 | fileinput=[PathName FileName];%complete file name |
---|
[206] | 354 | % testblank=findstr(fileinput,' ');%look for blanks |
---|
| 355 | % if ~isempty(testblank) |
---|
| 356 | % errordlg('forbidden input file name: contain blanks') |
---|
| 357 | % return |
---|
| 358 | % end |
---|
[2] | 359 | sizf=size(fileinput); |
---|
| 360 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 361 | [path,name,ext]=fileparts(fileinput); |
---|
| 362 | SeriesData=[];%dfault |
---|
| 363 | if isequal(ext,'.xml') |
---|
[206] | 364 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 365 | elseif isequal(ext,'.xls') |
---|
[206] | 366 | msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
[2] | 367 | else |
---|
[350] | 368 | update_rootfile(handles,fileinput,1) |
---|
[2] | 369 | %update list of recent files in the menubar |
---|
| 370 | MenuFile_1=fileinput; |
---|
| 371 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 372 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 373 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 374 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 375 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 376 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 377 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 378 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 379 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 380 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
| 381 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
| 382 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
| 383 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
| 384 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
| 385 | dir_perso=prefdir; |
---|
| 386 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 387 | if exist(profil_perso,'file') |
---|
| 388 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 389 | else |
---|
[147] | 390 | txt=ver('MATLAB'); |
---|
| 391 | Release=txt.Release; |
---|
[2] | 392 | relnumb=str2num(Release(3:4)); |
---|
| 393 | if relnumb >= 14 |
---|
| 394 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 395 | else |
---|
| 396 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 397 | end |
---|
| 398 | end |
---|
| 399 | end |
---|
| 400 | %------------------------------------------------ |
---|
| 401 | |
---|
| 402 | % -------------------------------------------------------------------- |
---|
| 403 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
| 404 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
[350] | 405 | update_rootfile(handles,fileinput,1) |
---|
[2] | 406 | |
---|
| 407 | % -------------------------------------------------------------------- |
---|
| 408 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
| 409 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
[350] | 410 | update_rootfile(handles,fileinput,1) |
---|
[2] | 411 | |
---|
| 412 | % -------------------------------------------------------------------- |
---|
| 413 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
| 414 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
[350] | 415 | update_rootfile( handles,fileinput,1) |
---|
[2] | 416 | |
---|
| 417 | % -------------------------------------------------------------------- |
---|
| 418 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
| 419 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
[350] | 420 | update_rootfile( handles,fileinput,1) |
---|
[2] | 421 | |
---|
| 422 | % -------------------------------------------------------------------- |
---|
| 423 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
| 424 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
[350] | 425 | update_rootfile(handles,fileinput,1) |
---|
[2] | 426 | |
---|
[89] | 427 | %------------------------------------------------------------------------ |
---|
| 428 | % --- refresh the GUI data after introduction of a new file series |
---|
[332] | 429 | % INPUT: |
---|
| 430 | % handles: |
---|
| 431 | % fileinput: name of the input file |
---|
| 432 | % addtest: =0 to refresh the list of file series, =1 to append a new series to the list (from the menu bar option 'Open_insert') |
---|
[350] | 433 | function update_rootfile(handles,fileinput,addtest) |
---|
[89] | 434 | %------------------------------------------------------------------------ |
---|
[332] | 435 | |
---|
| 436 | %% enable other menus and uicontrols |
---|
| 437 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 438 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 439 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 440 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 441 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 442 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 443 | set(handles.RUN, 'Enable','On') |
---|
| 444 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
[350] | 445 | % set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
| 446 | set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
[332] | 447 | drawnow |
---|
| 448 | |
---|
| 449 | %% get the input root name, indices, file extension and nomenclature NomType |
---|
[29] | 450 | if ~exist(fileinput,'file') |
---|
| 451 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 452 | return |
---|
| 453 | end |
---|
[350] | 454 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); |
---|
[89] | 455 | |
---|
[332] | 456 | %% determine reference field indices |
---|
[2] | 457 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
[339] | 458 | if ~isempty(i1) |
---|
| 459 | ref_i=i1; |
---|
| 460 | if ~isempty(i2) |
---|
| 461 | ref_i=floor((ref_i+i2)/2);% reference image number corresponding to the file |
---|
| 462 | % SeriesData.browse_Di=i2-i1; |
---|
[2] | 463 | end |
---|
| 464 | end |
---|
| 465 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
[339] | 466 | set(handles.num_first_i,'String',num2str(ref_i)); |
---|
| 467 | set(handles.num_last_i,'String',num2str(ref_i)); |
---|
[2] | 468 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
[339] | 469 | if ~isempty(j1) |
---|
| 470 | ref_j=j1; |
---|
| 471 | if ~isempty(j2) |
---|
| 472 | ref_j=floor((j1+j2)/2); |
---|
| 473 | % SeriesData.browse_Dj=j2-j1; |
---|
[2] | 474 | end |
---|
| 475 | end |
---|
| 476 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[339] | 477 | set(handles.num_first_j,'String',num2str(ref_j)) |
---|
| 478 | set(handles.num_last_j,'String',num2str(ref_j)); |
---|
[2] | 479 | TimeUnit=''; %default |
---|
| 480 | time=[];%default |
---|
| 481 | |
---|
| 482 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 483 | FileBase=fullfile(RootPath,RootFile); |
---|
| 484 | |
---|
| 485 | testima=0; %test for image input |
---|
| 486 | if isequal(lower(FileExt),'.avi') %.avi file |
---|
| 487 | testima=1; |
---|
[332] | 488 | % info=aviinfo([FileBase FileExt]); |
---|
| 489 | % time=(0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond)'; |
---|
[339] | 490 | % num_MaxIndex_i=info.NumFrames; |
---|
| 491 | % num_MaxIndex_j=1; |
---|
[2] | 492 | elseif ~isempty(imformats(FileExt(2:end))) |
---|
| 493 | testima=1; |
---|
[332] | 494 | % if isequal(NomType,'*')% multi-frame image |
---|
| 495 | % imainfo=imfinfo([FileBase FileExt]); |
---|
| 496 | % if length(imainfo) >1 %case of image with multiple frames |
---|
[339] | 497 | % num_MaxIndex_i=length(imainfo); |
---|
| 498 | % num_MaxIndex_j=1; |
---|
[332] | 499 | % end |
---|
| 500 | % end |
---|
[2] | 501 | elseif isequal(FileExt,'.vol') |
---|
| 502 | testima=1; |
---|
| 503 | end |
---|
| 504 | |
---|
[332] | 505 | %% fill the list of file series |
---|
[339] | 506 | |
---|
| 507 | % insert the current file series at the head of the list |
---|
[350] | 508 | InputTable=get(handles.InputTable,'Data'); |
---|
[332] | 509 | if addtest |
---|
[350] | 510 | % SeriesData=get(handles.series,'UserData'); |
---|
| 511 | % % SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num]; |
---|
| 512 | % SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile; |
---|
| 513 | % SeriesData.i1_series=[SeriesData.i1_series;{i1_series}]; |
---|
| 514 | % SeriesData.i2_series=[SeriesData.i2_series;{i2_series}]; |
---|
| 515 | % SeriesData.j1_series=[SeriesData.j1_series;{j1_series}]; |
---|
| 516 | % SeriesData.j2_series=[SeriesData.j2_series;{j2_series}]; |
---|
| 517 | InputTable=get(handles.InputTable,'Data'); |
---|
| 518 | InputTable=[{RootPath},{RootFile},{SubDir},{NomType},{FileExt};InputTable]; |
---|
| 519 | % RootPathCell=[{RootPath}; InputTable{] ; |
---|
| 520 | % SubDirCell=[{SubDir}; get(handles.SubDir,'String')]; |
---|
| 521 | % RootFileCell=[{RootFile}; get(handles.RootFile,'String')]; |
---|
| 522 | % NomTypeCell=[{NomType}; SeriesData.NomType]; |
---|
| 523 | % FileExtCell=[{FileExt}; get(handles.FileExt,'String')]; |
---|
| 524 | % FileTypeCell=[{FileType};SeriesData.FileType]; |
---|
| 525 | % set(handles.NomType,'String',[{};get(handles.NomType,'String')]) |
---|
[339] | 526 | |
---|
[332] | 527 | % or re-initialise the list of input file series |
---|
| 528 | else |
---|
[350] | 529 | InputTable=[{RootPath},{RootFile},{SubDir},{NomType},{FileExt}]; |
---|
[332] | 530 | end |
---|
[350] | 531 | set(handles.InputTable,'Data',InputTable) |
---|
| 532 | % SeriesData=[];%re-initialisation |
---|
| 533 | % % SeriesData.displ_num=[0 0 0 0]; |
---|
| 534 | % % SeriesData.i1_series={i1_series}; |
---|
| 535 | % % SeriesData.i2_series={i2_series}; |
---|
| 536 | % % SeriesData.j1_series={j1_series}; |
---|
| 537 | % % SeriesData.j2_series={j2_series}; |
---|
| 538 | % RootPathCell={RootPath}; |
---|
| 539 | % SubDirCell={SubDir}; |
---|
| 540 | % RootFileCell={RootFile}; |
---|
| 541 | % NomTypeCell={NomType}; |
---|
| 542 | % FileExtCell={FileExt}; |
---|
| 543 | % % FileTypeCell={FileType}; |
---|
| 544 | % end |
---|
| 545 | % SeriesData.NomType=NomTypeCell; |
---|
| 546 | %SeriesData.FileType=FileTypeCell; |
---|
[332] | 547 | SeriesData.CurrentInputFile=fileinput; |
---|
[350] | 548 | % set(handles.RootPath,'String',RootPathCell); |
---|
| 549 | % set(handles.SubDir,'String',SubDirCell); |
---|
| 550 | % set(handles.RootFile,'String',RootFileCell); |
---|
| 551 | % set(handles.NomType,'String',NomTypeCell); |
---|
| 552 | % set(handles.FileExt,'String',FileExtCell); |
---|
| 553 | %set(handles.InputTable,'Data',[RootPathCell SubDirCell RootFileCell NomTypeCell FileExtCell]) ; |
---|
| 554 | update_indices(handles,fileinput,1) |
---|
[332] | 555 | |
---|
[2] | 556 | |
---|
[350] | 557 | % %% display times |
---|
| 558 | % if addtest |
---|
| 559 | % SeriesData.Time=[{time} SeriesData.Time]; |
---|
| 560 | % else |
---|
| 561 | % SeriesData.Time={time}; |
---|
| 562 | % end |
---|
| 563 | % set(handles.TimeUnit,'String',TimeUnit) |
---|
| 564 | % set(handles.series,'UserData',SeriesData); |
---|
| 565 | % time_display=[time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j);... |
---|
| 566 | % time(MinIndex_i,MinIndex_j) time(ref_i,ref_j) time(ref_i,ref_j) time(MaxIndex_i,MaxIndex_j)]; |
---|
| 567 | % set(handles.time_table,'Data',time_display) |
---|
[332] | 568 | |
---|
[2] | 569 | |
---|
| 570 | |
---|
[89] | 571 | %store the root name for future opening of uvmat |
---|
[2] | 572 | dir_perso=prefdir; |
---|
| 573 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 574 | if exist(profil_perso,'file') |
---|
| 575 | save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat |
---|
| 576 | else |
---|
[147] | 577 | txt=ver('MATLAB'); |
---|
| 578 | Release=txt.Release; |
---|
[2] | 579 | relnumb=str2num(Release(3:4)); |
---|
| 580 | if relnumb >= 14 |
---|
| 581 | save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6') %store the root name for future opening of uvmat |
---|
| 582 | else |
---|
| 583 | save(profil_perso,'RootPath','SubDir','RootFile','NomType') |
---|
| 584 | end |
---|
| 585 | end |
---|
[350] | 586 | set(handles.InputTable,'BackgroundColor',[1 1 1]) |
---|
[332] | 587 | % set(handles.PathCampaign,'String',SeriesData.PathCampaign) |
---|
[350] | 588 | %num_last_j_Callback([], [], handles)% TODO:update |
---|
| 589 | %num_last_i_Callback([], [], handles) |
---|
[2] | 590 | |
---|
[350] | 591 | % %------------------------------------------------------------------------ |
---|
| 592 | % function RootPath_Callback(hObject, eventdata, handles) |
---|
| 593 | % %------------------------------------------------------------------------ |
---|
| 594 | % Val=get(handles.RootPath,'Value'); |
---|
| 595 | % synchronise_view(handles,Val) |
---|
| 596 | % NomType_Callback(hObject, eventdata, handles) |
---|
[2] | 597 | |
---|
[350] | 598 | % %------------------------------------------------------------------------ |
---|
| 599 | % function synchronise_view(handles,Val) |
---|
| 600 | % %------------------------------------------------------------------------ |
---|
| 601 | % set(handles.RootPath,'Value',Val) |
---|
| 602 | % set(handles.SubDir,'Value',Val) |
---|
| 603 | % set(handles.RootFile,'Value',Val) |
---|
| 604 | % set(handles.NomType,'Value',Val) |
---|
| 605 | % set(handles.FileExt,'Value',Val) |
---|
| 606 | % set(handles.num_MaxIndex_i,'Value',Val) |
---|
| 607 | % set(handles.num_MaxIndex_j,'Value',Val) |
---|
| 608 | % % set(handles.time_first,'Value',Val) |
---|
| 609 | % % set(handles.time_last,'Value',Val) |
---|
[2] | 610 | |
---|
| 611 | |
---|
[350] | 612 | % %------------------------------------------------------------------------ |
---|
| 613 | % % Executes on carriage return on the subdir civ1 edit window |
---|
| 614 | % function SubDir_Callback(hObject, eventdata, handles) |
---|
| 615 | % %------------------------------------------------------------------------ |
---|
| 616 | % Val=get(handles.SubDir,'Value'); |
---|
| 617 | % synchronise_view(handles,Val) |
---|
| 618 | % NomType_Callback(hObject, eventdata, handles) |
---|
[2] | 619 | |
---|
[350] | 620 | % %------------------------------------------------------------------------ |
---|
| 621 | % % --- function activated when a new filebase (image series) is introduced |
---|
| 622 | % function RootFile_Callback(hObject, eventdata, handles) |
---|
| 623 | % %------------------------------------------------------------------------ |
---|
| 624 | % Val=get(handles.RootFile,'Value'); |
---|
| 625 | % synchronise_view(handles,Val) |
---|
| 626 | % NomType_Callback(hObject, eventdata, handles) |
---|
[2] | 627 | |
---|
| 628 | %-------------------------------------------------------------- |
---|
[350] | 629 | % %function activated when a new filebase (image series) is introduced |
---|
| 630 | % %------------------------------------------------------------ |
---|
| 631 | % function FileExt_Callback(hObject, eventdata, handles) |
---|
| 632 | % Val=get(handles.FileExt,'Value'); |
---|
| 633 | % synchronise_view(handles,Val) |
---|
[2] | 634 | |
---|
[350] | 635 | % %-------------------------------------------------------------- |
---|
| 636 | % %function activated when a new filebase (image series) is introduced |
---|
| 637 | % %------------------------------------------------------------ |
---|
| 638 | % function num_MaxIndex_i_Callback(hObject, eventdata, handles) |
---|
| 639 | % Val=get(handles.num_MaxIndex_i,'Value'); |
---|
| 640 | % synchronise_view(handles,Val) |
---|
[2] | 641 | |
---|
[350] | 642 | % %-------------------------------------------------------------- |
---|
| 643 | % %function activated when a new filebase (image series) is introduced |
---|
| 644 | % %------------------------------------------------------------ |
---|
| 645 | % function num_MaxIndex_j_Callback(hObject, eventdata, handles) |
---|
| 646 | % Val=get(handles.num_MaxIndex_j,'Value'); |
---|
| 647 | % synchronise_view(handles,Val) |
---|
| 648 | % |
---|
| 649 | % %-------------------------------------------------------------- |
---|
| 650 | % %function activated when a new filebase (image series) is introduced |
---|
| 651 | % %------------------------------------------------------------ |
---|
| 652 | % function time_first_Callback(hObject, eventdata, handles) |
---|
| 653 | % Val=get(handles.time_first,'Value'); |
---|
| 654 | % synchronise_view(handles,Val) |
---|
| 655 | % |
---|
| 656 | % %-------------------------------------------------------------- |
---|
| 657 | % %function activated when a new filebase (image series) is introduced |
---|
| 658 | % %------------------------------------------------------------ |
---|
| 659 | % function time_last_Callback(hObject, eventdata, handles) |
---|
| 660 | % Val=get(handles.time_last,'Value'); |
---|
| 661 | % synchronise_view(handles,Val) |
---|
| 662 | % NomType_Callback(hObject, eventdata, handles) |
---|
[2] | 663 | |
---|
[350] | 664 | % %------------------------------------------------------------------------ |
---|
| 665 | % function NomType_Callback(hObject, eventdata, handles) |
---|
| 666 | % %------------------------------------------------------------------------ |
---|
[2] | 667 | |
---|
[350] | 668 | % --- Executes when entered data in editable cell(s) in InputTable. |
---|
| 669 | function InputTable_CellEditCallback(hObject, eventdata, handles) |
---|
| 670 | % hObject handle to InputTable (see GCBO) |
---|
| 671 | % eventdata structure with the following fields (see UITABLE) |
---|
| 672 | % Indices: row and column indices of the cell(s) edited |
---|
| 673 | % PreviousData: previous data for the cell(s) edited |
---|
| 674 | % EditData: string(s) entered by the user |
---|
| 675 | % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed |
---|
| 676 | % Error: error string when failed to convert EditData to appropriate value for Data |
---|
| 677 | % handles structure with handles and user data (see GUIDATA) |
---|
| 678 | eventdata |
---|
| 679 | list_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
| 680 | list_lines(eventdata.Indices(1))=1; %select the edited line for refresh |
---|
| 681 | set(handles.REFRESH_INDICES,'UserData',list_lines); |
---|
| 682 | set(handles.REFRESH_INDICES,'Visible','on') |
---|
[2] | 683 | |
---|
[339] | 684 | |
---|
[2] | 685 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%???????????? |
---|
| 686 | % --- Executes on button press in mode. |
---|
| 687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[350] | 688 | function mode_Callback(hObject, eventdata, handles) |
---|
| 689 | |
---|
| 690 | SeriesData=get(handles.series,'UserData'); |
---|
| 691 | mode_list=get(handles.mode,'String'); |
---|
| 692 | mode_value=get(handles.mode,'Value'); |
---|
| 693 | mode=mode_list{mode_value}; |
---|
| 694 | NomType=[]; |
---|
| 695 | % test_find_pair=0; |
---|
| 696 | % if isfield(SeriesData,'NomType') |
---|
| 697 | NomTypeCell=SeriesData.NomType; |
---|
| 698 | Val=get(handles.NomType,'Value'); |
---|
| 699 | NomType=NomTypeCell{Val}; |
---|
| 700 | check_pairs=~isempty(SeriesData.i2_series{Val})||~isempty(SeriesData.j2_series{Val}); |
---|
| 701 | |
---|
| 702 | time=[]; |
---|
| 703 | if isfield(SeriesData,'Time') |
---|
| 704 | time=SeriesData.Time{1}; %get the set of times |
---|
| 705 | end |
---|
| 706 | siztime=size(time); |
---|
| 707 | nbfield=siztime(1); |
---|
| 708 | nbfield2=siztime(2); |
---|
| 709 | % indchosen=1; %%first pair selected by default |
---|
| 710 | if isequal(mode,'bursts') |
---|
| 711 | enable_i(handles,'On') |
---|
| 712 | enable_j(handles,'Off') %do not display j index scanning in burst mode (j is fixed by the burst choice) |
---|
| 713 | elseif ~isempty(SeriesData.j2_series{Val}) |
---|
| 714 | enable_i(handles,'On') |
---|
| 715 | enable_j(handles,'On') % allow both i and j index scanning |
---|
| 716 | else |
---|
| 717 | enable_i(handles,'On') |
---|
| 718 | enable_j(handles,'Off') |
---|
| 719 | end |
---|
| 720 | % set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1 |
---|
| 721 | set(handles.series,'UserData',SeriesData) |
---|
| 722 | |
---|
| 723 | %list pairs if relevant |
---|
| 724 | if check_pairs |
---|
| 725 | find_netcpair_civ(handles,Val) |
---|
| 726 | end |
---|
[339] | 727 | |
---|
[2] | 728 | %------------------------------------- |
---|
| 729 | function enable_i(handles,state) |
---|
| 730 | set(handles.i_txt,'Visible',state) |
---|
[339] | 731 | set(handles.num_first_i,'Visible',state) |
---|
| 732 | set(handles.num_last_i,'Visible',state) |
---|
| 733 | set(handles.num_incr_i,'Visible',state) |
---|
| 734 | set(handles.num_MaxIndex_i,'Visible',state) |
---|
[2] | 735 | set(handles.ref_i,'Visible',state) |
---|
| 736 | set(handles.ref_i_text,'Visible',state) |
---|
| 737 | |
---|
| 738 | %----------------------------------- |
---|
| 739 | function enable_j(handles,state) |
---|
| 740 | set(handles.j_txt,'Visible',state) |
---|
[339] | 741 | set(handles.num_MinIndex_j,'Visible',state) |
---|
| 742 | set(handles.num_first_j,'Visible',state) |
---|
| 743 | set(handles.num_last_j,'Visible',state) |
---|
| 744 | set(handles.num_incr_j,'Visible',state) |
---|
| 745 | set(handles.num_MaxIndex_j,'Visible',state) |
---|
[2] | 746 | set(handles.ref_j,'Visible',state) |
---|
| 747 | set(handles.ref_j_text,'Visible',state) |
---|
| 748 | |
---|
| 749 | %----------------------------------- |
---|
| 750 | function view_FieldMenu(handles,state) |
---|
[350] | 751 | % set(handles.FieldMenu,'Visible',state) |
---|
| 752 | % set(handles.Field_text,'Visible',state) |
---|
| 753 | set(handles.InputFields,'Visible',state) |
---|
[2] | 754 | |
---|
| 755 | %----------------------------------- |
---|
| 756 | function view_FieldMenu_1(handles,state) |
---|
| 757 | set(handles.FieldMenu_1,'Visible',state) |
---|
| 758 | set(handles.Field_text_1,'Visible',state) |
---|
| 759 | |
---|
[339] | 760 | % %----------------------------------- |
---|
| 761 | % function view_TRANSFORM(handles,state) |
---|
| 762 | % set(handles.TRANSFORM_frame,'Visible',state) |
---|
| 763 | % set(handles.transform_fct,'Visible',state); |
---|
| 764 | % set(handles.TRANSFORM_title,'Visible',state) |
---|
[2] | 765 | |
---|
| 766 | %-------------------------------------------------------------- |
---|
[89] | 767 | % determine the menu for civ1 pairs depending on existing netcdf files |
---|
| 768 | % with the reference indices ref_i and ref_j |
---|
[2] | 769 | %---------------------------------------------------------------- |
---|
[339] | 770 | function find_netcpair_civ(handles,Val) |
---|
[332] | 771 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 772 | % NomTypeCell=get(handles.NomType,'String'); |
---|
| 773 | NomTypeCell=SeriesData.NomType; |
---|
| 774 | NomType=NomTypeCell{Val}; |
---|
[339] | 775 | |
---|
| 776 | set(handles.Pairs,'Visible','on')% makes the panel "Pairs' visible |
---|
[2] | 777 | %nomenclature types |
---|
| 778 | RootPathCell=get(handles.RootPath,'String'); |
---|
| 779 | filepath=RootPathCell{Val}; |
---|
| 780 | RootFileCell=get(handles.RootFile,'String'); |
---|
| 781 | filename=RootFileCell{Val}; |
---|
| 782 | filebase=fullfile(filepath,filename); |
---|
| 783 | SubDirCell=get(handles.SubDir,'String'); |
---|
| 784 | subdir=SubDirCell{Val}; |
---|
| 785 | if ~exist(fullfile(filepath,subdir),'dir') |
---|
| 786 | msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist']) |
---|
| 787 | set(handles.list_pair_civ,'String',{''}); |
---|
| 788 | return |
---|
| 789 | end |
---|
| 790 | mode_list=get(handles.mode,'String'); |
---|
| 791 | mode_value=get(handles.mode,'Value'); |
---|
| 792 | mode=mode_list{mode_value}; |
---|
| 793 | |
---|
| 794 | %reads image numbers from the interface |
---|
[339] | 795 | % ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 796 | % ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 797 | % ref_time=0; |
---|
| 798 | % nbfield=50; |
---|
| 799 | % nbfield2=50;%default max number of pairs |
---|
[188] | 800 | |
---|
[2] | 801 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 802 | % be performed, while the result is needed for next steps. |
---|
[339] | 803 | |
---|
| 804 | % ind_exist=0; |
---|
[2] | 805 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 806 | if length(TimeUnit)>=1 |
---|
| 807 | dtunit=['m' TimeUnit]; |
---|
| 808 | else |
---|
| 809 | dtunit='e-03'; |
---|
| 810 | end |
---|
[339] | 811 | |
---|
| 812 | %% NEW |
---|
| 813 | i1_series=SeriesData.i1_series{Val}; |
---|
| 814 | i2_series=SeriesData.i2_series{Val}; |
---|
| 815 | j1_series=SeriesData.j1_series{Val}; |
---|
| 816 | j2_series=SeriesData.j2_series{Val}; |
---|
| 817 | displ_pair={}; |
---|
[118] | 818 | if strcmp(mode,'series(Di)') |
---|
[339] | 819 | if isempty(i2_series) |
---|
| 820 | msgbox_uvmat('ERROR','no i1-i2 pair available') |
---|
| 821 | return |
---|
| 822 | end |
---|
| 823 | diff_i=i2_series-i1_series; |
---|
| 824 | min_diff=min(diff_i(diff_i>0)); |
---|
| 825 | max_diff=max(diff_i(diff_i>0)); |
---|
| 826 | for ipair=min_diff:max_diff |
---|
| 827 | if numel(diff_i(diff_i==ipair))>0 |
---|
| 828 | displ_pair=[displ_pair;{['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}]; |
---|
| 829 | end |
---|
| 830 | end |
---|
| 831 | if ~isempty(displ_pair) |
---|
| 832 | displ_pair=[displ_pair;{'Di=*|*'}]; |
---|
| 833 | end |
---|
| 834 | elseif strcmp(mode,'series(Dj)') |
---|
| 835 | if isempty(j2_series) |
---|
| 836 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 837 | return |
---|
| 838 | end |
---|
| 839 | diff_j=j2_series-j1_series; |
---|
| 840 | min_diff=min(diff_j(diff_j>0)); |
---|
| 841 | max_diff=max(diff_j(diff_j>0)); |
---|
| 842 | for ipair=min_diff:max_diff |
---|
| 843 | if numel(diff_j(diff_j==ipair))>0 |
---|
| 844 | displ_pair=[displ_pair;{['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ]}]; |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | if ~isempty(displ_pair) |
---|
| 848 | displ_pair=[displ_pair;{'Dj=*|*'}]; |
---|
| 849 | end |
---|
| 850 | elseif strcmp(mode,'bursts') |
---|
| 851 | if isempty(j2_series) |
---|
| 852 | msgbox_uvmat('ERROR','no j1-j2 pair available') |
---|
| 853 | return |
---|
| 854 | end |
---|
| 855 | diff_j=j2_series-j1_series; |
---|
| 856 | min_j1=min(j1_series(j1_series>0)); |
---|
| 857 | max_j1=max(j1_series(j1_series>0)); |
---|
| 858 | min_j2=min(j2_series(j2_series>0)); |
---|
| 859 | max_j2=max(j2_series(j2_series>0)); |
---|
| 860 | for pair1=min_j1:min(max_j1,min_j1+20) |
---|
| 861 | for pair2=min_j2:min(max_j2,min_j2+20) |
---|
| 862 | if numel(j1_series(j1_series==pair1))>0 && numel(j2_series(j2_series==pair2))>0 |
---|
| 863 | displ_pair=[displ_pair;{['j= ' num2str(pair1) '-' num2str(pair2)]}]; |
---|
| 864 | end |
---|
| 865 | end |
---|
| 866 | end |
---|
| 867 | if ~isempty(displ_pair) |
---|
| 868 | displ_pair=[displ_pair;{'j=*-*'}]; |
---|
| 869 | end |
---|
| 870 | end |
---|
| 871 | |
---|
| 872 | %% display list of pairs |
---|
| 873 | displ_pair_list=get(handles.list_pair_civ,'String'); |
---|
| 874 | NewVal=[]; |
---|
| 875 | if ~isempty(displ_pair_list) |
---|
| 876 | Val=get(handles.list_pair_civ,'Value'); |
---|
| 877 | NewVal=find(strcmp(displ_pair_list{Val},displ_pair),1);% look at the previous display in the new menu displ_pâir |
---|
| 878 | end |
---|
| 879 | if ~isempty(NewVal) |
---|
| 880 | set(handles.list_pair_civ,'Value',NewVal) |
---|
| 881 | else |
---|
| 882 | set(handles.list_pair_civ,'Value',1) |
---|
| 883 | end |
---|
| 884 | set(handles.list_pair_civ,'String',displ_pair) |
---|
| 885 | displ_pair |
---|
| 886 | |
---|
| 887 | % displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
| 888 | % if strcmp(mode,'series(Di)') |
---|
| 889 | % for index=1:min(nbfield-1,50) |
---|
| 890 | % filename=name_generator(filebase,ref_i-floor(index/2),ref_j,'.nc',NomType,1,ref_i+ceil(index/2),ref_j,subdir); |
---|
| 891 | % select=(exist(filename,'file')==2); |
---|
| 892 | % if select==1 |
---|
| 893 | % ind_exist=ind_exist+1; |
---|
| 894 | % displ_num(1,ind_exist)=0; |
---|
| 895 | % displ_num(2,ind_exist)=0; |
---|
| 896 | % displ_num(3,ind_exist)=-floor(index/2); |
---|
| 897 | % displ_num(4,ind_exist)=ceil(index/2); |
---|
| 898 | % %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'}); |
---|
| 899 | % [Cte,var_detect,ichoice]=nc2struct(filename,{}); |
---|
| 900 | % if isfield(Cte,'dt2') |
---|
| 901 | % dt=Cte.dt2; |
---|
| 902 | % elseif isfield(Cte,'dt') |
---|
| 903 | % dt=Cte.dt; |
---|
| 904 | % end |
---|
| 905 | % if isfield(Cte,'absolut_time_TO_2') |
---|
| 906 | % ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
| 907 | % elseif isfield(Cte,'absolut_time_TO') |
---|
| 908 | % ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
| 909 | % elseif isfield(Cte,'Time') |
---|
| 910 | % ref_time(ind_exist)=Cte.Time; |
---|
| 911 | % end |
---|
| 912 | % displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
| 913 | % end |
---|
| 914 | % end |
---|
| 915 | % set(handles.list_pair_civ,'String',[displ_pair';{'Di=*|*'}]); |
---|
| 916 | % elseif isequal(mode,'series(Dj)')% series on the j index |
---|
| 917 | % for index=1:min(nbfield2-1,50) |
---|
| 918 | % filename=name_generator(filebase,ref_i,ref_j-floor(index/2),'.nc',NomType,1,ref_i,ref_j+ceil(index/2),subdir); |
---|
| 919 | % select=(exist(filename,'file')==2); |
---|
| 920 | % if select==1 |
---|
| 921 | % ind_exist=ind_exist+1; |
---|
| 922 | % displ_num(1,ind_exist)=-floor(index/2); |
---|
| 923 | % displ_num(2,ind_exist)=ceil(index/2); |
---|
| 924 | % displ_num(3,ind_exist)=0; |
---|
| 925 | % displ_num(4,ind_exist)=0; |
---|
| 926 | % [Cte,var_detect,ichoice]=nc2struct(filename,{}); |
---|
| 927 | % if isfield(Cte,'dt2') |
---|
| 928 | % dt=Cte.dt2; |
---|
| 929 | % elseif isfield(Cte,'dt') |
---|
| 930 | % dt=Cte.dt; |
---|
| 931 | % end |
---|
| 932 | % if isfield(Cte,'absolut_time_TO_2') |
---|
| 933 | % ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
| 934 | % elseif isfield(Cte,'absolut_time_TO') |
---|
| 935 | % ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
| 936 | % elseif isfield(Cte,'Time') |
---|
| 937 | % ref_time(ind_exist)=Cte.Time; |
---|
| 938 | % end |
---|
| 939 | % displ_pair{ind_exist}=['Dj= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
| 940 | % end |
---|
| 941 | % end |
---|
| 942 | % set(handles.list_pair_civ,'String',[displ_pair';{'Dj=*|*'}]); |
---|
| 943 | % elseif isequal(mode,'bursts') %case of bursts |
---|
| 944 | % for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'bursts' mode |
---|
| 945 | % for numod_b=(numod_a+1):nbfield2 |
---|
| 946 | % [filename]=name_generator(filebase,ref_i,numod_a,'.nc',NomType,1,ref_i,numod_b,subdir) |
---|
| 947 | % select=(exist(filename,'file')==2) |
---|
| 948 | % if select==1 |
---|
| 949 | % ind_exist=ind_exist+1; |
---|
| 950 | % numlist_a(ind_exist)=numod_a; |
---|
| 951 | % numlist_b(ind_exist)=numod_b; |
---|
| 952 | % Attr=nc2struct(filename,[]); |
---|
| 953 | % isfield(Attr,'absolut_time_T0_2') |
---|
| 954 | % if isfield(Attr,'dt2') |
---|
| 955 | % dt(ind_exist)=Attr.dt2; |
---|
| 956 | % ref_time(ind_exist)=Attr.absolut_time_T0_2; |
---|
| 957 | % elseif isfield(Attr,'dt')& isfield(Attr,'absolut_time_T0') |
---|
| 958 | % dt(ind_exist)=Attr.dt; |
---|
| 959 | % ref_time(ind_exist)=Attr.absolut_time_T0; |
---|
[2] | 960 | % else |
---|
[339] | 961 | % dt(ind_exist)=NaN;%no information on dt |
---|
| 962 | % end |
---|
| 963 | % %determine nom_type_ima for pair display (used in num2stra.m) |
---|
| 964 | % switch NomType |
---|
| 965 | % case {'#ab'} |
---|
| 966 | % nom_type_ima='#a'; |
---|
| 967 | % case {'#AB'} |
---|
| 968 | % nom_type_ima='#A'; |
---|
| 969 | % otherwise |
---|
| 970 | % nom_type_ima='_1_1'; |
---|
| 971 | % end |
---|
| 972 | % displ_pair{ind_exist}=['j= ' num2stra(numod_a,nom_type_ima,2) '-' num2stra(numod_b,nom_type_ima,2) ... |
---|
| 973 | % ' :dt= ' num2str(dt(ind_exist)*1000)]; |
---|
| 974 | % end |
---|
| 975 | % end |
---|
| 976 | % set(handles.list_pair_civ,'String',[displ_pair';{'j=*-*'}]); |
---|
| 977 | % end |
---|
| 978 | % if exist('dt','var') & ~isempty(dt) |
---|
| 979 | % [dtsort,indsort]=sort(dt); |
---|
| 980 | % displ_num(1,:)=numlist_a(indsort); |
---|
| 981 | % displ_num(2,:)=numlist_b(indsort); |
---|
| 982 | % displ_num(3,:)=0; |
---|
| 983 | % displ_num(4,:)=0; |
---|
| 984 | % displ_pair=displ_pair(indsort); |
---|
| 985 | % ref_time=ref_time(indsort); |
---|
| 986 | % end |
---|
| 987 | % end |
---|
| 988 | if isempty(displ_pair) |
---|
| 989 | msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' subdir]) |
---|
[2] | 990 | end |
---|
[339] | 991 | return |
---|
| 992 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END FUNCTION |
---|
| 993 | |
---|
| 994 | |
---|
[2] | 995 | if ind_exist==0 |
---|
| 996 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
| 997 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir]) |
---|
| 998 | else |
---|
| 999 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir]) |
---|
| 1000 | end |
---|
| 1001 | if isequal(mode,'bursts') %case of bursts |
---|
| 1002 | set(handles.list_pair_civ,'String',{'j=*-*'}); |
---|
| 1003 | elseif isequal(mode,'series(Di)') %case of bursts |
---|
| 1004 | set(handles.list_pair_civ,'String',{'Di=*|*'}); |
---|
| 1005 | elseif isequal(mode,'series(Dj)') %case of bursts |
---|
| 1006 | set(handles.list_pair_civ,'String',{'Dj=*|*'}); |
---|
| 1007 | end |
---|
| 1008 | end |
---|
[339] | 1009 | return |
---|
| 1010 | %TO update |
---|
[2] | 1011 | val=get(handles.list_pair_civ,'Value'); |
---|
| 1012 | if val > length(displ_pair) |
---|
| 1013 | set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu |
---|
| 1014 | val=1; |
---|
| 1015 | end |
---|
| 1016 | iview=get(handles.NomType,'Value'); |
---|
| 1017 | SeriesData.displ_num(iview,:)=(displ_num(:,val))'; |
---|
| 1018 | SeriesData.ref_time=ref_time; |
---|
[332] | 1019 | set(handles.series,'UserData',SeriesData) |
---|
[339] | 1020 | list_pair_civ_Callback([],[],handles) |
---|
[2] | 1021 | |
---|
| 1022 | %------------------------------------------------------------- |
---|
| 1023 | % --- Executes on selection in list_pair_civ. |
---|
[339] | 1024 | function list_pair_civ_Callback(hObject,eventdata,handles) |
---|
[2] | 1025 | %------------------------------------------------------------ |
---|
[339] | 1026 | return |
---|
| 1027 | %%%%%%%% |
---|
| 1028 | %update num_first_i and num_last_i according to the chosen image pairs |
---|
[2] | 1029 | testupdate=0; |
---|
| 1030 | Val=get(handles.RootPath,'Value'); |
---|
| 1031 | IndexCell=get(handles.NomType,'String'); |
---|
[332] | 1032 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1033 | NomType=SeriesData.NomType{Val}; |
---|
| 1034 | list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs |
---|
| 1035 | index_pair=get(handles.list_pair_civ,'Value'); |
---|
| 1036 | str_pair=list_pair{index_pair}; |
---|
| 1037 | ind_equ=strfind(str_pair,'=');%find '=' |
---|
| 1038 | ind_sep=strfind(str_pair,'|');%find pair separator '|' |
---|
| 1039 | ind_com=strfind(str_pair,':');%find ':' |
---|
| 1040 | test_bursts=0; |
---|
| 1041 | if isempty(ind_sep) |
---|
| 1042 | ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|' |
---|
| 1043 | test_bursts=1;% we are in the case of bursts |
---|
| 1044 | end |
---|
| 1045 | displ_num=[0 0 0 0]; %default |
---|
| 1046 | if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-') |
---|
| 1047 | num1_str=str_pair(ind_equ(1)+1:ind_sep-1); |
---|
| 1048 | num2_str=str_pair(ind_sep+1:ind_com-1); |
---|
| 1049 | num1=str2double(num1_str); |
---|
| 1050 | num2=str2double(num2_str); |
---|
| 1051 | if isequal(num1_str(1),' ') |
---|
| 1052 | num1_str(1)=[]; |
---|
| 1053 | end |
---|
| 1054 | if isequal(num2_str(end),' ') |
---|
| 1055 | num2_str(end)=[]; |
---|
| 1056 | end |
---|
| 1057 | switch NomType |
---|
[332] | 1058 | case {'_1-2_1'} |
---|
[2] | 1059 | if isequal(num1_str(1),'0') |
---|
| 1060 | IndexCell{Val}=['_(i-(i+' num2_str ')_j']; |
---|
| 1061 | else |
---|
| 1062 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j']; |
---|
| 1063 | end |
---|
| 1064 | displ_num(3)=num1; |
---|
| 1065 | displ_num(4)=num2; |
---|
[332] | 1066 | case {'_1-2'} |
---|
[2] | 1067 | if isequal(num1_str(1),'0') |
---|
| 1068 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
| 1069 | else |
---|
| 1070 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
| 1071 | end |
---|
| 1072 | displ_num(3)=num1; |
---|
| 1073 | displ_num(4)=num2; |
---|
[332] | 1074 | case '_1_1-2' |
---|
[2] | 1075 | if test_bursts |
---|
| 1076 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
| 1077 | else |
---|
| 1078 | if isequal(num1_str(1),'0') |
---|
| 1079 | IndexCell{Val}=['_i_j-(j+' num2_str ')']; |
---|
| 1080 | else |
---|
| 1081 | IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')']; |
---|
| 1082 | end |
---|
| 1083 | end |
---|
| 1084 | displ_num(1)=num1; |
---|
| 1085 | displ_num(2)=num2; |
---|
| 1086 | case {'#_ab'} %TO COMPLETE |
---|
| 1087 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
| 1088 | |
---|
| 1089 | end |
---|
| 1090 | end |
---|
| 1091 | set(handles.NomType,'String',IndexCell) |
---|
| 1092 | SeriesData.displ_num(Val,:)=displ_num; |
---|
[332] | 1093 | set(handles.series,'UserData',SeriesData) |
---|
[2] | 1094 | % set(handles.NomType,'Value',Val) |
---|
| 1095 | |
---|
| 1096 | if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*') |
---|
| 1097 | mode_list=get(handles.mode,'String'); |
---|
| 1098 | mode_value=get(handles.mode,'Value'); |
---|
| 1099 | mode=mode_list{mode_value}; |
---|
| 1100 | if isequal(mode,'series(Di)') |
---|
[339] | 1101 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 1102 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 1103 | incr_i=str2num(get(handles.num_incr_i,'String')); |
---|
[2] | 1104 | num1=first_i:incr_i:last_i; |
---|
[339] | 1105 | lastfieldCell=get(handles.num_MaxIndex_i,'String'); |
---|
[2] | 1106 | lastfield=str2num(lastfieldCell{1}); |
---|
| 1107 | if ~isempty(lastfield) |
---|
| 1108 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1109 | num1=num1(ind); |
---|
| 1110 | end |
---|
[100] | 1111 | if ~isempty(num1) |
---|
[339] | 1112 | set(handles.num_first_i,'String',num2str(num1(1))); |
---|
| 1113 | set(handles.num_last_i,'String',num2str(num1(end))); |
---|
[100] | 1114 | end |
---|
[2] | 1115 | testupdate=1; |
---|
| 1116 | elseif isequal(mode,'series(Dj)') |
---|
[339] | 1117 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 1118 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 1119 | incr_j=str2num(get(handles.num_incr_j,'String')); |
---|
[2] | 1120 | num_j=first_j:incr_j:last_j; |
---|
[339] | 1121 | lastfieldCell=get(handles.num_MaxIndex_j,'String'); |
---|
[2] | 1122 | if ~isempty(lastfieldCell) |
---|
| 1123 | lastfield2=lastfieldCell{1}; |
---|
| 1124 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1125 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1126 | end |
---|
| 1127 | testupdate=1; |
---|
| 1128 | end |
---|
| 1129 | |
---|
| 1130 | %update the first and last times of the series |
---|
[46] | 1131 | if testupdate && isfield(SeriesData,'Time') |
---|
[2] | 1132 | if ~isempty(SeriesData.Time{1}) |
---|
[350] | 1133 | displ_time(handles); |
---|
[2] | 1134 | end |
---|
| 1135 | end |
---|
| 1136 | end |
---|
[41] | 1137 | |
---|
| 1138 | %------------------------------------------------------------------------ |
---|
[2] | 1139 | % --- Executes on button press in RUN. |
---|
| 1140 | function RUN_Callback(hObject, eventdata, handles) |
---|
[41] | 1141 | %------------------------------------------------------------------------ |
---|
[339] | 1142 | %% read root name and field type |
---|
[2] | 1143 | set(handles.RUN,'BusyAction','queue'); |
---|
[332] | 1144 | set(0,'CurrentFigure',handles.series) |
---|
[46] | 1145 | if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1) |
---|
[2] | 1146 | Series.GetObject=1; |
---|
| 1147 | GetObject_Callback(hObject, eventdata, handles) |
---|
| 1148 | else |
---|
| 1149 | Series.GetObject=0; |
---|
| 1150 | end |
---|
[332] | 1151 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1152 | |
---|
[339] | 1153 | % Series.hseries=handles.series; % handles to the series GUI |
---|
[2] | 1154 | |
---|
[339] | 1155 | %% Read parameters from series |
---|
| 1156 | Series=read_GUI(handles.series);%TODO: extend to all input param |
---|
| 1157 | Series.hseries=handles.series; % handles to the series GUI |
---|
| 1158 | |
---|
| 1159 | first_i=1; |
---|
| 1160 | last_i=1; |
---|
| 1161 | incr_i=1; |
---|
| 1162 | first_j=1; |
---|
| 1163 | last_j=1; |
---|
| 1164 | incr_j=1; |
---|
| 1165 | if isfield(Series.IndexRange,'first_i') |
---|
| 1166 | first_i=Series.IndexRange.first_i; |
---|
| 1167 | incr_i=Series.IndexRange.incr_i; |
---|
| 1168 | last_i=Series.IndexRange.last_i; |
---|
| 1169 | end |
---|
| 1170 | if isfield(Series.IndexRange,'first_j') |
---|
| 1171 | first_j=Series.IndexRange.first_j; |
---|
| 1172 | incr_j=Series.IndexRange.incr_j; |
---|
| 1173 | last_j=Series.IndexRange.last_j; |
---|
| 1174 | end |
---|
| 1175 | |
---|
| 1176 | %% read input file parameters and set menus |
---|
[2] | 1177 | Series.PathProject=get(handles.PathCampaign,'String'); |
---|
| 1178 | RootPath=get(handles.RootPath,'String');% path of the root name of the first field series |
---|
| 1179 | RootFile=get(handles.RootFile,'String');% root name of the first field series |
---|
| 1180 | SubDir=get(handles.SubDir,'String');% subdirectory for netcdf files |
---|
| 1181 | FileExt=get(handles.FileExt,'String');%file extension |
---|
| 1182 | if isempty(SeriesData) |
---|
| 1183 | msgbox_uvmat('ERROR','no input file series') |
---|
| 1184 | return |
---|
| 1185 | end |
---|
| 1186 | NomType=SeriesData.NomType; |
---|
| 1187 | if length(RootPath)==1 %string character input for user fct |
---|
| 1188 | Series.RootPath=RootPath{1}; |
---|
| 1189 | Series.RootFile=RootFile{1}; |
---|
| 1190 | Series.SubDir=SubDir{1}; |
---|
| 1191 | Series.FileExt=FileExt{1}; |
---|
| 1192 | Series.NomType=NomType{1}; |
---|
| 1193 | else %cell input for user fct |
---|
| 1194 | Series.RootPath=RootPath; |
---|
| 1195 | Series.RootFile=RootFile; |
---|
| 1196 | Series.SubDir=SubDir; |
---|
| 1197 | Series.FileExt=FileExt; |
---|
| 1198 | Series.NomType=NomType; |
---|
| 1199 | end |
---|
| 1200 | if isequal(get(handles.FieldMenu,'Visible'),'on') |
---|
| 1201 | FieldMenu=get(handles.FieldMenu,'String'); |
---|
| 1202 | FieldValue=get(handles.FieldMenu,'Value'); |
---|
| 1203 | Series.Field=FieldMenu(FieldValue); |
---|
| 1204 | end |
---|
[39] | 1205 | menu_coord_state=get(handles.transform_fct,'Visible'); |
---|
[2] | 1206 | Series.CoordType='';%default |
---|
| 1207 | if isequal(menu_coord_state,'on') |
---|
[41] | 1208 | % menu_coord=get(handles.transform_fct,'String'); |
---|
[39] | 1209 | menu_index=get(handles.transform_fct,'Value'); |
---|
[41] | 1210 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1211 | Series.transform_fct=transform_list{menu_index};% transform function handles |
---|
[2] | 1212 | end |
---|
[339] | 1213 | |
---|
| 1214 | % |
---|
| 1215 | % first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 1216 | % last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 1217 | % incr_i=str2num(get(handles.num_incr_i,'String')); |
---|
| 1218 | % first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 1219 | % last_j=str2num(get(handles.num_last_j,'String')); |
---|
| 1220 | % incr_j=str2num(get(handles.num_incr_j,'String')); |
---|
| 1221 | % if ~isequal(get(handles.num_first_i,'Visible'),'on') |
---|
| 1222 | % first_i=1; |
---|
| 1223 | % last_i=1; |
---|
| 1224 | % incr_i=1; |
---|
| 1225 | % end |
---|
| 1226 | % if ~isequal(get(handles.num_first_j,'Visible'),'on') |
---|
| 1227 | % first_j=1; |
---|
| 1228 | % last_j=1; |
---|
| 1229 | % incr_j=1; |
---|
| 1230 | % end |
---|
[2] | 1231 | |
---|
[339] | 1232 | %reinitiate waitbar position |
---|
| 1233 | Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS |
---|
| 1234 | waitbarpos=Series.WaitbarPos; |
---|
| 1235 | waitbarpos(4)=0.005;%reinitialize waitbar to zero height |
---|
| 1236 | waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005; |
---|
| 1237 | % set(handles.waitbar,'Position',waitbarpos) |
---|
| 1238 | |
---|
[341] | 1239 | if isfield(Series.IndexRange,'NbSlice') |
---|
[339] | 1240 | Series.NbSlice=Series.IndexRange.NbSlice; |
---|
[341] | 1241 | end |
---|
[2] | 1242 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
| 1243 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
[205] | 1244 | num_i=first_i:incr_i:last_i; |
---|
| 1245 | num_j=first_j:incr_j:last_j; |
---|
[339] | 1246 | nbfield_cell=get(handles.num_MaxIndex_i,'String'); |
---|
[2] | 1247 | nbfield=[]; %default |
---|
| 1248 | for iview=1:length(nbfield_cell) |
---|
| 1249 | nb=str2num(nbfield_cell{iview}); |
---|
| 1250 | if ~isempty(nb) |
---|
| 1251 | nbfield=[nbfield nb]; |
---|
| 1252 | end |
---|
| 1253 | end |
---|
| 1254 | nbfield=min(nbfield); |
---|
[339] | 1255 | nbfield2_cell=get(handles.num_MaxIndex_j,'String'); |
---|
[2] | 1256 | nbfield2=[]; %default |
---|
| 1257 | for iview=1:length(nbfield2_cell) |
---|
| 1258 | nb=str2num(nbfield2_cell{iview}); |
---|
| 1259 | if ~isempty(nb) |
---|
| 1260 | nbfield2=[nbfield2 nb]; |
---|
| 1261 | end |
---|
| 1262 | end |
---|
| 1263 | nbfield2=min(nbfield2); |
---|
| 1264 | |
---|
| 1265 | %get complementary information from the 'series' interface |
---|
| 1266 | list_action=get(handles.ACTION,'String');% list menu action |
---|
| 1267 | index_action=get(handles.ACTION,'Value');% selected string index |
---|
| 1268 | action= list_action{index_action}; % selected string |
---|
| 1269 | mode_list=get(handles.mode,'String'); |
---|
| 1270 | index_mode=get(handles.mode,'Value'); |
---|
| 1271 | mode=mode_list{index_mode}; |
---|
| 1272 | ind_shift=0;%default |
---|
| 1273 | |
---|
| 1274 | %determine the list of input file names |
---|
| 1275 | nbmissing=0; |
---|
| 1276 | for iview=1:length(RootPath) |
---|
| 1277 | %case of pairs (.nc files) |
---|
[339] | 1278 | fileinput=name_generator(fullfile(RootPath{iview},RootFile{iview}),first_i,first_j,FileExt{iview},NomType{iview},1,first_i+1,first_j+1,SubDir{iview}); |
---|
| 1279 | if strcmp(get(handles.Pairs,'Visible'),'on') |
---|
| 1280 | pair_list=get(handles.list_pair_civ,'String'); |
---|
| 1281 | val=get(handles.list_pair_civ,'Value'); |
---|
| 1282 | pair_string=pair_list{val}; |
---|
| 1283 | r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names'); |
---|
| 1284 | if ~isempty(r) |
---|
| 1285 | if strcmp(r.num1,'*')%free pairs |
---|
| 1286 | [~,RootFile,i1_series,i2_series,j1_series,j2_series,~,~,Object]=find_file_series(fileinput)% TODO: choice pair when multiple choice |
---|
| 1287 | |
---|
| 1288 | if isempty(i2_series) %j pairs |
---|
| 1289 | ind_sel=i1_series>=i1_series>=first_i & i1_series<=last_i & j1_series>first_j & j2_series<last_j; |
---|
| 1290 | j2_series=j2_series(ind_sel); |
---|
| 1291 | else%i pairs |
---|
| 1292 | if isempty(j1_series) %j pairs |
---|
| 1293 | ind_sel=i1_series>=first_i & i2_series<=last_i ; |
---|
| 1294 | else |
---|
| 1295 | ind_sel=i1_series>=first_i & i2_series<=last_i& j1_series>first_j & j1_series<last_j; |
---|
| 1296 | j1_series=j1_series(ind_sel); |
---|
| 1297 | i2_series=i2_series(ind_sel); |
---|
| 1298 | end |
---|
| 1299 | end |
---|
| 1300 | i1_series=i1_series(ind_sel); |
---|
| 1301 | else |
---|
| 1302 | if strcmp(r.delim,'-') |
---|
| 1303 | ind_shift(1)=str2num(r.num1); |
---|
| 1304 | ind_shift(2)=str2num(r.num2); |
---|
| 1305 | else |
---|
| 1306 | ind_shift(1)=-str2num(r.num1); |
---|
| 1307 | ind_shift(2)=str2num(r.num2); |
---|
| 1308 | end |
---|
| 1309 | [i1_series,i2_series,j1_series,j2_series,nbmissing]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode); |
---|
| 1310 | end |
---|
| 1311 | end |
---|
| 1312 | if isempty(i1_series) |
---|
| 1313 | msgbox_uvmat('ERROR','no file in the considered range') |
---|
| 1314 | return |
---|
| 1315 | end |
---|
| 1316 | if isempty(i2_series) |
---|
| 1317 | i2_series=i1_series; |
---|
| 1318 | end |
---|
| 1319 | if isempty(j2_series) |
---|
| 1320 | j2_series=j1_series; |
---|
| 1321 | end |
---|
| 1322 | % if isequal(NomType{iview},'_1_1-2')|| isequal(NomType{iview},'_1-2_1')|| isequal(NomType{iview},'_1-2')|| isequal(NomType{iview},'#_ab') |
---|
| 1323 | % ind_shift=SeriesData.displ_num(iview,:); |
---|
| 1324 | % if isequal(ind_shift,[0 0 0 0]) % undefined pairs |
---|
| 1325 | % if isequal(NomType{iview},'#_ab') |
---|
| 1326 | % mode='#_ab'; |
---|
| 1327 | % end |
---|
| 1328 | % [num_i1,i2_series,j1_series,num_j2,nbmissing]=netseries_generator(fullfile(RootPath{iview},RootFile{iview}),SubDir{iview},mode,num_first_i,num_incr_i,num_last_i,num_first_j,num_incr_j,num_last_j); |
---|
| 1329 | % else |
---|
| 1330 | % [num_i1,num_i2,num_j1,num_j2,num_i,num_j]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode); |
---|
| 1331 | % if isempty(num_i) |
---|
| 1332 | % msgbox_uvmat('ERROR','ERROR: empty set of input files chosen') |
---|
| 1333 | % return |
---|
| 1334 | % end |
---|
| 1335 | % if num_i(1)>num_first_i |
---|
| 1336 | % set(handles.num_first_i,'String',num2str(num_i(1)))%update the display of first field |
---|
| 1337 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 1338 | % end |
---|
| 1339 | % if num_i(end)<num_last_i |
---|
| 1340 | % set(handles.num_last_i,'String',num2str(num_i(end)))%update the display of last field |
---|
| 1341 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 1342 | % end |
---|
| 1343 | % if num_j(1)>num_first_j |
---|
| 1344 | % set(handles.num_first_j,'String',num2str(num_j(1)))%update the display of first field |
---|
| 1345 | % last_j_Callback(hObject, eventdata, handles) |
---|
| 1346 | % end |
---|
| 1347 | % if num_j(end)<num_last_j |
---|
| 1348 | % set(handles.num_last_j,'String',num2str(num_j(end)))%update the display of last field |
---|
| 1349 | % last_j_Callback(hObject, eventdata, handles) |
---|
| 1350 | % end |
---|
| 1351 | % end |
---|
[2] | 1352 | else%case of images |
---|
[339] | 1353 | [i1_series,j1_series]=meshgrid(num_i,num_j); |
---|
| 1354 | i2_series=i1_series; |
---|
| 1355 | j2_series=j1_series; |
---|
[2] | 1356 | end |
---|
| 1357 | if length(RootPath)>1 |
---|
[339] | 1358 | i1_series_cell{iview}=i1_series; |
---|
| 1359 | i2_series_cell{iview}=i2_series; |
---|
| 1360 | j1_series_cell{iview}=j1_series; |
---|
| 1361 | j2_series_cell{iview}=j2_series; |
---|
[2] | 1362 | end |
---|
| 1363 | end |
---|
| 1364 | |
---|
[41] | 1365 | % defining the ACTION function handle |
---|
[2] | 1366 | path_series=which('series'); |
---|
| 1367 | list_path=get(handles.ACTION,'UserData'); |
---|
| 1368 | index=get(handles.ACTION,'Value'); |
---|
| 1369 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
| 1370 | if ~isequal(fct_path,path_series) |
---|
| 1371 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
[41] | 1372 | if ~exist(fct_path,'dir') |
---|
| 1373 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
| 1374 | return |
---|
| 1375 | end |
---|
| 1376 | if ~isequal(spath,fct_path) |
---|
[2] | 1377 | addpath(fct_path)% add the prescribed path if not the current one |
---|
| 1378 | end |
---|
| 1379 | end |
---|
[41] | 1380 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
[26] | 1381 | if ~isequal(fct_path,path_series) |
---|
| 1382 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
| 1383 | end |
---|
| 1384 | |
---|
[41] | 1385 | % RUN ACTION |
---|
[2] | 1386 | Series.Action=action;%name of the processing programme |
---|
| 1387 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1388 | if length(RootPath)>1 |
---|
[339] | 1389 | h_fun(i1_series_cell,i2_series_cell,j1_series_cell,j2_series_cell,Series); |
---|
[2] | 1390 | else |
---|
[339] | 1391 | h_fun(i1_series,i2_series,j1_series,j2_series,Series); |
---|
[2] | 1392 | end |
---|
| 1393 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1394 | |
---|
| 1395 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 1396 | % detect=1; |
---|
| 1397 | % while detect==1 |
---|
| 1398 | % namefigfull=[namedoc '.fig']; |
---|
| 1399 | % hh=dir(namefigfull); |
---|
| 1400 | % if ~isempty(hh) |
---|
| 1401 | % detect=1; |
---|
| 1402 | % namedoc=[namedoc '.0']; |
---|
| 1403 | % else |
---|
| 1404 | % detect=0; |
---|
| 1405 | % end |
---|
| 1406 | % end |
---|
| 1407 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 1408 | |
---|
[41] | 1409 | %------------------------------------------------------------------------ |
---|
[2] | 1410 | function STOP_Callback(hObject, eventdata, handles) |
---|
[41] | 1411 | %------------------------------------------------------------------------ |
---|
[2] | 1412 | set(handles.RUN, 'BusyAction','cancel') |
---|
| 1413 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1414 | |
---|
| 1415 | |
---|
[41] | 1416 | %------------------------------------------------------------------------ |
---|
[339] | 1417 | function num_first_i_Callback(hObject, eventdata, handles) |
---|
[41] | 1418 | %------------------------------------------------------------------------ |
---|
[342] | 1419 | num_last_i_Callback(hObject, eventdata, handles) |
---|
[2] | 1420 | |
---|
[41] | 1421 | %------------------------------------------------------------------------ |
---|
[339] | 1422 | function num_last_i_Callback(hObject, eventdata, handles) |
---|
[41] | 1423 | %------------------------------------------------------------------------ |
---|
[332] | 1424 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1425 | if ~isfield(SeriesData,'Time') |
---|
| 1426 | SeriesData.Time{1}=[]; |
---|
| 1427 | end |
---|
[350] | 1428 | displ_time(handles); |
---|
[2] | 1429 | |
---|
[41] | 1430 | %------------------------------------------------------------------------ |
---|
[339] | 1431 | function num_first_j_Callback(hObject, eventdata, handles) |
---|
[41] | 1432 | %------------------------------------------------------------------------ |
---|
[342] | 1433 | num_last_j_Callback(hObject, eventdata, handles) |
---|
[2] | 1434 | |
---|
[41] | 1435 | %------------------------------------------------------------------------ |
---|
[339] | 1436 | function num_last_j_Callback(hObject, eventdata, handles) |
---|
[41] | 1437 | %------------------------------------------------------------------------ |
---|
[339] | 1438 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 1439 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
[2] | 1440 | ref_j=ceil((first_j+last_j)/2); |
---|
| 1441 | set(handles.ref_j,'String', num2str(ref_j)) |
---|
| 1442 | ref_j_Callback(hObject, eventdata, handles) |
---|
[332] | 1443 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1444 | if ~isfield(SeriesData,'Time') |
---|
| 1445 | SeriesData.Time{1}=[]; |
---|
| 1446 | end |
---|
[350] | 1447 | displ_time(handles); |
---|
[2] | 1448 | |
---|
| 1449 | |
---|
[41] | 1450 | %------------------------------------------------------------------------ |
---|
[2] | 1451 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[41] | 1452 | %------------------------------------------------------------------------ |
---|
[2] | 1453 | mode_list=get(handles.mode,'String'); |
---|
| 1454 | mode_value=get(handles.mode,'Value'); |
---|
| 1455 | mode=mode_list{mode_value}; |
---|
[332] | 1456 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1457 | %NomTypeCell=get(handles.NomType,'String'); |
---|
| 1458 | NomTypeCell=SeriesData.NomType; |
---|
| 1459 | if ~isempty(NomTypeCell) |
---|
| 1460 | Val=get(handles.NomType,'Value'); |
---|
| 1461 | NomType=NomTypeCell{Val}; |
---|
| 1462 | % for ilist=1:length(NomType) |
---|
[332] | 1463 | if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2') |
---|
[2] | 1464 | if isequal(mode,'series(Di)') |
---|
[339] | 1465 | find_netcpair_civ(handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
[2] | 1466 | % break |
---|
| 1467 | end |
---|
| 1468 | end |
---|
| 1469 | end |
---|
| 1470 | |
---|
[41] | 1471 | %------------------------------------------------------------------------ |
---|
[2] | 1472 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[41] | 1473 | %------------------------------------------------------------------------ |
---|
[2] | 1474 | mode_list=get(handles.mode,'String'); |
---|
| 1475 | mode_value=get(handles.mode,'Value'); |
---|
| 1476 | mode=mode_list{mode_value}; |
---|
[332] | 1477 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1478 | NomTypeCell=SeriesData.NomType; |
---|
| 1479 | if ~isempty(NomTypeCell) |
---|
[29] | 1480 | Val=get(handles.NomType,'Value'); |
---|
| 1481 | NomType=NomTypeCell{Val}; |
---|
[332] | 1482 | if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2') |
---|
[2] | 1483 | if isequal(mode,'series(Dj)') |
---|
[339] | 1484 | find_netcpair_civ(handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
[2] | 1485 | end |
---|
| 1486 | end |
---|
| 1487 | end |
---|
| 1488 | |
---|
[41] | 1489 | %------------------------------------------------------------------------ |
---|
[2] | 1490 | % --- Executes on selection change in ACTION. |
---|
| 1491 | function ACTION_Callback(hObject, eventdata, handles) |
---|
[41] | 1492 | %------------------------------------------------------------------------ |
---|
[205] | 1493 | global nb_builtin_ACTION |
---|
[2] | 1494 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
| 1495 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
| 1496 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
| 1497 | path_series=which('series');%path to series.m |
---|
| 1498 | list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION |
---|
[39] | 1499 | default_file=fullfile(list_path{end},ACTION); |
---|
[29] | 1500 | % add a new function to the menu if the selected item is 'more...' |
---|
[2] | 1501 | if isequal(ACTION,'more...') |
---|
| 1502 | pathfct=fileparts(path_series); |
---|
| 1503 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1504 | {'*.m', ' (*.m)'; |
---|
| 1505 | '*.m', '.m files '; ... |
---|
| 1506 | '*.*', 'All Files (*.*)'}, ... |
---|
[39] | 1507 | 'Pick a file',default_file); |
---|
[2] | 1508 | if length(FileName)<2 |
---|
| 1509 | return |
---|
[29] | 1510 | end |
---|
| 1511 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
[2] | 1512 | if ~isequal(ext_fct,'.m') |
---|
| 1513 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1514 | return |
---|
| 1515 | end |
---|
| 1516 | |
---|
| 1517 | % insert the choice in the action menu |
---|
| 1518 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
| 1519 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
| 1520 | list_path{index_ACTION}=PathName; |
---|
[205] | 1521 | if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
| 1522 | nbremove=length(menu_str)-nb_builtin_ACTION-5; |
---|
| 1523 | menu_str(nb_builtin_ACTION+1:end-5)=[]; |
---|
| 1524 | list_path(nb_builtin_ACTION+1:end-4)=[]; |
---|
[2] | 1525 | index_ACTION=index_ACTION-nbremove; |
---|
| 1526 | set(handles.ACTION,'Value',index_ACTION) |
---|
| 1527 | set(handles.ACTION,'String',menu_str) |
---|
| 1528 | end |
---|
| 1529 | list_path{index_ACTION}=PathName; |
---|
| 1530 | set(handles.ACTION,'UserData',list_path); |
---|
| 1531 | set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
| 1532 | |
---|
| 1533 | %record the current menu in personal file profil_perso |
---|
| 1534 | dir_perso=prefdir; |
---|
| 1535 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
[205] | 1536 | for ilist=nb_builtin_ACTION+1:length(menu_str)-1 |
---|
| 1537 | series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
[2] | 1538 | end |
---|
[206] | 1539 | if nb_builtin_ACTION+1<=length(menu_str)-1 |
---|
| 1540 | if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1 |
---|
| 1541 | save(profil_perso,'series_fct','-append') |
---|
| 1542 | else |
---|
| 1543 | txt=ver('MATLAB'); |
---|
| 1544 | Release=txt.Release; |
---|
| 1545 | relnumb=str2num(Release(3:4)); |
---|
| 1546 | if relnumb >= 14%recent relaese of Matlab |
---|
| 1547 | save(profil_perso,'series_fct','-V6') |
---|
| 1548 | else |
---|
| 1549 | save(profil_perso, 'series_fct') |
---|
| 1550 | end |
---|
| 1551 | end |
---|
[2] | 1552 | end |
---|
| 1553 | end |
---|
| 1554 | |
---|
| 1555 | %check the current path to the selected function |
---|
| 1556 | PathName=list_path{index_ACTION};%current recorded path |
---|
| 1557 | set(handles.path,'String',PathName); %show the path to the senlected function |
---|
| 1558 | |
---|
| 1559 | %default setting for the visibility of the GUI elements |
---|
[350] | 1560 | % set(handles.RootPath,'UserData','many') |
---|
| 1561 | % set(handles.SubDir,'Visible','on') |
---|
| 1562 | % set(handles.RootFile,'Visible','on') |
---|
| 1563 | % set(handles.NomType,'Visible','on') |
---|
| 1564 | % set(handles.FileExt,'Visible','on') |
---|
[339] | 1565 | set(handles.num_NbSlice,'Visible','off') |
---|
[2] | 1566 | set(handles.NbSlice_title,'Visible','off') |
---|
| 1567 | set(handles.VelTypeMenu,'Visible','off'); |
---|
| 1568 | set(handles.VelType_text,'Visible','off'); |
---|
| 1569 | set(handles.VelTypeMenu_1,'Visible','off'); |
---|
| 1570 | set(handles.VelType_text_1,'Visible','off'); |
---|
| 1571 | view_FieldMenu(handles,'off') |
---|
| 1572 | view_FieldMenu_1(handles,'off') |
---|
[339] | 1573 | set(handles.FieldTransform,'Visible','off') |
---|
| 1574 | % view_TRANSFORM(handles,'off')Visible','off') |
---|
| 1575 | set(handles.Objects,'Visible','off'); |
---|
[2] | 1576 | set(handles.GetMask,'Visible','off') |
---|
| 1577 | set(handles.Mask,'Visible','off') |
---|
[339] | 1578 | % set(handles.GetObject,'Visible','off'); |
---|
[2] | 1579 | set(handles.OutputDir,'Visible','off'); |
---|
[339] | 1580 | % set(handles.PARAMETERS_frame,'Visible','off'); |
---|
| 1581 | % set(handles.PARAMETERS_title,'Visible','off'); |
---|
[2] | 1582 | set(handles.ParamKey,'Visible','off') |
---|
| 1583 | set(handles.ParamVal,'Visible','off') |
---|
| 1584 | ParamKey={}; |
---|
| 1585 | set(handles.FieldMenu,'Enable','off') |
---|
| 1586 | set(handles.VelTypeMenu,'Enable','off') |
---|
| 1587 | set(handles.FieldMenu_1,'Enable','off') |
---|
| 1588 | set(handles.VelTypeMenu_1,'Enable','off') |
---|
[39] | 1589 | set(handles.transform_fct,'Enable','off') |
---|
[2] | 1590 | %set the displayed GUI item needed for input parameters |
---|
[29] | 1591 | if ~isequal(path_series,PathName) |
---|
| 1592 | addpath(PathName) |
---|
| 1593 | end |
---|
| 1594 | eval(['h_function=@' ACTION ';']); |
---|
[244] | 1595 | try |
---|
| 1596 | [fid,errormsg] =fopen([ACTION '.m']); |
---|
| 1597 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
| 1598 | fclose(fid) |
---|
| 1599 | set(handles.ACTION,'ToolTipString',InputText{1}{1}) |
---|
| 1600 | end |
---|
[29] | 1601 | if ~isequal(path_series,PathName) |
---|
| 1602 | rmpath(PathName) |
---|
| 1603 | end |
---|
| 1604 | varargout=h_function(); |
---|
[2] | 1605 | Param_list={}; |
---|
| 1606 | |
---|
| 1607 | %nb_series=length(RootFile); |
---|
[350] | 1608 | % FileExt=get(handles.FileExt,'String'); |
---|
| 1609 | % nb_series=length(FileExt); |
---|
| 1610 | InputFiles=get(handles.InputTable,'Data') |
---|
| 1611 | FileExt=InputFiles(:,5); |
---|
| 1612 | checkcell=find(cellfun('isempty',FileExt)~=0); |
---|
| 1613 | nb_series=0; |
---|
| 1614 | if ~isempty(checkcell) |
---|
| 1615 | nb_series=checkcell(end); |
---|
| 1616 | end |
---|
| 1617 | % nb_series=size(InputFiles,1) |
---|
[2] | 1618 | testima_series=1; %test for a list of images only |
---|
| 1619 | testima=1; |
---|
| 1620 | testima_1=1; |
---|
| 1621 | testciv_series=1; |
---|
| 1622 | for iview=1:nb_series |
---|
[350] | 1623 | ext=FileExt{iview}; |
---|
[2] | 1624 | if length(ext)<2 |
---|
| 1625 | ext='.none'; |
---|
| 1626 | end |
---|
| 1627 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
| 1628 | if ~testimaview |
---|
| 1629 | if iview==1 |
---|
| 1630 | testima=0; |
---|
| 1631 | end |
---|
| 1632 | if iview==2 |
---|
| 1633 | testima_1=0; |
---|
| 1634 | end |
---|
| 1635 | testima_series=0; |
---|
| 1636 | end |
---|
| 1637 | end |
---|
| 1638 | for ilist=1:length(varargout)-1 |
---|
| 1639 | switch varargout{ilist} |
---|
| 1640 | %RootFile always visible |
---|
[350] | 1641 | % case 'RootPath' %visible by default |
---|
| 1642 | % value=lower(varargout{ilist+1}); |
---|
| 1643 | % if isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
| 1644 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
| 1645 | % end |
---|
| 1646 | % case 'SubDir' %visible by default |
---|
| 1647 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1648 | % set(handles.SubDir,'Visible','off') |
---|
| 1649 | % end |
---|
| 1650 | % case 'RootFile' %visible by default |
---|
| 1651 | % value=lower(varargout{ilist+1}); |
---|
| 1652 | % if isequal(value,'off') |
---|
| 1653 | % set(handles.RootFile,'Visible','off') |
---|
| 1654 | % elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
| 1655 | % set(handles.RootFile,'Visible','on') |
---|
| 1656 | % set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
| 1657 | % end |
---|
| 1658 | % case 'NomType' %visible by default |
---|
| 1659 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1660 | % set(handles.NomType,'Visible','off') |
---|
| 1661 | % end |
---|
| 1662 | % case 'FileExt' %visible by default |
---|
| 1663 | % if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1664 | % set(handles.FileExt,'Visible','off') |
---|
| 1665 | % end |
---|
[2] | 1666 | case 'NbSlice' %hidden by default |
---|
| 1667 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[339] | 1668 | set(handles.num_NbSlice,'Visible','on') |
---|
[2] | 1669 | set(handles.NbSlice_title,'Visible','on') |
---|
| 1670 | end |
---|
| 1671 | case 'VelTypeMenu' %hidden by default |
---|
| 1672 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
| 1673 | set(handles.VelTypeMenu,'Enable','on') |
---|
| 1674 | if nb_series >=1 && ~testima_series |
---|
| 1675 | set(handles.VelTypeMenu,'Visible','on') |
---|
| 1676 | set(handles.VelType_text,'Visible','on'); |
---|
| 1677 | set(handles.Field_frame,'Visible','on') |
---|
| 1678 | end |
---|
| 1679 | end |
---|
| 1680 | if isequal(lower(varargout{ilist+1}),'two') |
---|
| 1681 | set(handles.VelTypeMenu_1,'Enable','on') |
---|
| 1682 | if nb_series >=2 && ~testima_series |
---|
| 1683 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
| 1684 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 1685 | end |
---|
| 1686 | end |
---|
| 1687 | case 'FieldMenu' %hidden by default |
---|
| 1688 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
| 1689 | set(handles.FieldMenu,'Enable','on') % test for MenuBorser |
---|
| 1690 | if nb_series >=1 && ~testima_series |
---|
| 1691 | view_FieldMenu(handles,'on') |
---|
| 1692 | end |
---|
| 1693 | end |
---|
| 1694 | if isequal(lower(varargout{ilist+1}),'two') |
---|
| 1695 | set(handles.FieldMenu_1,'Enable','on') |
---|
| 1696 | if nb_series >=2 && ~testima_1 |
---|
| 1697 | view_FieldMenu_1(handles,'on') |
---|
| 1698 | end |
---|
| 1699 | end |
---|
| 1700 | case 'CoordType' %hidden by default |
---|
| 1701 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[39] | 1702 | set(handles.transform_fct,'Enable','on') |
---|
[339] | 1703 | set(handles.FieldTransform,'Visible','on') |
---|
| 1704 | % view_TRANSFORM(handles,'on') |
---|
[2] | 1705 | end |
---|
| 1706 | case 'GetObject' %hidden by default |
---|
| 1707 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[339] | 1708 | set(handles.Objects,'Visible','on') |
---|
| 1709 | % set(handles.GetObject,'Visible','on'); |
---|
[2] | 1710 | end |
---|
| 1711 | case 'Mask' %hidden by default |
---|
| 1712 | if isequal(lower(varargout{ilist+1}),'on') |
---|
[339] | 1713 | set(handles.Objects,'Visible','on') |
---|
| 1714 | % set(handles.GetMask,'Visible','on'); |
---|
[2] | 1715 | end |
---|
| 1716 | case 'PARAMETER' |
---|
| 1717 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
| 1718 | set(handles.PARAMETERS_title,'Visible','on') |
---|
| 1719 | set(handles.ParamKey,'Visible','on') |
---|
| 1720 | %set(handles.ParamVal,'Visible','on') |
---|
| 1721 | Param_str=varargout{ilist+1}; |
---|
| 1722 | Param_list=[Param_list; {Param_str}]; |
---|
| 1723 | end |
---|
| 1724 | end |
---|
| 1725 | if ~isempty(Param_list) |
---|
| 1726 | set(handles.ParamKey,'String',Param_list) |
---|
| 1727 | set(handles.ParamVal,'Visible','on') |
---|
| 1728 | end |
---|
| 1729 | |
---|
[41] | 1730 | %------------------------------------------------------------------------ |
---|
[2] | 1731 | % --- Executes on selection change in FieldMenu. |
---|
| 1732 | function FieldMenu_Callback(hObject, eventdata, handles) |
---|
[41] | 1733 | %------------------------------------------------------------------------ |
---|
[2] | 1734 | field_str=get(handles.FieldMenu,'String'); |
---|
| 1735 | field_index=get(handles.FieldMenu,'Value'); |
---|
| 1736 | field=field_str{field_index(1)}; |
---|
| 1737 | if isequal(field,'get_field...') |
---|
| 1738 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1739 | if ~isempty(hget_field) |
---|
| 1740 | delete(hget_field)%delete opened versions of get_field |
---|
| 1741 | end |
---|
[332] | 1742 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1743 | filename=SeriesData.CurrentInputFile; |
---|
| 1744 | if exist(filename,'file') |
---|
| 1745 | get_field(filename) |
---|
| 1746 | end |
---|
| 1747 | elseif isequal(field,'more...') |
---|
| 1748 | str=calc_field; |
---|
| 1749 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1750 | 'SelectionMode','single',... |
---|
| 1751 | 'ListString',str); |
---|
| 1752 | % edit the choice in the fields and action menu |
---|
| 1753 | scalar=cell2mat(str(ind_answer)); |
---|
| 1754 | update_menu(handles.FieldMenu,scalar) |
---|
| 1755 | end |
---|
| 1756 | |
---|
[41] | 1757 | %------------------------------------------------------------------------ |
---|
[2] | 1758 | % --- Executes on selection change in FieldMenu_1. |
---|
| 1759 | function FieldMenu_1_Callback(hObject, eventdata, handles) |
---|
[41] | 1760 | %------------------------------------------------------------------------ |
---|
[2] | 1761 | field_str=get(handles.FieldMenu_1,'String'); |
---|
| 1762 | field_index=get(handles.FieldMenu_1,'Value'); |
---|
| 1763 | field=field_str{field_index}; |
---|
| 1764 | if isequal(field,'get_field...') |
---|
| 1765 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 1766 | if ~isempty(hget_field) |
---|
| 1767 | delete(hget_field) |
---|
| 1768 | end |
---|
[332] | 1769 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1770 | filename=SeriesData.CurrentInputFile_1; |
---|
| 1771 | if exist(filename,'file') |
---|
| 1772 | hget_field=get_field(filename); |
---|
| 1773 | set(hget_field,'name','get_field_1') |
---|
| 1774 | end |
---|
| 1775 | elseif isequal(field,'more...') |
---|
| 1776 | str=calc_field; |
---|
| 1777 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1778 | 'SelectionMode','single',... |
---|
| 1779 | 'ListString',str); |
---|
| 1780 | % edit the choice in the fields and action menu |
---|
| 1781 | scalar=cell2mat(str(ind_answer)); |
---|
| 1782 | update_menu(handles.FieldMenu_1,scalar) |
---|
| 1783 | end |
---|
[29] | 1784 | |
---|
[244] | 1785 | |
---|
[2] | 1786 | %%%%%%%%%%%%% |
---|
| 1787 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
[339] | 1788 | indsel=ind_i; |
---|
| 1789 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
| 1790 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
| 1791 | if ~isempty(indiff) |
---|
| 1792 | indiff2=diff(indiff); |
---|
| 1793 | indiffp=[indiff2 1]; |
---|
| 1794 | indiffm=[1 indiff2]; |
---|
| 1795 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
| 1796 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
| 1797 | %for each multiplet, select the most recent file |
---|
| 1798 | ind_remove=[]; |
---|
| 1799 | for i=1:length(ind_multi_m) |
---|
| 1800 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
| 1801 | for imulti=1:length(ind_pairs) |
---|
| 1802 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
[2] | 1803 | end |
---|
[339] | 1804 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
| 1805 | ind_s=indsort2(1:end-1);% |
---|
| 1806 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
| 1807 | end |
---|
| 1808 | end |
---|
[2] | 1809 | |
---|
[89] | 1810 | %------------------------------------------------------------------------ |
---|
| 1811 | % --- determine the list of index pairs of processing file |
---|
[32] | 1812 | 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] | 1813 | %------------------------------------------------------------------------ |
---|
[32] | 1814 | num_i1=num_i;% set of first image numbers by default |
---|
| 1815 | num_i2=num_i; |
---|
| 1816 | num_j1=num_j; |
---|
| 1817 | num_j2=num_j; |
---|
| 1818 | num_i_out=num_i; |
---|
| 1819 | num_j_out=num_j; |
---|
[339] | 1820 | % if isequal (NomType,'_1-2_1') || isequal (NomType,'_1-2') |
---|
| 1821 | if isequal(mode,'series(Di)') |
---|
[32] | 1822 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
| 1823 | num_i2_line=num_i+ind_shift(4); |
---|
| 1824 | % adjust the first and last field number |
---|
| 1825 | indsel=find(num_i1_line >= 1); |
---|
| 1826 | num_i_out=num_i(indsel); |
---|
| 1827 | num_i1_line=num_i1_line(indsel); |
---|
| 1828 | num_i2_line=num_i2_line(indsel); |
---|
| 1829 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1830 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
| 1831 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
| 1832 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
[339] | 1833 | elseif isequal (mode,'series(Dj)')||isequal (mode,'bursts') |
---|
[32] | 1834 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
| 1835 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
| 1836 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
| 1837 | else |
---|
| 1838 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
| 1839 | num_j2_col=num_j+ind_shift(2); |
---|
| 1840 | % adjust the first field number |
---|
| 1841 | indsel=find((num_j1_col >= 1)); |
---|
| 1842 | num_j_out=num_j(indsel); |
---|
| 1843 | num_j1_col=num_j1_col(indsel); |
---|
| 1844 | num_j2_col=num_j2_col(indsel); |
---|
| 1845 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
| 1846 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
| 1847 | end |
---|
| 1848 | end |
---|
[2] | 1849 | |
---|
[41] | 1850 | %------------------------------------------------------------------------ |
---|
| 1851 | % ---- find the times corresponding to the first and last indices of a series |
---|
[350] | 1852 | function displ_time(handles) |
---|
[41] | 1853 | %------------------------------------------------------------------------ |
---|
[332] | 1854 | SeriesData=get(handles.series,'UserData');% |
---|
[339] | 1855 | first_i=str2num(get(handles.num_first_i,'String')); |
---|
| 1856 | first_j=str2num(get(handles.num_first_j,'String')); |
---|
| 1857 | last_i=str2num(get(handles.num_last_i,'String')); |
---|
| 1858 | last_j=str2num(get(handles.num_last_j,'String')); |
---|
[2] | 1859 | NomType=SeriesData.NomType; |
---|
| 1860 | mode_list=get(handles.mode,'String'); |
---|
| 1861 | index_mode=get(handles.mode,'Value'); |
---|
| 1862 | mode=mode_list{index_mode}; |
---|
| 1863 | |
---|
| 1864 | time_first=[]; |
---|
| 1865 | time_last=[]; |
---|
| 1866 | if ~isfield(SeriesData,'Time') |
---|
| 1867 | SeriesData.Time{1}=[]; |
---|
| 1868 | end |
---|
| 1869 | for iview=1:length(NomType) |
---|
| 1870 | time_first_cell{iview}='?'; |
---|
| 1871 | time_last_cell{iview}='?';%default |
---|
| 1872 | time=SeriesData.Time{iview}; |
---|
[332] | 1873 | if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2') |
---|
[2] | 1874 | if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num) |
---|
| 1875 | ind_shift=SeriesData.displ_num(iview,:); |
---|
| 1876 | if isequal(mode,'bursts') |
---|
| 1877 | first_j=0; |
---|
| 1878 | last_j=0; |
---|
| 1879 | end |
---|
| 1880 | first_i1=first_i +ind_shift(3); |
---|
| 1881 | first_i2 =first_i +ind_shift(4); |
---|
| 1882 | first_j1 =first_j +ind_shift(1); |
---|
| 1883 | first_j2 =first_j +ind_shift(2); |
---|
| 1884 | last_i1=last_i +ind_shift(3); |
---|
| 1885 | last_i2 =last_i +ind_shift(4); |
---|
| 1886 | last_j1 =last_j +ind_shift(1); |
---|
| 1887 | last_j2 =last_j +ind_shift(2); |
---|
| 1888 | siz=size(SeriesData.Time{1}); |
---|
[25] | 1889 | if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2 |
---|
[2] | 1890 | time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2; |
---|
| 1891 | time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2; |
---|
| 1892 | else%read the time in the nc files |
---|
| 1893 | RootPath=get(handles.RootPath,'String'); |
---|
| 1894 | RootFile=get(handles.RootFile,'String'); |
---|
| 1895 | SubDir=get(handles.SubDir,'String'); |
---|
| 1896 | %VelType=get(handles.VelType,'String'); |
---|
| 1897 | VelType_str=get(handles.VelTypeMenu,'String'); |
---|
| 1898 | VelType_val=get(handles.VelTypeMenu,'Value'); |
---|
| 1899 | VelType=VelType_str{VelType_val}; |
---|
| 1900 | filebase=fullfile(RootPath{1},RootFile{1}); |
---|
| 1901 | [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview}); |
---|
| 1902 | if exist(filefirst,'file') |
---|
| 1903 | Attrib=nc2struct(filefirst,[]); |
---|
| 1904 | if isfield(Attrib,'Time') |
---|
| 1905 | time_first=Attrib.Time; |
---|
| 1906 | else |
---|
| 1907 | if isfield(Attrib,'absolut_time_T0') |
---|
| 1908 | time_first=Attrib.absolut_time_T0; |
---|
| 1909 | end |
---|
[12] | 1910 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
[2] | 1911 | time_first=Attrib.absolut_time_T0_2; |
---|
| 1912 | end |
---|
| 1913 | end |
---|
| 1914 | end |
---|
| 1915 | [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview}); |
---|
| 1916 | if exist(filelast,'file') |
---|
| 1917 | Attrib=nc2struct(filelast,[]); |
---|
| 1918 | if isfield(Attrib,'Time') |
---|
| 1919 | time_last=Attrib.Time; |
---|
| 1920 | else |
---|
| 1921 | if isfield(Attrib,'absolut_time_T0') |
---|
| 1922 | time_last=Attrib.absolut_time_T0; |
---|
| 1923 | end |
---|
[12] | 1924 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
[2] | 1925 | time_last=Attrib.absolut_time_T0_2; |
---|
| 1926 | end |
---|
| 1927 | end |
---|
| 1928 | end |
---|
| 1929 | end |
---|
| 1930 | end |
---|
| 1931 | else |
---|
[350] | 1932 | siz=size(time); |
---|
[39] | 1933 | if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1 |
---|
[2] | 1934 | time_first=times(first_i,first_j); |
---|
| 1935 | time_last=times(last_i,last_j); |
---|
| 1936 | end |
---|
| 1937 | end |
---|
| 1938 | time_first_cell{iview}=num2str(time_first,4); |
---|
| 1939 | time_last_cell{iview}=num2str(time_last,4); |
---|
| 1940 | end |
---|
[350] | 1941 | % set(handles.time_first,'Value',1) |
---|
| 1942 | % set(handles.time_last,'Value',1) |
---|
| 1943 | % set(handles.time_first,'String',time_first_cell); |
---|
| 1944 | % set(handles.time_last,'String',time_last_cell); |
---|
[2] | 1945 | |
---|
[41] | 1946 | %------------------------------------------------------------------------ |
---|
[2] | 1947 | % --- Executes on button press in GetObject. |
---|
| 1948 | function GetObject_Callback(hObject, eventdata, handles) |
---|
[41] | 1949 | %------------------------------------------------------------------------ |
---|
[332] | 1950 | SeriesData=get(handles.series,'UserData'); |
---|
[2] | 1951 | value=get(handles.GetObject,'Value'); |
---|
| 1952 | if value |
---|
| 1953 | set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
[46] | 1954 | % DataInit.ParentButton=handles.GetObject; |
---|
[76] | 1955 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
[2] | 1956 | if ishandle(hset_object) |
---|
[46] | 1957 | uistack(hset_object,'top') |
---|
| 1958 | %[SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface |
---|
[2] | 1959 | else |
---|
[41] | 1960 | %get the object file |
---|
| 1961 | defaultname=get(handles.RootPath,'String'); |
---|
[106] | 1962 | if isempty(defaultname) |
---|
| 1963 | defaultname={''}; |
---|
| 1964 | end |
---|
[41] | 1965 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1966 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 1967 | '*.xml', '.xml files '; ... |
---|
| 1968 | '*.mat', '.mat matlab files '}, ... |
---|
[46] | 1969 | 'Pick an xml object file (or use uvmat to create it)',defaultname{1}); |
---|
[41] | 1970 | fileinput=[PathName FileName];%complete file name |
---|
| 1971 | testblank=findstr(fileinput,' ');%look for blanks |
---|
| 1972 | if ~isempty(testblank) |
---|
| 1973 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks') |
---|
| 1974 | return |
---|
| 1975 | end |
---|
| 1976 | sizf=size(fileinput); |
---|
| 1977 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 1978 | %read the file |
---|
| 1979 | t=xmltree(fileinput); |
---|
| 1980 | data=convert(t); |
---|
| 1981 | if ~isfield(data,'Style') |
---|
| 1982 | data.Style='points'; |
---|
| 1983 | end |
---|
| 1984 | if ~isfield(data,'ProjMode') |
---|
| 1985 | data.ProjMode='projection'; |
---|
| 1986 | end |
---|
| 1987 | transform_menu=get(handles.transform_fct,'String'); |
---|
| 1988 | ichoice=get(handles.transform_fct,'Value'); |
---|
[158] | 1989 | % if isequal(transform_menu{ichoice},'px'); |
---|
| 1990 | % data.CoordType='px'; |
---|
| 1991 | % else |
---|
| 1992 | % data.CoordType='phys'; |
---|
| 1993 | % end |
---|
[41] | 1994 | data.desable_plot=1; |
---|
| 1995 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface |
---|
[2] | 1996 | end |
---|
| 1997 | else |
---|
[46] | 1998 | set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
[41] | 1999 | % if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object) |
---|
| 2000 | % close(SeriesData.hset_object) |
---|
| 2001 | % end |
---|
[2] | 2002 | end |
---|
[332] | 2003 | set(handles.series,'UserData',SeriesData) |
---|
[2] | 2004 | |
---|
| 2005 | %-------------------------------------------------------------- |
---|
| 2006 | function GetMask_Callback(hObject, eventdata, handles) |
---|
| 2007 | value=get(handles.GetMask,'Value'); |
---|
| 2008 | if value |
---|
[41] | 2009 | msgbox_uvmat('ERROR','not implemented yet') |
---|
[2] | 2010 | end |
---|
| 2011 | %-------------------------------------------------------------- |
---|
| 2012 | |
---|
[41] | 2013 | %------------------------------------------------------------------- |
---|
[2] | 2014 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
| 2015 | function ncbrowser_uvmat(hObject, eventdata) |
---|
[41] | 2016 | %------------------------------------------------------------------- |
---|
[2] | 2017 | bla=get(gcbo,'String'); |
---|
| 2018 | ind=get(gcbo,'Value'); |
---|
| 2019 | filename=cell2mat(bla(ind)); |
---|
| 2020 | blank=find(filename==' '); |
---|
| 2021 | filename=filename(1:blank-1); |
---|
| 2022 | get_field(filename) |
---|
| 2023 | |
---|
[41] | 2024 | % ------------------------------------------------------------------ |
---|
[2] | 2025 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[41] | 2026 | %------------------------------------------------------------------- |
---|
[2] | 2027 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 2028 | pathelp=fileparts(path_to_uvmat); |
---|
[36] | 2029 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 2030 | 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] | 2031 | else |
---|
[36] | 2032 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 2033 | web([helpfile '#series']) |
---|
[2] | 2034 | end |
---|
| 2035 | |
---|
[41] | 2036 | %------------------------------------------------------------------- |
---|
[39] | 2037 | % --- Executes on selection change in transform_fct. |
---|
| 2038 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
[41] | 2039 | %------------------------------------------------------------------- |
---|
[39] | 2040 | global nb_transform |
---|
[2] | 2041 | |
---|
[39] | 2042 | menu=get(handles.transform_fct,'String'); |
---|
| 2043 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 2044 | coord_option=menu{ind_coord}; |
---|
[55] | 2045 | list_transform=get(handles.transform_fct,'UserData'); |
---|
[39] | 2046 | ff=functions(list_transform{end}); |
---|
| 2047 | if isequal(coord_option,'more...'); |
---|
| 2048 | coord_fct=''; |
---|
| 2049 | prompt = {'Enter the name of the transform function'}; |
---|
| 2050 | dlg_title = 'user defined transform'; |
---|
| 2051 | num_lines= 1; |
---|
| 2052 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 2053 | {'*.m', ' (*.m)'; |
---|
| 2054 | '*.m', '.m files '; ... |
---|
| 2055 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2056 | 'Pick a file', ff.file); |
---|
| 2057 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 2058 | PathName(end)=[]; |
---|
| 2059 | end |
---|
| 2060 | transform_selected =fullfile(PathName,FileName); |
---|
| 2061 | if ~exist(transform_selected,'file') |
---|
| 2062 | return |
---|
| 2063 | end |
---|
| 2064 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
| 2065 | if ~isequal(ext_fct,'.m') |
---|
| 2066 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 2067 | return |
---|
| 2068 | end |
---|
| 2069 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
| 2070 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 2071 | addpath(PathName) |
---|
| 2072 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
| 2073 | set(handles.transform_fct,'UserData',list_transform) |
---|
| 2074 | rmpath(PathName) |
---|
| 2075 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 2076 | dir_perso=prefdir;%personal Matalb directory |
---|
| 2077 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2078 | if exist(profil_perso,'file') |
---|
| 2079 | for ilist=nb_transform+1:numel(list_transform) |
---|
[55] | 2080 | ff=functions(list_transform{ilist}); |
---|
[39] | 2081 | transform_fct{ilist-nb_transform}=ff.file; |
---|
| 2082 | end |
---|
| 2083 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
| 2084 | end |
---|
| 2085 | end |
---|
[2] | 2086 | |
---|
[39] | 2087 | %check the current path to the selected function |
---|
[248] | 2088 | if ~isempty(list_transform{ind_coord}) |
---|
[39] | 2089 | func=functions(list_transform{ind_coord}); |
---|
| 2090 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
[248] | 2091 | else |
---|
| 2092 | set(handles.path_transform,'String',''); %show the path to the senlected function |
---|
| 2093 | end |
---|
[89] | 2094 | %------------------------------------------------------------------------ |
---|
| 2095 | % --- generates a series of file names with reference numbers between range1 and |
---|
| 2096 | % --- range2 with increment incr. The reference number num_ref is the image number at the middle of the |
---|
| 2097 | % --- image pair. The set of first numbers num1 of the image pairs is also |
---|
| 2098 | % --- given as output |
---|
[339] | 2099 | % function [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(filebase,subdir,mode,first_i,incr_i,last_i,first_j,incr_j,last_j) |
---|
| 2100 | % %------------------------------------------------------------------------ |
---|
| 2101 | % [Path,Name]=fileparts(filebase); |
---|
| 2102 | % filebasesub=fullfile(Path,subdir,Name); |
---|
| 2103 | % filecell={};%default |
---|
| 2104 | % num_i1=[]; |
---|
| 2105 | % num_i2=[]; |
---|
| 2106 | % num_j1=[]; |
---|
| 2107 | % num_j2=[]; |
---|
| 2108 | % ind0_i=first_i:incr_i:last_i; |
---|
| 2109 | % nbcolumn=length(ind0_i); |
---|
| 2110 | % ind0_j=first_j:incr_j:last_j; |
---|
| 2111 | % nbline=length(ind0_j); |
---|
| 2112 | % if isequal(mode,'#_ab') |
---|
| 2113 | % dirpair=dir([filebasesub '*_*.nc']); |
---|
| 2114 | % elseif isequal(mode,'bursts')||isequal(mode,'series(Dj)') |
---|
| 2115 | % dirpair=dir([filebasesub '_*_*-*.nc']); |
---|
| 2116 | % elseif isequal(mode,'series(Di)') |
---|
| 2117 | % dirpair=dir([filebasesub '_*-*_*.nc']); |
---|
| 2118 | % else |
---|
| 2119 | % msgbox_uvmat('ERROR','option *|* not yet implemented') |
---|
| 2120 | % return |
---|
| 2121 | % end |
---|
| 2122 | % if isempty(dirpair) |
---|
| 2123 | % msgbox_uvmat('ERROR','no pair detected in the selected range') |
---|
| 2124 | % return |
---|
| 2125 | % end |
---|
| 2126 | % |
---|
| 2127 | % if isequal(mode,'bursts')||isequal(mode,'#_ab') |
---|
| 2128 | % icount=0; |
---|
| 2129 | % for ifile=1:length(dirpair) |
---|
| 2130 | % [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
| 2131 | % num1_r=str2num(str_1); |
---|
| 2132 | % if isequal(RootFile,Name) & ~isempty(num1_r) |
---|
| 2133 | % num_i1(ifile)=num1_r; |
---|
| 2134 | % num_a(ifile)=stra2num(str_a); |
---|
| 2135 | % num_b(ifile)=stra2num(str_b); |
---|
| 2136 | % end |
---|
| 2137 | % end |
---|
| 2138 | % test_range= (num_i1 >=first_i)&(num_i1<= last_i);% =1 when both numbers are in the range |
---|
| 2139 | % ind_i=((num_i1-first_i)/incr_i)+1;%indices i in the list of prescribed file indices |
---|
| 2140 | % select=find(test_range &(floor(ind_i)==ind_i));%selected indices of num_i1 in the file directory |
---|
| 2141 | % ind_i=ind_i(select);%set of selected indices ind_i |
---|
| 2142 | % [ind_i,indsort]=sort(ind_i);%sorted list of ind_i |
---|
| 2143 | % select=select(indsort); |
---|
| 2144 | % num_i1=num_i1(select); |
---|
| 2145 | % num_a=num_a(select); |
---|
| 2146 | % num_b=num_b(select); |
---|
| 2147 | % dirpair=dirpair(select); |
---|
| 2148 | % [ind_remove]=find_pairs(dirpair,ind_i,nbcolumn); |
---|
| 2149 | % ind_i(ind_remove)=[]; |
---|
| 2150 | % num_a(ind_remove)=[]; |
---|
| 2151 | % num_b(ind_remove)=[]; |
---|
| 2152 | % num_j1=zeros(1,nbcolumn);%default |
---|
| 2153 | % num_j2=num_j1; |
---|
| 2154 | % num_j1(ind_i)=num_a; |
---|
| 2155 | % num_j2(ind_i)=num_b; |
---|
| 2156 | % num_i1=first_i:incr_i:last_i; |
---|
| 2157 | % num_i2=num_i1; |
---|
| 2158 | % nbmissing=nbcolumn-length(ind_i); |
---|
| 2159 | % |
---|
| 2160 | % elseif isequal(mode,'series(Di)') |
---|
| 2161 | % %ind0_i=num_first_i:num_incr_i:num_last_i; |
---|
| 2162 | % %nbcolumn=length(ind0_i); |
---|
| 2163 | % %ind0_j=num_first_j:num_incr_j:num_last_j; |
---|
| 2164 | % %nbline=length(ind0_j); |
---|
| 2165 | % %dirpair=dir([filebasesub '_*-*_*.nc']); |
---|
| 2166 | % for ifile=1:length(dirpair) |
---|
| 2167 | % [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
| 2168 | % num_i1_r(ifile)=str2num(str_1); |
---|
| 2169 | % num_i2_r(ifile)=str2num(str_2); |
---|
| 2170 | % num_j(ifile)=str2num(str_a); |
---|
| 2171 | % end |
---|
| 2172 | % num_i=floor((num_i1_r+num_i2_r)/2); %list of reference indices of the detected files |
---|
| 2173 | % test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range |
---|
| 2174 | % ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices |
---|
| 2175 | % ind_j=((num_j-first_j)/incr_j)+1; |
---|
| 2176 | % ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices |
---|
| 2177 | % select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory |
---|
| 2178 | % ind_ij=ind_ij(select);%set of selected indices ind_ij |
---|
| 2179 | % [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij |
---|
| 2180 | % select=select(indsort); |
---|
| 2181 | % num_i1_r=num_i1_r(select); |
---|
| 2182 | % num_i2_r=num_i2_r(select); |
---|
| 2183 | % dirpair=dirpair(select); |
---|
| 2184 | % [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; |
---|
| 2185 | % ind_ij(ind_remove)=[]; |
---|
| 2186 | % num_i1_r(ind_remove)=[]; |
---|
| 2187 | % num_i2_r(ind_remove)=[]; |
---|
| 2188 | % num_i1=zeros(1,nbline*nbcolumn);%default |
---|
| 2189 | % num_i2=num_i1; |
---|
| 2190 | % num_i1(ind_ij)=num_i1_r; |
---|
| 2191 | % num_j2(ind_ij)=num_i2_r; |
---|
| 2192 | % num_i1=reshape(num_i1,nbline,nbcolumn); |
---|
| 2193 | % num_i2=reshape(num_i2,nbline,nbcolumn); |
---|
| 2194 | % num_j1=meshgrid(ind0_i,ind0_j); |
---|
| 2195 | % num_j2=num_j1; |
---|
| 2196 | % nbmissing=nbline*nbcolumn-length(ind_ij); |
---|
| 2197 | % elseif isequal(mode,'series(Dj)') |
---|
| 2198 | % for ifile=1:length(dirpair) |
---|
| 2199 | % [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
| 2200 | % num_i(ifile)=str2num(str_1); |
---|
| 2201 | % num_a(ifile)=str2num(str_a); |
---|
| 2202 | % num_b(ifile)=str2num(str_b); |
---|
| 2203 | % end |
---|
| 2204 | % num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files |
---|
| 2205 | % test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);% =1 when both numbers are in the range |
---|
| 2206 | % ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices |
---|
| 2207 | % ind_j=((num_j-first_j)/incr_j)+1; |
---|
| 2208 | % ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices |
---|
| 2209 | % select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory |
---|
| 2210 | % ind_ij=ind_ij(select);%set of selected indices ind_ij |
---|
| 2211 | % [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij |
---|
| 2212 | % select=select(indsort); |
---|
| 2213 | % num_i=num_i(select); |
---|
| 2214 | % num_a=num_a(select); |
---|
| 2215 | % num_b=num_b(select); |
---|
| 2216 | % dirpair=dirpair(select); |
---|
| 2217 | % [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; |
---|
| 2218 | % ind_ij(ind_remove)=[]; |
---|
| 2219 | % num_a(ind_remove)=[]; |
---|
| 2220 | % num_b(ind_remove)=[]; |
---|
| 2221 | % num_j1=zeros(1,nbline*nbcolumn);%default |
---|
| 2222 | % num_j2=num_j1; |
---|
| 2223 | % num_j1(ind_ij)=num_a; |
---|
| 2224 | % num_j2(ind_ij)=num_b; |
---|
| 2225 | % num_j1=reshape(num_j1,nbline,nbcolumn); |
---|
| 2226 | % num_j2=reshape(num_j2,nbline,nbcolumn); |
---|
| 2227 | % num_i1=meshgrid(ind0_i,ind0_j); |
---|
| 2228 | % num_i2=num_i1; |
---|
| 2229 | % nbmissing=nbline*nbcolumn-length(ind_ij); |
---|
| 2230 | % end |
---|
[350] | 2231 | |
---|
| 2232 | |
---|
| 2233 | % --- Executes on button press in REFRESH_INDICES. |
---|
| 2234 | function REFRESH_INDICES_Callback(hObject, eventdata, handles) |
---|
| 2235 | % hObject handle to REFRESH_INDICES (see GCBO) |
---|
| 2236 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 2237 | % handles structure with handles and user data (see GUIDATA) |
---|
| 2238 | set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2239 | InputTable=get(handles.InputTable,'Data'); |
---|
| 2240 | list_lines=get(handles.REFRESH_INDICES,'UserData'); |
---|
| 2241 | |
---|
| 2242 | %% check the indices and FileTypes for each series (limited to the new ones to save time) |
---|
| 2243 | for ind_list=1:length(list_lines) |
---|
| 2244 | if list_lines(ind_list) |
---|
| 2245 | InputLine=InputTable(list_lines(ind_list),:); |
---|
| 2246 | detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data) |
---|
| 2247 | if ~isempty(detect_idem)&& list_lines(ind_list)>1 |
---|
| 2248 | InputLine{detect_idem}=InputTable(list_lines(ind_list)-1,detect_idem); |
---|
| 2249 | set(handles.InputTable,'Data',InputTable) |
---|
| 2250 | end |
---|
| 2251 | fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2}); |
---|
| 2252 | %update file series defined by the selected line |
---|
| 2253 | [InputTable{list_lines(ind_list),1},InputTable{list_lines(ind_list),2},InputTable{list_lines(ind_list),4},errormsg]=update_indices(handles,fileinput,list_lines(ind_list)); |
---|
| 2254 | if ~isempty(errormsg) |
---|
| 2255 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2256 | return |
---|
| 2257 | end |
---|
| 2258 | end |
---|
| 2259 | end |
---|
| 2260 | set(handles.InputTable,'Data',InputTable) |
---|
| 2261 | SeriesData=get(handles.series,'UserData'); |
---|
| 2262 | |
---|
| 2263 | state_j='off'; |
---|
| 2264 | state_Pairs='off'; |
---|
| 2265 | state_InputFields='off'; |
---|
| 2266 | if ~isempty(SeriesData) |
---|
| 2267 | for ilist=1:size(InputTable,1) |
---|
| 2268 | if ~isempty(SeriesData.j1_series{ilist}) |
---|
| 2269 | state_j='on'; |
---|
| 2270 | end |
---|
| 2271 | if ~isempty(SeriesData.i2_series{ilist})||~isempty(SeriesData.j2_series{ilist}) |
---|
| 2272 | state_Pairs='on'; |
---|
| 2273 | end |
---|
| 2274 | if strcmp(SeriesData.FileType,'civx')||strcmp(SeriesData.FileType,'civdata') |
---|
| 2275 | state_InputFields='on'; |
---|
| 2276 | end |
---|
| 2277 | end |
---|
| 2278 | end |
---|
| 2279 | set(handles.num_first_j,'Visible',state_j) |
---|
| 2280 | set(handles.num_last_j,'Visible',state_j) |
---|
| 2281 | set(handles.num_incr_j,'Visible',state_j) |
---|
| 2282 | set(handles.Pairs,'Visible',state_InputFields) |
---|
| 2283 | |
---|
| 2284 | set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0]) |
---|
| 2285 | set(handles.REFRESH_INDICES,'visible','off') |
---|
| 2286 | |
---|
| 2287 | % update min and max indices for a series |
---|
| 2288 | function [RootPath,RootFile,NomType,errormsg]=update_indices(handles,fileinput,index) |
---|
| 2289 | |
---|
| 2290 | %% look for min and max indices existing in the file series and update SeriesData |
---|
| 2291 | errormsg=''; |
---|
| 2292 | [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput); |
---|
| 2293 | if isempty(RootFile)&&isempty(i1_series) |
---|
| 2294 | errormsg='not input file in the series'; |
---|
| 2295 | return |
---|
| 2296 | end |
---|
| 2297 | [~,~,FileExt]=fileparts(fileinput); |
---|
| 2298 | |
---|
| 2299 | MinIndex=get(handles.MinIndex,'Data'); |
---|
| 2300 | MaxIndex=get(handles.MaxIndex,'Data'); |
---|
| 2301 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
| 2302 | if ~isempty(i2_series) |
---|
| 2303 | MaxIndex_i=max(i2_series(i2_series>0)); |
---|
| 2304 | else |
---|
| 2305 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
| 2306 | end |
---|
| 2307 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
| 2308 | if ~isempty(j2_series) |
---|
| 2309 | MaxIndex_j=max(j2_series(j2_series>0)); |
---|
| 2310 | else |
---|
| 2311 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
| 2312 | end |
---|
| 2313 | MinIndex{index,1}=MinIndex_i; |
---|
| 2314 | MinIndex{index,2}=MinIndex_j; |
---|
| 2315 | MaxIndex{index,1}=MaxIndex_i; |
---|
| 2316 | MaxIndex{index,2}=MaxIndex_j; |
---|
| 2317 | set(handles.MinIndex,'Data',MinIndex) |
---|
| 2318 | set(handles.MaxIndex,'Data',MaxIndex) |
---|
| 2319 | SeriesData=get(handles.series,'UserData'); |
---|
| 2320 | SeriesData.i1_series{index}=i1_series; |
---|
| 2321 | SeriesData.i2_series{index}=i2_series; |
---|
| 2322 | SeriesData.j1_series{index}=j1_series; |
---|
| 2323 | SeriesData.j2_series{index}=j2_series; |
---|
| 2324 | SeriesData.FileType{index}=FileType; |
---|
| 2325 | |
---|
| 2326 | %% represents the set of existing files as an image |
---|
| 2327 | set(handles.waitbar_frame,'Units','pixels') |
---|
| 2328 | pos=get(handles.waitbar_frame,'Position'); |
---|
| 2329 | xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices |
---|
| 2330 | yima=0.5:pos(4)-0.5; |
---|
| 2331 | [XIma,YIma]=meshgrid(xima,yima); |
---|
| 2332 | nb_i=size(i1_series,1); |
---|
| 2333 | nb_j=size(i1_series,2); |
---|
| 2334 | ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i; |
---|
| 2335 | ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j; |
---|
| 2336 | [Ind_i,Ind_j]=meshgrid(ind_i,ind_j); |
---|
| 2337 | CData=zeros([size(XIma) 3]); |
---|
| 2338 | file_ima=double((i1_series(:,:,1)>0)'); |
---|
| 2339 | if numel(file_ima)>=2 |
---|
| 2340 | if size(file_ima,1)==1 |
---|
| 2341 | CLine=interp1(ind_i,file_ima,xima,'nearest'); |
---|
| 2342 | CData(:,:,2)=ones(size(yima'))*CLine; |
---|
| 2343 | else |
---|
| 2344 | CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest'); |
---|
| 2345 | end |
---|
| 2346 | set(handles.waitbar_frame,'CData',CData) |
---|
| 2347 | end |
---|
| 2348 | set(handles.waitbar_frame,'Units','normalized') |
---|
| 2349 | |
---|
| 2350 | %% enable field and veltype menus |
---|
| 2351 | testfield=isequal(get(handles.FieldMenu,'enable'),'on'); |
---|
| 2352 | testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on'); |
---|
| 2353 | testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); |
---|
| 2354 | testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); |
---|
| 2355 | testtransform=isequal(get(handles.transform_fct,'Enable'),'on'); |
---|
| 2356 | testnc=0; |
---|
| 2357 | testnc_1=0; |
---|
| 2358 | testcivx=0; |
---|
| 2359 | testcivx_1=0; |
---|
| 2360 | %TODO: update |
---|
| 2361 | % if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
| 2362 | % for iview=1:length(FileExtCell) |
---|
| 2363 | % if isequal(FileExtCell{iview},'.nc') |
---|
| 2364 | % testnc=1; |
---|
| 2365 | % end |
---|
| 2366 | % if isequal(FileTypeCell{iview},'civx') |
---|
| 2367 | % testcivx=1; |
---|
| 2368 | % end |
---|
| 2369 | % end |
---|
| 2370 | % elseif length(FileExtCell)==2 |
---|
| 2371 | % testnc=isequal(FileExtCell{1},'.nc'); |
---|
| 2372 | % testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
| 2373 | % testcivx=isequal(FileTypeCell{1},'civx'); |
---|
| 2374 | % testcivx_1=isequal(FileTypeCell{2},'civx'); |
---|
| 2375 | % end |
---|
| 2376 | if testfield && testnc |
---|
| 2377 | view_FieldMenu(handles,'on') |
---|
| 2378 | if testcivx |
---|
| 2379 | menustr=get(handles.FieldMenu,'String'); |
---|
| 2380 | if isequal(menustr,{'get_field...'}) |
---|
| 2381 | set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
| 2382 | end |
---|
| 2383 | else |
---|
| 2384 | set(handles.FieldMenu,'Value',1) |
---|
| 2385 | set(handles.FieldMenu,'String',{'get_field...'}) |
---|
| 2386 | end |
---|
| 2387 | else |
---|
| 2388 | view_FieldMenu(handles,'off') |
---|
| 2389 | end |
---|
| 2390 | if testfield_1 && testnc_1 |
---|
| 2391 | view_FieldMenu_1(handles,'on') |
---|
| 2392 | if testcivx_1 |
---|
| 2393 | menustr=get(handles.FieldMenu_1,'String'); |
---|
| 2394 | if isequal(menustr,{'get_field...'}) |
---|
| 2395 | set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
| 2396 | end |
---|
| 2397 | else |
---|
| 2398 | set(handles.FieldMenu_1,'Value',1) |
---|
| 2399 | set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
| 2400 | end |
---|
| 2401 | else |
---|
| 2402 | view_FieldMenu_1(handles,'off') |
---|
| 2403 | end |
---|
| 2404 | if testveltype && testcivx |
---|
| 2405 | set(handles.VelTypeMenu,'Visible','on') |
---|
| 2406 | set(handles.VelType_text,'Visible','on'); |
---|
| 2407 | else |
---|
| 2408 | set(handles.VelTypeMenu,'Visible','off') |
---|
| 2409 | set(handles.VelType_text,'Visible','off'); |
---|
| 2410 | end |
---|
| 2411 | if testveltype_1 && testcivx_1 |
---|
| 2412 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
| 2413 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 2414 | else |
---|
| 2415 | set(handles.VelTypeMenu_1,'Visible','off') |
---|
| 2416 | set(handles.VelType_text_1,'Visible','off'); |
---|
| 2417 | end |
---|
| 2418 | if testtransform && (testcivx || testima) |
---|
| 2419 | set(handles.FieldTransform,'Visible','on') |
---|
| 2420 | % view_TRANSFORM(handles,'on') |
---|
| 2421 | else |
---|
| 2422 | set(handles.FieldTransform,'Visible','off') |
---|
| 2423 | % view_TRANSFORM(handles,'off') |
---|
| 2424 | end |
---|
| 2425 | %TODO:update |
---|
| 2426 | % if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
| 2427 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
| 2428 | % return |
---|
| 2429 | % end |
---|
| 2430 | |
---|
| 2431 | %% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2432 | ext_imadoc=''; |
---|
| 2433 | FileBase=fullfile(RootPath,RootFile); |
---|
| 2434 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
| 2435 | ext_imadoc=FileExt; |
---|
| 2436 | elseif exist([FileBase '.xml'],'file') |
---|
| 2437 | ext_imadoc='.xml'; |
---|
| 2438 | elseif exist([FileBase '.civ'],'file') |
---|
| 2439 | ext_imadoc='.civ'; |
---|
| 2440 | end |
---|
| 2441 | %read the ImaDoc file |
---|
| 2442 | XmlData=[]; |
---|
| 2443 | NbSlice_calib={}; |
---|
| 2444 | if isequal(ext_imadoc,'.xml') |
---|
| 2445 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
| 2446 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName) |
---|
| 2447 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 2448 | end |
---|
| 2449 | if isfield(XmlData,'Time') |
---|
| 2450 | time=XmlData.Time; |
---|
| 2451 | end |
---|
| 2452 | if isfield(XmlData,'Camera') |
---|
| 2453 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 2454 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 2455 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 2456 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 2457 | end |
---|
| 2458 | end |
---|
| 2459 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 2460 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 2461 | end |
---|
| 2462 | end |
---|
| 2463 | if ~isempty(warntext) |
---|
| 2464 | msgbox_uvmat('WARNING',warntext) |
---|
| 2465 | end |
---|
| 2466 | elseif isequal(ext_imadoc,'.civ') |
---|
| 2467 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
| 2468 | time=XmlData.Time; |
---|
| 2469 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
| 2470 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 2471 | end |
---|
| 2472 | end |
---|
| 2473 | |
---|
| 2474 | |
---|
| 2475 | %% number of slices |
---|
| 2476 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 2477 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 2478 | if siz(1)>1 |
---|
| 2479 | NbSlice=siz(1); |
---|
| 2480 | else |
---|
| 2481 | NbSlice=1; |
---|
| 2482 | end |
---|
| 2483 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 2484 | end |
---|
| 2485 | % set(handles.mode,'Visible','off') % do not show index pairs by default |
---|
| 2486 | set(handles.Pairs,'Visible','off') |
---|
| 2487 | % set(handles.ref_i,'Visible','off') |
---|
| 2488 | % set(handles.ref_i_text,'Visible','off') |
---|
| 2489 | testpair=0; |
---|
| 2490 | %set the menus of image pairs and default selection for series |
---|
| 2491 | %list pairs if relevant |
---|
| 2492 | % Val=get(handles.NomType,'Value'); |
---|
| 2493 | % synchronise_view(handles,Val) |
---|
| 2494 | |
---|
| 2495 | % if ~isfield(SeriesData,'j1_series')||isempty(SeriesData.j1_series{index}) |
---|
| 2496 | % state_j='off'; %no need for j index |
---|
| 2497 | % else |
---|
| 2498 | % state_j='on'; %case of j index |
---|
| 2499 | % end |
---|
| 2500 | % show index pairs if files exist |
---|
| 2501 | if isfield(SeriesData,'j1_series')&&(~isempty(SeriesData.i2_series{index})||~isempty(SeriesData.j2_series{index})) |
---|
| 2502 | testpair=1; |
---|
| 2503 | if ~isempty(SeriesData.i2_series{index}) %pairs with i index |
---|
| 2504 | set(handles.mode,'Value',1) |
---|
| 2505 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 2506 | else %pairs with j index |
---|
| 2507 | set(handles.mode,'Value',1) |
---|
| 2508 | set(handles.mode,'String',{'bursts';'series(Dj)'}) |
---|
| 2509 | if nbfield2>10 || nbfield==1 |
---|
| 2510 | set(handles.mode,'Value',2); |
---|
| 2511 | else |
---|
| 2512 | set(handles.mode,'Value',1); |
---|
| 2513 | end |
---|
| 2514 | end |
---|
| 2515 | set(handles.mode,'Visible','on') |
---|
| 2516 | else |
---|
| 2517 | set(handles.mode,'Visible','off') |
---|
| 2518 | end |
---|
| 2519 | % if ~isempty(NomTypeCell) |
---|
| 2520 | % NomType=NomTypeCell{Val}; |
---|
| 2521 | % switch NomType |
---|
| 2522 | % case {'_1-2_1', '_1-2'} |
---|
| 2523 | % set(handles.mode,'String',{'series(Di)'}) |
---|
| 2524 | % set(handles.mode,'Value',1); |
---|
| 2525 | % set(handles.mode,'Visible','on') |
---|
| 2526 | % testpair=1; |
---|
| 2527 | % case {'#_ab'} |
---|
| 2528 | % set(handles.mode,'String',{'bursts'}) |
---|
| 2529 | % set(handles.mode,'Value',1); |
---|
| 2530 | % testpair=1; |
---|
| 2531 | % case '_1_1-2' |
---|
| 2532 | % set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice |
---|
| 2533 | % if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1)) |
---|
| 2534 | % set(handles.mode,'Value',2); |
---|
| 2535 | % else |
---|
| 2536 | % set(handles.mode,'Value',1);% advice 'bursts' for small bursts |
---|
| 2537 | % end |
---|
| 2538 | % set(handles.mode,'Visible','on') |
---|
| 2539 | % testpair=1; |
---|
| 2540 | % end |
---|
| 2541 | % switch NomType |
---|
| 2542 | % case {'_1_1','_1_1-2','_1-2_1','1_ab','01_ab'},% two navigation indices |
---|
| 2543 | % state_j='on'; |
---|
| 2544 | % end |
---|
| 2545 | % end |
---|
| 2546 | set(handles.series,'UserData',SeriesData) |
---|
| 2547 | if testpair |
---|
| 2548 | mode_Callback(hObject, eventdata, handles) |
---|
| 2549 | else |
---|
| 2550 | % set(handles.NomType,'String',NomTypeCell) |
---|
| 2551 | % set(handles.j_txt,'Visible',state_j) |
---|
| 2552 | % set(handles.num_MinIndex_j,'Visible',state_j) |
---|
| 2553 | % set(handles.num_first_j,'Visible',state_j) |
---|
| 2554 | % set(handles.num_incr_j,'Visible',state_j) |
---|
| 2555 | % set(handles.num_last_j,'Visible',state_j) |
---|
| 2556 | % set(handles.num_MaxIndex_j,'Visible',state_j) |
---|
| 2557 | end |
---|
| 2558 | |
---|