[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) |
---|
| 8 | % .menu_coord_str: string for the CoordType (menu for coordinate transforms) |
---|
| 9 | % .menu_coord_val: value for CoordType (menu for coordinate transforms) |
---|
| 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) |
---|
| 57 | |
---|
| 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') |
---|
| 98 | set(handles.CoordType,'String',param.menu_coord_str) |
---|
| 99 | end |
---|
| 100 | if isfield(param,'menu_coord_val') |
---|
| 101 | set(handles.CoordType,'Value',param.menu_coord_val); |
---|
| 102 | else |
---|
| 103 | set(handles.CoordType,'Value',1);%default |
---|
| 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,'UserData', SeriesData) |
---|
| 132 | set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) |
---|
| 133 | NomType_Callback(hObject, eventdata, handles) |
---|
| 134 | %mode_Callback(hObject, eventdata, handles) |
---|
| 135 | |
---|
| 136 | %loads the information stored in prefdir to initiate the browser and the list of functions |
---|
[26] | 137 | menu_str={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'}; |
---|
| 138 | |
---|
| 139 | % menu_str=get(handles.ACTION,'String');%list of functions included in 'series.m' |
---|
| 140 | |
---|
| 141 | %remove from the list the last option 'more...' |
---|
| 142 | [path_series,name,ext]=fileparts(which('series')); |
---|
| 143 | path_series=fullfile(path_series,'/series');%path of the function 'series' |
---|
| 144 | |
---|
[2] | 145 | for ilist=1:length(menu_str) |
---|
| 146 | fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m' |
---|
| 147 | end |
---|
| 148 | dir_perso=prefdir; |
---|
| 149 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 150 | if exist(profil_perso,'file') |
---|
| 151 | h=load (profil_perso); |
---|
| 152 | if isfield(h,'series_fct') && iscell(h.series_fct) |
---|
| 153 | for ilist=1:length(h.series_fct) |
---|
| 154 | [path,file]=fileparts(h.series_fct{ilist}); |
---|
| 155 | fct_path=[fct_path; {path}];%concatene the list of paths |
---|
| 156 | menu_str=[menu_str; {file}]; |
---|
| 157 | end |
---|
| 158 | end |
---|
| 159 | end |
---|
[26] | 160 | |
---|
| 161 | menu_str=[menu_str;{'more...'}]; |
---|
| 162 | set(handles.ACTION,'String',menu_str) |
---|
[2] | 163 | set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION |
---|
| 164 | |
---|
| 165 | % display the GUI for the default action 'check_files' |
---|
| 166 | ACTION_Callback(hObject, eventdata, handles) |
---|
| 167 | |
---|
| 168 | %-------------------------------------------------------------- |
---|
| 169 | % --- Outputs from this function are returned to the command line. |
---|
| 170 | %----------------------------------------------------------------- |
---|
| 171 | function varargout = series_OutputFcn(hObject, eventdata, handles) |
---|
| 172 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 173 | % hObject handle to figure |
---|
| 174 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 175 | % handles structure with handles and user data (see GUIDATA) |
---|
| 176 | % Get default command line output from handles structure |
---|
| 177 | varargout{1} = handles.output; |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | % -------------------------------------------------------------------- |
---|
| 181 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 182 | |
---|
| 183 | RootPathCell=get(handles.RootPath,'String'); |
---|
| 184 | SubDirCell=get(handles.SubDir,'String'); |
---|
| 185 | RootFileCell=get(handles.RootFile,'String'); |
---|
| 186 | oldfile=''; %default |
---|
| 187 | if isempty(RootPathCell)|isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
| 188 | dir_perso=prefdir; |
---|
| 189 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 190 | if exist(profil_perso,'file') |
---|
| 191 | h=load (profil_perso); |
---|
| 192 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 193 | oldfile=h.filebase; |
---|
| 194 | end |
---|
| 195 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 196 | oldfile=h.RootPath; |
---|
| 197 | end |
---|
| 198 | end |
---|
| 199 | else |
---|
| 200 | oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1}); |
---|
| 201 | end |
---|
| 202 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 203 | {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)'; |
---|
| 204 | '*.xml', '.xml files '; ... |
---|
| 205 | '*.xls', '.xls files '; ... |
---|
| 206 | '*.png','.png image files'; ... |
---|
| 207 | '*.tif','.tif image files'; ... |
---|
| 208 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 209 | '*.nc','.netcdf files'; ... |
---|
| 210 | '*.*', 'All Files (*.*)'}, ... |
---|
| 211 | 'Pick a file',oldfile); |
---|
| 212 | fileinput=[PathName FileName];%complete file name |
---|
| 213 | testblank=findstr(fileinput,' ');%look for blanks |
---|
| 214 | if ~isempty(testblank) |
---|
| 215 | errordlg('forbidden input file name: contain blanks') |
---|
| 216 | return |
---|
| 217 | end |
---|
| 218 | sizf=size(fileinput); |
---|
| 219 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 220 | [path,name,ext]=fileparts(fileinput); |
---|
| 221 | SeriesData=[];%dfault |
---|
| 222 | if isequal(ext,'.xml') |
---|
| 223 | errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
| 224 | elseif isequal(ext,'.xls') |
---|
| 225 | errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
| 226 | else |
---|
| 227 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 228 | %update list of recent files in the menubar |
---|
| 229 | MenuFile_1=fileinput; |
---|
| 230 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 231 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 232 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 233 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 234 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 235 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 236 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 237 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 238 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 239 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
| 240 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
| 241 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
| 242 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
| 243 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
| 244 | dir_perso=prefdir; |
---|
| 245 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 246 | if exist(profil_perso,'file') |
---|
| 247 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 248 | else |
---|
| 249 | txt=ver; |
---|
| 250 | Release=txt(1).Release; |
---|
| 251 | relnumb=str2num(Release(3:4)); |
---|
| 252 | if relnumb >= 14 |
---|
| 253 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 254 | else |
---|
| 255 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 256 | end |
---|
| 257 | end |
---|
| 258 | end |
---|
| 259 | % set(hseries,'UserData',SeriesData); |
---|
| 260 | % RootFile_Callback(hObject, eventdata, handles); |
---|
| 261 | % FileExt_Callback(hObject, eventdata, handles); |
---|
| 262 | % NomType_Callback(hObject, eventdata, handles) |
---|
| 263 | % mode_Callback(hObject, eventdata, handles) |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | % -------------------------------------------------------------------- |
---|
| 267 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 268 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
| 269 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 270 | |
---|
| 271 | % -------------------------------------------------------------------- |
---|
| 272 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 273 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
| 274 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 275 | |
---|
| 276 | % -------------------------------------------------------------------- |
---|
| 277 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 278 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
| 279 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 280 | |
---|
| 281 | % -------------------------------------------------------------------- |
---|
| 282 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 283 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
| 284 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 285 | |
---|
| 286 | % -------------------------------------------------------------------- |
---|
| 287 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 288 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
| 289 | update_file(hObject, eventdata, handles,fileinput,0) |
---|
| 290 | |
---|
| 291 | % -------------------------------------------------------------------- |
---|
| 292 | function MenuBrowse_insert_Callback(hObject, eventdata, handles) |
---|
| 293 | |
---|
| 294 | %hseries=get(handles.browse_root,'parent'); |
---|
| 295 | RootPathCell=get(handles.RootPath,'String'); |
---|
| 296 | % SubDirCell=get(handles.SubDir,'String'); |
---|
| 297 | RootFileCell=get(handles.RootFile,'String'); |
---|
| 298 | oldfile=''; %default |
---|
| 299 | if isempty(RootPathCell)|isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box |
---|
| 300 | dir_perso=prefdir; |
---|
| 301 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 302 | if exist(profil_perso,'file') |
---|
| 303 | h=load (profil_perso); |
---|
| 304 | if isfield(h,'filebase')&ischar(h.filebase) |
---|
| 305 | oldfile=h.filebase; |
---|
| 306 | end |
---|
| 307 | if isfield(h,'RootPath')&ischar(h.RootPath) |
---|
| 308 | oldfile=h.RootPath; |
---|
| 309 | end |
---|
| 310 | end |
---|
| 311 | else |
---|
| 312 | oldfile=fullfile(RootPathCell{1},RootFileCell{1}); |
---|
| 313 | end |
---|
| 314 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 315 | {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)'; |
---|
| 316 | '*.xml', '.xml files '; ... |
---|
| 317 | '*.xls', '.xls files '; ... |
---|
| 318 | '*.png','.png image files'; ... |
---|
| 319 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 320 | '*.nc','.netcdf files'; ... |
---|
| 321 | '*.*', 'All Files (*.*)'}, ... |
---|
| 322 | 'Pick a file',oldfile); |
---|
| 323 | fileinput=[PathName FileName];%complete file name |
---|
| 324 | testblank=findstr(fileinput,' ');%look for blanks |
---|
| 325 | if ~isempty(testblank) |
---|
| 326 | errordlg('forbidden input file name: contain blanks') |
---|
| 327 | return |
---|
| 328 | end |
---|
| 329 | sizf=size(fileinput); |
---|
| 330 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
| 331 | [path,name,ext]=fileparts(fileinput); |
---|
| 332 | SeriesData=[];%dfault |
---|
| 333 | if isequal(ext,'.xml') |
---|
| 334 | errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
| 335 | elseif isequal(ext,'.xls') |
---|
| 336 | errordlg('input file type not implemented')%A Faire: ouvrir le fichier pour naviguer |
---|
| 337 | else |
---|
| 338 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 339 | %update list of recent files in the menubar |
---|
| 340 | MenuFile_1=fileinput; |
---|
| 341 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 342 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 343 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 344 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 345 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 346 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 347 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 348 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 349 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 350 | set(handles.MenuFile_insert_1,'Label',MenuFile_1) |
---|
| 351 | set(handles.MenuFile_insert_2,'Label',MenuFile_2) |
---|
| 352 | set(handles.MenuFile_insert_3,'Label',MenuFile_3) |
---|
| 353 | set(handles.MenuFile_insert_4,'Label',MenuFile_4) |
---|
| 354 | set(handles.MenuFile_insert_5,'Label',MenuFile_5) |
---|
| 355 | dir_perso=prefdir; |
---|
| 356 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 357 | if exist(profil_perso,'file') |
---|
| 358 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 359 | else |
---|
| 360 | txt=ver; |
---|
| 361 | Release=txt(1).Release; |
---|
| 362 | relnumb=str2num(Release(3:4)); |
---|
| 363 | if relnumb >= 14 |
---|
| 364 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 365 | else |
---|
| 366 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 367 | end |
---|
| 368 | end |
---|
| 369 | end |
---|
| 370 | %------------------------------------------------ |
---|
| 371 | |
---|
| 372 | % -------------------------------------------------------------------- |
---|
| 373 | function MenuFile_insert_1_Callback(hObject, eventdata, handles) |
---|
| 374 | fileinput=get(handles.MenuFile_insert_1,'Label'); |
---|
| 375 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 376 | |
---|
| 377 | % -------------------------------------------------------------------- |
---|
| 378 | function MenuFile_insert_2_Callback(hObject, eventdata, handles) |
---|
| 379 | fileinput=get(handles.MenuFile_insert_2,'Label'); |
---|
| 380 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 381 | |
---|
| 382 | % -------------------------------------------------------------------- |
---|
| 383 | function MenuFile_insert_3_Callback(hObject, eventdata, handles) |
---|
| 384 | fileinput=get(handles.MenuFile_insert_3,'Label'); |
---|
| 385 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 386 | |
---|
| 387 | % -------------------------------------------------------------------- |
---|
| 388 | function MenuFile_insert_4_Callback(hObject, eventdata, handles) |
---|
| 389 | fileinput=get(handles.MenuFile_insert_4,'Label'); |
---|
| 390 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 391 | |
---|
| 392 | % -------------------------------------------------------------------- |
---|
| 393 | function MenuFile_insert_5_Callback(hObject, eventdata, handles) |
---|
| 394 | fileinput=get(handles.MenuFile_insert_5,'Label'); |
---|
| 395 | update_file(hObject, eventdata, handles,fileinput,1) |
---|
| 396 | |
---|
| 397 | % -------------------------------------------------------------------- |
---|
| 398 | % refresh the GUI data after introduction of a new file series |
---|
| 399 | function update_file(hObject, eventdata, handles,fileinput,addtest) |
---|
| 400 | hseries=get(handles.RootPath,'parent'); |
---|
| 401 | % refresh input root name, indices, file extension and nomenclature |
---|
| 402 | [RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput); |
---|
| 403 | %check for movie image files |
---|
| 404 | if ~isempty(imformats(FileExt(2:end))) |
---|
| 405 | imainfo=imfinfo(fileinput); |
---|
| 406 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 407 | NomType='*'; |
---|
| 408 | [RootPath,RootFile]=fileparts(fileinput); |
---|
| 409 | end |
---|
| 410 | end |
---|
| 411 | NcType='none';%default |
---|
| 412 | if isequal(FileExt,'.nc') |
---|
| 413 | Data=nc2struct(fileinput,[]); |
---|
| 414 | if isfield(Data,'absolut_time_T0') |
---|
| 415 | NcType='civx'; % test for civx velocity fields |
---|
| 416 | end |
---|
| 417 | end |
---|
| 418 | |
---|
| 419 | set(handles.RootPath,'Value',1) |
---|
| 420 | set(handles.SubDir,'Value',1) |
---|
| 421 | set(handles.RootFile,'Value',1) |
---|
| 422 | set(handles.NomType,'Value',1) |
---|
| 423 | set(handles.FileExt,'Value',1) |
---|
| 424 | set(handles.nb_field,'Value',1) |
---|
| 425 | set(handles.nb_field2,'Value',1) |
---|
| 426 | if addtest |
---|
| 427 | SeriesData=get(hseries,'UserData'); |
---|
| 428 | SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num]; |
---|
| 429 | SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile; |
---|
| 430 | RootPathCell=[{RootPath}; get(handles.RootPath,'String')] ; |
---|
| 431 | SubDirCell=[{SubDir}; get(handles.SubDir,'String')]; |
---|
| 432 | RootFileCell=[{RootFile}; get(handles.RootFile,'String')]; |
---|
| 433 | NomTypeCell=[{NomType}; SeriesData.NomType]; |
---|
| 434 | FileExtCell=[{FileExt}; get(handles.FileExt,'String')]; |
---|
| 435 | NcTypeCell=[{NcType};SeriesData.NcType]; |
---|
| 436 | set(handles.NomType,'String',[{};get(handles.NomType,'String')]) |
---|
| 437 | else |
---|
| 438 | SeriesData=[];%re-initialisation |
---|
| 439 | SeriesData.displ_num=[0 0 0 0]; |
---|
| 440 | RootPathCell={RootPath}; |
---|
| 441 | SubDirCell={SubDir}; |
---|
| 442 | RootFileCell={RootFile}; |
---|
| 443 | NomTypeCell={NomType}; |
---|
| 444 | FileExtCell={FileExt}; |
---|
| 445 | NcTypeCell={NcType}; |
---|
| 446 | end |
---|
| 447 | |
---|
| 448 | SeriesData.NomType=NomTypeCell; |
---|
| 449 | SeriesData.NcType=NcTypeCell; |
---|
| 450 | SeriesData.CurrentInputFile=fileinput; |
---|
| 451 | set(handles.RootPath,'String',RootPathCell); |
---|
| 452 | set(handles.SubDir,'String',SubDirCell); |
---|
| 453 | set(handles.RootFile,'String',RootFileCell); |
---|
| 454 | set(handles.NomType,'String',NomTypeCell); |
---|
| 455 | set(handles.FileExt,'String',FileExtCell); |
---|
| 456 | |
---|
| 457 | %determine field indices |
---|
| 458 | ref_i=1; %default ref_i is a reference frame index used to find existing pairs from PIV |
---|
| 459 | if ~isempty(str2num(field_count)) |
---|
| 460 | ref_i=str2num(field_count); |
---|
| 461 | if ~isempty(str2num(str2)) |
---|
| 462 | ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file |
---|
| 463 | SeriesData.browse_Di=str2num(str2)-str2num(field_count); |
---|
| 464 | end |
---|
| 465 | end |
---|
| 466 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 467 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 468 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 469 | ref_j=1; %default ref_j is a reference frame index used to find existing pairs from PIV |
---|
| 470 | if ~isempty(str2num(str_a)) |
---|
| 471 | ref_j=str2num(str_a); |
---|
| 472 | if ~isempty(str2num(str_b)) |
---|
| 473 | ref_j=floor((str2num(str_a)+str2num(str_b))/2); |
---|
| 474 | SeriesData.browse_Dj=str2num(str_b)-str2num(str_a); |
---|
| 475 | end |
---|
| 476 | end |
---|
| 477 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
| 478 | set(handles.first_j,'String',num2str(ref_j)) |
---|
| 479 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 480 | %set(hseries,'UserData',SeriesData); |
---|
| 481 | |
---|
| 482 | %enable other menus and uicontrols |
---|
| 483 | set(handles.MenuOpen_insert,'Enable','on') |
---|
| 484 | set(handles.MenuFile_insert_1,'Enable','on') |
---|
| 485 | set(handles.MenuFile_insert_2,'Enable','on') |
---|
| 486 | set(handles.MenuFile_insert_3,'Enable','on') |
---|
| 487 | set(handles.MenuFile_insert_4,'Enable','on') |
---|
| 488 | set(handles.MenuFile_insert_5,'Enable','on') |
---|
| 489 | set(handles.RUN, 'Enable','On') |
---|
| 490 | set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red |
---|
| 491 | set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box to yellow |
---|
| 492 | drawnow |
---|
| 493 | |
---|
| 494 | % hseries=get(handles.RootFile,'parent'); |
---|
| 495 | % SeriesData=get(hseries,'UserData');%read information set by the browser |
---|
| 496 | % ext_ima_read=[]; |
---|
| 497 | % field_count=1;%default |
---|
| 498 | % pxcmx=1; |
---|
| 499 | % pxcmy=1; |
---|
| 500 | TimeUnit=''; %default |
---|
| 501 | % CoordUnit='';%default |
---|
| 502 | time=[];%default |
---|
| 503 | GeometryCalib=[];%default |
---|
| 504 | nb_field=[];%default |
---|
| 505 | nb_field2=[];%default |
---|
| 506 | % Heading=[]; |
---|
| 507 | % [PD,Device]=fileparts(RootPathCell{1}); |
---|
| 508 | SeriesData.PathCampaign=get(handles.PathCampaign,'String'); |
---|
| 509 | |
---|
| 510 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 511 | %icell=length(RootPathCell); |
---|
| 512 | FileBase=fullfile(RootPath,RootFile); |
---|
| 513 | |
---|
| 514 | % nb_field{icell,1}='?';%default |
---|
| 515 | % nb_field2{icell,1}='?';%default |
---|
| 516 | testima=0; %test for image input |
---|
| 517 | if isequal(lower(FileExt),'.avi') %.avi file |
---|
| 518 | testima=1; |
---|
| 519 | info=aviinfo([FileBase FileExt]); |
---|
| 520 | time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]'; |
---|
| 521 | nb_field=info.NumFrames; |
---|
| 522 | nb_field2=1; |
---|
| 523 | elseif ~isempty(imformats(FileExt(2:end))) |
---|
| 524 | testima=1; |
---|
| 525 | if isequal(NomType,'*')% multi-frame image |
---|
| 526 | imainfo=imfinfo([FileBase FileExt]); |
---|
| 527 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 528 | nb_field=length(imainfo); |
---|
| 529 | nb_field2=1; |
---|
| 530 | end |
---|
| 531 | end |
---|
| 532 | elseif isequal(FileExt,'.vol') |
---|
| 533 | testima=1; |
---|
| 534 | end |
---|
| 535 | |
---|
| 536 | % enable field and veltype menus |
---|
| 537 | testfield=isequal(get(handles.FieldMenu,'enable'),'on'); |
---|
| 538 | testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on'); |
---|
| 539 | testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on'); |
---|
| 540 | testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on'); |
---|
| 541 | testtransform=isequal(get(handles.CoordType,'Enable'),'on'); |
---|
| 542 | testnc=0; |
---|
| 543 | testnc_1=0; |
---|
| 544 | testcivx=0; |
---|
| 545 | testcivx_1=0; |
---|
| 546 | if length(FileExtCell)==1 || length(FileExtCell)>2 |
---|
| 547 | for iview=1:length(FileExtCell) |
---|
| 548 | if isequal(FileExtCell{iview},'.nc') |
---|
| 549 | testnc=1; |
---|
| 550 | end |
---|
| 551 | if isequal(NcTypeCell{iview},'civx') |
---|
| 552 | testcivx=1; |
---|
| 553 | end |
---|
| 554 | end |
---|
| 555 | elseif length(FileExtCell)==2 |
---|
| 556 | testnc=isequal(FileExtCell{1},'.nc'); |
---|
| 557 | testnc_1=isequal(FileExtCell{2},'.nc'); |
---|
| 558 | testcivx=isequal(NcTypeCell{1},'civx'); |
---|
| 559 | testcivx_1=isequal(NcTypeCell{2},'civx'); |
---|
| 560 | end |
---|
| 561 | if testfield && testnc |
---|
| 562 | view_FieldMenu(handles,'on') |
---|
| 563 | if testcivx |
---|
| 564 | menustr=get(handles.FieldMenu,'String'); |
---|
| 565 | if isequal(menustr,{'get_field...'}) |
---|
| 566 | set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
| 567 | end |
---|
| 568 | else |
---|
| 569 | set(handles.FieldMenu,'Value',1) |
---|
| 570 | set(handles.FieldMenu,'String',{'get_field...'}) |
---|
| 571 | end |
---|
| 572 | else |
---|
| 573 | view_FieldMenu(handles,'off') |
---|
| 574 | end |
---|
| 575 | if testfield_1 && testnc_1 |
---|
| 576 | view_FieldMenu_1(handles,'on') |
---|
| 577 | if testcivx_1 |
---|
| 578 | menustr=get(handles.FieldMenu_1,'String'); |
---|
| 579 | if isequal(menustr,{'get_field...'}) |
---|
| 580 | set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'}) |
---|
| 581 | end |
---|
| 582 | else |
---|
| 583 | set(handles.FieldMenu_1,'Value',1) |
---|
| 584 | set(handles.FieldMenu_1,'String',{'get_field...'}) |
---|
| 585 | end |
---|
| 586 | else |
---|
| 587 | view_FieldMenu_1(handles,'off') |
---|
| 588 | end |
---|
| 589 | if testveltype && testcivx |
---|
| 590 | set(handles.VelTypeMenu,'Visible','on') |
---|
| 591 | set(handles.VelType_text,'Visible','on'); |
---|
| 592 | else |
---|
| 593 | set(handles.VelTypeMenu,'Visible','off') |
---|
| 594 | set(handles.VelType_text,'Visible','off'); |
---|
| 595 | end |
---|
| 596 | if testveltype_1 && testcivx_1 |
---|
| 597 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
| 598 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 599 | else |
---|
| 600 | set(handles.VelTypeMenu_1,'Visible','off') |
---|
| 601 | set(handles.VelType_text_1,'Visible','off'); |
---|
| 602 | end |
---|
| 603 | if testtransform && (testcivx || testima) |
---|
| 604 | view_TRANSFORM(handles,'on') |
---|
| 605 | else |
---|
| 606 | view_TRANSFORM(handles,'off') |
---|
| 607 | end |
---|
| 608 | if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima |
---|
| 609 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt]) |
---|
| 610 | return |
---|
| 611 | end |
---|
| 612 | |
---|
| 613 | %%%%%%%% read image documentation file if found%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 614 | %look for the file existence |
---|
| 615 | ext_imadoc=''; |
---|
| 616 | if isequal(FileExt,'.xml')||isequal(FileExt,'.civ') |
---|
| 617 | ext_imadoc=FileExt; |
---|
| 618 | elseif exist([FileBase '.xml'],'file') |
---|
| 619 | ext_imadoc='.xml'; |
---|
| 620 | elseif exist([FileBase '.civ'],'file') |
---|
| 621 | ext_imadoc='.civ'; |
---|
| 622 | end |
---|
| 623 | %read the ImaDoc file |
---|
| 624 | % mode=''; %default |
---|
| 625 | % testheading=0; |
---|
| 626 | XmlData=[]; |
---|
| 627 | NbSlice_calib={}; |
---|
| 628 | if isequal(ext_imadoc,'.xml') |
---|
| 629 | [XmlData,warntext]=imadoc2struct([FileBase '.xml']); |
---|
| 630 | if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') |
---|
| 631 | [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName); |
---|
| 632 | end |
---|
| 633 | if isfield(XmlData,'Time') |
---|
| 634 | time=XmlData.Time; |
---|
| 635 | end |
---|
| 636 | if isfield(XmlData,'Camera') |
---|
| 637 | if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) |
---|
| 638 | NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform |
---|
| 639 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 640 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 641 | end |
---|
| 642 | end |
---|
| 643 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) |
---|
| 644 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 645 | end |
---|
| 646 | end |
---|
| 647 | if ~isempty(warntext) |
---|
| 648 | msgbox_uvmat('WARNING',warntext) |
---|
| 649 | end |
---|
| 650 | elseif isequal(ext_imadoc,'.civ') |
---|
| 651 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
| 652 | time=XmlData.Time; |
---|
| 653 | size(time) |
---|
| 654 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
| 655 | GeometryCalib.Tx=0; |
---|
| 656 | GeometryCalib.Ty=0; |
---|
| 657 | GeometryCalib.Tz=1; |
---|
| 658 | GeometryCalib.dpx=1; |
---|
| 659 | GeometryCalib.dpy=1; |
---|
| 660 | GeometryCalib.sx=1; |
---|
| 661 | GeometryCalib.Cx=0; |
---|
| 662 | GeometryCalib.Cy=0; |
---|
| 663 | GeometryCalib.f=1; |
---|
| 664 | GeometryCalib.kappa1=0; |
---|
| 665 | GeometryCalib.CoordUnit='cm'; |
---|
| 666 | XmlData.GeometryCalib=GeometryCalib; |
---|
| 667 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
| 668 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 669 | end |
---|
| 670 | % set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box |
---|
| 671 | % set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box |
---|
| 672 | % set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box |
---|
| 673 | % set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box |
---|
| 674 | % set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box |
---|
| 675 | % set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box |
---|
| 676 | % set(handles.view_xml,'Visible','on') |
---|
| 677 | % set(handles.view_xml,'String','view .civ') |
---|
| 678 | end |
---|
| 679 | if addtest |
---|
| 680 | SeriesData.Time=[{time} SeriesData.Time]; |
---|
| 681 | else |
---|
| 682 | SeriesData.Time={time}; |
---|
| 683 | end |
---|
| 684 | |
---|
| 685 | if ~isempty(time) |
---|
| 686 | siztime=size(time); |
---|
| 687 | nb_field=siztime(1); |
---|
| 688 | nb_field2=siztime(2); |
---|
| 689 | end |
---|
| 690 | set(handles.TimeUnit,'String',TimeUnit) |
---|
| 691 | if isempty(nb_field) |
---|
| 692 | nb_field_str='?'; |
---|
| 693 | nb_field_str2='?'; |
---|
| 694 | else |
---|
| 695 | nb_field_str=num2str(nb_field); |
---|
| 696 | nb_field_str2=num2str(nb_field2); |
---|
| 697 | end |
---|
| 698 | if addtest |
---|
| 699 | nb_field_cell=[{nb_field_str} ;get(handles.nb_field,'String')]; |
---|
| 700 | nb_field2_cell=[{nb_field_str2} ;get(handles.nb_field2,'String')]; |
---|
| 701 | else |
---|
| 702 | nb_field_cell={nb_field_str}; |
---|
| 703 | nb_field2_cell={nb_field_str2}; |
---|
| 704 | end |
---|
| 705 | set(handles.nb_field,'String',nb_field_cell); |
---|
| 706 | set(handles.nb_field2,'String',nb_field2_cell); |
---|
| 707 | set(hseries,'UserData',SeriesData); |
---|
| 708 | |
---|
| 709 | %number of slices |
---|
| 710 | if isfield(XmlData,'GeometryCalib') && isfield(XmlData.GeometryCalib,'SliceCoord') |
---|
| 711 | siz=size(XmlData.GeometryCalib.SliceCoord); |
---|
| 712 | if siz(1)>1 |
---|
| 713 | NbSlice=siz(1); |
---|
| 714 | else |
---|
| 715 | NbSlice=1; |
---|
| 716 | end |
---|
| 717 | set(handles.NbSlice,'String',num2str(NbSlice)) |
---|
| 718 | end |
---|
| 719 | |
---|
| 720 | % set menus of index pairs |
---|
| 721 | NomType_Callback(hObject, eventdata, handles) |
---|
| 722 | |
---|
| 723 | dir_perso=prefdir; |
---|
| 724 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 725 | % save(profil_perso, 'FileBase'); %store the root name for future opening of uvmat |
---|
| 726 | if exist(profil_perso,'file') |
---|
| 727 | save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append'); %store the root name for future opening of uvmat |
---|
| 728 | else |
---|
| 729 | txt=ver; |
---|
| 730 | Release=txt(1).Release; |
---|
| 731 | relnumb=str2num(Release(3:4)); |
---|
| 732 | if relnumb >= 14 |
---|
| 733 | save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6') %store the root name for future opening of uvmat |
---|
| 734 | else |
---|
| 735 | save(profil_perso,'RootPath','SubDir','RootFile','NomType') |
---|
| 736 | end |
---|
| 737 | end |
---|
| 738 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
| 739 | set(handles.PathCampaign,'String',SeriesData.PathCampaign) |
---|
| 740 | last_j_Callback(hObject, eventdata, handles) |
---|
| 741 | last_i_Callback(hObject, eventdata, handles) |
---|
| 742 | |
---|
| 743 | %------------------------------------------------------------ |
---|
| 744 | function RootPath_Callback(hObject, eventdata, handles) |
---|
| 745 | Val=get(handles.RootPath,'Value'); |
---|
| 746 | synchronise_view(handles,Val) |
---|
| 747 | NomType_Callback(hObject, eventdata, handles) |
---|
| 748 | %------------------------------------------------------------ |
---|
| 749 | |
---|
| 750 | function synchronise_view(handles,Val) |
---|
| 751 | set(handles.RootPath,'Value',Val) |
---|
| 752 | set(handles.SubDir,'Value',Val) |
---|
| 753 | set(handles.RootFile,'Value',Val) |
---|
| 754 | set(handles.NomType,'Value',Val) |
---|
| 755 | set(handles.FileExt,'Value',Val) |
---|
| 756 | set(handles.nb_field,'Value',Val) |
---|
| 757 | set(handles.nb_field2,'Value',Val) |
---|
| 758 | set(handles.time_first,'Value',Val) |
---|
| 759 | set(handles.time_last,'Value',Val) |
---|
| 760 | |
---|
| 761 | |
---|
| 762 | %--------------------------------------------------------- |
---|
| 763 | % Executes on carriage return on the subdir civ1 edit window |
---|
| 764 | %-------------------------------------------------------- |
---|
| 765 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 766 | |
---|
| 767 | Val=get(handles.SubDir,'Value'); |
---|
| 768 | synchronise_view(handles,Val) |
---|
| 769 | NomType_Callback(hObject, eventdata, handles) |
---|
| 770 | |
---|
| 771 | %-------------------------------------------------------------- |
---|
| 772 | %function activated when a new filebase (image series) is introduced |
---|
| 773 | %------------------------------------------------------------ |
---|
| 774 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 775 | Val=get(handles.RootFile,'Value'); |
---|
| 776 | synchronise_view(handles,Val) |
---|
| 777 | NomType_Callback(hObject, eventdata, handles) |
---|
| 778 | |
---|
| 779 | %-------------------------------------------------------------- |
---|
| 780 | %function activated when a new filebase (image series) is introduced |
---|
| 781 | %------------------------------------------------------------ |
---|
| 782 | function FileExt_Callback(hObject, eventdata, handles) |
---|
| 783 | Val=get(handles.FileExt,'Value'); |
---|
| 784 | synchronise_view(handles,Val) |
---|
| 785 | |
---|
| 786 | %-------------------------------------------------------------- |
---|
| 787 | %function activated when a new filebase (image series) is introduced |
---|
| 788 | %------------------------------------------------------------ |
---|
| 789 | function nb_field_Callback(hObject, eventdata, handles) |
---|
| 790 | Val=get(handles.nb_field,'Value'); |
---|
| 791 | synchronise_view(handles,Val) |
---|
| 792 | |
---|
| 793 | %-------------------------------------------------------------- |
---|
| 794 | %function activated when a new filebase (image series) is introduced |
---|
| 795 | %------------------------------------------------------------ |
---|
| 796 | function nb_field2_Callback(hObject, eventdata, handles) |
---|
| 797 | Val=get(handles.nb_field2,'Value'); |
---|
| 798 | synchronise_view(handles,Val) |
---|
| 799 | |
---|
| 800 | %-------------------------------------------------------------- |
---|
| 801 | %function activated when a new filebase (image series) is introduced |
---|
| 802 | %------------------------------------------------------------ |
---|
| 803 | function time_first_Callback(hObject, eventdata, handles) |
---|
| 804 | Val=get(handles.time_first,'Value'); |
---|
| 805 | synchronise_view(handles,Val) |
---|
| 806 | |
---|
| 807 | %-------------------------------------------------------------- |
---|
| 808 | %function activated when a new filebase (image series) is introduced |
---|
| 809 | %------------------------------------------------------------ |
---|
| 810 | function time_last_Callback(hObject, eventdata, handles) |
---|
| 811 | Val=get(handles.time_last,'Value'); |
---|
| 812 | synchronise_view(handles,Val) |
---|
| 813 | |
---|
| 814 | %-------------------------------------------------------------- |
---|
| 815 | %function activated by NomType |
---|
| 816 | %------------------------------------------------------------ |
---|
| 817 | NomType_Callback(hObject, eventdata, handles) |
---|
| 818 | |
---|
| 819 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 820 | hseries=get(handles.ProjObject,'Parent'); |
---|
| 821 | SeriesData=get(hseries,'UserData'); |
---|
| 822 | if isfield(SeriesData,'NomType') |
---|
| 823 | NomTypeCell=SeriesData.NomType; |
---|
| 824 | else |
---|
| 825 | NomTypeCell={}; |
---|
| 826 | end |
---|
| 827 | nbfield2_cell=get(handles.nb_field2,'String'); |
---|
| 828 | val=get(handles.nb_field2,'Value'); |
---|
| 829 | if iscell(nbfield2_cell) |
---|
| 830 | nbfield2=str2num(nbfield2_cell{val}); |
---|
| 831 | else |
---|
| 832 | nbfield2=str2num(nbfield2_cell); |
---|
| 833 | end |
---|
| 834 | nbfield_cell=get(handles.nb_field,'String'); |
---|
| 835 | if iscell(nbfield_cell) |
---|
| 836 | nbfield=str2num(nbfield_cell{val}); |
---|
| 837 | else |
---|
| 838 | nbfield=str2num(nbfield_cell); |
---|
| 839 | end |
---|
| 840 | |
---|
| 841 | set(handles.mode,'Visible','off') % do not show index pairs by default |
---|
| 842 | set(handles.list_pair_civ,'Visible','off') |
---|
| 843 | set(handles.ref_i,'Visible','off') |
---|
| 844 | set(handles.ref_i_text,'Visible','off') |
---|
| 845 | testpair=0; |
---|
| 846 | state_j='off'; |
---|
| 847 | %set the menus of image pairs and default selection for series |
---|
| 848 | %list pairs if relevant |
---|
| 849 | Val=get(handles.NomType,'Value'); |
---|
| 850 | synchronise_view(handles,Val) |
---|
| 851 | if ~isempty(NomTypeCell) |
---|
| 852 | NomType=NomTypeCell{Val}; |
---|
| 853 | switch NomType |
---|
| 854 | case {'_i1-i2_j', '_i1-i2'} |
---|
| 855 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 856 | set(handles.mode,'Value',1); |
---|
| 857 | set(handles.mode,'Visible','on') |
---|
| 858 | testpair=1; |
---|
| 859 | case {'#_ab'} |
---|
| 860 | set(handles.mode,'String',{'bursts'}) |
---|
| 861 | set(handles.mode,'Value',1); |
---|
| 862 | testpair=1; |
---|
| 863 | case '_i_j1-j2' |
---|
| 864 | set(handles.mode,'String',{'bursts';'series(Dj)'})%multiple choice |
---|
| 865 | if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1)) |
---|
| 866 | set(handles.mode,'Value',2); |
---|
| 867 | else |
---|
| 868 | set(handles.mode,'Value',1);% advice 'bursts' for small bursts |
---|
| 869 | end |
---|
| 870 | set(handles.mode,'Visible','on') |
---|
| 871 | testpair=1; |
---|
| 872 | end |
---|
| 873 | switch NomType |
---|
| 874 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices |
---|
| 875 | state_j='on'; |
---|
| 876 | end |
---|
| 877 | end |
---|
| 878 | if testpair |
---|
| 879 | mode_Callback(hObject, eventdata, handles) |
---|
| 880 | else |
---|
| 881 | set(handles.NomType,'String',NomTypeCell) |
---|
| 882 | end |
---|
| 883 | set(handles.first_j,'Visible',state_j) |
---|
| 884 | set(handles.incr_j,'Visible',state_j) |
---|
| 885 | set(handles.last_j,'Visible',state_j) |
---|
| 886 | set(handles.nb_field2,'Visible',state_j) |
---|
| 887 | |
---|
| 888 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%???????????? |
---|
| 889 | % --- Executes on button press in mode. |
---|
| 890 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 891 | function mode_Callback(hObject, eventdata, handles) |
---|
| 892 | hseries=get(handles.mode,'parent'); |
---|
| 893 | SeriesData=get(hseries,'UserData'); |
---|
| 894 | mode_list=get(handles.mode,'String'); |
---|
| 895 | mode_value=get(handles.mode,'Value'); |
---|
| 896 | mode=mode_list{mode_value}; |
---|
| 897 | NomType=[]; |
---|
| 898 | test_find_pair=0; |
---|
| 899 | if isfield(SeriesData,'NomType') |
---|
| 900 | NomTypeCell=SeriesData.NomType; |
---|
| 901 | Val=get(handles.NomType,'Value'); |
---|
| 902 | NomType=NomTypeCell{Val}; |
---|
| 903 | test_find_pair=isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')|| isequal(NomType,'#_ab'); |
---|
| 904 | end |
---|
| 905 | % displ_num=[];%default |
---|
| 906 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 907 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 908 | time=[]; |
---|
| 909 | if isfield(SeriesData,'Time') |
---|
| 910 | time=SeriesData.Time{1}; %get the set of times |
---|
| 911 | end |
---|
| 912 | siztime=size(time); |
---|
| 913 | nbfield=siztime(1); |
---|
| 914 | nbfield2=siztime(2); |
---|
| 915 | indchosen=1; %%first pair selected by default |
---|
| 916 | if isequal(mode,'bursts') |
---|
| 917 | enable_i(handles,'On') |
---|
| 918 | enable_j(handles,'Off') |
---|
| 919 | elseif isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j') |
---|
| 920 | enable_i(handles,'On') |
---|
| 921 | enable_j(handles,'On') |
---|
| 922 | else |
---|
| 923 | enable_i(handles,'On') |
---|
| 924 | enable_j(handles,'Off') |
---|
| 925 | end |
---|
| 926 | |
---|
| 927 | |
---|
| 928 | % elseif isequal(mode,'series(Dj)') |
---|
| 929 | % enable_j(handles,'On') |
---|
| 930 | % if nbfield==1 |
---|
| 931 | % enable_i(handles,'Off') |
---|
| 932 | % else |
---|
| 933 | % enable_i(handles,'On') |
---|
| 934 | % end |
---|
| 935 | % elseif isequal(mode,'series(Di)') |
---|
| 936 | % if nbfield2 > 1 |
---|
| 937 | % enable_j(handles,'On') |
---|
| 938 | % else |
---|
| 939 | % enable_j(handles,'Off') |
---|
| 940 | % end |
---|
| 941 | % end |
---|
| 942 | set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1 |
---|
| 943 | % SetSeries.displ_num=displ_num; |
---|
| 944 | set(hseries,'UserData',SeriesData) |
---|
| 945 | |
---|
| 946 | %list pairs if relevant |
---|
| 947 | if test_find_pair |
---|
| 948 | find_netcpair_civ(hObject, eventdata, handles,Val) |
---|
| 949 | end |
---|
| 950 | |
---|
| 951 | %------------------------------------- |
---|
| 952 | function enable_i(handles,state) |
---|
| 953 | set(handles.i_txt,'Visible',state) |
---|
| 954 | set(handles.first_i,'Visible',state) |
---|
| 955 | set(handles.last_i,'Visible',state) |
---|
| 956 | set(handles.incr_i,'Visible',state) |
---|
| 957 | set(handles.nb_field,'Visible',state) |
---|
| 958 | set(handles.ref_i,'Visible',state) |
---|
| 959 | set(handles.ref_i_text,'Visible',state) |
---|
| 960 | |
---|
| 961 | %----------------------------------- |
---|
| 962 | function enable_j(handles,state) |
---|
| 963 | set(handles.j_txt,'Visible',state) |
---|
| 964 | set(handles.first_j,'Visible',state) |
---|
| 965 | set(handles.last_j,'Visible',state) |
---|
| 966 | set(handles.incr_j,'Visible',state) |
---|
| 967 | set(handles.nb_field2,'Visible',state) |
---|
| 968 | set(handles.ref_j,'Visible',state) |
---|
| 969 | set(handles.ref_j_text,'Visible',state) |
---|
| 970 | |
---|
| 971 | %----------------------------------- |
---|
| 972 | function view_FieldMenu(handles,state) |
---|
| 973 | set(handles.FieldMenu,'Visible',state) |
---|
| 974 | set(handles.Field_text,'Visible',state) |
---|
| 975 | set(handles.Field_frame,'Visible',state) |
---|
| 976 | |
---|
| 977 | %----------------------------------- |
---|
| 978 | function view_FieldMenu_1(handles,state) |
---|
| 979 | set(handles.FieldMenu_1,'Visible',state) |
---|
| 980 | set(handles.Field_text_1,'Visible',state) |
---|
| 981 | |
---|
| 982 | %----------------------------------- |
---|
| 983 | function view_TRANSFORM(handles,state) |
---|
| 984 | set(handles.TRANSFORM_frame,'Visible',state) |
---|
| 985 | set(handles.CoordType,'Visible',state); |
---|
| 986 | set(handles.TRANSFORM_title,'Visible',state) |
---|
| 987 | |
---|
| 988 | %-------------------------------------------------------------- |
---|
| 989 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 990 | % the field series set by first_i, incr, last_i |
---|
| 991 | %---------------------------------------------------------------- |
---|
| 992 | function find_netcpair_civ(hObject, eventdata, handles,Val) |
---|
| 993 | hseries=get(handles.list_pair_civ,'parent'); |
---|
| 994 | SeriesData=get(hseries,'UserData'); |
---|
| 995 | % NomTypeCell=get(handles.NomType,'String'); |
---|
| 996 | NomTypeCell=SeriesData.NomType; |
---|
| 997 | NomType=NomTypeCell{Val}; |
---|
| 998 | set(handles.list_pair_civ,'Visible','on') |
---|
| 999 | %nomenclature types |
---|
| 1000 | RootPathCell=get(handles.RootPath,'String'); |
---|
| 1001 | filepath=RootPathCell{Val}; |
---|
| 1002 | RootFileCell=get(handles.RootFile,'String'); |
---|
| 1003 | filename=RootFileCell{Val}; |
---|
| 1004 | filebase=fullfile(filepath,filename); |
---|
| 1005 | SubDirCell=get(handles.SubDir,'String'); |
---|
| 1006 | subdir=SubDirCell{Val}; |
---|
| 1007 | if ~exist(fullfile(filepath,subdir),'dir') |
---|
| 1008 | msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist']) |
---|
| 1009 | set(handles.list_pair_civ,'String',{''}); |
---|
| 1010 | return |
---|
| 1011 | end |
---|
| 1012 | mode_list=get(handles.mode,'String'); |
---|
| 1013 | mode_value=get(handles.mode,'Value'); |
---|
| 1014 | mode=mode_list{mode_value}; |
---|
| 1015 | |
---|
| 1016 | %reads image numbers from the interface |
---|
| 1017 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1018 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1019 | % time=[]; |
---|
| 1020 | % ref_time=[]; |
---|
| 1021 | ref_time=0; |
---|
| 1022 | if isfield(SeriesData,'Time')&~isempty(SeriesData.Time{Val})&~isequal(SeriesData.Time{Val},0) |
---|
| 1023 | time=SeriesData.Time{Val}; %get the set of times |
---|
| 1024 | siztime=size(time); |
---|
| 1025 | nbfield=siztime(1); |
---|
| 1026 | nbfield2=siztime(2); |
---|
| 1027 | % test_imadoc=1; |
---|
| 1028 | else |
---|
| 1029 | % test_imadoc=0;%no image documentation file |
---|
| 1030 | nbfield=50; |
---|
| 1031 | nbfield2=50;%default max number of pairs |
---|
| 1032 | end |
---|
| 1033 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1034 | % be performed, while the result is needed for next steps. |
---|
| 1035 | displ_pair={''}; |
---|
| 1036 | displ_num=[]; |
---|
| 1037 | ind_exist=0; |
---|
| 1038 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1039 | if length(TimeUnit)>=1 |
---|
| 1040 | dtunit=['m' TimeUnit]; |
---|
| 1041 | else |
---|
| 1042 | dtunit='e-03'; |
---|
| 1043 | end |
---|
| 1044 | if isequal(mode,'series(Di)') |
---|
| 1045 | for index=1:min(nbfield-1,50) |
---|
| 1046 | filename=name_generator(filebase,ref_i-floor(index/2),ref_j,'.nc',NomType,1,ref_i+ceil(index/2),ref_j,subdir); |
---|
| 1047 | select=(exist(filename,'file')==2); |
---|
| 1048 | if select==1 |
---|
| 1049 | ind_exist=ind_exist+1; |
---|
| 1050 | displ_num(1,ind_exist)=0; |
---|
| 1051 | displ_num(2,ind_exist)=0; |
---|
| 1052 | displ_num(3,ind_exist)=-floor(index/2); |
---|
| 1053 | displ_num(4,ind_exist)=ceil(index/2); |
---|
| 1054 | %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'}); |
---|
| 1055 | [Cte,var_detect,ichoice]=nc2struct(filename,{}); |
---|
| 1056 | if isfield(Cte,'dt2') |
---|
| 1057 | dt=Cte.dt2; |
---|
| 1058 | elseif isfield(Cte,'dt') |
---|
| 1059 | dt=Cte.dt; |
---|
| 1060 | end |
---|
| 1061 | if isfield(Cte,'absolut_time_TO_2') |
---|
| 1062 | ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
| 1063 | elseif isfield(Cte,'absolut_time_TO') |
---|
| 1064 | ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
| 1065 | elseif isfield(Cte,'Time') |
---|
| 1066 | ref_time(ind_exist)=Cte.Time; |
---|
| 1067 | end |
---|
| 1068 | displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
| 1069 | end |
---|
| 1070 | end |
---|
| 1071 | set(handles.list_pair_civ,'String',[displ_pair';{'Di=*|*'}]); |
---|
| 1072 | elseif isequal(mode,'series(Dj)')% series on the j index |
---|
| 1073 | for index=1:min(nbfield2-1,50) |
---|
| 1074 | filename=name_generator(filebase,ref_i,ref_j-floor(index/2),'.nc',NomType,1,ref_i,ref_j+ceil(index/2),subdir); |
---|
| 1075 | select=(exist(filename,'file')==2); |
---|
| 1076 | if select==1 |
---|
| 1077 | ind_exist=ind_exist+1; |
---|
| 1078 | displ_num(1,ind_exist)=-floor(index/2); |
---|
| 1079 | displ_num(2,ind_exist)=ceil(index/2); |
---|
| 1080 | displ_num(3,ind_exist)=0; |
---|
| 1081 | displ_num(4,ind_exist)=0; |
---|
| 1082 | %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'}); |
---|
| 1083 | [Cte,var_detect,ichoice]=nc2struct(nc,{}); |
---|
| 1084 | if isfield(Cte,'dt2') |
---|
| 1085 | dt=Cte.dt2; |
---|
| 1086 | elseif isfield(Cte,'dt') |
---|
| 1087 | dt=Cte.dt; |
---|
| 1088 | end |
---|
| 1089 | if isfield(Cte,'absolut_time_TO_2') |
---|
| 1090 | ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
| 1091 | elseif isfield(Cte,'absolut_time_TO') |
---|
| 1092 | ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
| 1093 | elseif isfield(Cte,'Time') |
---|
| 1094 | ref_time(ind_exist)=Cte.Time; |
---|
| 1095 | end |
---|
| 1096 | % if cte_detect(2)==1; |
---|
| 1097 | % dt=cte_read(2); |
---|
| 1098 | % ref_time(ind_exist)=cte_read(4);%civ2 data used in priority |
---|
| 1099 | % else |
---|
| 1100 | % dt=cte_read(1); |
---|
| 1101 | % ref_time(ind_exist)=cte_read(3); |
---|
| 1102 | % end |
---|
| 1103 | displ_pair{ind_exist}=['Dj= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
| 1104 | end |
---|
| 1105 | end |
---|
| 1106 | set(handles.list_pair_civ,'String',[displ_pair';{'Dj=*|*'}]); |
---|
| 1107 | elseif isequal(mode,'bursts') %case of bursts |
---|
| 1108 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'bursts' mode |
---|
| 1109 | for numod_b=(numod_a+1):nbfield2 |
---|
| 1110 | [filename]=name_generator(filebase,ref_i,numod_a,'.nc',NomType,1,ref_i,numod_b,subdir); |
---|
| 1111 | select=(exist(filename,'file')==2); |
---|
| 1112 | if select==1 |
---|
| 1113 | ind_exist=ind_exist+1; |
---|
| 1114 | numlist_a(ind_exist)=numod_a; |
---|
| 1115 | numlist_b(ind_exist)=numod_b; |
---|
| 1116 | Attr=nc2struct(filename,[]); |
---|
| 1117 | isfield(Attr,'absolut_time_T0_2') |
---|
| 1118 | if isfield(Attr,'dt2') |
---|
| 1119 | dt(ind_exist)=Attr.dt2; |
---|
| 1120 | ref_time(ind_exist)=Attr.absolut_time_T0_2; |
---|
| 1121 | elseif isfield(Attr,'dt')& isfield(Attr,'absolut_time_T0') |
---|
| 1122 | dt(ind_exist)=Attr.dt; |
---|
| 1123 | ref_time(ind_exist)=Attr.absolut_time_T0; |
---|
| 1124 | else |
---|
| 1125 | dt(ind_exist)=NaN;%no information on dt |
---|
| 1126 | end |
---|
| 1127 | %determine nom_type_ima for pair display (used in num2stra.m) |
---|
| 1128 | switch NomType |
---|
| 1129 | case {'#ab'} |
---|
| 1130 | nom_type_ima='#a'; |
---|
| 1131 | case {'#AB'} |
---|
| 1132 | nom_type_ima='#A'; |
---|
| 1133 | otherwise |
---|
| 1134 | nom_type_ima='_i_j'; |
---|
| 1135 | end |
---|
| 1136 | displ_pair{ind_exist}=['j= ' num2stra(numod_a,nom_type_ima,2) '-' num2stra(numod_b,nom_type_ima,2) ... |
---|
| 1137 | ' :dt= ' num2str(dt(ind_exist)*1000)]; |
---|
| 1138 | end |
---|
| 1139 | end |
---|
| 1140 | set(handles.list_pair_civ,'String',[displ_pair';{'j=*-*'}]); |
---|
| 1141 | end |
---|
| 1142 | if exist('dt','var') & ~isempty(dt) |
---|
| 1143 | [dtsort,indsort]=sort(dt); |
---|
| 1144 | displ_num(1,:)=numlist_a(indsort); |
---|
| 1145 | displ_num(2,:)=numlist_b(indsort); |
---|
| 1146 | displ_num(3,:)=0; |
---|
| 1147 | displ_num(4,:)=0; |
---|
| 1148 | displ_pair=displ_pair(indsort); |
---|
| 1149 | ref_time=ref_time(indsort); |
---|
| 1150 | end |
---|
| 1151 | end |
---|
| 1152 | if ind_exist==0 |
---|
| 1153 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
| 1154 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir]) |
---|
| 1155 | else |
---|
| 1156 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir]) |
---|
| 1157 | end |
---|
| 1158 | if isequal(mode,'bursts') %case of bursts |
---|
| 1159 | set(handles.list_pair_civ,'String',{'j=*-*'}); |
---|
| 1160 | elseif isequal(mode,'series(Di)') %case of bursts |
---|
| 1161 | set(handles.list_pair_civ,'String',{'Di=*|*'}); |
---|
| 1162 | elseif isequal(mode,'series(Dj)') %case of bursts |
---|
| 1163 | set(handles.list_pair_civ,'String',{'Dj=*|*'}); |
---|
| 1164 | end |
---|
| 1165 | end |
---|
| 1166 | |
---|
| 1167 | val=get(handles.list_pair_civ,'Value'); |
---|
| 1168 | if val > length(displ_pair) |
---|
| 1169 | set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu |
---|
| 1170 | val=1; |
---|
| 1171 | end |
---|
| 1172 | iview=get(handles.NomType,'Value'); |
---|
| 1173 | SeriesData.displ_num(iview,:)=(displ_num(:,val))'; |
---|
| 1174 | SeriesData.ref_time=ref_time; |
---|
| 1175 | set(hseries,'UserData',SeriesData) |
---|
| 1176 | list_pair_civ_Callback(hObject, eventdata, handles) |
---|
| 1177 | |
---|
| 1178 | %------------------------------------------------------------- |
---|
| 1179 | % --- Executes on selection in list_pair_civ. |
---|
| 1180 | function list_pair_civ_Callback(hObject, eventdata, handles) |
---|
| 1181 | %------------------------------------------------------------ |
---|
| 1182 | |
---|
| 1183 | %update first_i and last_i according to the chosen image pairs |
---|
| 1184 | testupdate=0; |
---|
| 1185 | Val=get(handles.RootPath,'Value'); |
---|
| 1186 | IndexCell=get(handles.NomType,'String'); |
---|
| 1187 | hseries=get(handles.list_pair_civ,'parent'); |
---|
| 1188 | SeriesData=get(hseries,'UserData'); |
---|
| 1189 | NomType=SeriesData.NomType{Val}; |
---|
| 1190 | list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs |
---|
| 1191 | index_pair=get(handles.list_pair_civ,'Value'); |
---|
| 1192 | str_pair=list_pair{index_pair}; |
---|
| 1193 | ind_equ=strfind(str_pair,'=');%find '=' |
---|
| 1194 | ind_sep=strfind(str_pair,'|');%find pair separator '|' |
---|
| 1195 | ind_com=strfind(str_pair,':');%find ':' |
---|
| 1196 | test_bursts=0; |
---|
| 1197 | if isempty(ind_sep) |
---|
| 1198 | ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|' |
---|
| 1199 | test_bursts=1;% we are in the case of bursts |
---|
| 1200 | end |
---|
| 1201 | displ_num=[0 0 0 0]; %default |
---|
| 1202 | if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-') |
---|
| 1203 | num1_str=str_pair(ind_equ(1)+1:ind_sep-1); |
---|
| 1204 | num2_str=str_pair(ind_sep+1:ind_com-1); |
---|
| 1205 | num1=str2double(num1_str); |
---|
| 1206 | num2=str2double(num2_str); |
---|
| 1207 | if isequal(num1_str(1),' ') |
---|
| 1208 | num1_str(1)=[]; |
---|
| 1209 | end |
---|
| 1210 | if isequal(num2_str(end),' ') |
---|
| 1211 | num2_str(end)=[]; |
---|
| 1212 | end |
---|
| 1213 | switch NomType |
---|
| 1214 | case {'_i1-i2_j'} |
---|
| 1215 | if isequal(num1_str(1),'0') |
---|
| 1216 | IndexCell{Val}=['_(i-(i+' num2_str ')_j']; |
---|
| 1217 | else |
---|
| 1218 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j']; |
---|
| 1219 | end |
---|
| 1220 | displ_num(3)=num1; |
---|
| 1221 | displ_num(4)=num2; |
---|
| 1222 | case {'_i1-i2'} |
---|
| 1223 | if isequal(num1_str(1),'0') |
---|
| 1224 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
| 1225 | else |
---|
| 1226 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
| 1227 | end |
---|
| 1228 | displ_num(3)=num1; |
---|
| 1229 | displ_num(4)=num2; |
---|
| 1230 | case '_i_j1-j2' |
---|
| 1231 | if test_bursts |
---|
| 1232 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
| 1233 | else |
---|
| 1234 | if isequal(num1_str(1),'0') |
---|
| 1235 | IndexCell{Val}=['_i_j-(j+' num2_str ')']; |
---|
| 1236 | else |
---|
| 1237 | IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')']; |
---|
| 1238 | end |
---|
| 1239 | end |
---|
| 1240 | displ_num(1)=num1; |
---|
| 1241 | displ_num(2)=num2; |
---|
| 1242 | case {'#_ab'} %TO COMPLETE |
---|
| 1243 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
| 1244 | |
---|
| 1245 | end |
---|
| 1246 | end |
---|
| 1247 | set(handles.NomType,'String',IndexCell) |
---|
| 1248 | SeriesData.displ_num(Val,:)=displ_num; |
---|
| 1249 | set(hseries,'UserData',SeriesData) |
---|
| 1250 | % set(handles.NomType,'Value',Val) |
---|
| 1251 | |
---|
| 1252 | if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*') |
---|
| 1253 | mode_list=get(handles.mode,'String'); |
---|
| 1254 | mode_value=get(handles.mode,'Value'); |
---|
| 1255 | mode=mode_list{mode_value}; |
---|
| 1256 | if isequal(mode,'series(Di)') |
---|
| 1257 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1258 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1259 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1260 | num1=first_i:incr_i:last_i; |
---|
| 1261 | lastfieldCell=get(handles.nb_field,'String'); |
---|
| 1262 | lastfield=str2num(lastfieldCell{1}); |
---|
| 1263 | if ~isempty(lastfield) |
---|
| 1264 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1265 | num1=num1(ind); |
---|
| 1266 | end |
---|
| 1267 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1268 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1269 | testupdate=1; |
---|
| 1270 | elseif isequal(mode,'series(Dj)') |
---|
| 1271 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1272 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1273 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1274 | num_j=first_j:incr_j:last_j; |
---|
| 1275 | lastfieldCell=get(handles.nb_field2,'String'); |
---|
| 1276 | if ~isempty(lastfieldCell) |
---|
| 1277 | lastfield2=lastfieldCell{1}; |
---|
| 1278 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1279 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1280 | end |
---|
| 1281 | testupdate=1; |
---|
| 1282 | end |
---|
| 1283 | |
---|
| 1284 | %update the first and last times of the series |
---|
| 1285 | if testupdate & isfield(SeriesData,'Time') |
---|
| 1286 | if ~isempty(SeriesData.Time{1}) |
---|
| 1287 | displ_time(handles,SeriesData.Time{1}); |
---|
| 1288 | end |
---|
| 1289 | end |
---|
| 1290 | end |
---|
| 1291 | %--------------------------------------------------- |
---|
| 1292 | % --- Executes on button press in RUN. |
---|
| 1293 | %------------------------------------------------------ |
---|
| 1294 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1295 | |
---|
| 1296 | %read root name and field type |
---|
| 1297 | set(handles.RUN,'BusyAction','queue'); |
---|
| 1298 | hseries=get(handles.RUN,'parent'); |
---|
| 1299 | set(0,'CurrentFigure',hseries) |
---|
| 1300 | if isequal(get(handles.GetObject,'Value'),1) |
---|
| 1301 | Series.GetObject=1; |
---|
| 1302 | GetObject_Callback(hObject, eventdata, handles) |
---|
| 1303 | else |
---|
| 1304 | Series.GetObject=0; |
---|
| 1305 | end |
---|
| 1306 | SeriesData=get(hseries,'UserData'); |
---|
| 1307 | if isfield(SeriesData,'sethandles') |
---|
| 1308 | if iscell(SeriesData.sethandles) |
---|
| 1309 | Series.sethandles=SeriesData.sethandles{1}; |
---|
| 1310 | else |
---|
| 1311 | Series.sethandles=SeriesData.sethandles;%retrieve the handles of the set_object interface (to define projection objects) |
---|
| 1312 | end |
---|
| 1313 | end |
---|
| 1314 | |
---|
| 1315 | %reinitiate waitbar position |
---|
| 1316 | Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS |
---|
| 1317 | waitbarpos=Series.WaitbarPos; |
---|
| 1318 | waitbarpos(4)=0.005;%reinitialize waitbar to zero height |
---|
| 1319 | waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005; |
---|
| 1320 | set(handles.waitbar,'Position',waitbarpos) |
---|
| 1321 | |
---|
| 1322 | % read input file parameters and set menus |
---|
| 1323 | Series.PathProject=get(handles.PathCampaign,'String'); |
---|
| 1324 | RootPath=get(handles.RootPath,'String');% path of the root name of the first field series |
---|
| 1325 | RootFile=get(handles.RootFile,'String');% root name of the first field series |
---|
| 1326 | SubDir=get(handles.SubDir,'String');% subdirectory for netcdf files |
---|
| 1327 | FileExt=get(handles.FileExt,'String');%file extension |
---|
| 1328 | if isempty(SeriesData) |
---|
| 1329 | msgbox_uvmat('ERROR','no input file series') |
---|
| 1330 | return |
---|
| 1331 | end |
---|
| 1332 | NomType=SeriesData.NomType; |
---|
| 1333 | if length(RootPath)==1 %string character input for user fct |
---|
| 1334 | Series.RootPath=RootPath{1}; |
---|
| 1335 | Series.RootFile=RootFile{1}; |
---|
| 1336 | Series.SubDir=SubDir{1}; |
---|
| 1337 | Series.FileExt=FileExt{1}; |
---|
| 1338 | Series.NomType=NomType{1}; |
---|
| 1339 | else %cell input for user fct |
---|
| 1340 | Series.RootPath=RootPath; |
---|
| 1341 | Series.RootFile=RootFile; |
---|
| 1342 | Series.SubDir=SubDir; |
---|
| 1343 | Series.FileExt=FileExt; |
---|
| 1344 | Series.NomType=NomType; |
---|
| 1345 | end |
---|
| 1346 | if isequal(get(handles.FieldMenu,'Visible'),'on') |
---|
| 1347 | FieldMenu=get(handles.FieldMenu,'String'); |
---|
| 1348 | FieldValue=get(handles.FieldMenu,'Value'); |
---|
| 1349 | Series.Field=FieldMenu(FieldValue); |
---|
| 1350 | end |
---|
| 1351 | menu_coord_state=get(handles.CoordType,'Visible'); |
---|
| 1352 | Series.CoordType='';%default |
---|
| 1353 | if isequal(menu_coord_state,'on') |
---|
| 1354 | menu_coord=get(handles.CoordType,'String'); |
---|
| 1355 | menu_index=get(handles.CoordType,'Value'); |
---|
| 1356 | Series.CoordType=menu_coord{menu_index}; |
---|
| 1357 | end |
---|
| 1358 | Series.hseries=get(hObject,'Parent'); |
---|
| 1359 | if isequal(get(handles.ParamVal,'Visible'),'on') |
---|
| 1360 | ParamKey=get(handles.ParamKey,'String'); |
---|
| 1361 | if ischar(ParamKey) |
---|
| 1362 | ParamKey{1}=ParamKey; |
---|
| 1363 | end |
---|
| 1364 | ParamString=get(handles.ParamVal,'String'); |
---|
| 1365 | if ischar(ParamString) |
---|
| 1366 | for ilist=1:size(ParamString,1) |
---|
| 1367 | ParamVal{ilist}=ParamString(ilist,:); |
---|
| 1368 | end |
---|
| 1369 | else |
---|
| 1370 | ParamVal=ParamString; |
---|
| 1371 | end |
---|
| 1372 | end |
---|
| 1373 | |
---|
| 1374 | %read the set of field numbers |
---|
| 1375 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1376 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1377 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1378 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1379 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1380 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1381 | if ~isequal(get(handles.first_i,'Visible'),'on') |
---|
| 1382 | first_i=1; |
---|
| 1383 | last_i=1; |
---|
| 1384 | incr_i=1; |
---|
| 1385 | end |
---|
| 1386 | if ~isequal(get(handles.first_j,'Visible'),'on') |
---|
| 1387 | first_j=1; |
---|
| 1388 | last_j=1; |
---|
| 1389 | incr_j=1; |
---|
| 1390 | end |
---|
| 1391 | Series.NbSlice=str2num(get(handles.NbSlice,'String')); |
---|
| 1392 | if isequal(first_i,[])|isequal(first_j,[]), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1393 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1394 | if isequal(last_i,[])| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
| 1395 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1396 | if isequal(incr_i,[])| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
| 1397 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1398 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
| 1399 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1400 | num_i=[first_i:incr_i:last_i]; |
---|
| 1401 | num_j=[first_j:incr_j:last_j]; |
---|
| 1402 | nbfield_cell=get(handles.nb_field,'String'); |
---|
| 1403 | nbfield=[]; %default |
---|
| 1404 | for iview=1:length(nbfield_cell) |
---|
| 1405 | nb=str2num(nbfield_cell{iview}); |
---|
| 1406 | if ~isempty(nb) |
---|
| 1407 | nbfield=[nbfield nb]; |
---|
| 1408 | end |
---|
| 1409 | end |
---|
| 1410 | nbfield=min(nbfield); |
---|
| 1411 | nbfield2_cell=get(handles.nb_field2,'String'); |
---|
| 1412 | nbfield2=[]; %default |
---|
| 1413 | for iview=1:length(nbfield2_cell) |
---|
| 1414 | nb=str2num(nbfield2_cell{iview}); |
---|
| 1415 | if ~isempty(nb) |
---|
| 1416 | nbfield2=[nbfield2 nb]; |
---|
| 1417 | end |
---|
| 1418 | end |
---|
| 1419 | nbfield2=min(nbfield2); |
---|
| 1420 | |
---|
| 1421 | %get complementary information from the 'series' interface |
---|
| 1422 | list_action=get(handles.ACTION,'String');% list menu action |
---|
| 1423 | index_action=get(handles.ACTION,'Value');% selected string index |
---|
| 1424 | action= list_action{index_action}; % selected string |
---|
| 1425 | mode_list=get(handles.mode,'String'); |
---|
| 1426 | index_mode=get(handles.mode,'Value'); |
---|
| 1427 | mode=mode_list{index_mode}; |
---|
| 1428 | ind_shift=0;%default |
---|
| 1429 | |
---|
| 1430 | %determine the list of input file names |
---|
| 1431 | nbmissing=0; |
---|
| 1432 | for iview=1:length(RootPath) |
---|
| 1433 | %case of pairs (.nc files) |
---|
| 1434 | |
---|
| 1435 | if isequal(NomType{iview},'_i_j1-j2')| isequal(NomType{iview},'_i1-i2_j')| isequal(NomType{iview},'_i1-i2')| isequal(NomType{iview},'#_ab') |
---|
| 1436 | ind_shift=SeriesData.displ_num(iview,:); |
---|
| 1437 | if isequal(ind_shift,[0 0 0 0]) % undefined pairs |
---|
| 1438 | if isequal(NomType{iview},'#_ab') |
---|
| 1439 | mode='#_ab'; |
---|
| 1440 | end |
---|
| 1441 | [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); |
---|
| 1442 | else |
---|
| 1443 | [num_i1,num_i2,num_j1,num_j2,num_i,num_j]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode); |
---|
| 1444 | if isempty(num_i) |
---|
| 1445 | msgbox_uvmat('ERROR','ERROR: empty set of input files chosen') |
---|
| 1446 | return |
---|
| 1447 | end |
---|
| 1448 | if num_i(1)>first_i |
---|
| 1449 | set(handles.first_i,'String',num2str(num_i(1)))%update the display of first field |
---|
| 1450 | last_i_Callback(hObject, eventdata, handles) |
---|
| 1451 | end |
---|
| 1452 | if num_i(end)<last_i |
---|
| 1453 | set(handles.last_i,'String',num2str(num_i(end)))%update the display of last field |
---|
| 1454 | last_i_Callback(hObject, eventdata, handles) |
---|
| 1455 | end |
---|
| 1456 | if num_j(1)>first_j |
---|
| 1457 | set(handles.first_j,'String',num2str(num_j(1)))%update the display of first field |
---|
| 1458 | last_j_Callback(hObject, eventdata, handles) |
---|
| 1459 | end |
---|
| 1460 | if num_j(end)<last_j |
---|
| 1461 | set(handles.last_j,'String',num2str(num_j(end)))%update the display of last field |
---|
| 1462 | last_j_Callback(hObject, eventdata, handles) |
---|
| 1463 | end |
---|
| 1464 | end |
---|
| 1465 | else%case of images |
---|
| 1466 | [num_i1,num_j1]=meshgrid(num_i,num_j); |
---|
| 1467 | num_i2=num_i1; |
---|
| 1468 | num_j2=num_j1; |
---|
| 1469 | end |
---|
| 1470 | if length(RootPath)>1 |
---|
| 1471 | num_i1_cell{iview}=num_i1; |
---|
| 1472 | num_i2_cell{iview}=num_i2; |
---|
| 1473 | num_j1_cell{iview}=num_j1; |
---|
| 1474 | num_j2_cell{iview}=num_j2; |
---|
| 1475 | end |
---|
| 1476 | end |
---|
| 1477 | |
---|
| 1478 | % RUN RUN' |
---|
| 1479 | path_series=which('series'); |
---|
| 1480 | list_path=get(handles.ACTION,'UserData'); |
---|
| 1481 | index=get(handles.ACTION,'Value'); |
---|
| 1482 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
| 1483 | if ~isequal(fct_path,path_series) |
---|
| 1484 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
| 1485 | if ~isequal(spath,fct_path)& exist(fct_path,'dir') |
---|
| 1486 | addpath(fct_path)% add the prescribed path if not the current one |
---|
| 1487 | end |
---|
| 1488 | end |
---|
[26] | 1489 | % fct_path |
---|
| 1490 | eval(['h_fun=@' action]) |
---|
| 1491 | if ~isequal(fct_path,path_series) |
---|
| 1492 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
| 1493 | end |
---|
| 1494 | |
---|
[2] | 1495 | Series.Action=action;%name of the processing programme |
---|
| 1496 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1497 | drawnow |
---|
| 1498 | if length(RootPath)>1 |
---|
[26] | 1499 | % feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series); |
---|
| 1500 | h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series); |
---|
[2] | 1501 | else |
---|
[26] | 1502 | h_fun(num_i1,num_i2,num_j1,num_j2,Series); |
---|
| 1503 | % feval(action,num_i1,num_i2,num_j1,num_j2,Series); |
---|
[2] | 1504 | end |
---|
| 1505 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1506 | |
---|
| 1507 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 1508 | % detect=1; |
---|
| 1509 | % while detect==1 |
---|
| 1510 | % namefigfull=[namedoc '.fig']; |
---|
| 1511 | % hh=dir(namefigfull); |
---|
| 1512 | % if ~isempty(hh) |
---|
| 1513 | % detect=1; |
---|
| 1514 | % namedoc=[namedoc '.0']; |
---|
| 1515 | % else |
---|
| 1516 | % detect=0; |
---|
| 1517 | % end |
---|
| 1518 | % end |
---|
| 1519 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 1520 | |
---|
| 1521 | %---------------------------------------------------- |
---|
| 1522 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1523 | set(handles.RUN, 'BusyAction','cancel') |
---|
| 1524 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1525 | |
---|
| 1526 | %---------------------------------------------- |
---|
| 1527 | |
---|
| 1528 | %---------------------------------------------------- |
---|
| 1529 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 1530 | last_i_Callback(hObject, eventdata, handles) |
---|
| 1531 | |
---|
| 1532 | %---------------------------------------------- |
---|
| 1533 | function last_i_Callback(hObject, eventdata, handles) |
---|
| 1534 | hseries=get(handles.last_i,'parent'); |
---|
| 1535 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1536 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1537 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1538 | set(handles.ref_i,'String', num2str(ref_i)) |
---|
| 1539 | ref_i_Callback(hObject, eventdata, handles) |
---|
| 1540 | SeriesData=get(hseries,'UserData'); |
---|
| 1541 | if ~isfield(SeriesData,'Time') |
---|
| 1542 | SeriesData.Time{1}=[]; |
---|
| 1543 | end |
---|
| 1544 | displ_time(handles,SeriesData.Time{1}); |
---|
| 1545 | |
---|
| 1546 | %------------------------------------------------------- |
---|
| 1547 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 1548 | last_j_Callback(hObject, eventdata, handles) |
---|
| 1549 | |
---|
| 1550 | %------------------------------------------------------- |
---|
| 1551 | function last_j_Callback(hObject, eventdata, handles) |
---|
| 1552 | hseries=get(handles.last_i,'parent'); |
---|
| 1553 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1554 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1555 | ref_j=ceil((first_j+last_j)/2); |
---|
| 1556 | set(handles.ref_j,'String', num2str(ref_j)) |
---|
| 1557 | |
---|
| 1558 | ref_j_Callback(hObject, eventdata, handles) |
---|
| 1559 | SeriesData=get(hseries,'UserData'); |
---|
| 1560 | if ~isfield(SeriesData,'Time') |
---|
| 1561 | SeriesData.Time{1}=[]; |
---|
| 1562 | end |
---|
| 1563 | displ_time(handles,SeriesData.Time{1}); |
---|
| 1564 | |
---|
| 1565 | |
---|
| 1566 | |
---|
| 1567 | |
---|
| 1568 | %------------------------------------------------------- |
---|
| 1569 | function ref_i_Callback(hObject, eventdata, handles) |
---|
| 1570 | mode_list=get(handles.mode,'String'); |
---|
| 1571 | mode_value=get(handles.mode,'Value'); |
---|
| 1572 | mode=mode_list{mode_value}; |
---|
| 1573 | hseries=get(handles.ref_i,'parent'); |
---|
| 1574 | SeriesData=get(hseries,'UserData'); |
---|
| 1575 | %NomTypeCell=get(handles.NomType,'String'); |
---|
| 1576 | NomTypeCell=SeriesData.NomType; |
---|
| 1577 | if ~isempty(NomTypeCell) |
---|
| 1578 | Val=get(handles.NomType,'Value'); |
---|
| 1579 | NomType=NomTypeCell{Val}; |
---|
| 1580 | % for ilist=1:length(NomType) |
---|
| 1581 | if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2') |
---|
| 1582 | if isequal(mode,'series(Di)') |
---|
| 1583 | find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
| 1584 | % break |
---|
| 1585 | end |
---|
| 1586 | end |
---|
| 1587 | end |
---|
| 1588 | |
---|
| 1589 | %---------------------------------------------------- |
---|
| 1590 | function ref_j_Callback(hObject, eventdata, handles) |
---|
| 1591 | mode_list=get(handles.mode,'String'); |
---|
| 1592 | mode_value=get(handles.mode,'Value'); |
---|
| 1593 | mode=mode_list{mode_value}; |
---|
| 1594 | hseries=get(handles.ref_i,'parent'); |
---|
| 1595 | SeriesData=get(hseries,'UserData'); |
---|
| 1596 | %NomTypeCell=get(handles.NomType,'String'); |
---|
| 1597 | NomTypeCell=SeriesData.NomType; |
---|
| 1598 | if ~isempty(NomTypeCell) |
---|
| 1599 | Val=get(handles.NomType,'Value'); |
---|
| 1600 | NomType=NomTypeCell{Val}; |
---|
| 1601 | % NomType=get(handles.NomType,'String'); |
---|
| 1602 | if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2') |
---|
| 1603 | if isequal(mode,'series(Dj)') |
---|
| 1604 | find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
| 1605 | % break |
---|
| 1606 | end |
---|
| 1607 | end |
---|
| 1608 | end |
---|
| 1609 | |
---|
| 1610 | %---------------------------------------------------- |
---|
| 1611 | % --- Executes on selection change in ACTION. |
---|
| 1612 | function ACTION_Callback(hObject, eventdata, handles) |
---|
| 1613 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
| 1614 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
| 1615 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
| 1616 | path_series=which('series');%path to series.m |
---|
| 1617 | list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION |
---|
| 1618 | nb_builtin=0; |
---|
| 1619 | for ilist=1:length(list_path) |
---|
| 1620 | if isequal(list_path{ilist},path_series) |
---|
| 1621 | nb_builtin=nb_builtin+1; |
---|
| 1622 | else |
---|
| 1623 | break |
---|
| 1624 | end |
---|
| 1625 | end |
---|
| 1626 | if nb_builtin==0% the path of series has been changed, reinitialize |
---|
[26] | 1627 | % series_OpeningFcn(hObject, eventdata, handles) |
---|
[2] | 1628 | return |
---|
| 1629 | end |
---|
| 1630 | |
---|
| 1631 | % add a new function to the menu |
---|
| 1632 | if isequal(ACTION,'more...') |
---|
| 1633 | pathfct=fileparts(path_series); |
---|
[26] | 1634 | browse_name=fullfile(path_series,'series');%go to UVMAT/SERIES_FCT by default |
---|
[2] | 1635 | if length(list_path)>nb_builtin |
---|
| 1636 | browse_name=list_path{end};% initialize browser with the path of the last introduced function |
---|
| 1637 | end |
---|
| 1638 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1639 | {'*.m', ' (*.m)'; |
---|
| 1640 | '*.m', '.m files '; ... |
---|
| 1641 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1642 | 'Pick a file',browse_name); |
---|
| 1643 | if length(FileName)<2 |
---|
| 1644 | return |
---|
| 1645 | end |
---|
[26] | 1646 | |
---|
| 1647 | |
---|
| 1648 | |
---|
| 1649 | ext_fct=FileName(end-1:end);% to be replaced by fileparts |
---|
[2] | 1650 | if ~isequal(ext_fct,'.m') |
---|
| 1651 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1652 | return |
---|
| 1653 | end |
---|
| 1654 | ACTION=FileName(1:end-2);% ACTION choice updated by the selected item |
---|
| 1655 | |
---|
[26] | 1656 | addpath(PathName) |
---|
| 1657 | eval(['h_function=@' ACTION]); |
---|
| 1658 | if ~isequal(path_series,PathName) |
---|
| 1659 | rmpath(PathName) |
---|
| 1660 | end |
---|
| 1661 | functions(h_function) |
---|
| 1662 | |
---|
[2] | 1663 | % insert the choice in the action menu |
---|
| 1664 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
| 1665 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
| 1666 | list_path{index_ACTION}=PathName; |
---|
| 1667 | if length(menu_str)>nb_builtin+5; |
---|
| 1668 | nbremove=length(menu_str)-nb_builtin-5; |
---|
| 1669 | menu_str(nb_builtin+1:end-5)=[]; |
---|
| 1670 | list_path(nb_builtin+1:end-4)=[]; |
---|
| 1671 | index_ACTION=index_ACTION-nbremove; |
---|
| 1672 | set(handles.ACTION,'Value',index_ACTION) |
---|
| 1673 | set(handles.ACTION,'String',menu_str) |
---|
| 1674 | end |
---|
| 1675 | list_path{index_ACTION}=PathName; |
---|
| 1676 | set(handles.ACTION,'UserData',list_path); |
---|
| 1677 | set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
| 1678 | |
---|
| 1679 | %record the current menu in personal file profil_perso |
---|
| 1680 | dir_perso=prefdir; |
---|
| 1681 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1682 | for ilist=nb_builtin+1:length(menu_str)-1 |
---|
| 1683 | series_fct{ilist-nb_builtin}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
| 1684 | end |
---|
| 1685 | if exist(profil_perso,'file') |
---|
| 1686 | save(profil_perso,'series_fct','-append') |
---|
| 1687 | else |
---|
| 1688 | txt=ver; |
---|
| 1689 | Release=txt(1).Release; |
---|
| 1690 | relnumb=str2num(Release(3:4)); |
---|
| 1691 | if relnumb >= 14 |
---|
| 1692 | save(profil_perso,'series_fct','-V6') |
---|
| 1693 | else |
---|
| 1694 | save(profil_perso, 'series_fct') |
---|
| 1695 | end |
---|
| 1696 | end |
---|
| 1697 | end |
---|
| 1698 | |
---|
| 1699 | %check the current path to the selected function |
---|
| 1700 | PathName=list_path{index_ACTION};%current recorded path |
---|
| 1701 | if ~isequal(path_series,PathName) |
---|
| 1702 | CurrentPath=fileparts(which(ACTION)); |
---|
[17] | 1703 | if ~isequal(CurrentPath,PathName)&&~isequal(CurrentPath,fullfile(PathName,'private')) |
---|
[2] | 1704 | addpath(PathName) |
---|
| 1705 | errormsg=check_functions; |
---|
| 1706 | msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg]) |
---|
| 1707 | end |
---|
| 1708 | end |
---|
| 1709 | set(handles.path,'String',PathName); %show the path to the senlected function |
---|
| 1710 | |
---|
| 1711 | %default setting for the visibility of the GUI elements |
---|
| 1712 | %set( handles.Field,'Visible','off')%default |
---|
| 1713 | set(handles.RootPath,'UserData','many') |
---|
| 1714 | set(handles.SubDir,'Visible','on') |
---|
| 1715 | set(handles.RootFile,'Visible','on') |
---|
| 1716 | set(handles.NomType,'Visible','on') |
---|
| 1717 | set(handles.FileExt,'Visible','on') |
---|
| 1718 | set(handles.NbSlice,'Visible','off') |
---|
| 1719 | set(handles.NbSlice_title,'Visible','off') |
---|
| 1720 | set(handles.VelTypeMenu,'Visible','off'); |
---|
| 1721 | set(handles.VelType_text,'Visible','off'); |
---|
| 1722 | set(handles.VelTypeMenu_1,'Visible','off'); |
---|
| 1723 | set(handles.VelType_text_1,'Visible','off'); |
---|
| 1724 | view_FieldMenu(handles,'off') |
---|
| 1725 | view_FieldMenu_1(handles,'off') |
---|
| 1726 | view_TRANSFORM(handles,'off') |
---|
| 1727 | set(handles.ProjObject_frame,'Visible','off'); |
---|
| 1728 | set(handles.GetMask,'Visible','off') |
---|
| 1729 | set(handles.Mask,'Visible','off') |
---|
| 1730 | set(handles.GetObject,'Visible','off'); |
---|
| 1731 | set(handles.ProjObject,'Visible','off'); |
---|
| 1732 | set(handles.OutputDir,'Visible','off'); |
---|
| 1733 | set(handles.PARAMETERS_frame,'Visible','off'); |
---|
| 1734 | set(handles.PARAMETERS_title,'Visible','off'); |
---|
| 1735 | set(handles.ParamKey,'Visible','off') |
---|
| 1736 | set(handles.ParamVal,'Visible','off') |
---|
| 1737 | ParamKey={}; |
---|
| 1738 | set(handles.FieldMenu,'Enable','off') |
---|
| 1739 | set(handles.VelTypeMenu,'Enable','off') |
---|
| 1740 | set(handles.FieldMenu_1,'Enable','off') |
---|
| 1741 | set(handles.VelTypeMenu_1,'Enable','off') |
---|
| 1742 | set(handles.CoordType,'Enable','off') |
---|
| 1743 | %set the displayed GUI item needed for input parameters |
---|
| 1744 | %list_input=feval(ACTION);% input list asked by the selected function |
---|
| 1745 | varargout=feval(ACTION);% input list asked by the selected function |
---|
| 1746 | Param_list={}; |
---|
| 1747 | % RootPath=get(handles.RootPath,'String'); |
---|
| 1748 | % RootFile=get(handles.RootFile,'String'); |
---|
| 1749 | |
---|
| 1750 | %nb_series=length(RootFile); |
---|
| 1751 | FileExt=get(handles.FileExt,'String'); |
---|
| 1752 | nb_series=length(FileExt); |
---|
| 1753 | testima_series=1; %test for a list of images only |
---|
| 1754 | testima=1; |
---|
| 1755 | testima_1=1; |
---|
| 1756 | testciv_series=1; |
---|
| 1757 | for iview=1:nb_series |
---|
| 1758 | ext=FileExt{iview}; |
---|
| 1759 | if length(ext)<2 |
---|
| 1760 | ext='.none'; |
---|
| 1761 | end |
---|
| 1762 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
| 1763 | if ~testimaview |
---|
| 1764 | if iview==1 |
---|
| 1765 | testima=0; |
---|
| 1766 | end |
---|
| 1767 | if iview==2 |
---|
| 1768 | testima_1=0; |
---|
| 1769 | end |
---|
| 1770 | testima_series=0; |
---|
| 1771 | end |
---|
| 1772 | end |
---|
| 1773 | for ilist=1:length(varargout)-1 |
---|
| 1774 | switch varargout{ilist} |
---|
| 1775 | %RootFile always visible |
---|
| 1776 | case 'RootPath' %visible by default |
---|
| 1777 | value=lower(varargout{ilist+1}); |
---|
| 1778 | if isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
| 1779 | set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
| 1780 | end |
---|
| 1781 | case 'SubDir' %visible by default |
---|
| 1782 | if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1783 | set(handles.SubDir,'Visible','off') |
---|
| 1784 | end |
---|
| 1785 | case 'RootFile' %visible by default |
---|
| 1786 | value=lower(varargout{ilist+1}); |
---|
| 1787 | if isequal(value,'off') |
---|
| 1788 | set(handles.RootFile,'Visible','off') |
---|
| 1789 | elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
| 1790 | set(handles.RootFile,'Visible','on') |
---|
| 1791 | set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
| 1792 | end |
---|
| 1793 | case 'NomType' %visible by default |
---|
| 1794 | if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1795 | set(handles.NomType,'Visible','off') |
---|
| 1796 | end |
---|
| 1797 | case 'FileExt' %visible by default |
---|
| 1798 | if isequal(lower(varargout{ilist+1}),'off') |
---|
| 1799 | set(handles.FileExt,'Visible','off') |
---|
| 1800 | end |
---|
| 1801 | case 'NbSlice' %hidden by default |
---|
| 1802 | if isequal(lower(varargout{ilist+1}),'on') |
---|
| 1803 | set(handles.NbSlice,'Visible','on') |
---|
| 1804 | set(handles.NbSlice_title,'Visible','on') |
---|
| 1805 | end |
---|
| 1806 | case 'VelTypeMenu' %hidden by default |
---|
| 1807 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
| 1808 | set(handles.VelTypeMenu,'Enable','on') |
---|
| 1809 | if nb_series >=1 && ~testima_series |
---|
| 1810 | set(handles.VelTypeMenu,'Visible','on') |
---|
| 1811 | set(handles.VelType_text,'Visible','on'); |
---|
| 1812 | set(handles.Field_frame,'Visible','on') |
---|
| 1813 | end |
---|
| 1814 | end |
---|
| 1815 | if isequal(lower(varargout{ilist+1}),'two') |
---|
| 1816 | set(handles.VelTypeMenu_1,'Enable','on') |
---|
| 1817 | if nb_series >=2 && ~testima_series |
---|
| 1818 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
| 1819 | set(handles.VelType_text_1,'Visible','on'); |
---|
| 1820 | end |
---|
| 1821 | end |
---|
| 1822 | case 'FieldMenu' %hidden by default |
---|
| 1823 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
| 1824 | set(handles.FieldMenu,'Enable','on') % test for MenuBorser |
---|
| 1825 | if nb_series >=1 && ~testima_series |
---|
| 1826 | view_FieldMenu(handles,'on') |
---|
| 1827 | end |
---|
| 1828 | end |
---|
| 1829 | if isequal(lower(varargout{ilist+1}),'two') |
---|
| 1830 | set(handles.FieldMenu_1,'Enable','on') |
---|
| 1831 | if nb_series >=2 && ~testima_1 |
---|
| 1832 | view_FieldMenu_1(handles,'on') |
---|
| 1833 | end |
---|
| 1834 | end |
---|
| 1835 | case 'CoordType' %hidden by default |
---|
| 1836 | if isequal(lower(varargout{ilist+1}),'on') |
---|
| 1837 | set(handles.CoordType,'Enable','on') |
---|
| 1838 | view_TRANSFORM(handles,'on') |
---|
| 1839 | end |
---|
| 1840 | case 'GetObject' %hidden by default |
---|
| 1841 | if isequal(lower(varargout{ilist+1}),'on') |
---|
| 1842 | set(handles.ProjObject_frame,'Visible','on') |
---|
| 1843 | set(handles.GetObject,'Visible','on'); |
---|
| 1844 | end |
---|
| 1845 | case 'Mask' %hidden by default |
---|
| 1846 | if isequal(lower(varargout{ilist+1}),'on') |
---|
| 1847 | set(handles.ProjObject_frame,'Visible','on') |
---|
| 1848 | set(handles.GetMask,'Visible','on'); |
---|
| 1849 | end |
---|
| 1850 | case 'PARAMETER' |
---|
| 1851 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
| 1852 | set(handles.PARAMETERS_title,'Visible','on') |
---|
| 1853 | set(handles.ParamKey,'Visible','on') |
---|
| 1854 | %set(handles.ParamVal,'Visible','on') |
---|
| 1855 | Param_str=varargout{ilist+1}; |
---|
| 1856 | Param_list=[Param_list; {Param_str}]; |
---|
| 1857 | end |
---|
| 1858 | end |
---|
| 1859 | if ~isempty(Param_list) |
---|
| 1860 | set(handles.ParamKey,'String',Param_list) |
---|
| 1861 | set(handles.ParamVal,'Visible','on') |
---|
| 1862 | end |
---|
| 1863 | |
---|
| 1864 | %------------------------------------------------------------------- |
---|
| 1865 | % --- Executes on selection change in FieldMenu. |
---|
| 1866 | %------------------------------------------------------------------- |
---|
| 1867 | function FieldMenu_Callback(hObject, eventdata, handles) |
---|
| 1868 | |
---|
| 1869 | field_str=get(handles.FieldMenu,'String'); |
---|
| 1870 | field_index=get(handles.FieldMenu,'Value'); |
---|
| 1871 | field=field_str{field_index(1)}; |
---|
| 1872 | if isequal(field,'get_field...') |
---|
| 1873 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 1874 | if ~isempty(hget_field) |
---|
| 1875 | delete(hget_field)%delete opened versions of get_field |
---|
| 1876 | end |
---|
| 1877 | hseries=get(handles.FieldMenu,'parent'); |
---|
| 1878 | SeriesData=get(hseries,'UserData'); |
---|
| 1879 | filename=SeriesData.CurrentInputFile; |
---|
| 1880 | if exist(filename,'file') |
---|
| 1881 | get_field(filename) |
---|
| 1882 | end |
---|
| 1883 | elseif isequal(field,'more...') |
---|
| 1884 | str=calc_field; |
---|
| 1885 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1886 | 'SelectionMode','single',... |
---|
| 1887 | 'ListString',str); |
---|
| 1888 | % edit the choice in the fields and action menu |
---|
| 1889 | scalar=cell2mat(str(ind_answer)); |
---|
| 1890 | update_menu(handles.FieldMenu,scalar) |
---|
| 1891 | end |
---|
| 1892 | |
---|
| 1893 | %------------------------------------------------------ |
---|
| 1894 | % --- Executes on selection change in FieldMenu_1. |
---|
| 1895 | %----------------------------------------------------- |
---|
| 1896 | function FieldMenu_1_Callback(hObject, eventdata, handles) |
---|
| 1897 | field_str=get(handles.FieldMenu_1,'String'); |
---|
| 1898 | field_index=get(handles.FieldMenu_1,'Value'); |
---|
| 1899 | field=field_str{field_index}; |
---|
| 1900 | if isequal(field,'get_field...') |
---|
| 1901 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 1902 | if ~isempty(hget_field) |
---|
| 1903 | delete(hget_field) |
---|
| 1904 | end |
---|
| 1905 | hseries=get(handles.FieldMenu,'parent'); |
---|
| 1906 | SeriesData=get(hseries,'UserData'); |
---|
| 1907 | filename=SeriesData.CurrentInputFile_1; |
---|
| 1908 | if exist(filename,'file') |
---|
| 1909 | hget_field=get_field(filename); |
---|
| 1910 | set(hget_field,'name','get_field_1') |
---|
| 1911 | end |
---|
| 1912 | elseif isequal(field,'more...') |
---|
| 1913 | str=calc_field; |
---|
| 1914 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
| 1915 | 'SelectionMode','single',... |
---|
| 1916 | 'ListString',str); |
---|
| 1917 | % edit the choice in the fields and action menu |
---|
| 1918 | scalar=cell2mat(str(ind_answer)); |
---|
| 1919 | update_menu(handles.FieldMenu_1,scalar) |
---|
| 1920 | end |
---|
| 1921 | % %---------------------------------------------------------------------- |
---|
| 1922 | % % --makes a time averaged velocity field |
---|
| 1923 | % %---------------------------------------------------------------------- |
---|
| 1924 | % function aver_vel(num_i1,num_i2,num_j1,num_j2,Series) |
---|
| 1925 | % %handles of the GUI series |
---|
| 1926 | % |
---|
| 1927 | % hseries=guidata(Series.hseries);%handles of the GUI series |
---|
| 1928 | % WaitbarPos=get(hseries.waitbar_frame,'Position'); |
---|
| 1929 | % Field_list=get(hseries.FieldMenu,'String'); |
---|
| 1930 | % val=get(hseries.FieldMenu,'Value'); |
---|
| 1931 | % FieldName=Field_list{val(1)}; |
---|
| 1932 | % set(hseries.FieldMenu,'Value',val(1))% select only one input field |
---|
| 1933 | % if isequal(FieldName,'get_field...') |
---|
| 1934 | % hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI |
---|
| 1935 | % end |
---|
| 1936 | % %root input file and type |
---|
| 1937 | % RootPath=get(hseries.RootPath,'String'); |
---|
| 1938 | % SubDir=get(hseries.SubDir,'String'); |
---|
| 1939 | % RootFile=get(hseries.RootFile,'String'); |
---|
| 1940 | % %NomType=get(hseries.NomType,'String'); |
---|
| 1941 | % NomType=Series.NomType; |
---|
| 1942 | % FileExt=get(hseries.FileExt,'String'); |
---|
| 1943 | % ext=FileExt{1}; |
---|
| 1944 | % VelType_str=get(hseries.VelTypeMenu,'String'); |
---|
| 1945 | % VelType_val=get(hseries.VelTypeMenu,'Value'); |
---|
| 1946 | % VelType{1}=VelType_str{VelType_val}; |
---|
| 1947 | % |
---|
| 1948 | % time=0; %default |
---|
| 1949 | % % number of slices |
---|
| 1950 | % NbSlice=str2num(get(hseries.NbSlice,'String')); |
---|
| 1951 | % if isempty(NbSlice) |
---|
| 1952 | % NbSlice=1; |
---|
| 1953 | % end |
---|
| 1954 | % NbSlice_name=num2str(NbSlice); |
---|
| 1955 | % filebase=fullfile(RootPath{1},RootFile{1}); |
---|
| 1956 | % Calib=[]; |
---|
| 1957 | % if exist([filebase '.xml'],'file') |
---|
| 1958 | % %[error,Heading,nom_type_read,ext_ima_read,time_imadoc,TimeUnit,mode,NbSlice,npx,npy,Calib]=read_imadoc([filebase '.xml']); |
---|
| 1959 | % [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
| 1960 | % end |
---|
| 1961 | % if NbSlice==1 |
---|
| 1962 | % filebase_mean=[filebase '_mean']; %root name for the result |
---|
| 1963 | % else |
---|
| 1964 | % filebase_mean=[filebase '_' NbSlice_name 'mean']; %root name for the results |
---|
| 1965 | % answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_mean ' ...']}); |
---|
| 1966 | % if ~isequal(answeryes,'Yes') |
---|
| 1967 | % return |
---|
| 1968 | % end |
---|
| 1969 | % end |
---|
| 1970 | % siz=size(num_i1); |
---|
| 1971 | % nbfield2=siz(1); %nb of consecutive fields at each level(burst) |
---|
| 1972 | % lengthtot=siz(1)*siz(2); |
---|
| 1973 | % nbfield=floor(lengthtot/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices) |
---|
| 1974 | % nbfield_slice=nbfield*nbfield2;% number of fields per slice |
---|
| 1975 | % %projection object |
---|
| 1976 | % GridX=[]; |
---|
| 1977 | % GridY=[]; |
---|
| 1978 | % if isfield(Series,'sethandles') |
---|
| 1979 | % Series.ProjObject=read_set_object(Series.sethandles); |
---|
| 1980 | % if isfield(Series.ProjObject,'Style') |
---|
| 1981 | % answeryes=questdlg({['statistics on field series projected on ' Series.ProjObject.Style]}); |
---|
| 1982 | % if ~isequal(answeryes,'Yes') |
---|
| 1983 | % return |
---|
| 1984 | % end |
---|
| 1985 | % end |
---|
| 1986 | % end |
---|
| 1987 | % |
---|
| 1988 | % %LOOP ON SLICES |
---|
| 1989 | % for i_slice=1:NbSlice |
---|
| 1990 | % %select the series of image indices at the level islice |
---|
| 1991 | % for ifield=1:nbfield |
---|
| 1992 | % indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice |
---|
| 1993 | % end |
---|
| 1994 | % %name of result file |
---|
| 1995 | % [filemean,idetect]=... |
---|
| 1996 | % name_generator(filebase_mean,num_i1(i_slice),num_j1(1),Series.FileExt{1},'_i1-i2_j1-j2',1,num_i2(i_slice+nbfield_slice*NbSlice-1),num_j2(end),Series.SubDir{1}); |
---|
| 1997 | % |
---|
| 1998 | % % field=get(handles.civ1,'UserData');%read current selected field type (civ1,civ2...) |
---|
| 1999 | % itime=0; |
---|
| 2000 | % dt=[]; |
---|
| 2001 | % %LOOP ON FIELDS IN A SLICE |
---|
| 2002 | % test_interpolate=0;%default |
---|
| 2003 | % for index=1:nbfield*nbfield2 |
---|
| 2004 | % ifile=indselect(index); |
---|
| 2005 | % stopstate=get(hseries.RUN,'BusyAction'); |
---|
| 2006 | % if isequal(stopstate,'queue')% enable STOP command |
---|
| 2007 | % update_waitbar(hseries.waitbar,WaitbarPos,ifile/(nbfield*nbfield2)) |
---|
| 2008 | % %name of the current file |
---|
| 2009 | % [filename,idetect]=name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt{1},Series.NomType{1},1,num_i2(ifile),num_j2(ifile),Series.SubDir{1}); |
---|
| 2010 | % %read input file |
---|
| 2011 | % itime=itime+1; |
---|
| 2012 | % if isequal(FieldName,'get_field...') |
---|
| 2013 | % hhget_field=guidata(hget_field);%handles of GUI elements in get_field |
---|
| 2014 | % hObject=0; |
---|
| 2015 | % eventdata=0; |
---|
| 2016 | % SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI |
---|
| 2017 | % [Data,var_detect]=nc2struct(filename,SubField.ListVarName); %read input data |
---|
| 2018 | % time(itime)=itime; |
---|
| 2019 | % dt=1; |
---|
| 2020 | % Calib_read=[]; |
---|
| 2021 | % else |
---|
| 2022 | % [nb_coord,nb_dim,Civ,CivStage,timeread,Data,VelTypeOut,Calib_read]=read_ncfield(filename,VelType{1});%reading the first file |
---|
| 2023 | % time(itime)=timeread; |
---|
| 2024 | % if isequal(Civ,1) |
---|
| 2025 | % Data.CoordType='px';%test for pixel coordinates |
---|
| 2026 | % if isequal(itime,1) |
---|
| 2027 | % dt=Data.dt; |
---|
| 2028 | % elseif ~isequal(Data.dt,dt) |
---|
| 2029 | % warndlg_uvmat('series with non constant dt, need phys coordinates','ERROR') |
---|
| 2030 | % return |
---|
| 2031 | % end |
---|
| 2032 | % end |
---|
| 2033 | % end |
---|
| 2034 | % %increment the detected fields, skip the others |
---|
| 2035 | % if idetect==0 |
---|
| 2036 | % warndlg_uvmat(['input file ' filename ' not found'],'ERROR') |
---|
| 2037 | % %A FAIRE STOCKER LE RESULT ACTUEL S'IL EXISTE |
---|
| 2038 | % end |
---|
| 2039 | % % itime=itime+1; |
---|
| 2040 | % % time(itime)=timeread; |
---|
| 2041 | % |
---|
| 2042 | % %coordinate transform |
---|
| 2043 | % if isempty(Calib) |
---|
| 2044 | % Calib=Calib_read;%use Calib from xml file in priority, then Calib from the current file |
---|
| 2045 | % end |
---|
| 2046 | % if ~isequal(Series.CoordType,'') |
---|
| 2047 | % Data=feval(Series.CoordType,Data,Calib); |
---|
| 2048 | % end |
---|
| 2049 | % %projection on object if defined |
---|
| 2050 | % if isfield(Series,'ProjObject'); |
---|
| 2051 | % Data=proj_field(Data,Series.ProjObject); |
---|
| 2052 | % if isequal(itime,1)%use the positions on the first field for the whole series, ou utiliser grille |
---|
| 2053 | % if isfield(Data,'Txt')%display error message |
---|
| 2054 | % warndlg(Data.Txt,'ERROR') |
---|
| 2055 | % return |
---|
| 2056 | % end |
---|
| 2057 | % end |
---|
| 2058 | % else%remove false vectors and interpolate on the positions of the first field |
---|
| 2059 | % Data=document_field(Data); |
---|
| 2060 | % Data.Style='plane'; |
---|
| 2061 | % end |
---|
| 2062 | % %%%%%%%%% initiate the average at the first iteration: check list and structure of variables |
---|
| 2063 | % if ifile==i_slice%first field in the slice |
---|
| 2064 | % testfalse=0; |
---|
| 2065 | % ListIndex={}; |
---|
| 2066 | % testnewcell=1; |
---|
| 2067 | % %group the variables (fields of 'Data') in cells of variables with the same dimensions |
---|
| 2068 | % [DimVarIndex,CellVarIndex]=find_field_indices(Data); |
---|
| 2069 | % VarIndex=CellVarIndex{1}; % ONLY THE FIRST VAR GROUP IS AVERAGED |
---|
| 2070 | % DimIndex=Data.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) |
---|
| 2071 | % MeanData=Data;%transfer heading |
---|
| 2072 | % MeanData.Time=[time(1) time(end)]; |
---|
| 2073 | % MeanData.Action=Series.Action;%name of the processing programme |
---|
| 2074 | % MeanData.ListDimName=Data.ListDimName(DimIndex);%name of dimension |
---|
| 2075 | % MeanData.DimValue=Data.DimValue(DimIndex);%values of dimension (nbre of vectors) |
---|
| 2076 | % MeanData.ListVarName=Data.ListVarName; |
---|
| 2077 | % MeanData.VarDimIndex=Data.VarDimIndex; |
---|
| 2078 | % MeanData.ListVarAttribute={'Role'};%list of variable attribute names A FAIRE: transferer les autres attributs |
---|
| 2079 | % testsum=ones(size(VarIndex)); |
---|
| 2080 | % indexfalse=0; |
---|
| 2081 | % CoordName={}; |
---|
| 2082 | % indexremove=[]; |
---|
| 2083 | % if isfield(Data,'Role') % look for coordinate and flag variables |
---|
| 2084 | % for ivar=1:length(VarIndex) |
---|
| 2085 | % VarName=Data.ListVarName{VarIndex(ivar)}; |
---|
| 2086 | % var_role=Data.Role{VarIndex(ivar)};%'role' of the variable |
---|
| 2087 | % MeanData.Role{ivar}=var_role; |
---|
| 2088 | % if isequal(var_role,'falseflag') |
---|
| 2089 | % indexfalse=ivar; %test for false flag |
---|
| 2090 | % indexremove=ivar; |
---|
| 2091 | % FFName=VarName; |
---|
| 2092 | % testsum(ivar)=0; |
---|
| 2093 | % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable |
---|
| 2094 | % end |
---|
| 2095 | % if isequal(var_role,'warnflag') |
---|
| 2096 | % testsum(ivar)=0; %do not sum warn flag |
---|
| 2097 | % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable |
---|
| 2098 | % indexremove=[indexremove ivar]; |
---|
| 2099 | % end |
---|
| 2100 | % if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|isequal(var_role,'coord_z') |
---|
| 2101 | % eval(['MeanData.' VarName '=Data.' VarName ';']); |
---|
| 2102 | % testsum(ivar)=0; |
---|
| 2103 | % eval(['CoordName=[CoordName ''' VarName '''];']); |
---|
| 2104 | % end |
---|
| 2105 | % if testsum(ivar)~=0 |
---|
| 2106 | % eval(['MeanData.' VarName '=zeros(size(Data.' VarName '));']);%initialise sum |
---|
| 2107 | % end |
---|
| 2108 | % end |
---|
| 2109 | % end |
---|
| 2110 | % findsum=find(testsum); |
---|
| 2111 | % VarIndexSum=VarIndex(findsum);%indices of variables to sum (not coordinates nor flags) |
---|
| 2112 | % if length(CoordName)==0 |
---|
| 2113 | % if isempty(DimVarIndex)|isequal(DimVarIndex,0)% no coordinate variable for structured coordinates, prepare histograms |
---|
| 2114 | % for ilist=1:length(VarIndexSum) |
---|
| 2115 | % VarName=Data.ListVarName{VarIndexSum(ilist)}; |
---|
| 2116 | % eval(['MeanData=rmfield(MeanData,''' VarName ''');']);%remove variable |
---|
| 2117 | % indexremove=[indexremove ilist]; |
---|
| 2118 | % eval(['[MeanData.' VarName 'hist,MeanData.' VarName 'val]=hist(Data.' VarName ',100);']);%make histo |
---|
| 2119 | % eval(['sizhist=size(MeanData.' VarName 'hist);']) |
---|
| 2120 | % if sizhist(1)==1 |
---|
| 2121 | % eval(['MeanData.' VarName 'hist=MeanData.' VarName 'hist'';']) |
---|
| 2122 | % end |
---|
| 2123 | % eval(['maxval=max(MeanData.' VarName 'val);']); |
---|
| 2124 | % eval(['minval=min(MeanData.' VarName 'val);']); |
---|
| 2125 | % dC(ilist)=(maxval-minval)/100;%size of the histogram bin |
---|
| 2126 | % end |
---|
| 2127 | % else |
---|
| 2128 | % % icoord=0; |
---|
| 2129 | % % for ilist=1:length(DimVarIndex) |
---|
| 2130 | % % VarDim=Data.ListVarName{DimVarIndex(ilist)}; |
---|
| 2131 | % % icoord=icoord+1; |
---|
| 2132 | % % % eval(['Coord{' num2str(icord) '}=[' CoordName ''' VarName ''']']); |
---|
| 2133 | % % %eval(['Data.' CoordName{icoord} '=Data.' CoordName{icoord} '(indsel);']); |
---|
| 2134 | % % end |
---|
| 2135 | % end |
---|
| 2136 | % end |
---|
| 2137 | % if ~isempty(indexremove) |
---|
| 2138 | % MeanData.ListVarName(VarIndex(indexremove))=[]; |
---|
| 2139 | % MeanData.VarDimIndex(VarIndex(indexremove))=[]; |
---|
| 2140 | % if isfield(MeanData,'Role')%generaliser aus autres attributs |
---|
| 2141 | % MeanData.Role(VarIndex(indexremove))=[]; |
---|
| 2142 | % end |
---|
| 2143 | % end |
---|
| 2144 | % % END OF INITIALISATION |
---|
| 2145 | % |
---|
| 2146 | % end |
---|
| 2147 | % |
---|
| 2148 | % % A FAIRE: regular grid if coord_x undefined |
---|
| 2149 | % if indexfalse~=0 %suppress false data |
---|
| 2150 | % eval(['testexist=isfield(Data,''' FFName ''');']) |
---|
| 2151 | % if testexist |
---|
| 2152 | % eval(['indsel=find(Data.' FFName '==0);']); |
---|
| 2153 | % for icoord=1:length(CoordName) |
---|
| 2154 | % eval(['Data.' CoordName{icoord} '=Data.' CoordName{icoord} '(indsel);']); |
---|
| 2155 | % end |
---|
| 2156 | % end |
---|
| 2157 | % end |
---|
| 2158 | % for ilist=1:length(VarIndexSum) |
---|
| 2159 | % VarName=Data.ListVarName{VarIndexSum(ilist)}; |
---|
| 2160 | % if indexfalse~=0 & testexist |
---|
| 2161 | % eval(['Data.' VarName '=Data.' VarName '(indsel);']); |
---|
| 2162 | % end |
---|
| 2163 | % if length(CoordName)==0%no variable use dfor unstructured coordinates |
---|
| 2164 | % if isempty(DimVarIndex)|isequal(DimVarIndex,0)% no coordinate variable for structured coordinates |
---|
| 2165 | % % %update histogram with the current field #ifile |
---|
| 2166 | % str_left=['[MeanData.' VarName 'val,MeanData.' VarName 'hist]=']; |
---|
| 2167 | % str_right=['hist_update(MeanData.' VarName 'val,MeanData.' VarName 'hist,Data.' VarName ',dC(ilist));']; |
---|
| 2168 | % eval([str_left str_right]);%update global histo |
---|
| 2169 | % else |
---|
| 2170 | % %INTERPOLER |
---|
| 2171 | % |
---|
| 2172 | % eval(['MeanData.' VarName '=MeanData.' VarName '+Data.' VarName ';']);%increment sum%CAS x,y change |
---|
| 2173 | % end |
---|
| 2174 | % else |
---|
| 2175 | % if length(CoordName)==2 |
---|
| 2176 | % eval(['test_interp= ~isequal(Data.' CoordName{1} ',MeanData.' CoordName{1} ... |
---|
| 2177 | % ')|~isequal(Data.' CoordName{2} ',MeanData.' CoordName{2} ');']) |
---|
| 2178 | % if test_interp |
---|
| 2179 | % eval(['Data.' VarName '=griddata_uvmat(Data.' CoordName{1} ',Data.' CoordName{2}... |
---|
| 2180 | % ',Data.' VarName ',MeanData.' CoordName{1} ',MeanData.' CoordName{2} ');']); |
---|
| 2181 | % test_interpolate=1; |
---|
| 2182 | % end |
---|
| 2183 | % end |
---|
| 2184 | % eval(['MeanData.' VarName '=MeanData.' VarName '+Data.' VarName ';']);%increment sum |
---|
| 2185 | % end |
---|
| 2186 | % end |
---|
| 2187 | % end |
---|
| 2188 | % end |
---|
| 2189 | % if length(CoordName)~=0 | ~isequal(DimVarIndex,0)% no coordinate variable for structured coordinates |
---|
| 2190 | % for ilist=1:length(VarIndexSum) |
---|
| 2191 | % VarName=Data.ListVarName{VarIndexSum(ilist)}; |
---|
| 2192 | % eval(['MeanData.' VarName '=MeanData.' VarName '/itime;']);%normalize sum by the number of fields |
---|
| 2193 | % end |
---|
| 2194 | % else |
---|
| 2195 | % MeanData.NbDim=1; |
---|
| 2196 | % MeanData.ListDimName={}; |
---|
| 2197 | % MeanData.DimValue=[]; |
---|
| 2198 | % for ilist=1:length(VarIndexSum) |
---|
| 2199 | % VarName=Data.ListVarName{VarIndexSum(ilist)}; |
---|
| 2200 | % MeanData.ListVarName=[MeanData.ListVarName {[VarName 'val']} {[VarName 'hist']}]; |
---|
| 2201 | % MeanData.VarDimIndex=[MeanData.VarDimIndex {[ilist]} {[ilist]}]; |
---|
| 2202 | % MeanData.ListDimName=[MeanData.ListDimName {[VarName 'val']}]; |
---|
| 2203 | % eval(['MeanData.DimValue=[MeanData.DimValue length(MeanData.' VarName 'val)];']); |
---|
| 2204 | % end |
---|
| 2205 | % end |
---|
| 2206 | % figure |
---|
| 2207 | % haxes=axes; |
---|
| 2208 | % plot_field(MeanData,haxes)%plot the resulting average |
---|
| 2209 | % % change variable names for consitency with civ1 data (need to generalize these programs) |
---|
| 2210 | % if length(MeanData.ListVarName) >= 4 & isequal(MeanData.ListVarName(1:4), {'X' 'Y' 'U' 'V'}) |
---|
| 2211 | % MeanData.ListGlobalAttribute={'nb_coord','nb_dim','dt','absolut_time_T0','pixcmx','pixcmy','hart','civ','fix'}; |
---|
| 2212 | % MeanData.nb_coord=2; |
---|
| 2213 | % MeanData.nb_dim=2; |
---|
| 2214 | % MeanData.dt=1; |
---|
| 2215 | % MeanData.absolut_time_T0=0; |
---|
| 2216 | % MeanData.pixcmx=1; %pix per cm (1 by default) |
---|
| 2217 | % MeanData.pixcmy=1; %pix per cm (1 by default) |
---|
| 2218 | % MeanData.hart=0; |
---|
| 2219 | % if isequal(Data.CoordType,'px') |
---|
| 2220 | % MeanData.civ=1; |
---|
| 2221 | % else |
---|
| 2222 | % MeanData.civ=0; |
---|
| 2223 | % end |
---|
| 2224 | % MeanData.fix=0; |
---|
| 2225 | % MeanData.ListVarName(1:4)={'vec_X' 'vec_Y' 'vec_U' 'vec_V'}; |
---|
| 2226 | % MeanData.vec_X=MeanData.X; |
---|
| 2227 | % MeanData.vec_Y=MeanData.Y; |
---|
| 2228 | % MeanData.vec_U=MeanData.U; |
---|
| 2229 | % MeanData.vec_V=MeanData.V; |
---|
| 2230 | % end |
---|
| 2231 | % error=struct2nc(filemean,MeanData); %save result file |
---|
| 2232 | % if isequal(error,0) |
---|
| 2233 | % if test_interpolate |
---|
| 2234 | % 'fields interpolated to the positions of the first one' |
---|
| 2235 | % end |
---|
| 2236 | % [filemean ' written'] |
---|
| 2237 | % else |
---|
| 2238 | % warndlg_uvmat(error,'ERROR') |
---|
| 2239 | % end |
---|
| 2240 | % end |
---|
| 2241 | |
---|
| 2242 | %---------------------------------------------------------------------- |
---|
| 2243 | % --project fields on a projection object (e. g. a regular grid), possibly |
---|
| 2244 | % merge several fields |
---|
| 2245 | %---------------------------------------------------------------------- |
---|
| 2246 | %INPUT: |
---|
| 2247 | %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
| 2248 | %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
| 2249 | %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) |
---|
| 2250 | %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) |
---|
| 2251 | %OTHER INPUTS given by the structure Series |
---|
| 2252 | function GUI_input=merge_proj(num_i1,num_i2,num_j1,num_j2,Series); |
---|
| 2253 | |
---|
| 2254 | %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) |
---|
| 2255 | if ~exist('num_i1','var') |
---|
| 2256 | GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') |
---|
| 2257 | 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) |
---|
| 2258 | 'RootFile';'on';... %root input file name ('on' by default) |
---|
| 2259 | 'FileExt';'on';... %input file extension ('on' by default) |
---|
| 2260 | 'NomType';'on';...%type of file indexing ('on' by default) |
---|
| 2261 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
| 2262 | 'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default) |
---|
| 2263 | 'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
| 2264 | 'CoordType';'on';...%can use a transform function 'off' by default |
---|
| 2265 | 'GetObject';'on';...%can use projection object ,'off' by default |
---|
| 2266 | %'GetMask';'on'...%can use mask option ,'off' by default |
---|
| 2267 | %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter |
---|
| 2268 | ''}; |
---|
| 2269 | return %exit the function |
---|
| 2270 | end |
---|
| 2271 | |
---|
| 2272 | %------------------------------------------------- |
---|
| 2273 | hseries=guidata(Series.hseries);%handles of the GUI series |
---|
| 2274 | WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame |
---|
| 2275 | %------------------------------------------------- |
---|
| 2276 | |
---|
| 2277 | %numbers of view fields (nbre of inputs in RootPath) |
---|
| 2278 | testcell=iscell(Series.RootFile); |
---|
| 2279 | if ~testcell |
---|
| 2280 | Series.RootPath={Series.RootPath}; |
---|
| 2281 | Series.RootFile={Series.RootFile}; |
---|
| 2282 | Series.SubDir={Series.SubDir}; |
---|
| 2283 | Series.FileExt={Series.FileExt}; |
---|
| 2284 | Series.NomType={Series.NomType}; |
---|
| 2285 | num_i1={num_i1}; |
---|
| 2286 | num_i2={num_i2}; |
---|
| 2287 | num_j1={num_j1}; |
---|
| 2288 | num_j2={num_j2}; |
---|
| 2289 | end |
---|
| 2290 | nbview=length(Series.RootFile);%number of views (file series to merge) |
---|
| 2291 | nbfield=size(num_i1{1},1)*size(num_i1{1},2);%number of fields in the time series |
---|
| 2292 | transform=Series.CoordType; % field transform function |
---|
| 2293 | hhh=which('mmreader'); |
---|
| 2294 | for iview=1:nbview |
---|
| 2295 | test_movie(iview)=0; |
---|
| 2296 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported() |
---|
| 2297 | if isequal(lower(FileExt{iview}),'.avi') |
---|
| 2298 | MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); |
---|
| 2299 | test_movie(iview)=1; |
---|
| 2300 | end |
---|
| 2301 | end |
---|
| 2302 | end |
---|
| 2303 | |
---|
| 2304 | %Calibration data and timing: read the ImaDoc files |
---|
| 2305 | mode=''; %default |
---|
| 2306 | timecell={}; |
---|
| 2307 | itime=0; |
---|
| 2308 | NbSlice_calib={}; %test for z index |
---|
| 2309 | for iview=1:nbview%Loop on views |
---|
| 2310 | XmlData{iview}=[];%default |
---|
| 2311 | filebase{iview}=fullfile(Series.RootPath{iview},Series.RootFile{iview}); |
---|
| 2312 | if exist([filebase{iview} '.xml'],'file') |
---|
| 2313 | [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); |
---|
| 2314 | if isfield(XmlData{iview},'Time') |
---|
| 2315 | itime=itime+1; |
---|
| 2316 | timecell{itime}=XmlData{iview}.Time; |
---|
| 2317 | end |
---|
| 2318 | if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') |
---|
| 2319 | NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1); |
---|
| 2320 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 2321 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 2322 | end |
---|
| 2323 | end |
---|
| 2324 | elseif exist([filebase{iview} '.civ'],'file') |
---|
| 2325 | [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); |
---|
| 2326 | itime=itime+1; |
---|
| 2327 | timecell{itime}=time; |
---|
| 2328 | XmlData{iview}.Time=time; |
---|
| 2329 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
| 2330 | GeometryCalib.Tx=0; |
---|
| 2331 | GeometryCalib.Ty=0; |
---|
| 2332 | GeometryCalib.Tz=1; |
---|
| 2333 | GeometryCalib.dpx=1; |
---|
| 2334 | GeometryCalib.dpy=1; |
---|
| 2335 | GeometryCalib.sx=1; |
---|
| 2336 | GeometryCalib.Cx=0; |
---|
| 2337 | GeometryCalib.Cy=0; |
---|
| 2338 | GeometryCalib.f=1; |
---|
| 2339 | GeometryCalib.kappa1=0; |
---|
| 2340 | GeometryCalib.CoordUnit='cm'; |
---|
| 2341 | XmlData{iview}.GeometryCalib=GeometryCalib; |
---|
| 2342 | if error==1 |
---|
| 2343 | msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 2344 | end |
---|
| 2345 | end |
---|
| 2346 | end |
---|
| 2347 | |
---|
| 2348 | %check coincidence in time |
---|
| 2349 | multitime=0; |
---|
| 2350 | if length(timecell)==0 |
---|
| 2351 | time=[]; |
---|
| 2352 | elseif length(timecell)==1 |
---|
| 2353 | time=timecell{1}; |
---|
| 2354 | elseif length(timecell)>1 |
---|
| 2355 | multitime=1; |
---|
| 2356 | for icell=1:length(timecell) |
---|
| 2357 | if ~isequal(size(timecell{icell}),size(timecell{1})) |
---|
| 2358 | msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') |
---|
| 2359 | time=timecell{1}; |
---|
| 2360 | multitime=0; |
---|
| 2361 | break |
---|
| 2362 | end |
---|
| 2363 | end |
---|
| 2364 | end |
---|
| 2365 | if multitime |
---|
| 2366 | for icell=1:length(timecell) |
---|
| 2367 | time(icell,:,:)=timecell{icell}; |
---|
| 2368 | end |
---|
| 2369 | diff_time=max(max(diff(time))); |
---|
| 2370 | if diff_time>0 |
---|
| 2371 | msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) |
---|
| 2372 | end |
---|
| 2373 | end |
---|
| 2374 | if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file' |
---|
| 2375 | time=[]; |
---|
| 2376 | end |
---|
| 2377 | |
---|
| 2378 | % Field and velocity type (the same for all views) |
---|
| 2379 | Field_str=get(hseries.FieldMenu,'String'); |
---|
| 2380 | val=get(hseries.FieldMenu,'Value'); |
---|
| 2381 | FieldName=Field_str(val);%the same set of fields for all views |
---|
| 2382 | VelType_str=get(hseries.VelTypeMenu,'String'); |
---|
| 2383 | VelType_val=get(hseries.VelTypeMenu,'Value'); |
---|
| 2384 | VelType=VelType_str{VelType_val}; %the same for all views |
---|
| 2385 | if isequal(FieldName,'get_field...') |
---|
| 2386 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI |
---|
[12] | 2387 | % hhget_field=guidata(hget_field);%handles of GUI elements in get_field |
---|
| 2388 | SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI |
---|
| 2389 | % if isequal(get(hhget_field.menu_coord,'Visible'),'on') |
---|
| 2390 | % list_transform=get(hhget_field.menu_coord,'String'); |
---|
| 2391 | % val_list=get(hhget_field.menu_coord,'Value'); |
---|
| 2392 | % transform=list_transform{val_list}; |
---|
| 2393 | % end |
---|
[2] | 2394 | end |
---|
| 2395 | %detect whether all the files are 'images' or 'netcdf' |
---|
| 2396 | testima=0; |
---|
| 2397 | testvol=0; |
---|
| 2398 | testcivx=0; |
---|
| 2399 | testnc=0; |
---|
| 2400 | FileExt=get(hseries.FileExt,'String'); |
---|
| 2401 | for iview=1:nbview |
---|
| 2402 | ext=FileExt{iview}; |
---|
| 2403 | form=imformats(ext([2:end])); |
---|
| 2404 | if isequal(lower(ext),'.vol') |
---|
| 2405 | testvol=testvol+1; |
---|
| 2406 | elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab |
---|
| 2407 | testima=testima+1; |
---|
| 2408 | elseif isequal(ext,'.nc') |
---|
| 2409 | testnc=testnc+1; |
---|
| 2410 | end |
---|
| 2411 | end |
---|
| 2412 | if testvol |
---|
| 2413 | msgbox_uvmat('ERROR','volume images not implemented yet') |
---|
| 2414 | return |
---|
| 2415 | end |
---|
| 2416 | if testnc~=nbview && testima~=nbview && testvol~=nbview |
---|
| 2417 | msgbox_uvmat('ERROR','need a set of images or a set of netcdf files with the same fields as input') |
---|
| 2418 | return |
---|
| 2419 | end |
---|
| 2420 | if ~isequal(FieldName,'get_field...') |
---|
| 2421 | testcivx=testnc; |
---|
| 2422 | end |
---|
| 2423 | %name of output files and directory: |
---|
| 2424 | % res_subdir=fullfile(Series.RootPath{1},[Series.SubDir{1} '_STAT']); |
---|
| 2425 | ProjectDir=fileparts(fileparts(Series.RootPath{1}));% preoject directory (GERK) |
---|
| 2426 | prompt={['result directory (in' ProjectDir ')']}; |
---|
| 2427 | RootPath=get(hseries.RootPath,'String'); |
---|
| 2428 | SubDir=get(hseries.SubDir,'String'); |
---|
| 2429 | if isequal(length(RootPath),1) |
---|
| 2430 | fulldir=RootPath{1}; |
---|
| 2431 | subdir='GRID'; |
---|
| 2432 | res_subdir=fullfile(fulldir,subdir); |
---|
| 2433 | else |
---|
| 2434 | def={fullfile(ProjectDir,'0_RESULTS')}; |
---|
| 2435 | dlgTitle='result directory'; |
---|
| 2436 | lineNo=1; |
---|
| 2437 | answer=msgbox_uvmat('INPUT_TXT',dlgTitle,def); |
---|
| 2438 | fulldir=answer{1}; |
---|
| 2439 | subdir=[]; |
---|
| 2440 | dirlist=sort(Series.RootFile); |
---|
| 2441 | for iview=1:nbview |
---|
| 2442 | if ~isempty(subdir) |
---|
| 2443 | subdir=[subdir '-']; |
---|
| 2444 | end |
---|
| 2445 | subdir=[subdir dirlist{iview}]; |
---|
| 2446 | end |
---|
| 2447 | res_subdir=fullfile(fulldir,subdir); |
---|
| 2448 | end |
---|
| 2449 | ext=FileExt{1}; |
---|
| 2450 | if ~exist(fulldir,'dir') |
---|
| 2451 | msgbox_uvmat('ERROR',['directory ' fulldir ' needs to be created']) |
---|
| 2452 | return |
---|
| 2453 | end |
---|
| 2454 | if ~exist(res_subdir,'dir') |
---|
| 2455 | dircur=pwd; |
---|
| 2456 | cd(fulldir) |
---|
| 2457 | error=mkdir(subdir); |
---|
| 2458 | cd(dircur) |
---|
| 2459 | end |
---|
| 2460 | filebasesub=fullfile(res_subdir,Series.RootFile{1}); |
---|
| 2461 | filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files |
---|
| 2462 | |
---|
| 2463 | %projection object |
---|
| 2464 | if isfield(Series,'sethandles') |
---|
| 2465 | if ishandle(Series.sethandles.set_object) |
---|
| 2466 | Series.ProjObject=read_set_object(Series.sethandles); |
---|
| 2467 | if ~isfield(Series.ProjObject,'Style') |
---|
| 2468 | msgbox_uvmat('ERROR','Undefined projection object style') |
---|
| 2469 | return |
---|
| 2470 | end |
---|
| 2471 | if ~isequal(Series.ProjObject.Style,'plane') |
---|
| 2472 | msgbox_uvmat('ERROR','The projection object must be a plane') |
---|
| 2473 | return |
---|
| 2474 | end |
---|
| 2475 | end |
---|
| 2476 | end |
---|
| 2477 | |
---|
| 2478 | %MAIN LOOP |
---|
| 2479 | for ifile=1:nbfield |
---|
| 2480 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
| 2481 | if isequal(stopstate,'queue')% enable STOP command from the 'series' interface |
---|
| 2482 | update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) |
---|
| 2483 | Amerge=0; |
---|
| 2484 | |
---|
| 2485 | %----------LOOP ON VIEWS---------------------- |
---|
| 2486 | nbtime=0; |
---|
| 2487 | for iview=1:nbview |
---|
| 2488 | %name of the current file |
---|
| 2489 | filename=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview}); |
---|
| 2490 | if ~exist(filename,'file') |
---|
| 2491 | msgbox_uvmat('ERROR',['missing input file' filename]) |
---|
| 2492 | break |
---|
| 2493 | end |
---|
| 2494 | |
---|
| 2495 | %reading the current file |
---|
| 2496 | if testima |
---|
| 2497 | if test_movie(iview) |
---|
| 2498 | Field{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile)); |
---|
| 2499 | else |
---|
| 2500 | Field{iview}.A=read_image(filename,Series.NomType{iview},num_i1{iview}(ifile)); |
---|
| 2501 | end % TODO: introduce ListVarName |
---|
| 2502 | npxy=size(Field{iview}.A); |
---|
| 2503 | Field{iview}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers |
---|
| 2504 | Field{iview}.AY=[npxy(1)-0.5 0.5]; |
---|
| 2505 | Field{iview}.CoordType='px'; |
---|
| 2506 | Field{iview}.AName='image'; |
---|
| 2507 | else |
---|
| 2508 | if testcivx |
---|
| 2509 | [Field{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); |
---|
| 2510 | else |
---|
| 2511 | [Field{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data |
---|
| 2512 | Field{iview}.VarAttribute=SubField.VarAttribute; |
---|
| 2513 | end |
---|
| 2514 | if isfield(Field{iview},'Time') |
---|
| 2515 | timeread(iview)=Field{iview}.Time; |
---|
| 2516 | nbtime=nbtime+1; |
---|
| 2517 | end |
---|
| 2518 | end |
---|
| 2519 | % coord transform |
---|
| 2520 | % z index |
---|
| 2521 | if ~isempty(NbSlice_calib) |
---|
| 2522 | Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1; |
---|
| 2523 | end |
---|
| 2524 | if ~isequal(transform,'') |
---|
| 2525 | Field{iview}=feval(Series.CoordType,Field{iview},XmlData{iview});%transform to phys if requested |
---|
| 2526 | end |
---|
| 2527 | if testcivx |
---|
| 2528 | Field{iview}=calc_field(FieldName,Field{iview}); |
---|
| 2529 | end |
---|
| 2530 | |
---|
| 2531 | %projection on object (gridded plane) |
---|
| 2532 | if isfield(Series,'ProjObject') |
---|
| 2533 | Field{iview}=proj_field(Field{iview},Series.ProjObject); |
---|
| 2534 | end |
---|
| 2535 | end |
---|
| 2536 | |
---|
| 2537 | %----------END LOOP ON VIEWS---------------------- |
---|
| 2538 | |
---|
| 2539 | %merge the nbview fields |
---|
| 2540 | MergeData=merge_field(Field); |
---|
| 2541 | if isfield(MergeData,'Txt') |
---|
| 2542 | msgbox_uvmat('ERROR',MergeData.Txt) |
---|
| 2543 | return |
---|
| 2544 | end |
---|
| 2545 | |
---|
| 2546 | % generating the name of the merged field |
---|
| 2547 | mergename=name_generator(filebase_merge,num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile)); |
---|
| 2548 | |
---|
| 2549 | % time: |
---|
| 2550 | time_i=0;%default |
---|
| 2551 | if isempty(time)% time from ImaDoc prevails |
---|
| 2552 | time_i=sum(timeread)/nbtime; |
---|
| 2553 | else |
---|
| 2554 | time_i=(time(iview,num_i1{iview}(ifile),num_j1{iview}(ifile))+time(iview,num_i2{iview}(ifile),num_j2{iview}(ifile)))/2; |
---|
| 2555 | end |
---|
| 2556 | |
---|
| 2557 | % recording the merged field |
---|
| 2558 | if testima %in case of input images an image is produced |
---|
| 2559 | if isa(MergeData.A,'uint8') |
---|
| 2560 | bitdepth=8; |
---|
| 2561 | elseif isa(MergeData.A,'uint16') |
---|
| 2562 | bitdepth=16; |
---|
| 2563 | end |
---|
| 2564 | imwrite(MergeData.A,mergename,'BitDepth',bitdepth); |
---|
| 2565 | %write xml calibration file |
---|
| 2566 | siz=size(MergeData.A); |
---|
| 2567 | npy=siz(1); |
---|
| 2568 | npx=siz(2); |
---|
| 2569 | if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1') |
---|
| 2570 | Rangx=MergeData.VarAttribute{1}.Coord_2; |
---|
| 2571 | Rangy=MergeData.VarAttribute{1}.Coord_1; |
---|
| 2572 | elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY') |
---|
| 2573 | Rangx=[MergeData.AX(1) MergeData.AX(end)]; |
---|
| 2574 | Rangy=[MergeData.AY(1) MergeData.AY(end)]; |
---|
| 2575 | else |
---|
| 2576 | Rangx=[0.5 npx-0.5]; |
---|
| 2577 | Rangy=[npy-0.5 0.5];%default |
---|
| 2578 | end |
---|
| 2579 | pxcmx=(npx-1)/(Rangx(2)-Rangx(1)); |
---|
| 2580 | pxcmy=(npy-1)/(Rangy(1)-Rangy(2)); |
---|
| 2581 | T_x=-pxcmx*Rangx(1)+0.5; |
---|
| 2582 | T_y=-pxcmy*Rangy(2)+0.5; |
---|
| 2583 | GeometryCal.focal=1; |
---|
| 2584 | GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1]; |
---|
| 2585 | GeometryCal.Tx_Ty_Tz=[T_x T_y 1]; |
---|
| 2586 | ImaDoc.GeometryCalib=GeometryCal; |
---|
| 2587 | t=struct2xml(ImaDoc); |
---|
| 2588 | t=set(t,1,'name','ImaDoc'); |
---|
| 2589 | save(t,[filebase_merge '.xml']) |
---|
| 2590 | display([filebase_merge '.xml saved']) |
---|
| 2591 | else |
---|
| 2592 | MergeData.ListGlobalAttribute={'Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'}; |
---|
| 2593 | MergeData.nb_coord=2; |
---|
| 2594 | MergeData.nb_dim=2; |
---|
| 2595 | MergeData.dt=1; |
---|
| 2596 | MergeData.Time=time_i; |
---|
| 2597 | error=struct2nc(mergename,MergeData); %save result file |
---|
| 2598 | if isempty(error) |
---|
| 2599 | display(['output file ' mergename ' written']) |
---|
| 2600 | else |
---|
| 2601 | display(error) |
---|
| 2602 | end |
---|
| 2603 | end |
---|
| 2604 | end |
---|
| 2605 | end |
---|
| 2606 | |
---|
| 2607 | %-------------------------------------------------------------------------- |
---|
| 2608 | function MergeData=merge_field(Data) |
---|
| 2609 | % initiate Matlab structure for physical field |
---|
| 2610 | if isempty(Data)||~iscell(Data) |
---|
| 2611 | MergeData=[]; |
---|
| 2612 | return |
---|
| 2613 | end |
---|
| 2614 | MergeData=Data{1};%default |
---|
| 2615 | error=0; |
---|
| 2616 | nbview=length(Data); |
---|
| 2617 | if nbview==1 |
---|
| 2618 | return |
---|
| 2619 | end |
---|
| 2620 | for iview=1:nbview |
---|
| 2621 | if ~isequal(MergeData.ListDimName,Data{iview}.ListDimName) |
---|
| 2622 | error=1; |
---|
| 2623 | end |
---|
| 2624 | if ~isequal(MergeData.ListVarName,Data{iview}.ListVarName) |
---|
| 2625 | error=1; |
---|
| 2626 | end |
---|
| 2627 | % if ~isequal(MergeData.VarDimIndex,Data{iview}.VarDimIndex) |
---|
| 2628 | % error=1; |
---|
| 2629 | % end |
---|
| 2630 | end |
---|
| 2631 | if error |
---|
| 2632 | MergeData.Txt='ERROR: attempt at merging fields of incompatible type'; |
---|
| 2633 | return |
---|
| 2634 | end |
---|
| 2635 | %group the variables (fields of 'FieldData') in cells of variables with the same dimensions |
---|
| 2636 | %----------------------------------------------------------------- |
---|
| 2637 | [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1}); |
---|
| 2638 | %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS |
---|
| 2639 | % CellVarIndex=cells of variable index arrays |
---|
| 2640 | ivar_new=0; % index of the current variable in the projected field |
---|
| 2641 | icoord=0; |
---|
| 2642 | for icell=1:length(CellVarIndex) |
---|
| 2643 | if NbDim(icell)==1 |
---|
| 2644 | continue |
---|
| 2645 | end |
---|
| 2646 | VarIndex=CellVarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName |
---|
| 2647 | VarType=VarTypeCell{icell}; |
---|
| 2648 | ivar_X=VarType.coord_x; |
---|
| 2649 | ivar_Y=VarType.coord_y; |
---|
| 2650 | ivar_FF=VarType.errorflag; |
---|
| 2651 | if isempty(ivar_X) |
---|
| 2652 | test_grid=1;%test for input data on regular grid (e.g. image)coordinates |
---|
| 2653 | else |
---|
| 2654 | if length(ivar_Y)~=1 |
---|
[12] | 2655 | warndlg_uvmat('y coordinate missing in proj_field.m','ERROR') |
---|
[2] | 2656 | return |
---|
| 2657 | end |
---|
| 2658 | test_grid=0; |
---|
| 2659 | end |
---|
[12] | 2660 | % DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell) |
---|
[2] | 2661 | %case of input fields with unstructured coordinates |
---|
| 2662 | if ~test_grid |
---|
| 2663 | for ivar=VarIndex |
---|
| 2664 | VarName=MergeData.ListVarName{ivar}; |
---|
| 2665 | for iview=1:nbview |
---|
| 2666 | eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';']) |
---|
| 2667 | end |
---|
| 2668 | end |
---|
| 2669 | %case of fields defined on a structured grid |
---|
| 2670 | else |
---|
[12] | 2671 | % DimValue=MergeData.DimValue(DimIndices);%set of dimension values |
---|
[2] | 2672 | testFF=0; |
---|
| 2673 | for iview=2:nbview |
---|
| 2674 | % if ~isequal(DimValue,Data{iview}.DimValue(DimIndices)) |
---|
| 2675 | % MergeData.Txt='ERROR: attempt at merging structured fields with different sizes'; |
---|
| 2676 | % return |
---|
| 2677 | % end |
---|
| 2678 | for ivar=VarIndex |
---|
| 2679 | VarName=MergeData.ListVarName{ivar}; |
---|
| 2680 | if isfield(MergeData,'VarAttribute') |
---|
| 2681 | if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag') |
---|
| 2682 | testFF=1; |
---|
| 2683 | end |
---|
| 2684 | end |
---|
| 2685 | eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';']) |
---|
| 2686 | end |
---|
| 2687 | end |
---|
| 2688 | if testFF |
---|
| 2689 | nbaver=nbview-MergeData.FF; |
---|
| 2690 | indgood=find(nbaver>0); |
---|
| 2691 | for ivar=VarIndex |
---|
| 2692 | VarName=MergeData.ListVarName{ivar}; |
---|
| 2693 | eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);']) |
---|
| 2694 | end |
---|
| 2695 | else |
---|
| 2696 | for ivar=VarIndex |
---|
| 2697 | VarName=MergeData.ListVarName{ivar}; |
---|
| 2698 | eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;']) |
---|
| 2699 | end |
---|
| 2700 | end |
---|
| 2701 | end |
---|
| 2702 | end |
---|
| 2703 | |
---|
| 2704 | |
---|
| 2705 | |
---|
| 2706 | |
---|
| 2707 | %----------------------------- |
---|
| 2708 | function mouse_up_gui(ggg,eventdata,handles) |
---|
| 2709 | if isequal(get(ggg,'SelectionType'),'alt') |
---|
| 2710 | display('global CurData, UserData of GUI series') |
---|
| 2711 | global CurData |
---|
| 2712 | CurData=get(ggg,'UserData'); |
---|
| 2713 | evalin('base','global CurData');%make CurData global in the workspace |
---|
| 2714 | evalin('base','CurData'); %display CurData in the workspace |
---|
| 2715 | commandwindow |
---|
| 2716 | % plot_text(CurData) |
---|
| 2717 | end |
---|
| 2718 | |
---|
| 2719 | |
---|
| 2720 | |
---|
| 2721 | % %---------------------------------------------------------------------- |
---|
| 2722 | % % --- display image movie and display time average |
---|
| 2723 | % %OBSOLETE: A SUPPRIMER |
---|
| 2724 | % %---------------------------------------------------------------------- |
---|
| 2725 | % function movie_ima(handles,filecell,filecell_1,num1,num_a,field) |
---|
| 2726 | % |
---|
| 2727 | % global hfig1 hfig2 hfig3 poscolbar |
---|
| 2728 | % global A val HIST |
---|
| 2729 | % |
---|
| 2730 | % A=[];aviobj=[]; |
---|
| 2731 | % % set(hfig1,'UserData','ima')% set the current field state to 'image' |
---|
| 2732 | % set(handles.zoom,'Value',1); %put zoom on |
---|
| 2733 | % nom_type=get(handles.file_input,'UserData'); |
---|
| 2734 | % % field=get(handles.civ1,'UserData'); |
---|
| 2735 | % % fields=field(1).fields; |
---|
| 2736 | % set(handles.speed,'Visible','On')%show slider to set movie speed |
---|
| 2737 | % set(handles.mo_speed_txt,'Visible','On') |
---|
| 2738 | % |
---|
| 2739 | % if ~isempty(filecell_1) |
---|
| 2740 | % file1=get(handles.file1_input,'UserData'); |
---|
| 2741 | % field1=file1.field; |
---|
| 2742 | % scal_type1=field1.fields; |
---|
| 2743 | % vel_type1=field1.vel_type; |
---|
| 2744 | % filename_1=filecell_1(1);% first file name in the series |
---|
| 2745 | % else |
---|
| 2746 | % filename_1=[]; |
---|
| 2747 | % end |
---|
| 2748 | % scal_type{1}=field(1).fields; |
---|
| 2749 | % vel_type{1}=field(1).vel_type; |
---|
| 2750 | % % display the first field |
---|
| 2751 | % [A,time,dt,rangx0,rangy0]=view_ima(handles,cell2mat(filecell(1)),filename_1,num1(1),num_a(1)); |
---|
| 2752 | % |
---|
| 2753 | % % calculate the histogram of the first image |
---|
| 2754 | % nxy=size(A); |
---|
| 2755 | % ndim=length(nxy); |
---|
| 2756 | % if ndim==2 % case of B/W images |
---|
| 2757 | % nxy(3)=1; |
---|
| 2758 | % end |
---|
| 2759 | % C=reshape(A,nxy(1)*nxy(2),nxy(3)); |
---|
| 2760 | % Amaxmax=double(max(max(max(A)))); |
---|
| 2761 | % Aminmin=double(min(min(min(A)))); |
---|
| 2762 | % if isa(C,'uint8')|isa(C,'uint16') |
---|
| 2763 | % C=double(C); |
---|
| 2764 | % dC=1; |
---|
| 2765 | % else |
---|
| 2766 | % dC=(Amaxmax-Aminmin)/100; |
---|
| 2767 | % end |
---|
| 2768 | % val=[Aminmin:dC:Amaxmax];% define bins for histogram |
---|
| 2769 | % HIST=hist(C,val);% initiate the global histogram |
---|
| 2770 | % if ndim==2, HIST=HIST'; end; |
---|
| 2771 | % |
---|
| 2772 | % auto_scale=get(handles.auto_scale,'Value'); |
---|
| 2773 | % min_input=str2num(get(handles.min_input,'String'));% select the minimum |
---|
| 2774 | % max_input=str2num(get(handles.scale_input,'String'));% select the max |
---|
| 2775 | % zoomstate=get(handles.zoom,'Value'); |
---|
| 2776 | % |
---|
| 2777 | % if isequal(get(handles.window_input,'String'),'avi'), |
---|
| 2778 | % basename=get(handles.file_input,'String'); |
---|
| 2779 | % prompt = {'file name';'frames per second';'frame resolution ([nbpixels x y])';'axis position relative to the frame'}; |
---|
| 2780 | % dlg_title = 'select properties of the output avi movie'; |
---|
| 2781 | % num_lines= 1; |
---|
| 2782 | % def = {[basename '_out.avi'];'5';'[1024 768]';'[0.05 0.07 0.87 0.88]'}; |
---|
| 2783 | % answer = inputdlg(prompt,dlg_title,num_lines,def); |
---|
| 2784 | % aviname=answer{1}; |
---|
| 2785 | % fps=str2num(answer{2}); |
---|
| 2786 | % if exist(aviname,'file')==2 |
---|
| 2787 | % delete(aviname); |
---|
| 2788 | % end; |
---|
| 2789 | % aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 2790 | % |
---|
| 2791 | % %display first view for tests |
---|
| 2792 | % figure(2); |
---|
| 2793 | % hh=get(gcf,'CurrentAxes'); |
---|
| 2794 | % if isempty(hh), |
---|
| 2795 | % hfig1=axes; |
---|
| 2796 | % else |
---|
| 2797 | % hfig1=hh; |
---|
| 2798 | % end; |
---|
| 2799 | % if isequal(filecell_1,{}) |
---|
| 2800 | % filename_1=[]; |
---|
| 2801 | % else |
---|
| 2802 | % filename_1=cell2mat(filecell_1(1)); |
---|
| 2803 | % end |
---|
| 2804 | % poscolbar=[0.93 0.15 0.02 0.7]; |
---|
| 2805 | % view_ima(handles,cell2mat(filecell(1)),filename_1,num1(1),num_a(1));% show the first field |
---|
| 2806 | % nbpix=eval(answer{3}); |
---|
| 2807 | % set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 2808 | % set(hfig1,'Position',eval(answer{4})); |
---|
| 2809 | % |
---|
| 2810 | % msgbox({'adjust figure 2 with its matlab edit menu ' ;... |
---|
| 2811 | % 'then type any keyboard key to get the avi movie as a copy of figure 2 display'}) |
---|
| 2812 | % pause; |
---|
| 2813 | % hh=colorbar; |
---|
| 2814 | % poscolbar=get(hh,'Position'); |
---|
| 2815 | % end |
---|
| 2816 | % |
---|
| 2817 | % %%%%%%%%%%%%%%%% |
---|
| 2818 | % %mask and usrdfct |
---|
| 2819 | % maskname=[]; %default |
---|
| 2820 | % if isequal(get(handles.mask_test,'Value'),1) |
---|
| 2821 | % maskbase=get(handles.mask_test,'UserData'); |
---|
| 2822 | % end |
---|
| 2823 | % % image or scalar processing programme set by user |
---|
| 2824 | % % if (get(handles.usr_fct,'Value')==1) |
---|
| 2825 | % % usrfct=get(handles.usr_fct,'UserData'); |
---|
| 2826 | % % else |
---|
| 2827 | % % usrfct=''; |
---|
| 2828 | % % end |
---|
| 2829 | % nburst=1; % nburst(1) =nbre of names in filename= nbre of bursts |
---|
| 2830 | % set(handles.text_display_1,'String',['image movie']) |
---|
| 2831 | % nbfield=length(filecell); |
---|
| 2832 | % if nbfield >1 |
---|
| 2833 | % for ifile=2:nbfield |
---|
| 2834 | % stopstate=get(handles.run0,'BusyAction'); |
---|
| 2835 | % if isequal(stopstate,'queue')% enable STOP command |
---|
| 2836 | % pausetime=1.02-get(handles.speed,'Value'); |
---|
| 2837 | % pause(pausetime) |
---|
| 2838 | % if isequal(get(handles.mask_test,'Value'),1) |
---|
| 2839 | % maskname=name_generator(maskbase,num1(ifile),1,'.png','png_series'); |
---|
| 2840 | % end |
---|
| 2841 | % if isequal(AName{1},'image') |
---|
| 2842 | % A=read_image(cell2mat(filecell(ifile)),num1(ifile),maskname);% read the first image, num2 is the counter for avi files |
---|
| 2843 | % else % read the first field from the netcdf file, imposing the pixel positions in the selected domain |
---|
| 2844 | % [A,time(ifile),dtr,rgx,rgy,vt_out,erread]=read_scalar(filecell{ifile},vel_type,scal_type,rangx0,rangy0,nxy,maskname); |
---|
| 2845 | % if erread==1; |
---|
| 2846 | % errordlg({['no spatial derivative in ' filecell{ifile}]; 'run patch first'}); return |
---|
| 2847 | % elseif erread==2; |
---|
| 2848 | % errordlg(['no field ' vel_type{1} ' in ' filecell{ifile}]); return |
---|
| 2849 | % elseif erread==3; |
---|
| 2850 | % errordlg(['scalar ' scal_type{1} ' not found in' filecell{ifile}]); return |
---|
| 2851 | % elseif erread==4; |
---|
| 2852 | % errordlg(['all points aligned in' filecell{ifile}]); return |
---|
| 2853 | % end |
---|
| 2854 | % end |
---|
| 2855 | % |
---|
| 2856 | % % read the second image |
---|
| 2857 | % if ~isempty(filecell_1) |
---|
| 2858 | % if isequal(scal_type{1},'image') |
---|
| 2859 | % A1=read_image(cell2mat(filecell_1(ifile)),num1(ifile),maskname);% read the second image, num2 is the counter for avi files |
---|
| 2860 | % Avalue_1=double(A1(indy,indx,:)); |
---|
| 2861 | % else % read the second field from the netcdf file, imposing the pixel positions in the selected domain |
---|
| 2862 | % [Avalue_1,time1(ifile),dtr,rgx,rgy,vt_out,erread]=read_scalar(filecell_1{ifile},{vel_type1},{scal_type1},rangx0,rangy0,npxy,maskname,usrfct); |
---|
| 2863 | % if erread==1; |
---|
| 2864 | % errordlg({['no spatial derivative in ' filecell_1{ifile}]; 'run patch first'}); return |
---|
| 2865 | % elseif erread==2; |
---|
| 2866 | % errordlg(['no field ' vel_type1 ' in ' filecell_1{ifile}]); return |
---|
| 2867 | % elseif erread==3; |
---|
| 2868 | % errordlg(['scalar ' scal_type1 ' not found in' filecell_1{ifile}]); return |
---|
| 2869 | % elseif erread==4; |
---|
| 2870 | % errordlg(['all points aligned in' filecell_1{ifile}]); return |
---|
| 2871 | % end |
---|
| 2872 | % end |
---|
| 2873 | % time(ifile)=(time(ifile)+time1(ifile))/2; |
---|
| 2874 | % Avalue=Avalue-Avalue_1; |
---|
| 2875 | % end |
---|
| 2876 | % set(handles.abs_time,'String',time); |
---|
| 2877 | % set(handles.field_counter,'String',num2str(num1(ifile))); |
---|
| 2878 | % set(handles.a_input,'String',num2stra(num_a(ifile),nom_type)); |
---|
| 2879 | % C=reshape(A,nxy(1)*nxy(2),nxy(3));% reshape in a vector |
---|
| 2880 | % [val,HIST]=hist_update(val,HIST,C,dC); |
---|
| 2881 | % [h,Amin,Amax]=plot_image(hfig1,rangx0,rangy0,1,scal_type{1},auto_scale,min_input,max_input,poscolbar,A); |
---|
| 2882 | % set(handles.min_input,'String',num2str(Amin));% select the minimum |
---|
| 2883 | % set(handles.scale_input,'String',num2str(Amax));% select the minimum |
---|
| 2884 | % if ~isequal(aviobj,[]), |
---|
| 2885 | % % mov=getframe(hfig1); |
---|
| 2886 | % mov=getframe(gcf); |
---|
| 2887 | % aviobj=addframe(aviobj,mov);end |
---|
| 2888 | % if (get(handles.zoom,'Value') == get(handles.zoom,'Max')),zoom on,end |
---|
| 2889 | % set(handles.field_counter,'String',num2str(num1(ifile))) |
---|
| 2890 | % % end |
---|
| 2891 | % end |
---|
| 2892 | % end |
---|
| 2893 | % end |
---|
| 2894 | % aviobj=close(aviobj); |
---|
| 2895 | % |
---|
| 2896 | % %plot global image histogram |
---|
| 2897 | % HIST=HIST/(nbfield*nxy(1)*nxy(2));% normalized by the number of points |
---|
| 2898 | % axes(hfig2) %in main window |
---|
| 2899 | % if ndim==2 |
---|
| 2900 | % plot(val,HIST) |
---|
| 2901 | % else |
---|
| 2902 | % plot(val,HIST(:,1),'r',val,HIST(:,2),'g',val,HIST(:,3),'b') |
---|
| 2903 | % end |
---|
| 2904 | % residu=1-sum(HIST,1); |
---|
| 2905 | % title(['histo, residu ' num2str(residu)]) |
---|
| 2906 | % grid on |
---|
| 2907 | % axes(hfig3) |
---|
| 2908 | % cla %clear the second histogram window |
---|
| 2909 | % |
---|
| 2910 | |
---|
| 2911 | |
---|
| 2912 | |
---|
| 2913 | |
---|
| 2914 | %%%%%%%%%%%%% |
---|
| 2915 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
| 2916 | |
---|
| 2917 | indsel=ind_i; |
---|
| 2918 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
| 2919 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
| 2920 | if ~isempty(indiff) |
---|
| 2921 | indiff2=diff(indiff); |
---|
| 2922 | indiffp=[indiff2 1]; |
---|
| 2923 | indiffm=[1 indiff2]; |
---|
| 2924 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
| 2925 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
| 2926 | %for each multiplet, select the most recent file |
---|
| 2927 | ind_remove=[]; |
---|
| 2928 | for i=1:length(ind_multi_m) |
---|
| 2929 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
| 2930 | for imulti=1:length(ind_pairs) |
---|
| 2931 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
| 2932 | end |
---|
| 2933 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
| 2934 | ind_s=indsort2(1:end-1);% |
---|
| 2935 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
| 2936 | end |
---|
| 2937 | end |
---|
| 2938 | |
---|
| 2939 | %-------------------------------------------------------- |
---|
| 2940 | |
---|
| 2941 | |
---|
| 2942 | %----------------------------------------------------------- |
---|
| 2943 | % find the times corresponding to the first and last indices of a series |
---|
| 2944 | % |
---|
| 2945 | function displ_time(handles,times) |
---|
| 2946 | hseries=get(handles.last_i,'parent'); |
---|
| 2947 | SeriesData=get(hseries,'UserData');% |
---|
| 2948 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2949 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2950 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2951 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2952 | % index_civ=get(handles.list_pair_civ,'Value'); |
---|
| 2953 | % NomType=get(handles.NomType,'String'); |
---|
| 2954 | NomType=SeriesData.NomType; |
---|
| 2955 | mode_list=get(handles.mode,'String'); |
---|
| 2956 | index_mode=get(handles.mode,'Value'); |
---|
| 2957 | mode=mode_list{index_mode}; |
---|
| 2958 | % ind_shift=0;%default |
---|
| 2959 | |
---|
| 2960 | time_first=[]; |
---|
| 2961 | time_last=[]; |
---|
| 2962 | if ~isfield(SeriesData,'Time') |
---|
| 2963 | SeriesData.Time{1}=[]; |
---|
| 2964 | end |
---|
| 2965 | for iview=1:length(NomType) |
---|
| 2966 | time_first_cell{iview}='?'; |
---|
| 2967 | time_last_cell{iview}='?';%default |
---|
| 2968 | time=SeriesData.Time{iview}; |
---|
| 2969 | if isequal(NomType{iview},'_i1-i2_j')|isequal(NomType{iview},'_i_j1-j2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_i1-i2') |
---|
| 2970 | if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num) |
---|
| 2971 | ind_shift=SeriesData.displ_num(iview,:); |
---|
| 2972 | if isequal(mode,'bursts') |
---|
| 2973 | first_j=0; |
---|
| 2974 | last_j=0; |
---|
| 2975 | end |
---|
| 2976 | first_i1=first_i +ind_shift(3); |
---|
| 2977 | first_i2 =first_i +ind_shift(4); |
---|
| 2978 | first_j1 =first_j +ind_shift(1); |
---|
| 2979 | first_j2 =first_j +ind_shift(2); |
---|
| 2980 | last_i1=last_i +ind_shift(3); |
---|
| 2981 | last_i2 =last_i +ind_shift(4); |
---|
| 2982 | last_j1 =last_j +ind_shift(1); |
---|
| 2983 | last_j2 =last_j +ind_shift(2); |
---|
| 2984 | siz=size(SeriesData.Time{1}); |
---|
[25] | 2985 | if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2 |
---|
[2] | 2986 | time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2; |
---|
| 2987 | time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2; |
---|
| 2988 | else%read the time in the nc files |
---|
| 2989 | RootPath=get(handles.RootPath,'String'); |
---|
| 2990 | RootFile=get(handles.RootFile,'String'); |
---|
| 2991 | SubDir=get(handles.SubDir,'String'); |
---|
| 2992 | %VelType=get(handles.VelType,'String'); |
---|
| 2993 | VelType_str=get(handles.VelTypeMenu,'String'); |
---|
| 2994 | VelType_val=get(handles.VelTypeMenu,'Value'); |
---|
| 2995 | VelType=VelType_str{VelType_val}; |
---|
| 2996 | filebase=fullfile(RootPath{1},RootFile{1}); |
---|
| 2997 | [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview}); |
---|
| 2998 | if exist(filefirst,'file') |
---|
| 2999 | Attrib=nc2struct(filefirst,[]); |
---|
| 3000 | if isfield(Attrib,'Time') |
---|
| 3001 | time_first=Attrib.Time; |
---|
| 3002 | else |
---|
| 3003 | if isfield(Attrib,'absolut_time_T0') |
---|
| 3004 | time_first=Attrib.absolut_time_T0; |
---|
| 3005 | end |
---|
[12] | 3006 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
[2] | 3007 | time_first=Attrib.absolut_time_T0_2; |
---|
| 3008 | end |
---|
| 3009 | end |
---|
| 3010 | end |
---|
| 3011 | [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview}); |
---|
| 3012 | if exist(filelast,'file') |
---|
| 3013 | Attrib=nc2struct(filelast,[]); |
---|
| 3014 | if isfield(Attrib,'Time') |
---|
| 3015 | time_last=Attrib.Time; |
---|
| 3016 | else |
---|
| 3017 | if isfield(Attrib,'absolut_time_T0') |
---|
| 3018 | time_last=Attrib.absolut_time_T0; |
---|
| 3019 | end |
---|
[12] | 3020 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
[2] | 3021 | time_last=Attrib.absolut_time_T0_2; |
---|
| 3022 | end |
---|
| 3023 | end |
---|
| 3024 | end |
---|
| 3025 | end |
---|
| 3026 | end |
---|
| 3027 | else |
---|
| 3028 | siz=size(times); |
---|
| 3029 | if siz(1)>=last_i & siz(2)>=last_j |
---|
| 3030 | time_first=times(first_i,first_j); |
---|
| 3031 | time_last=times(last_i,last_j); |
---|
| 3032 | end |
---|
| 3033 | end |
---|
| 3034 | time_first_cell{iview}=num2str(time_first,4); |
---|
| 3035 | time_last_cell{iview}=num2str(time_last,4); |
---|
| 3036 | end |
---|
| 3037 | set(handles.time_first,'Value',1) |
---|
| 3038 | set(handles.time_last,'Value',1) |
---|
| 3039 | set(handles.time_first,'String',time_first_cell); |
---|
| 3040 | set(handles.time_last,'String',time_last_cell); |
---|
| 3041 | |
---|
| 3042 | %-------------------------------------------------------------------- |
---|
| 3043 | % --- Executes on selection change in VelTypeMenu. |
---|
| 3044 | function VelTypeMenu_Callback(hObject, eventdata, handles) |
---|
| 3045 | % VelTypeList=get(handles.VelTypeMenu,'String'); |
---|
| 3046 | % VelTypeIndex=get(handles.VelTypeMenu,'Value'); |
---|
| 3047 | % VelTypeCell=get(handles.VelType,'String'); |
---|
| 3048 | % VelTypeCell{1}=VelTypeList{VelTypeIndex}; |
---|
| 3049 | % set(handles.VelType,'String',VelTypeCell) |
---|
| 3050 | |
---|
| 3051 | |
---|
| 3052 | %-------------------------------------------------------------------- |
---|
| 3053 | % --- Executes on button press in GetObject. |
---|
| 3054 | function GetObject_Callback(hObject, eventdata, handles) |
---|
| 3055 | hseries=get(handles.GetObject,'parent'); |
---|
| 3056 | SeriesData=get(hseries,'UserData'); |
---|
| 3057 | value=get(handles.GetObject,'Value'); |
---|
| 3058 | if value |
---|
| 3059 | set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
| 3060 | DataInit.ParentButton=handles.GetObject; |
---|
| 3061 | hset_object=findobj(allchild(0),'Name','set_object');%find the set_object interface handle |
---|
| 3062 | if ishandle(hset_object) |
---|
| 3063 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface |
---|
| 3064 | else |
---|
| 3065 | DataInit.TITLE='POINTS';%default option |
---|
| 3066 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface |
---|
| 3067 | end |
---|
| 3068 | else |
---|
| 3069 | set(handles.GetObject,'BackgroundColor',[0 1 0])%put activated buttons to green |
---|
| 3070 | if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object) |
---|
| 3071 | close(SeriesData.hset_object) |
---|
| 3072 | end |
---|
| 3073 | end |
---|
| 3074 | set(hseries,'UserData',SeriesData) |
---|
| 3075 | |
---|
| 3076 | %-------------------------------------------------------------- |
---|
| 3077 | function GetMask_Callback(hObject, eventdata, handles) |
---|
| 3078 | value=get(handles.GetMask,'Value'); |
---|
| 3079 | if value |
---|
| 3080 | errordlg('not implemented yet') |
---|
| 3081 | end |
---|
| 3082 | %-------------------------------------------------------------- |
---|
| 3083 | |
---|
| 3084 | %-------------------------------------------------------------------------- |
---|
| 3085 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
| 3086 | function ncbrowser_uvmat(hObject, eventdata) |
---|
| 3087 | bla=get(gcbo,'String'); |
---|
| 3088 | ind=get(gcbo,'Value'); |
---|
| 3089 | filename=cell2mat(bla(ind)); |
---|
| 3090 | blank=find(filename==' '); |
---|
| 3091 | filename=filename(1:blank-1); |
---|
| 3092 | get_field(filename) |
---|
| 3093 | |
---|
| 3094 | |
---|
| 3095 | |
---|
| 3096 | % -------------------------------------------------------------------- |
---|
| 3097 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 3098 | |
---|
| 3099 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 3100 | pathelp=fileparts(path_to_uvmat); |
---|
| 3101 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 3102 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 3103 | else |
---|
| 3104 | web([helpfile '#series']) |
---|
| 3105 | end |
---|
| 3106 | |
---|
| 3107 | |
---|
| 3108 | |
---|
| 3109 | |
---|
| 3110 | |
---|
| 3111 | |
---|