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