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