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