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