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