source: trunk/src/series.m @ 38

Last change on this file since 38 was 38, checked in by sommeria, 11 years ago

field transforms put in subdir transform_field. cleaning of obsolete functions

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