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