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 | % time=[]; |
---|
1018 | % ref_time=[]; |
---|
1019 | ref_time=0; |
---|
1020 | % if isfield(SeriesData,'Time')&~isempty(SeriesData.Time{Val})&~isequal(SeriesData.Time{Val},0) |
---|
1021 | % time=SeriesData.Time{Val}; %get the set of times |
---|
1022 | % siztime=size(time); |
---|
1023 | % nbfield=siztime(1); |
---|
1024 | % nbfield2=siztime(2); |
---|
1025 | % % test_imadoc=1; |
---|
1026 | % else |
---|
1027 | % test_imadoc=0;%no image documentation file |
---|
1028 | nbfield=50; |
---|
1029 | nbfield2=50;%default max number of pairs |
---|
1030 | % end |
---|
1031 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1032 | % be performed, while the result is needed for next steps. |
---|
1033 | displ_pair={''}; |
---|
1034 | displ_num=[]; |
---|
1035 | ind_exist=0; |
---|
1036 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
1037 | if length(TimeUnit)>=1 |
---|
1038 | dtunit=['m' TimeUnit]; |
---|
1039 | else |
---|
1040 | dtunit='e-03'; |
---|
1041 | end |
---|
1042 | if strcmp(mode,'series(Di)') |
---|
1043 | nbfield |
---|
1044 | for index=1:min(nbfield-1,50) |
---|
1045 | filename=name_generator(filebase,ref_i-floor(index/2),ref_j,'.nc',NomType,1,ref_i+ceil(index/2),ref_j,subdir); |
---|
1046 | select=(exist(filename,'file')==2); |
---|
1047 | if select==1 |
---|
1048 | ind_exist=ind_exist+1; |
---|
1049 | displ_num(1,ind_exist)=0; |
---|
1050 | displ_num(2,ind_exist)=0; |
---|
1051 | displ_num(3,ind_exist)=-floor(index/2); |
---|
1052 | displ_num(4,ind_exist)=ceil(index/2); |
---|
1053 | %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'}); |
---|
1054 | [Cte,var_detect,ichoice]=nc2struct(filename,{}); |
---|
1055 | if isfield(Cte,'dt2') |
---|
1056 | dt=Cte.dt2; |
---|
1057 | elseif isfield(Cte,'dt') |
---|
1058 | dt=Cte.dt; |
---|
1059 | end |
---|
1060 | if isfield(Cte,'absolut_time_TO_2') |
---|
1061 | ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
1062 | elseif isfield(Cte,'absolut_time_TO') |
---|
1063 | ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
1064 | elseif isfield(Cte,'Time') |
---|
1065 | ref_time(ind_exist)=Cte.Time; |
---|
1066 | end |
---|
1067 | displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
1068 | end |
---|
1069 | end |
---|
1070 | set(handles.list_pair_civ,'String',[displ_pair';{'Di=*|*'}]); |
---|
1071 | elseif isequal(mode,'series(Dj)')% series on the j index |
---|
1072 | for index=1:min(nbfield2-1,50) |
---|
1073 | filename=name_generator(filebase,ref_i,ref_j-floor(index/2),'.nc',NomType,1,ref_i,ref_j+ceil(index/2),subdir); |
---|
1074 | select=(exist(filename,'file')==2); |
---|
1075 | if select==1 |
---|
1076 | ind_exist=ind_exist+1; |
---|
1077 | displ_num(1,ind_exist)=-floor(index/2); |
---|
1078 | displ_num(2,ind_exist)=ceil(index/2); |
---|
1079 | displ_num(3,ind_exist)=0; |
---|
1080 | displ_num(4,ind_exist)=0; |
---|
1081 | %[cte_detect,vdt,cte_read]=read_netcdf(filename,{'dt','dt2','absolut_time_T0','absolute_time_TO_2'}); |
---|
1082 | [Cte,var_detect,ichoice]=nc2struct(filename,{}); |
---|
1083 | if isfield(Cte,'dt2') |
---|
1084 | dt=Cte.dt2; |
---|
1085 | elseif isfield(Cte,'dt') |
---|
1086 | dt=Cte.dt; |
---|
1087 | end |
---|
1088 | if isfield(Cte,'absolut_time_TO_2') |
---|
1089 | ref_time(ind_exist)=Cte.absolut_time_TO_2;%civ2 data used in priority |
---|
1090 | elseif isfield(Cte,'absolut_time_TO') |
---|
1091 | ref_time(ind_exist)=Cte.absolut_time_TO;%civ2 data used in priorit |
---|
1092 | elseif isfield(Cte,'Time') |
---|
1093 | ref_time(ind_exist)=Cte.Time; |
---|
1094 | end |
---|
1095 | % if cte_detect(2)==1; |
---|
1096 | % dt=cte_read(2); |
---|
1097 | % ref_time(ind_exist)=cte_read(4);%civ2 data used in priority |
---|
1098 | % else |
---|
1099 | % dt=cte_read(1); |
---|
1100 | % ref_time(ind_exist)=cte_read(3); |
---|
1101 | % end |
---|
1102 | displ_pair{ind_exist}=['Dj= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit]; |
---|
1103 | end |
---|
1104 | end |
---|
1105 | set(handles.list_pair_civ,'String',[displ_pair';{'Dj=*|*'}]); |
---|
1106 | elseif isequal(mode,'bursts') %case of bursts |
---|
1107 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'bursts' mode |
---|
1108 | for numod_b=(numod_a+1):nbfield2 |
---|
1109 | [filename]=name_generator(filebase,ref_i,numod_a,'.nc',NomType,1,ref_i,numod_b,subdir); |
---|
1110 | select=(exist(filename,'file')==2); |
---|
1111 | if select==1 |
---|
1112 | ind_exist=ind_exist+1; |
---|
1113 | numlist_a(ind_exist)=numod_a; |
---|
1114 | numlist_b(ind_exist)=numod_b; |
---|
1115 | Attr=nc2struct(filename,[]); |
---|
1116 | isfield(Attr,'absolut_time_T0_2') |
---|
1117 | if isfield(Attr,'dt2') |
---|
1118 | dt(ind_exist)=Attr.dt2; |
---|
1119 | ref_time(ind_exist)=Attr.absolut_time_T0_2; |
---|
1120 | elseif isfield(Attr,'dt')& isfield(Attr,'absolut_time_T0') |
---|
1121 | dt(ind_exist)=Attr.dt; |
---|
1122 | ref_time(ind_exist)=Attr.absolut_time_T0; |
---|
1123 | else |
---|
1124 | dt(ind_exist)=NaN;%no information on dt |
---|
1125 | end |
---|
1126 | %determine nom_type_ima for pair display (used in num2stra.m) |
---|
1127 | switch NomType |
---|
1128 | case {'#ab'} |
---|
1129 | nom_type_ima='#a'; |
---|
1130 | case {'#AB'} |
---|
1131 | nom_type_ima='#A'; |
---|
1132 | otherwise |
---|
1133 | nom_type_ima='_i_j'; |
---|
1134 | end |
---|
1135 | displ_pair{ind_exist}=['j= ' num2stra(numod_a,nom_type_ima,2) '-' num2stra(numod_b,nom_type_ima,2) ... |
---|
1136 | ' :dt= ' num2str(dt(ind_exist)*1000)]; |
---|
1137 | end |
---|
1138 | end |
---|
1139 | set(handles.list_pair_civ,'String',[displ_pair';{'j=*-*'}]); |
---|
1140 | end |
---|
1141 | if exist('dt','var') & ~isempty(dt) |
---|
1142 | [dtsort,indsort]=sort(dt); |
---|
1143 | displ_num(1,:)=numlist_a(indsort); |
---|
1144 | displ_num(2,:)=numlist_b(indsort); |
---|
1145 | displ_num(3,:)=0; |
---|
1146 | displ_num(4,:)=0; |
---|
1147 | displ_pair=displ_pair(indsort); |
---|
1148 | ref_time=ref_time(indsort); |
---|
1149 | end |
---|
1150 | end |
---|
1151 | if ind_exist==0 |
---|
1152 | if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') |
---|
1153 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir]) |
---|
1154 | else |
---|
1155 | msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir]) |
---|
1156 | end |
---|
1157 | if isequal(mode,'bursts') %case of bursts |
---|
1158 | set(handles.list_pair_civ,'String',{'j=*-*'}); |
---|
1159 | elseif isequal(mode,'series(Di)') %case of bursts |
---|
1160 | set(handles.list_pair_civ,'String',{'Di=*|*'}); |
---|
1161 | elseif isequal(mode,'series(Dj)') %case of bursts |
---|
1162 | set(handles.list_pair_civ,'String',{'Dj=*|*'}); |
---|
1163 | end |
---|
1164 | end |
---|
1165 | |
---|
1166 | val=get(handles.list_pair_civ,'Value'); |
---|
1167 | if val > length(displ_pair) |
---|
1168 | set(handles.list_pair_civ,'Value',1);% first pair proposed by default in the menu |
---|
1169 | val=1; |
---|
1170 | end |
---|
1171 | iview=get(handles.NomType,'Value'); |
---|
1172 | SeriesData.displ_num(iview,:)=(displ_num(:,val))'; |
---|
1173 | SeriesData.ref_time=ref_time; |
---|
1174 | set(handles.figure1,'UserData',SeriesData) |
---|
1175 | list_pair_civ_Callback(hObject, eventdata, handles) |
---|
1176 | |
---|
1177 | %------------------------------------------------------------- |
---|
1178 | % --- Executes on selection in list_pair_civ. |
---|
1179 | function list_pair_civ_Callback(hObject, eventdata, handles) |
---|
1180 | %------------------------------------------------------------ |
---|
1181 | |
---|
1182 | %update first_i and last_i according to the chosen image pairs |
---|
1183 | testupdate=0; |
---|
1184 | Val=get(handles.RootPath,'Value'); |
---|
1185 | IndexCell=get(handles.NomType,'String'); |
---|
1186 | %hseries=get(handles.list_pair_civ,'parent'); |
---|
1187 | SeriesData=get(handles.figure1,'UserData'); |
---|
1188 | NomType=SeriesData.NomType{Val}; |
---|
1189 | list_pair=get(handles.list_pair_civ,'String');%get the menu of image pairs |
---|
1190 | index_pair=get(handles.list_pair_civ,'Value'); |
---|
1191 | str_pair=list_pair{index_pair}; |
---|
1192 | ind_equ=strfind(str_pair,'=');%find '=' |
---|
1193 | ind_sep=strfind(str_pair,'|');%find pair separator '|' |
---|
1194 | ind_com=strfind(str_pair,':');%find ':' |
---|
1195 | test_bursts=0; |
---|
1196 | if isempty(ind_sep) |
---|
1197 | ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|' |
---|
1198 | test_bursts=1;% we are in the case of bursts |
---|
1199 | end |
---|
1200 | displ_num=[0 0 0 0]; %default |
---|
1201 | if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-') |
---|
1202 | num1_str=str_pair(ind_equ(1)+1:ind_sep-1); |
---|
1203 | num2_str=str_pair(ind_sep+1:ind_com-1); |
---|
1204 | num1=str2double(num1_str); |
---|
1205 | num2=str2double(num2_str); |
---|
1206 | if isequal(num1_str(1),' ') |
---|
1207 | num1_str(1)=[]; |
---|
1208 | end |
---|
1209 | if isequal(num2_str(end),' ') |
---|
1210 | num2_str(end)=[]; |
---|
1211 | end |
---|
1212 | switch NomType |
---|
1213 | case {'_i1-i2_j'} |
---|
1214 | if isequal(num1_str(1),'0') |
---|
1215 | IndexCell{Val}=['_(i-(i+' num2_str ')_j']; |
---|
1216 | else |
---|
1217 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j']; |
---|
1218 | end |
---|
1219 | displ_num(3)=num1; |
---|
1220 | displ_num(4)=num2; |
---|
1221 | case {'_i1-i2'} |
---|
1222 | if isequal(num1_str(1),'0') |
---|
1223 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
1224 | else |
---|
1225 | IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')']; |
---|
1226 | end |
---|
1227 | displ_num(3)=num1; |
---|
1228 | displ_num(4)=num2; |
---|
1229 | case '_i_j1-j2' |
---|
1230 | if test_bursts |
---|
1231 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
1232 | else |
---|
1233 | if isequal(num1_str(1),'0') |
---|
1234 | IndexCell{Val}=['_i_j-(j+' num2_str ')']; |
---|
1235 | else |
---|
1236 | IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')']; |
---|
1237 | end |
---|
1238 | end |
---|
1239 | displ_num(1)=num1; |
---|
1240 | displ_num(2)=num2; |
---|
1241 | case {'#_ab'} %TO COMPLETE |
---|
1242 | IndexCell{Val}=['_i_' num1_str '-' num2_str ]; |
---|
1243 | |
---|
1244 | end |
---|
1245 | end |
---|
1246 | set(handles.NomType,'String',IndexCell) |
---|
1247 | SeriesData.displ_num(Val,:)=displ_num; |
---|
1248 | set(handles.figure1,'UserData',SeriesData) |
---|
1249 | % set(handles.NomType,'Value',Val) |
---|
1250 | |
---|
1251 | if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*') |
---|
1252 | mode_list=get(handles.mode,'String'); |
---|
1253 | mode_value=get(handles.mode,'Value'); |
---|
1254 | mode=mode_list{mode_value}; |
---|
1255 | if isequal(mode,'series(Di)') |
---|
1256 | first_i=str2num(get(handles.first_i,'String')); |
---|
1257 | last_i=str2num(get(handles.last_i,'String')); |
---|
1258 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1259 | num1=first_i:incr_i:last_i; |
---|
1260 | lastfieldCell=get(handles.nb_field,'String'); |
---|
1261 | lastfield=str2num(lastfieldCell{1}); |
---|
1262 | if ~isempty(lastfield) |
---|
1263 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1264 | num1=num1(ind); |
---|
1265 | end |
---|
1266 | if ~isempty(num1) |
---|
1267 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1268 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1269 | end |
---|
1270 | testupdate=1; |
---|
1271 | elseif isequal(mode,'series(Dj)') |
---|
1272 | first_j=str2num(get(handles.first_j,'String')); |
---|
1273 | last_j=str2num(get(handles.last_j,'String')); |
---|
1274 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1275 | num_j=first_j:incr_j:last_j; |
---|
1276 | lastfieldCell=get(handles.nb_field2,'String'); |
---|
1277 | if ~isempty(lastfieldCell) |
---|
1278 | lastfield2=lastfieldCell{1}; |
---|
1279 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1280 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1281 | end |
---|
1282 | testupdate=1; |
---|
1283 | end |
---|
1284 | |
---|
1285 | %update the first and last times of the series |
---|
1286 | if testupdate && isfield(SeriesData,'Time') |
---|
1287 | if ~isempty(SeriesData.Time{1}) |
---|
1288 | displ_time(handles,SeriesData.Time{1}); |
---|
1289 | end |
---|
1290 | end |
---|
1291 | end |
---|
1292 | |
---|
1293 | %------------------------------------------------------------------------ |
---|
1294 | % --- Executes on button press in RUN. |
---|
1295 | function RUN_Callback(hObject, eventdata, handles) |
---|
1296 | %------------------------------------------------------------------------ |
---|
1297 | %read root name and field type |
---|
1298 | set(handles.RUN,'BusyAction','queue'); |
---|
1299 | %hseries=get(handles.RUN,'parent'); |
---|
1300 | set(0,'CurrentFigure',handles.figure1) |
---|
1301 | if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1) |
---|
1302 | Series.GetObject=1; |
---|
1303 | GetObject_Callback(hObject, eventdata, handles) |
---|
1304 | else |
---|
1305 | Series.GetObject=0; |
---|
1306 | end |
---|
1307 | SeriesData=get(handles.figure1,'UserData'); |
---|
1308 | |
---|
1309 | %reinitiate waitbar position |
---|
1310 | Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS |
---|
1311 | waitbarpos=Series.WaitbarPos; |
---|
1312 | waitbarpos(4)=0.005;%reinitialize waitbar to zero height |
---|
1313 | waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005; |
---|
1314 | set(handles.waitbar,'Position',waitbarpos) |
---|
1315 | |
---|
1316 | % read input file parameters and set menus |
---|
1317 | Series.PathProject=get(handles.PathCampaign,'String'); |
---|
1318 | RootPath=get(handles.RootPath,'String');% path of the root name of the first field series |
---|
1319 | RootFile=get(handles.RootFile,'String');% root name of the first field series |
---|
1320 | SubDir=get(handles.SubDir,'String');% subdirectory for netcdf files |
---|
1321 | FileExt=get(handles.FileExt,'String');%file extension |
---|
1322 | if isempty(SeriesData) |
---|
1323 | msgbox_uvmat('ERROR','no input file series') |
---|
1324 | return |
---|
1325 | end |
---|
1326 | NomType=SeriesData.NomType; |
---|
1327 | if length(RootPath)==1 %string character input for user fct |
---|
1328 | Series.RootPath=RootPath{1}; |
---|
1329 | Series.RootFile=RootFile{1}; |
---|
1330 | Series.SubDir=SubDir{1}; |
---|
1331 | Series.FileExt=FileExt{1}; |
---|
1332 | Series.NomType=NomType{1}; |
---|
1333 | else %cell input for user fct |
---|
1334 | Series.RootPath=RootPath; |
---|
1335 | Series.RootFile=RootFile; |
---|
1336 | Series.SubDir=SubDir; |
---|
1337 | Series.FileExt=FileExt; |
---|
1338 | Series.NomType=NomType; |
---|
1339 | end |
---|
1340 | if isequal(get(handles.FieldMenu,'Visible'),'on') |
---|
1341 | FieldMenu=get(handles.FieldMenu,'String'); |
---|
1342 | FieldValue=get(handles.FieldMenu,'Value'); |
---|
1343 | Series.Field=FieldMenu(FieldValue); |
---|
1344 | end |
---|
1345 | menu_coord_state=get(handles.transform_fct,'Visible'); |
---|
1346 | Series.CoordType='';%default |
---|
1347 | if isequal(menu_coord_state,'on') |
---|
1348 | % menu_coord=get(handles.transform_fct,'String'); |
---|
1349 | menu_index=get(handles.transform_fct,'Value'); |
---|
1350 | transform_list=get(handles.transform_fct,'UserData'); |
---|
1351 | Series.transform_fct=transform_list{menu_index};% transform function handles |
---|
1352 | end |
---|
1353 | Series.hseries=handles.figure1; % handles to the series GUI |
---|
1354 | |
---|
1355 | %read the set of field numbers |
---|
1356 | first_i=str2num(get(handles.first_i,'String')); |
---|
1357 | last_i=str2num(get(handles.last_i,'String')); |
---|
1358 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1359 | first_j=str2num(get(handles.first_j,'String')); |
---|
1360 | last_j=str2num(get(handles.last_j,'String')); |
---|
1361 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1362 | if ~isequal(get(handles.first_i,'Visible'),'on') |
---|
1363 | first_i=1; |
---|
1364 | last_i=1; |
---|
1365 | incr_i=1; |
---|
1366 | end |
---|
1367 | if ~isequal(get(handles.first_j,'Visible'),'on') |
---|
1368 | first_j=1; |
---|
1369 | last_j=1; |
---|
1370 | incr_j=1; |
---|
1371 | end |
---|
1372 | Series.NbSlice=str2num(get(handles.NbSlice,'String')); |
---|
1373 | if isequal(first_i,[])|isequal(first_j,[]), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
1374 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1375 | if isequal(last_i,[])| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
1376 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1377 | if isequal(incr_i,[])| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
1378 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1379 | if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1380 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
1381 | num_i=[first_i:incr_i:last_i]; |
---|
1382 | num_j=[first_j:incr_j:last_j]; |
---|
1383 | nbfield_cell=get(handles.nb_field,'String'); |
---|
1384 | nbfield=[]; %default |
---|
1385 | for iview=1:length(nbfield_cell) |
---|
1386 | nb=str2num(nbfield_cell{iview}); |
---|
1387 | if ~isempty(nb) |
---|
1388 | nbfield=[nbfield nb]; |
---|
1389 | end |
---|
1390 | end |
---|
1391 | nbfield=min(nbfield); |
---|
1392 | nbfield2_cell=get(handles.nb_field2,'String'); |
---|
1393 | nbfield2=[]; %default |
---|
1394 | for iview=1:length(nbfield2_cell) |
---|
1395 | nb=str2num(nbfield2_cell{iview}); |
---|
1396 | if ~isempty(nb) |
---|
1397 | nbfield2=[nbfield2 nb]; |
---|
1398 | end |
---|
1399 | end |
---|
1400 | nbfield2=min(nbfield2); |
---|
1401 | |
---|
1402 | %get complementary information from the 'series' interface |
---|
1403 | list_action=get(handles.ACTION,'String');% list menu action |
---|
1404 | index_action=get(handles.ACTION,'Value');% selected string index |
---|
1405 | action= list_action{index_action}; % selected string |
---|
1406 | mode_list=get(handles.mode,'String'); |
---|
1407 | index_mode=get(handles.mode,'Value'); |
---|
1408 | mode=mode_list{index_mode}; |
---|
1409 | ind_shift=0;%default |
---|
1410 | |
---|
1411 | %determine the list of input file names |
---|
1412 | nbmissing=0; |
---|
1413 | for iview=1:length(RootPath) |
---|
1414 | %case of pairs (.nc files) |
---|
1415 | |
---|
1416 | if isequal(NomType{iview},'_i_j1-j2')|| isequal(NomType{iview},'_i1-i2_j')|| isequal(NomType{iview},'_i1-i2')|| isequal(NomType{iview},'#_ab') |
---|
1417 | ind_shift=SeriesData.displ_num(iview,:); |
---|
1418 | if isequal(ind_shift,[0 0 0 0]) % undefined pairs |
---|
1419 | if isequal(NomType{iview},'#_ab') |
---|
1420 | mode='#_ab'; |
---|
1421 | end |
---|
1422 | [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); |
---|
1423 | else |
---|
1424 | [num_i1,num_i2,num_j1,num_j2,num_i,num_j]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode); |
---|
1425 | if isempty(num_i) |
---|
1426 | msgbox_uvmat('ERROR','ERROR: empty set of input files chosen') |
---|
1427 | return |
---|
1428 | end |
---|
1429 | if num_i(1)>first_i |
---|
1430 | set(handles.first_i,'String',num2str(num_i(1)))%update the display of first field |
---|
1431 | last_i_Callback(hObject, eventdata, handles) |
---|
1432 | end |
---|
1433 | if num_i(end)<last_i |
---|
1434 | set(handles.last_i,'String',num2str(num_i(end)))%update the display of last field |
---|
1435 | last_i_Callback(hObject, eventdata, handles) |
---|
1436 | end |
---|
1437 | if num_j(1)>first_j |
---|
1438 | set(handles.first_j,'String',num2str(num_j(1)))%update the display of first field |
---|
1439 | last_j_Callback(hObject, eventdata, handles) |
---|
1440 | end |
---|
1441 | if num_j(end)<last_j |
---|
1442 | set(handles.last_j,'String',num2str(num_j(end)))%update the display of last field |
---|
1443 | last_j_Callback(hObject, eventdata, handles) |
---|
1444 | end |
---|
1445 | end |
---|
1446 | else%case of images |
---|
1447 | [num_i1,num_j1]=meshgrid(num_i,num_j); |
---|
1448 | num_i2=num_i1; |
---|
1449 | num_j2=num_j1; |
---|
1450 | end |
---|
1451 | if length(RootPath)>1 |
---|
1452 | num_i1_cell{iview}=num_i1; |
---|
1453 | num_i2_cell{iview}=num_i2; |
---|
1454 | num_j1_cell{iview}=num_j1; |
---|
1455 | num_j2_cell{iview}=num_j2; |
---|
1456 | end |
---|
1457 | end |
---|
1458 | |
---|
1459 | % defining the ACTION function handle |
---|
1460 | path_series=which('series'); |
---|
1461 | list_path=get(handles.ACTION,'UserData'); |
---|
1462 | index=get(handles.ACTION,'Value'); |
---|
1463 | fct_path=list_path{index}; %path stored for the function ACTION |
---|
1464 | if ~isequal(fct_path,path_series) |
---|
1465 | eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION |
---|
1466 | if ~exist(fct_path,'dir') |
---|
1467 | msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist']) |
---|
1468 | return |
---|
1469 | end |
---|
1470 | if ~isequal(spath,fct_path) |
---|
1471 | addpath(fct_path)% add the prescribed path if not the current one |
---|
1472 | end |
---|
1473 | end |
---|
1474 | eval(['h_fun=@' action ';'])%create a function handle for ACTION |
---|
1475 | if ~isequal(fct_path,path_series) |
---|
1476 | rmpath(fct_path)% add the prescribed path if not the current one |
---|
1477 | end |
---|
1478 | |
---|
1479 | % RUN ACTION |
---|
1480 | Series.Action=action;%name of the processing programme |
---|
1481 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1482 | |
---|
1483 | if length(RootPath)>1 |
---|
1484 | h_fun(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series); |
---|
1485 | else |
---|
1486 | h_fun(num_i1,num_i2,num_j1,num_j2,Series); |
---|
1487 | end |
---|
1488 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1489 | |
---|
1490 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
1491 | % detect=1; |
---|
1492 | % while detect==1 |
---|
1493 | % namefigfull=[namedoc '.fig']; |
---|
1494 | % hh=dir(namefigfull); |
---|
1495 | % if ~isempty(hh) |
---|
1496 | % detect=1; |
---|
1497 | % namedoc=[namedoc '.0']; |
---|
1498 | % else |
---|
1499 | % detect=0; |
---|
1500 | % end |
---|
1501 | % end |
---|
1502 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
1503 | |
---|
1504 | %------------------------------------------------------------------------ |
---|
1505 | function STOP_Callback(hObject, eventdata, handles) |
---|
1506 | %------------------------------------------------------------------------ |
---|
1507 | set(handles.RUN, 'BusyAction','cancel') |
---|
1508 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1509 | |
---|
1510 | |
---|
1511 | %------------------------------------------------------------------------ |
---|
1512 | function first_i_Callback(hObject, eventdata, handles) |
---|
1513 | %------------------------------------------------------------------------ |
---|
1514 | last_i_Callback(hObject, eventdata, handles) |
---|
1515 | |
---|
1516 | %------------------------------------------------------------------------ |
---|
1517 | function last_i_Callback(hObject, eventdata, handles) |
---|
1518 | %------------------------------------------------------------------------ |
---|
1519 | % hseries=get(handles.last_i,'parent'); |
---|
1520 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1521 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1522 | % ref_i=ceil((first_i+last_i)/2); |
---|
1523 | % set(handles.ref_i,'String', num2str(ref_i)) |
---|
1524 | % ref_i_Callback(hObject, eventdata, handles) |
---|
1525 | SeriesData=get(handles.figure1,'UserData'); |
---|
1526 | if ~isfield(SeriesData,'Time') |
---|
1527 | SeriesData.Time{1}=[]; |
---|
1528 | end |
---|
1529 | displ_time(handles,SeriesData.Time{1}); |
---|
1530 | |
---|
1531 | %------------------------------------------------------------------------ |
---|
1532 | function first_j_Callback(hObject, eventdata, handles) |
---|
1533 | %------------------------------------------------------------------------ |
---|
1534 | last_j_Callback(hObject, eventdata, handles) |
---|
1535 | |
---|
1536 | %------------------------------------------------------------------------ |
---|
1537 | function last_j_Callback(hObject, eventdata, handles) |
---|
1538 | %------------------------------------------------------------------------ |
---|
1539 | first_j=str2num(get(handles.first_j,'String')); |
---|
1540 | last_j=str2num(get(handles.last_j,'String')); |
---|
1541 | ref_j=ceil((first_j+last_j)/2); |
---|
1542 | set(handles.ref_j,'String', num2str(ref_j)) |
---|
1543 | ref_j_Callback(hObject, eventdata, handles) |
---|
1544 | SeriesData=get(handles.figure1,'UserData'); |
---|
1545 | if ~isfield(SeriesData,'Time') |
---|
1546 | SeriesData.Time{1}=[]; |
---|
1547 | end |
---|
1548 | displ_time(handles,SeriesData.Time{1}); |
---|
1549 | |
---|
1550 | |
---|
1551 | %------------------------------------------------------------------------ |
---|
1552 | function ref_i_Callback(hObject, eventdata, handles) |
---|
1553 | %------------------------------------------------------------------------ |
---|
1554 | mode_list=get(handles.mode,'String'); |
---|
1555 | mode_value=get(handles.mode,'Value'); |
---|
1556 | mode=mode_list{mode_value}; |
---|
1557 | %hseries=get(handles.ref_i,'parent'); |
---|
1558 | SeriesData=get(handles.figure1,'UserData'); |
---|
1559 | %NomTypeCell=get(handles.NomType,'String'); |
---|
1560 | NomTypeCell=SeriesData.NomType; |
---|
1561 | if ~isempty(NomTypeCell) |
---|
1562 | Val=get(handles.NomType,'Value'); |
---|
1563 | NomType=NomTypeCell{Val}; |
---|
1564 | % for ilist=1:length(NomType) |
---|
1565 | if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2') |
---|
1566 | if isequal(mode,'series(Di)') |
---|
1567 | find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
1568 | % break |
---|
1569 | end |
---|
1570 | end |
---|
1571 | end |
---|
1572 | |
---|
1573 | %------------------------------------------------------------------------ |
---|
1574 | function ref_j_Callback(hObject, eventdata, handles) |
---|
1575 | %------------------------------------------------------------------------ |
---|
1576 | mode_list=get(handles.mode,'String'); |
---|
1577 | mode_value=get(handles.mode,'Value'); |
---|
1578 | mode=mode_list{mode_value}; |
---|
1579 | %hseries=get(handles.ref_i,'parent'); |
---|
1580 | SeriesData=get(handles.figure1,'UserData'); |
---|
1581 | NomTypeCell=SeriesData.NomType; |
---|
1582 | if ~isempty(NomTypeCell) |
---|
1583 | Val=get(handles.NomType,'Value'); |
---|
1584 | NomType=NomTypeCell{Val}; |
---|
1585 | if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2') |
---|
1586 | if isequal(mode,'series(Dj)') |
---|
1587 | find_netcpair_civ(hObject, eventdata, handles,Val);% update the menu of pairs depending on the available netcdf files |
---|
1588 | end |
---|
1589 | end |
---|
1590 | end |
---|
1591 | |
---|
1592 | %------------------------------------------------------------------------ |
---|
1593 | % --- Executes on selection change in ACTION. |
---|
1594 | function ACTION_Callback(hObject, eventdata, handles) |
---|
1595 | %------------------------------------------------------------------------ |
---|
1596 | global nb_builtin |
---|
1597 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
1598 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
1599 | ACTION= list_ACTION{index_ACTION}; % selected function name |
---|
1600 | path_series=which('series');%path to series.m |
---|
1601 | list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION |
---|
1602 | default_file=fullfile(list_path{end},ACTION); |
---|
1603 | % add a new function to the menu if the selected item is 'more...' |
---|
1604 | if isequal(ACTION,'more...') |
---|
1605 | pathfct=fileparts(path_series); |
---|
1606 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1607 | {'*.m', ' (*.m)'; |
---|
1608 | '*.m', '.m files '; ... |
---|
1609 | '*.*', 'All Files (*.*)'}, ... |
---|
1610 | 'Pick a file',default_file); |
---|
1611 | if length(FileName)<2 |
---|
1612 | return |
---|
1613 | end |
---|
1614 | [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end); |
---|
1615 | if ~isequal(ext_fct,'.m') |
---|
1616 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
1617 | return |
---|
1618 | end |
---|
1619 | |
---|
1620 | % insert the choice in the action menu |
---|
1621 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
1622 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
1623 | list_path{index_ACTION}=PathName; |
---|
1624 | if length(menu_str)>nb_builtin+5; %nb_builtin=nbre of functions always remaining in the initial menu |
---|
1625 | nbremove=length(menu_str)-nb_builtin-5; |
---|
1626 | menu_str(nb_builtin+1:end-5)=[]; |
---|
1627 | list_path(nb_builtin+1:end-4)=[]; |
---|
1628 | index_ACTION=index_ACTION-nbremove; |
---|
1629 | set(handles.ACTION,'Value',index_ACTION) |
---|
1630 | set(handles.ACTION,'String',menu_str) |
---|
1631 | end |
---|
1632 | list_path{index_ACTION}=PathName; |
---|
1633 | set(handles.ACTION,'UserData',list_path); |
---|
1634 | set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
1635 | |
---|
1636 | %record the current menu in personal file profil_perso |
---|
1637 | dir_perso=prefdir; |
---|
1638 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1639 | for ilist=nb_builtin+1:length(menu_str)-1 |
---|
1640 | series_fct{ilist-nb_builtin}=fullfile(list_path{ilist},[menu_str{ilist} '.m']); |
---|
1641 | end |
---|
1642 | if exist(profil_perso,'file') |
---|
1643 | save(profil_perso,'series_fct','-append') |
---|
1644 | else |
---|
1645 | txt=ver('MATLAB'); |
---|
1646 | Release=txt.Release; |
---|
1647 | relnumb=str2num(Release(3:4)); |
---|
1648 | if relnumb >= 14 |
---|
1649 | save(profil_perso,'series_fct','-V6') |
---|
1650 | else |
---|
1651 | save(profil_perso, 'series_fct') |
---|
1652 | end |
---|
1653 | end |
---|
1654 | end |
---|
1655 | |
---|
1656 | %check the current path to the selected function |
---|
1657 | PathName=list_path{index_ACTION};%current recorded path |
---|
1658 | set(handles.path,'String',PathName); %show the path to the senlected function |
---|
1659 | |
---|
1660 | %default setting for the visibility of the GUI elements |
---|
1661 | set(handles.RootPath,'UserData','many') |
---|
1662 | set(handles.SubDir,'Visible','on') |
---|
1663 | set(handles.RootFile,'Visible','on') |
---|
1664 | set(handles.NomType,'Visible','on') |
---|
1665 | set(handles.FileExt,'Visible','on') |
---|
1666 | set(handles.NbSlice,'Visible','off') |
---|
1667 | set(handles.NbSlice_title,'Visible','off') |
---|
1668 | set(handles.VelTypeMenu,'Visible','off'); |
---|
1669 | set(handles.VelType_text,'Visible','off'); |
---|
1670 | set(handles.VelTypeMenu_1,'Visible','off'); |
---|
1671 | set(handles.VelType_text_1,'Visible','off'); |
---|
1672 | view_FieldMenu(handles,'off') |
---|
1673 | view_FieldMenu_1(handles,'off') |
---|
1674 | view_TRANSFORM(handles,'off') |
---|
1675 | set(handles.ProjObject_frame,'Visible','off'); |
---|
1676 | set(handles.GetMask,'Visible','off') |
---|
1677 | set(handles.Mask,'Visible','off') |
---|
1678 | set(handles.GetObject,'Visible','off'); |
---|
1679 | set(handles.ProjObject,'Visible','off'); |
---|
1680 | set(handles.OutputDir,'Visible','off'); |
---|
1681 | set(handles.PARAMETERS_frame,'Visible','off'); |
---|
1682 | set(handles.PARAMETERS_title,'Visible','off'); |
---|
1683 | set(handles.ParamKey,'Visible','off') |
---|
1684 | set(handles.ParamVal,'Visible','off') |
---|
1685 | ParamKey={}; |
---|
1686 | set(handles.FieldMenu,'Enable','off') |
---|
1687 | set(handles.VelTypeMenu,'Enable','off') |
---|
1688 | set(handles.FieldMenu_1,'Enable','off') |
---|
1689 | set(handles.VelTypeMenu_1,'Enable','off') |
---|
1690 | set(handles.transform_fct,'Enable','off') |
---|
1691 | %set the displayed GUI item needed for input parameters |
---|
1692 | if ~isequal(path_series,PathName) |
---|
1693 | addpath(PathName) |
---|
1694 | end |
---|
1695 | eval(['h_function=@' ACTION ';']); |
---|
1696 | if ~isequal(path_series,PathName) |
---|
1697 | rmpath(PathName) |
---|
1698 | end |
---|
1699 | |
---|
1700 | varargout=h_function(); |
---|
1701 | Param_list={}; |
---|
1702 | |
---|
1703 | %nb_series=length(RootFile); |
---|
1704 | FileExt=get(handles.FileExt,'String'); |
---|
1705 | nb_series=length(FileExt); |
---|
1706 | testima_series=1; %test for a list of images only |
---|
1707 | testima=1; |
---|
1708 | testima_1=1; |
---|
1709 | testciv_series=1; |
---|
1710 | for iview=1:nb_series |
---|
1711 | ext=FileExt{iview}; |
---|
1712 | if length(ext)<2 |
---|
1713 | ext='.none'; |
---|
1714 | end |
---|
1715 | testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi'); |
---|
1716 | if ~testimaview |
---|
1717 | if iview==1 |
---|
1718 | testima=0; |
---|
1719 | end |
---|
1720 | if iview==2 |
---|
1721 | testima_1=0; |
---|
1722 | end |
---|
1723 | testima_series=0; |
---|
1724 | end |
---|
1725 | end |
---|
1726 | for ilist=1:length(varargout)-1 |
---|
1727 | switch varargout{ilist} |
---|
1728 | %RootFile always visible |
---|
1729 | case 'RootPath' %visible by default |
---|
1730 | value=lower(varargout{ilist+1}); |
---|
1731 | if isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1732 | set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1733 | end |
---|
1734 | case 'SubDir' %visible by default |
---|
1735 | if isequal(lower(varargout{ilist+1}),'off') |
---|
1736 | set(handles.SubDir,'Visible','off') |
---|
1737 | end |
---|
1738 | case 'RootFile' %visible by default |
---|
1739 | value=lower(varargout{ilist+1}); |
---|
1740 | if isequal(value,'off') |
---|
1741 | set(handles.RootFile,'Visible','off') |
---|
1742 | elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many') |
---|
1743 | set(handles.RootFile,'Visible','on') |
---|
1744 | set(handles.RootFile,'UserData',value)% for use in menu Open_insert |
---|
1745 | end |
---|
1746 | case 'NomType' %visible by default |
---|
1747 | if isequal(lower(varargout{ilist+1}),'off') |
---|
1748 | set(handles.NomType,'Visible','off') |
---|
1749 | end |
---|
1750 | case 'FileExt' %visible by default |
---|
1751 | if isequal(lower(varargout{ilist+1}),'off') |
---|
1752 | set(handles.FileExt,'Visible','off') |
---|
1753 | end |
---|
1754 | case 'NbSlice' %hidden by default |
---|
1755 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1756 | set(handles.NbSlice,'Visible','on') |
---|
1757 | set(handles.NbSlice_title,'Visible','on') |
---|
1758 | end |
---|
1759 | case 'VelTypeMenu' %hidden by default |
---|
1760 | if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two') |
---|
1761 | set(handles.VelTypeMenu,'Enable','on') |
---|
1762 | if nb_series >=1 && ~testima_series |
---|
1763 | set(handles.VelTypeMenu,'Visible','on') |
---|
1764 | set(handles.VelType_text,'Visible','on'); |
---|
1765 | set(handles.Field_frame,'Visible','on') |
---|
1766 | end |
---|
1767 | end |
---|
1768 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1769 | set(handles.VelTypeMenu_1,'Enable','on') |
---|
1770 | if nb_series >=2 && ~testima_series |
---|
1771 | set(handles.VelTypeMenu_1,'Visible','on') |
---|
1772 | set(handles.VelType_text_1,'Visible','on'); |
---|
1773 | end |
---|
1774 | end |
---|
1775 | case 'FieldMenu' %hidden by default |
---|
1776 | if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two') |
---|
1777 | set(handles.FieldMenu,'Enable','on') % test for MenuBorser |
---|
1778 | if nb_series >=1 && ~testima_series |
---|
1779 | view_FieldMenu(handles,'on') |
---|
1780 | end |
---|
1781 | end |
---|
1782 | if isequal(lower(varargout{ilist+1}),'two') |
---|
1783 | set(handles.FieldMenu_1,'Enable','on') |
---|
1784 | if nb_series >=2 && ~testima_1 |
---|
1785 | view_FieldMenu_1(handles,'on') |
---|
1786 | end |
---|
1787 | end |
---|
1788 | case 'CoordType' %hidden by default |
---|
1789 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1790 | set(handles.transform_fct,'Enable','on') |
---|
1791 | view_TRANSFORM(handles,'on') |
---|
1792 | end |
---|
1793 | case 'GetObject' %hidden by default |
---|
1794 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1795 | set(handles.ProjObject_frame,'Visible','on') |
---|
1796 | set(handles.GetObject,'Visible','on'); |
---|
1797 | end |
---|
1798 | case 'Mask' %hidden by default |
---|
1799 | if isequal(lower(varargout{ilist+1}),'on') |
---|
1800 | set(handles.ProjObject_frame,'Visible','on') |
---|
1801 | set(handles.GetMask,'Visible','on'); |
---|
1802 | end |
---|
1803 | case 'PARAMETER' |
---|
1804 | set(handles.PARAMETERS_frame,'Visible','on') |
---|
1805 | set(handles.PARAMETERS_title,'Visible','on') |
---|
1806 | set(handles.ParamKey,'Visible','on') |
---|
1807 | %set(handles.ParamVal,'Visible','on') |
---|
1808 | Param_str=varargout{ilist+1}; |
---|
1809 | Param_list=[Param_list; {Param_str}]; |
---|
1810 | end |
---|
1811 | end |
---|
1812 | if ~isempty(Param_list) |
---|
1813 | set(handles.ParamKey,'String',Param_list) |
---|
1814 | set(handles.ParamVal,'Visible','on') |
---|
1815 | end |
---|
1816 | |
---|
1817 | %------------------------------------------------------------------------ |
---|
1818 | % --- Executes on selection change in FieldMenu. |
---|
1819 | function FieldMenu_Callback(hObject, eventdata, handles) |
---|
1820 | %------------------------------------------------------------------------ |
---|
1821 | field_str=get(handles.FieldMenu,'String'); |
---|
1822 | field_index=get(handles.FieldMenu,'Value'); |
---|
1823 | field=field_str{field_index(1)}; |
---|
1824 | if isequal(field,'get_field...') |
---|
1825 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
1826 | if ~isempty(hget_field) |
---|
1827 | delete(hget_field)%delete opened versions of get_field |
---|
1828 | end |
---|
1829 | %hseries=get(handles.FieldMenu,'parent'); |
---|
1830 | SeriesData=get(handles.figure1,'UserData'); |
---|
1831 | filename=SeriesData.CurrentInputFile; |
---|
1832 | if exist(filename,'file') |
---|
1833 | get_field(filename) |
---|
1834 | end |
---|
1835 | elseif isequal(field,'more...') |
---|
1836 | str=calc_field; |
---|
1837 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1838 | 'SelectionMode','single',... |
---|
1839 | 'ListString',str); |
---|
1840 | % edit the choice in the fields and action menu |
---|
1841 | scalar=cell2mat(str(ind_answer)); |
---|
1842 | update_menu(handles.FieldMenu,scalar) |
---|
1843 | end |
---|
1844 | |
---|
1845 | %------------------------------------------------------------------------ |
---|
1846 | % --- Executes on selection change in FieldMenu_1. |
---|
1847 | function FieldMenu_1_Callback(hObject, eventdata, handles) |
---|
1848 | %------------------------------------------------------------------------ |
---|
1849 | field_str=get(handles.FieldMenu_1,'String'); |
---|
1850 | field_index=get(handles.FieldMenu_1,'Value'); |
---|
1851 | field=field_str{field_index}; |
---|
1852 | if isequal(field,'get_field...') |
---|
1853 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
1854 | if ~isempty(hget_field) |
---|
1855 | delete(hget_field) |
---|
1856 | end |
---|
1857 | %hseries=get(handles.FieldMenu,'parent'); |
---|
1858 | SeriesData=get(handles.figure1,'UserData'); |
---|
1859 | filename=SeriesData.CurrentInputFile_1; |
---|
1860 | if exist(filename,'file') |
---|
1861 | hget_field=get_field(filename); |
---|
1862 | set(hget_field,'name','get_field_1') |
---|
1863 | end |
---|
1864 | elseif isequal(field,'more...') |
---|
1865 | str=calc_field; |
---|
1866 | [ind_answer,v] = listdlg('PromptString','Select a file:',... |
---|
1867 | 'SelectionMode','single',... |
---|
1868 | 'ListString',str); |
---|
1869 | % edit the choice in the fields and action menu |
---|
1870 | scalar=cell2mat(str(ind_answer)); |
---|
1871 | update_menu(handles.FieldMenu_1,scalar) |
---|
1872 | end |
---|
1873 | |
---|
1874 | %----------------------------- |
---|
1875 | function mouse_up_gui(ggg,eventdata,handles) |
---|
1876 | if isequal(get(ggg,'SelectionType'),'alt') |
---|
1877 | display('global CurData, UserData of GUI series') |
---|
1878 | global CurData |
---|
1879 | CurData=get(ggg,'UserData'); |
---|
1880 | evalin('base','global CurData');%make CurData global in the workspace |
---|
1881 | evalin('base','CurData'); %display CurData in the workspace |
---|
1882 | commandwindow |
---|
1883 | % plot_text(CurData) |
---|
1884 | end |
---|
1885 | |
---|
1886 | %%%%%%%%%%%%% |
---|
1887 | function [ind_remove]=find_pairs(dirpair,ind_i,last_i) |
---|
1888 | |
---|
1889 | indsel=ind_i; |
---|
1890 | indiff=diff(ind_i); %test index increment to detect multiplets (several pairs with the same index ind_i) and holes in the series |
---|
1891 | indiff=[1 indiff last_i-ind_i(end)+1];%for testing gaps with the imposed bounds |
---|
1892 | if ~isempty(indiff) |
---|
1893 | indiff2=diff(indiff); |
---|
1894 | indiffp=[indiff2 1]; |
---|
1895 | indiffm=[1 indiff2]; |
---|
1896 | ind_multi_m=find((indiff==0)&(indiffm<0))-1;%indices of first members of multiplets |
---|
1897 | ind_multi_p=find((indiff==0)&(indiffp>0));%indices of last members of multiplets |
---|
1898 | %for each multiplet, select the most recent file |
---|
1899 | ind_remove=[]; |
---|
1900 | for i=1:length(ind_multi_m) |
---|
1901 | ind_pairs=ind_multi_m(i):ind_multi_p(i); |
---|
1902 | for imulti=1:length(ind_pairs) |
---|
1903 | datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);%dates of creation |
---|
1904 | end |
---|
1905 | [datenew,indsort2]=sort(datepair); %sort the multiplet by creation date |
---|
1906 | ind_s=indsort2(1:end-1);% |
---|
1907 | ind_remove=[ind_remove ind_pairs(ind_s)];%remove these indices, leave the last one |
---|
1908 | end |
---|
1909 | end |
---|
1910 | |
---|
1911 | %------------------------------------------------------------------------ |
---|
1912 | % --- determine the list of index pairs of processing file |
---|
1913 | 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) |
---|
1914 | %------------------------------------------------------------------------ |
---|
1915 | num_i1=num_i;% set of first image numbers by default |
---|
1916 | num_i2=num_i; |
---|
1917 | num_j1=num_j; |
---|
1918 | num_j2=num_j; |
---|
1919 | num_i_out=num_i; |
---|
1920 | num_j_out=num_j; |
---|
1921 | if isequal (NomType,'_i1-i2_j') || isequal (NomType,'_i1-i2') |
---|
1922 | num_i1_line=num_i+ind_shift(3);% set of first image numbers |
---|
1923 | num_i2_line=num_i+ind_shift(4); |
---|
1924 | % adjust the first and last field number |
---|
1925 | indsel=find(num_i1_line >= 1); |
---|
1926 | num_i_out=num_i(indsel); |
---|
1927 | num_i1_line=num_i1_line(indsel); |
---|
1928 | num_i2_line=num_i2_line(indsel); |
---|
1929 | num_j1=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1930 | num_j2=meshgrid(num_j,ones(size(num_i1_line))); |
---|
1931 | [xx,num_i1]=meshgrid(num_j,num_i1_line); |
---|
1932 | [xx,num_i2]=meshgrid(num_j,num_i2_line); |
---|
1933 | elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab') |
---|
1934 | if isequal(mode,'bursts') %case of bursts (png_old or png_2D) |
---|
1935 | num_j1=ind_shift(1)*ones(size(num_i)); |
---|
1936 | num_j2=ind_shift(2)*ones(size(num_i)); |
---|
1937 | else |
---|
1938 | num_j1_col=num_j+ind_shift(1);% set of first image numbers |
---|
1939 | num_j2_col=num_j+ind_shift(2); |
---|
1940 | % adjust the first field number |
---|
1941 | indsel=find((num_j1_col >= 1)); |
---|
1942 | num_j_out=num_j(indsel); |
---|
1943 | num_j1_col=num_j1_col(indsel); |
---|
1944 | num_j2_col=num_j2_col(indsel); |
---|
1945 | [num_i1,num_j1]=meshgrid(num_i,num_j1_col); |
---|
1946 | [num_i2,num_j2]=meshgrid(num_i,num_j2_col); |
---|
1947 | end |
---|
1948 | end |
---|
1949 | |
---|
1950 | %------------------------------------------------------------------------ |
---|
1951 | % ---- find the times corresponding to the first and last indices of a series |
---|
1952 | function displ_time(handles,times) |
---|
1953 | %------------------------------------------------------------------------ |
---|
1954 | hseries=get(handles.last_i,'parent'); |
---|
1955 | SeriesData=get(hseries,'UserData');% |
---|
1956 | first_i=str2num(get(handles.first_i,'String')); |
---|
1957 | first_j=str2num(get(handles.first_j,'String')); |
---|
1958 | last_i=str2num(get(handles.last_i,'String')); |
---|
1959 | last_j=str2num(get(handles.last_j,'String')); |
---|
1960 | % index_civ=get(handles.list_pair_civ,'Value'); |
---|
1961 | % NomType=get(handles.NomType,'String'); |
---|
1962 | NomType=SeriesData.NomType; |
---|
1963 | mode_list=get(handles.mode,'String'); |
---|
1964 | index_mode=get(handles.mode,'Value'); |
---|
1965 | mode=mode_list{index_mode}; |
---|
1966 | % ind_shift=0;%default |
---|
1967 | |
---|
1968 | time_first=[]; |
---|
1969 | time_last=[]; |
---|
1970 | if ~isfield(SeriesData,'Time') |
---|
1971 | SeriesData.Time{1}=[]; |
---|
1972 | end |
---|
1973 | for iview=1:length(NomType) |
---|
1974 | time_first_cell{iview}='?'; |
---|
1975 | time_last_cell{iview}='?';%default |
---|
1976 | time=SeriesData.Time{iview}; |
---|
1977 | if isequal(NomType{iview},'_i1-i2_j')|isequal(NomType{iview},'_i_j1-j2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_i1-i2') |
---|
1978 | if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num) |
---|
1979 | ind_shift=SeriesData.displ_num(iview,:); |
---|
1980 | if isequal(mode,'bursts') |
---|
1981 | first_j=0; |
---|
1982 | last_j=0; |
---|
1983 | end |
---|
1984 | first_i1=first_i +ind_shift(3); |
---|
1985 | first_i2 =first_i +ind_shift(4); |
---|
1986 | first_j1 =first_j +ind_shift(1); |
---|
1987 | first_j2 =first_j +ind_shift(2); |
---|
1988 | last_i1=last_i +ind_shift(3); |
---|
1989 | last_i2 =last_i +ind_shift(4); |
---|
1990 | last_j1 =last_j +ind_shift(1); |
---|
1991 | last_j2 =last_j +ind_shift(2); |
---|
1992 | siz=size(SeriesData.Time{1}); |
---|
1993 | if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2 |
---|
1994 | time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2; |
---|
1995 | time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2; |
---|
1996 | else%read the time in the nc files |
---|
1997 | RootPath=get(handles.RootPath,'String'); |
---|
1998 | RootFile=get(handles.RootFile,'String'); |
---|
1999 | SubDir=get(handles.SubDir,'String'); |
---|
2000 | %VelType=get(handles.VelType,'String'); |
---|
2001 | VelType_str=get(handles.VelTypeMenu,'String'); |
---|
2002 | VelType_val=get(handles.VelTypeMenu,'Value'); |
---|
2003 | VelType=VelType_str{VelType_val}; |
---|
2004 | filebase=fullfile(RootPath{1},RootFile{1}); |
---|
2005 | [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview}); |
---|
2006 | if exist(filefirst,'file') |
---|
2007 | Attrib=nc2struct(filefirst,[]); |
---|
2008 | if isfield(Attrib,'Time') |
---|
2009 | time_first=Attrib.Time; |
---|
2010 | else |
---|
2011 | if isfield(Attrib,'absolut_time_T0') |
---|
2012 | time_first=Attrib.absolut_time_T0; |
---|
2013 | end |
---|
2014 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
2015 | time_first=Attrib.absolut_time_T0_2; |
---|
2016 | end |
---|
2017 | end |
---|
2018 | end |
---|
2019 | [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview}); |
---|
2020 | if exist(filelast,'file') |
---|
2021 | Attrib=nc2struct(filelast,[]); |
---|
2022 | if isfield(Attrib,'Time') |
---|
2023 | time_last=Attrib.Time; |
---|
2024 | else |
---|
2025 | if isfield(Attrib,'absolut_time_T0') |
---|
2026 | time_last=Attrib.absolut_time_T0; |
---|
2027 | end |
---|
2028 | if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1')) |
---|
2029 | time_last=Attrib.absolut_time_T0_2; |
---|
2030 | end |
---|
2031 | end |
---|
2032 | end |
---|
2033 | end |
---|
2034 | end |
---|
2035 | else |
---|
2036 | siz=size(times); |
---|
2037 | if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1 |
---|
2038 | time_first=times(first_i,first_j); |
---|
2039 | time_last=times(last_i,last_j); |
---|
2040 | end |
---|
2041 | end |
---|
2042 | time_first_cell{iview}=num2str(time_first,4); |
---|
2043 | time_last_cell{iview}=num2str(time_last,4); |
---|
2044 | end |
---|
2045 | set(handles.time_first,'Value',1) |
---|
2046 | set(handles.time_last,'Value',1) |
---|
2047 | set(handles.time_first,'String',time_first_cell); |
---|
2048 | set(handles.time_last,'String',time_last_cell); |
---|
2049 | |
---|
2050 | %------------------------------------------------------------------------ |
---|
2051 | % --- Executes on button press in GetObject. |
---|
2052 | function GetObject_Callback(hObject, eventdata, handles) |
---|
2053 | %------------------------------------------------------------------------ |
---|
2054 | hseries=get(handles.GetObject,'parent'); |
---|
2055 | SeriesData=get(hseries,'UserData'); |
---|
2056 | value=get(handles.GetObject,'Value'); |
---|
2057 | if value |
---|
2058 | set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow |
---|
2059 | % DataInit.ParentButton=handles.GetObject; |
---|
2060 | hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle |
---|
2061 | if ishandle(hset_object) |
---|
2062 | uistack(hset_object,'top') |
---|
2063 | %[SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit); %open the set_object interface |
---|
2064 | else |
---|
2065 | %get the object file |
---|
2066 | defaultname=get(handles.RootPath,'String'); |
---|
2067 | if isempty(defaultname) |
---|
2068 | defaultname={''}; |
---|
2069 | end |
---|
2070 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
2071 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
2072 | '*.xml', '.xml files '; ... |
---|
2073 | '*.mat', '.mat matlab files '}, ... |
---|
2074 | 'Pick an xml object file (or use uvmat to create it)',defaultname{1}); |
---|
2075 | fileinput=[PathName FileName];%complete file name |
---|
2076 | testblank=findstr(fileinput,' ');%look for blanks |
---|
2077 | if ~isempty(testblank) |
---|
2078 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks') |
---|
2079 | return |
---|
2080 | end |
---|
2081 | sizf=size(fileinput); |
---|
2082 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
2083 | %read the file |
---|
2084 | t=xmltree(fileinput); |
---|
2085 | data=convert(t); |
---|
2086 | if ~isfield(data,'Style') |
---|
2087 | data.Style='points'; |
---|
2088 | end |
---|
2089 | if ~isfield(data,'ProjMode') |
---|
2090 | data.ProjMode='projection'; |
---|
2091 | end |
---|
2092 | transform_menu=get(handles.transform_fct,'String'); |
---|
2093 | ichoice=get(handles.transform_fct,'Value'); |
---|
2094 | % if isequal(transform_menu{ichoice},'px'); |
---|
2095 | % data.CoordType='px'; |
---|
2096 | % else |
---|
2097 | % data.CoordType='phys'; |
---|
2098 | % end |
---|
2099 | data.desable_plot=1; |
---|
2100 | [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface |
---|
2101 | end |
---|
2102 | else |
---|
2103 | set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green |
---|
2104 | % if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object) |
---|
2105 | % close(SeriesData.hset_object) |
---|
2106 | % end |
---|
2107 | end |
---|
2108 | set(hseries,'UserData',SeriesData) |
---|
2109 | |
---|
2110 | %-------------------------------------------------------------- |
---|
2111 | function GetMask_Callback(hObject, eventdata, handles) |
---|
2112 | value=get(handles.GetMask,'Value'); |
---|
2113 | if value |
---|
2114 | msgbox_uvmat('ERROR','not implemented yet') |
---|
2115 | end |
---|
2116 | %-------------------------------------------------------------- |
---|
2117 | |
---|
2118 | %------------------------------------------------------------------- |
---|
2119 | %'uv_ncbrowser': interactively calls the netcdf file browser 'get_field.m' |
---|
2120 | function ncbrowser_uvmat(hObject, eventdata) |
---|
2121 | %------------------------------------------------------------------- |
---|
2122 | bla=get(gcbo,'String'); |
---|
2123 | ind=get(gcbo,'Value'); |
---|
2124 | filename=cell2mat(bla(ind)); |
---|
2125 | blank=find(filename==' '); |
---|
2126 | filename=filename(1:blank-1); |
---|
2127 | get_field(filename) |
---|
2128 | |
---|
2129 | % ------------------------------------------------------------------ |
---|
2130 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
2131 | %------------------------------------------------------------------- |
---|
2132 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
2133 | pathelp=fileparts(path_to_uvmat); |
---|
2134 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
2135 | 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') |
---|
2136 | else |
---|
2137 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
2138 | web([helpfile '#series']) |
---|
2139 | end |
---|
2140 | |
---|
2141 | %------------------------------------------------------------------- |
---|
2142 | % --- Executes on selection change in transform_fct. |
---|
2143 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
2144 | %------------------------------------------------------------------- |
---|
2145 | global nb_transform |
---|
2146 | |
---|
2147 | % huvmat=get(handles.transform_fct,'parent'); |
---|
2148 | menu=get(handles.transform_fct,'String'); |
---|
2149 | ind_coord=get(handles.transform_fct,'Value'); |
---|
2150 | coord_option=menu{ind_coord}; |
---|
2151 | list_transform=get(handles.transform_fct,'UserData'); |
---|
2152 | ff=functions(list_transform{end}); |
---|
2153 | if isequal(coord_option,'more...'); |
---|
2154 | coord_fct=''; |
---|
2155 | prompt = {'Enter the name of the transform function'}; |
---|
2156 | dlg_title = 'user defined transform'; |
---|
2157 | num_lines= 1; |
---|
2158 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
2159 | {'*.m', ' (*.m)'; |
---|
2160 | '*.m', '.m files '; ... |
---|
2161 | '*.*', 'All Files (*.*)'}, ... |
---|
2162 | 'Pick a file', ff.file); |
---|
2163 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
2164 | PathName(end)=[]; |
---|
2165 | end |
---|
2166 | transform_selected =fullfile(PathName,FileName); |
---|
2167 | if ~exist(transform_selected,'file') |
---|
2168 | return |
---|
2169 | end |
---|
2170 | [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m |
---|
2171 | if ~isequal(ext_fct,'.m') |
---|
2172 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
2173 | return |
---|
2174 | end |
---|
2175 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
2176 | ind_coord=get(handles.transform_fct,'Value'); |
---|
2177 | addpath(PathName) |
---|
2178 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
2179 | set(handles.transform_fct,'UserData',list_transform) |
---|
2180 | rmpath(PathName) |
---|
2181 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
2182 | dir_perso=prefdir;%personal Matalb directory |
---|
2183 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2184 | if exist(profil_perso,'file') |
---|
2185 | for ilist=nb_transform+1:numel(list_transform) |
---|
2186 | ff=functions(list_transform{ilist}); |
---|
2187 | transform_fct{ilist-nb_transform}=ff.file; |
---|
2188 | end |
---|
2189 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
2190 | end |
---|
2191 | end |
---|
2192 | |
---|
2193 | %check the current path to the selected function |
---|
2194 | func=functions(list_transform{ind_coord}); |
---|
2195 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
2196 | |
---|
2197 | %------------------------------------------------------------------------ |
---|
2198 | % --- generates a series of file names with reference numbers between range1 and |
---|
2199 | % --- range2 with increment incr. The reference number num_ref is the image number at the middle of the |
---|
2200 | % --- image pair. The set of first numbers num1 of the image pairs is also |
---|
2201 | % --- given as output |
---|
2202 | 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) |
---|
2203 | %------------------------------------------------------------------------ |
---|
2204 | [Path,Name]=fileparts(filebase); |
---|
2205 | filebasesub=fullfile(Path,subdir,Name); |
---|
2206 | filecell={};%default |
---|
2207 | num_i1=[]; |
---|
2208 | num_i2=[]; |
---|
2209 | num_j1=[]; |
---|
2210 | num_j2=[]; |
---|
2211 | ind0_i=first_i:incr_i:last_i; |
---|
2212 | nbcolumn=length(ind0_i); |
---|
2213 | ind0_j=first_j:incr_j:last_j; |
---|
2214 | nbline=length(ind0_j); |
---|
2215 | if isequal(mode,'#_ab') |
---|
2216 | dirpair=dir([filebasesub '*_*.nc']); |
---|
2217 | elseif isequal(mode,'bursts')|isequal(mode,'series(Dj)') |
---|
2218 | dirpair=dir([filebasesub '_*_*-*.nc']); |
---|
2219 | elseif isequal(mode,'series(Di)') |
---|
2220 | dirpair=dir([filebasesub '_*-*_*.nc']); |
---|
2221 | else |
---|
2222 | msgbox_uvmat('ERROR','option *|* not yet implemented') |
---|
2223 | return |
---|
2224 | end |
---|
2225 | if isempty(dirpair) |
---|
2226 | msgbox_uvmat('ERROR','no pair detected in the selected range') |
---|
2227 | return |
---|
2228 | end |
---|
2229 | |
---|
2230 | if isequal(mode,'bursts')||isequal(mode,'#_ab') |
---|
2231 | icount=0; |
---|
2232 | for ifile=1:length(dirpair) |
---|
2233 | [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
2234 | num1_r=str2num(str_1); |
---|
2235 | if isequal(RootFile,Name) & ~isempty(num1_r) |
---|
2236 | num_i1(ifile)=num1_r; |
---|
2237 | num_a(ifile)=stra2num(str_a); |
---|
2238 | num_b(ifile)=stra2num(str_b); |
---|
2239 | end |
---|
2240 | end |
---|
2241 | test_range= (num_i1 >=first_i)&(num_i1<= last_i);% =1 when both numbers are in the range |
---|
2242 | ind_i=((num_i1-first_i)/incr_i)+1;%indices i in the list of prescribed file indices |
---|
2243 | select=find(test_range &(floor(ind_i)==ind_i));%selected indices of num_i1 in the file directory |
---|
2244 | ind_i=ind_i(select);%set of selected indices ind_i |
---|
2245 | [ind_i,indsort]=sort(ind_i);%sorted list of ind_i |
---|
2246 | select=select(indsort); |
---|
2247 | num_i1=num_i1(select); |
---|
2248 | num_a=num_a(select); |
---|
2249 | num_b=num_b(select); |
---|
2250 | dirpair=dirpair(select); |
---|
2251 | [ind_remove]=find_pairs(dirpair,ind_i,nbcolumn); |
---|
2252 | ind_i(ind_remove)=[]; |
---|
2253 | num_a(ind_remove)=[]; |
---|
2254 | num_b(ind_remove)=[]; |
---|
2255 | num_j1=zeros(1,nbcolumn);%default |
---|
2256 | num_j2=num_j1; |
---|
2257 | num_j1(ind_i)=num_a; |
---|
2258 | num_j2(ind_i)=num_b; |
---|
2259 | num_i1=first_i:incr_i:last_i; |
---|
2260 | num_i2=num_i1; |
---|
2261 | nbmissing=nbcolumn-length(ind_i); |
---|
2262 | |
---|
2263 | elseif isequal(mode,'series(Di)') |
---|
2264 | %ind0_i=first_i:incr_i:last_i; |
---|
2265 | %nbcolumn=length(ind0_i); |
---|
2266 | %ind0_j=first_j:incr_j:last_j; |
---|
2267 | %nbline=length(ind0_j); |
---|
2268 | %dirpair=dir([filebasesub '_*-*_*.nc']); |
---|
2269 | for ifile=1:length(dirpair) |
---|
2270 | [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
2271 | num_i1_r(ifile)=str2num(str_1); |
---|
2272 | num_i2_r(ifile)=str2num(str_2); |
---|
2273 | num_j(ifile)=str2num(str_a); |
---|
2274 | end |
---|
2275 | num_i=floor((num_i1_r+num_i2_r)/2); %list of reference indices of the detected files |
---|
2276 | 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 |
---|
2277 | ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices |
---|
2278 | ind_j=((num_j-first_j)/incr_j)+1; |
---|
2279 | ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices |
---|
2280 | select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory |
---|
2281 | ind_ij=ind_ij(select);%set of selected indices ind_ij |
---|
2282 | [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij |
---|
2283 | select=select(indsort); |
---|
2284 | num_i1_r=num_i1_r(select); |
---|
2285 | num_i2_r=num_i2_r(select); |
---|
2286 | dirpair=dirpair(select); |
---|
2287 | [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; |
---|
2288 | ind_ij(ind_remove)=[]; |
---|
2289 | num_i1_r(ind_remove)=[]; |
---|
2290 | num_i2_r(ind_remove)=[]; |
---|
2291 | num_i1=zeros(1,nbline*nbcolumn);%default |
---|
2292 | num_i2=num_i1; |
---|
2293 | num_i1(ind_ij)=num_i1_r; |
---|
2294 | num_j2(ind_ij)=num_i2_r; |
---|
2295 | num_i1=reshape(num_i1,nbline,nbcolumn); |
---|
2296 | num_i2=reshape(num_i2,nbline,nbcolumn); |
---|
2297 | num_j1=meshgrid(ind0_i,ind0_j); |
---|
2298 | num_j2=num_j1; |
---|
2299 | nbmissing=nbline*nbcolumn-length(ind_ij); |
---|
2300 | elseif isequal(mode,'series(Dj)') |
---|
2301 | for ifile=1:length(dirpair) |
---|
2302 | [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name); |
---|
2303 | num_i(ifile)=str2num(str_1); |
---|
2304 | num_a(ifile)=str2num(str_a); |
---|
2305 | num_b(ifile)=str2num(str_b); |
---|
2306 | end |
---|
2307 | num_j=floor((num_a+num_b)/2); %list of reference indices of the detected files |
---|
2308 | 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 |
---|
2309 | ind_i=((num_i-first_i)/incr_i)+1;%indices i and j in the list of prescribed file indices |
---|
2310 | ind_j=((num_j-first_j)/incr_j)+1; |
---|
2311 | ind_ij=ind_j+nbline*(ind_i-1);%indices in the reshhaped series of prescribed file indices |
---|
2312 | select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));%selected indices in the file directory |
---|
2313 | ind_ij=ind_ij(select);%set of selected indices ind_ij |
---|
2314 | [ind_ij,indsort]=sort(ind_ij);%sorted list of ind_ij |
---|
2315 | select=select(indsort); |
---|
2316 | num_i=num_i(select); |
---|
2317 | num_a=num_a(select); |
---|
2318 | num_b=num_b(select); |
---|
2319 | dirpair=dirpair(select); |
---|
2320 | [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ; |
---|
2321 | ind_ij(ind_remove)=[]; |
---|
2322 | num_a(ind_remove)=[]; |
---|
2323 | num_b(ind_remove)=[]; |
---|
2324 | num_j1=zeros(1,nbline*nbcolumn);%default |
---|
2325 | num_j2=num_j1; |
---|
2326 | num_j1(ind_ij)=num_a; |
---|
2327 | num_j2(ind_ij)=num_b; |
---|
2328 | num_j1=reshape(num_j1,nbline,nbcolumn); |
---|
2329 | num_j2=reshape(num_j2,nbline,nbcolumn); |
---|
2330 | num_i1=meshgrid(ind0_i,ind0_j); |
---|
2331 | num_i2=num_i1; |
---|
2332 | nbmissing=nbline*nbcolumn-length(ind_ij); |
---|
2333 | end |
---|
2334 | |
---|
2335 | %------------------------------------------------------------------------ |
---|
2336 | % --- generates series of file indices corresponding to a file fileinput |
---|
2337 | function [num_i1,num_i2,num_j1,num_j2]=find_indexseries(fileinput) |
---|
2338 | %------------------------------------------------------------------------ |
---|
2339 | num_i1=NaN;%default |
---|
2340 | num_i2=NaN;%default |
---|
2341 | num_j1=NaN;%default |
---|
2342 | num_j2=NaN;%default |
---|
2343 | % refresh input root name, indices, file extension and nomenclature |
---|
2344 | [RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput); |
---|
2345 | if strcmp(SubDir,'') |
---|
2346 | filebasesub=fullfile(RootPath,RootFile); |
---|
2347 | else |
---|
2348 | filebasesub=fullfile(RootPath,SubDir,RootFile); |
---|
2349 | end |
---|
2350 | dirpair=[]; %default |
---|
2351 | switch NomType |
---|
2352 | case '_i' |
---|
2353 | dirpair=dir([filebasesub '_*' FileExt]); |
---|
2354 | case '_i_j' |
---|
2355 | dirpair=dir([filebasesub '_*_*' FileExt]); |
---|
2356 | case '_i1-i2' |
---|
2357 | dirpair=dir([filebasesub '_*-*' FileExt]); |
---|
2358 | case '#_ab' |
---|
2359 | dirpair=dir([filebasesub '*_*' FileExt]); |
---|
2360 | case '_i_j1-j2' |
---|
2361 | dirpair=dir([filebasesub '*_*-*' FileExt]); |
---|
2362 | case '_i1-i2_j' |
---|
2363 | dirpair=dir([filebasesub '*-*_*' FileExt]); |
---|
2364 | end |
---|
2365 | % nom_type='#' series of indexed images wich is not series_i |
---|
2366 | % [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif' |
---|
2367 | % nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j') |
---|
2368 | % nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif' |
---|
2369 | % 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' |
---|
2370 | % nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE |
---|
2371 | % nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D') |
---|
2372 | % nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D') |
---|
2373 | for ifile=1:length(dirpair) |
---|
2374 | [RootPath,RF,str_1,str_2,str_a,str_b]=name2display(dirpair(ifile).name); |
---|
2375 | num_i1(ifile)=str2double(str_1); |
---|
2376 | num_i2(ifile)=str2double(str_2); |
---|
2377 | if isnan(num_i2(ifile)) |
---|
2378 | num_i2(ifile)=num_i1(ifile); |
---|
2379 | end |
---|
2380 | num_j1(ifile)=stra2num(str_a); |
---|
2381 | if isnan(num_j1(ifile)) |
---|
2382 | num_j1(ifile)=1; |
---|
2383 | end |
---|
2384 | num_j2(ifile)=stra2num(str_b); |
---|
2385 | if isnan(num_j2(ifile)) |
---|
2386 | num_j2(ifile)=num_j1(ifile); |
---|
2387 | end |
---|
2388 | end |
---|
2389 | |
---|