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