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