source: trunk/src/get_field.m @ 582

Last change on this file since 582 was 582, checked in by sommeria, 8 years ago

various bugs corrected

File size: 64.6 KB
Line 
1%'get_field': display variables and attributes from a Netcdf file, and OK selected fields
2%------------------------------------------------------------------------
3%function varargout = get_field(varargin)
4% associated with the GUI get_field.fig
5%
6%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
7%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
8%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
9%     This file is part of the toolbox UVMAT.
10%
11%     UVMAT is free software; you can redistribute it and/or modify
12%     it under the terms of the GNU General Public License as published by
13%     the Free Software Foundation; either version 2 of the License, or
14%     (at your option) any later version.
15%
16%     UVMAT is distributed in the hope that it will be useful,
17%     but WITHOUT ANY WARRANTY; without even the implied warranty of
18%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
20%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
21
22function varargout = get_field(varargin)
23
24% Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52
25
26% Begin initialization code - DO NOT EDIT
27gui_Singleton = 1;
28gui_State = struct('gui_Name',       mfilename, ...
29                   'gui_Singleton',  gui_Singleton, ...
30                   'gui_OpeningFcn', @get_field_OpeningFcn, ...
31                   'gui_OutputFcn',  @get_field_OutputFcn, ...
32                   'gui_LayoutFcn',  [] , ...
33                   'gui_Callback',   []);
34if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
35    gui_State.gui_Callback = str2func(varargin{1});
36end
37
38if nargout
39    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
40else
41    gui_mainfcn(gui_State, varargin{:});
42end
43% End initialization code - DO NOT EDIT
44
45%------------------------------------------------------------------------
46% --- Executes just before get_field is made visible.
47function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn)
48%------------------------------------------------------------------------
49global nb_builtin % nbre of functions to include by default in the menu of  functions called by RUN
50
51%% Choose default command line output for get_field
52handles.output = 'Cancel';
53
54%% Update handles structure
55guidata(hObject, handles);
56set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
57
58%% settings for 'slave' mode, called by uvmat, or 'master' mode
59if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
60    set(handles.inputfile,'String',filename)% prefill the input file name
61    Field=nc2struct(filename,[]);% reads the  field structure, without the variables
62    if isfield(Field,'Txt')
63        msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])
64    else
65        if ~exist('ParamIn','var')
66            ParamIn=[];
67        end
68        Field_input(handles,Field,ParamIn);
69    end
70else  %master mode
71    set(handles.inputfile,'String','')
72end
73
74%% put the GUI on the lower right of the sceen
75set(hObject,'Unit','pixel')
76pos_view_field=get(hObject,'Position');
77ScreenSize=get(0,'ScreenSize');
78pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
79pos_view_field(2)=ScreenSize(2);
80set(hObject,'Position',pos_view_field)
81set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
82drawnow
83uiwait(handles.get_field);
84
85%------------------------------------------------------------------------
86% --- update the display when a new field is introduced.
87function Field_input(handles,Field,ParamIn)
88%------------------------------------------------------------------------
89
90%% fill the list and values of dimensions
91if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
92    Tabcell(:,1)=Field.ListDimName;
93    for iline=1:length(Field.ListDimName)
94        Tabcell{iline,2}=num2str(Field.DimValue(iline));
95    end
96    Tabchar=cell2tab(Tabcell,' = ');
97    set(handles.dimensions,'String',Tabchar)
98end
99if ~isfield(Field,'ListVarName')
100    return
101end
102
103%% fill the list of variables
104Txt=Field.ListVarName;
105set(handles.variables,'Value',1)
106set(handles.variables,'String',[{'*'} Txt])
107variables_Callback(handles.variables,[], handles)
108
109% set(handles.abscissa,'String',[{''} Txt ])
110set(handles.ordinate,'String',Txt)
111set(handles.vector_x,'String',[Txt ])
112set(handles.vector_y,'String',[Txt ])
113set(handles.vector_z,'String',[{''} Txt ])
114set(handles.vec_color,'String',[{''} Txt ])
115set(handles.XVarName,'String',[{''} Txt ])
116set(handles.YVarName,'String',[{''} Txt ])
117set(handles.ZVarName,'String',[{''} Txt ])
118% set(handles.coord_x_vectors,'String',[{''} Txt ])
119% set(handles.coord_y_vectors,'String',[{''} Txt ])
120% set(handles.YVarName,'String',[{''} Txt ])
121% set(handles.TimeVarName,'String',[{''} Txt ])
122set(handles.scalar,'Value',1)
123set(handles.scalar,'String', Txt )
124
125%% ananlyse the input field cells
126[CellInfo,NbDim,errormsg]=find_field_cells(Field);
127if ~isempty(errormsg) 
128    msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg])
129    return
130end 
131[Field.MaxDim,imax]=max(NbDim);
132% look at variables with a single dimension
133for ilist=1:numel(Field.VarDimName)
134    if ischar(Field.VarDimName{ilist})
135        Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell
136    end
137    NbDim=numel(Field.VarDimName{ilist});% TODO eliminate singleton dimensions
138    check_singleton=false(1,NbDim);
139    for idim=1:NbDim
140        dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);
141        check_singleton(idim)=isequal(Field.DimValue(dim_index),1);
142    end
143    Field.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);
144    Field.NbDim(ilist)=numel(Field.VarDimName{ilist});
145    if Field.NbDim(ilist)==1
146        Field.VarDimName{ilist}=cell2mat(Field.VarDimName{ilist});
147    end
148end
149SingleVarName=Field.ListVarName(Field.NbDim==1);%list of variables with a single dim
150MultiVarName=Field.ListVarName(Field.NbDim>1);
151check_dim=zeros(size(Field.VarDimName));
152for ilist=1:numel(Field.VarDimName);
153    if iscell(Field.VarDimName{ilist})% exclude single dim
154        for idim=1:numel(Field.VarDimName{ilist})
155            check_dim=check_dim|strcmp(Field.VarDimName{ilist}{idim},Field.VarDimName);
156        end
157    end
158end
159Field.SingleVarName=Field.ListVarName(find(check_dim));%list of variables with a single dim
160Field.SingleDimName=Field.VarDimName(find(check_dim));% corresponding list of dimensions for variables with a single dim
161Field.MaxDim=max(Field.NbDim);
162
163%% set time mode
164ListSwitchVarIndexTime={'file index'};
165% look at global attributes with numerical values
166check_numvalue=false;
167check_time=false;
168    for ilist=1:numel(Field.ListGlobalAttribute)
169        Value=Field.(Field.ListGlobalAttribute{ilist});
170        check_numvalue(ilist)=isnumeric(Value);
171        check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1));
172    end 
173Field.ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value
174if ~isempty(Field.ListNumAttributes)
175ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];
176end
177nboption=numel(ListSwitchVarIndexTime);
178if Field.MaxDim>=2
179    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];
180end
181if Field.MaxDim>=4
182        option=nboption+1;
183elseif ~isempty(find(check_time, 1))
184    option=2;
185else
186    option=1;
187end
188set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime)
189set(handles.SwitchVarIndexTime,'Value',option)
190set(handles.get_field,'UserData',Field);% record the finput field structure
191SwitchVarIndexTime_Callback([],[], handles)
192
193%% set z coordinate menu if relevant
194if Field.MaxDim>=3
195    set(handles.vector_z,'Visible','on')
196    set(handles.vector_z,'String',[{''} Txt ])
197        set(handles.ZVarName,'Visible','on')
198    set(handles.SwitchVarIndexZ,'Visible','on')
199    set(handles.Z_title,'Visible','on')
200else
201    set(handles.vector_z,'Visible','off')
202    set(handles.ZVarName,'Visible','off')
203    set(handles.SwitchVarIndexZ,'Visible','off')
204    set(handles.Z_title,'Visible','off')
205end
206
207%% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields
208if Field.MaxDim>=2 % case of 2D (or 3D) fields
209    set(handles.CheckPlot1D,'Value',0)
210    if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
211        set(handles.CheckVector,'Value',1)
212        set(handles.CheckScalar,'Value',0)
213        set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
214        set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
215    else
216        set(handles.CheckScalar,'Value',1)
217        set(handles.CheckVector,'Value',0)
218    end
219else % case of 1D fields
220    set(handles.CheckPlot1D,'Value',1)
221    set(handles.CheckScalar,'Value',0)
222    set(handles.CheckVector,'Value',0)
223end
224
225%% Make choices in menus from input
226if exist('ParamIn','var')&&~isempty(ParamIn)
227    fill_GUI(ParamIn,handles);
228end
229CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
230CheckScalar_Callback(handles.CheckScalar, [], handles)
231CheckVector_Callback(handles.CheckVector, [], handles)
232
233%------------------------------------------------------------------------
234% --- Outputs from this function are returned to the command line.
235function varargout = get_field_OutputFcn(hObject, eventdata, handles)
236%------------------------------------------------------------------------
237varargout{1} = handles.output;
238delete(handles.get_field)
239
240
241% -----------------------------------------------------------------------
242% --- Activated by selection in the list of variables
243function variables_Callback(hObject, eventdata, handles)
244% -----------------------------------------------------------------------
245Tabchar={''};%default
246Tabcell=[];
247hselect_field=get(handles.variables,'parent');
248Field=get(handles.get_field,'UserData');
249index=get(handles.variables,'Value');%index in the list 'variables'
250
251%% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected
252if isequal(index,1)
253    set(handles.attributes_txt,'String','global attributes')
254    if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute)
255        for iline=1:length(Field.ListGlobalAttribute)
256            Tabcell{iline,1}=Field.ListGlobalAttribute{iline};   
257            if isfield(Field, Field.ListGlobalAttribute{iline})
258                eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
259                if ischar(val);% attribute value is char string
260                    Tabcell{iline,2}=val;
261                elseif size(val,1)==1 %attribute value is a number or matlab vector
262                    Tabcell{iline,2}=num2str(val);
263                end
264            end
265        end
266        Tabchar=cell2tab(Tabcell,'=');
267    end
268%% list Attribute names and values associated to the Variable # index-1   
269else
270    list_var=get(handles.variables,'String');
271    var_select=list_var{index};
272    set(handles.attributes_txt,'String', ['attributes of ' var_select])
273    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
274%         nbline=0;
275        VarAttr=Field.VarAttribute{index-1};
276        if isstruct(VarAttr)
277            attr_list=fieldnames(VarAttr);
278            for iline=1:length(attr_list)
279                Tabcell{iline,1}=attr_list{iline};
280                eval(['val=VarAttr.' attr_list{iline} ';'])
281                if ischar(val);
282                    Tabcell{iline,2}=val;
283                else
284                     Tabcell{iline,2}=num2str(val);
285                end
286            end
287        end
288    end
289
290end
291if ~isempty(Tabcell)
292    Tabchar=cell2tab(Tabcell,'=');
293    Tabchar=[{''};Tabchar];
294end
295set(handles.attributes,'Value',1);% select the first item
296set(handles.attributes,'String',Tabchar);
297
298%% update dimensions;
299if isfield(Field,'ListDimName')
300    Tabdim={};%default
301    if isequal(index,1)%list all dimensions
302        dim_indices=1:length(Field.ListDimName);
303        set(handles.dimensions_txt,'String', 'dimensions')
304    else
305        DimCell=Field.VarDimName{index-1};
306        if ischar(DimCell)
307            DimCell={DimCell};
308        end   
309        dim_indices=[];
310        for idim=1:length(DimCell)
311            dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0
312            dim_index=find(dim_index,1);
313            dim_indices=[dim_indices dim_index];
314        end
315        set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
316    end
317    for iline=1:length(dim_indices)
318        Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)};
319        Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline)));
320    end
321    Tabchar=cell2tab(Tabdim,' = ');
322    Tabchar=[{''} ;Tabchar];
323    set(handles.dimensions,'Value',1)
324    set(handles.dimensions,'String',Tabchar) 
325end 
326
327
328
329%------------------------------------------------------------------------
330% --- Executes on button press in CheckPlot1D.
331function CheckPlot1D_Callback(hObject, eventdata, handles)
332%------------------------------------------------------------------------
333val=get(handles.CheckPlot1D,'Value');
334if isequal(val,0)
335    set(handles.Panel1Dplot,'Visible','off')
336else
337    set(handles.Panel1Dplot,'Visible','on')
338    set(handles.PanelScalar,'Visible','off')
339    set(handles.CheckScalar,'Value',0)
340    set(handles.PanelVectors,'Visible','off')
341    set(handles.CheckVector,'Value',0)
342    set(handles.XVarName,'Visible','on')
343    set(handles.SwitchVarIndexX,'Visible','on')
344    set(handles.X_title,'Visible','on')
345    set(handles.YVarName,'Visible','off')
346    set(handles.SwitchVarIndexY,'Visible','off')
347    set(handles.Y_title,'Visible','off')
348    set(handles.ZVarName,'Visible','off')
349    set(handles.SwitchVarIndexZ,'Visible','off')
350    set(handles.Z_title,'Visible','off')
351    ordinate_Callback(hObject, eventdata, handles)
352end
353
354%------------------------------------------------------------------------
355function ordinate_Callback(hObject, eventdata, handles)
356%------------------------------------------------------------------------
357Field=get(handles.get_field,'UserData');
358list=get(handles.ordinate,'String');
359yindex=get(handles.ordinate,'Value');
360yindex=name2index(list{yindex(1)},Field.ListVarName);
361if ~isempty(yindex)
362    set(handles.variables,'Value',yindex+1)
363    variables_Callback(hObject, eventdata, handles)
364end
365[CellInfo,NbDim,errormsg]=find_field_cells(Field);
366%[CellVarIndex,NbDim,VarRole,errormsg]=find_field_cells(Field);
367for icell=1:numel(CellInfo)
368    VarIndex=CellInfo{icell}.VarIndex;
369    if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarRole{icell}.coord_x)||~isequal(VarRole{icell}.coord_x,VarIndex))
370        cell_select=icell;
371        break
372    end
373end
374val=get(handles.abscissa,'Value');
375set(handles.abscissa,'Value',min(val,2));
376coord_x_index=VarRole{cell_select}.coord;
377coord_x_index=coord_x_index(coord_x_index~=0);
378set(handles.XVarname,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
379
380%------------------------------------------------------------------------
381% --- Executes on button press in CheckScalar.
382function CheckScalar_Callback(hObject, eventdata, handles)
383%------------------------------------------------------------------------
384val=get(handles.CheckScalar,'Value');
385if isequal(val,0)
386    set(handles.PanelScalar,'Visible','off')
387else
388    set(handles.Panel1Dplot,'Visible','off')
389    set(handles.CheckPlot1D,'Value',0)
390    set(handles.PanelScalar,'Visible','on')
391    set(handles.PanelVectors,'Visible','off')
392    set(handles.CheckVector,'Value',0)
393end
394
395%------------------------------------------------------------------------
396% --- Executes on button press in CheckVector.
397function CheckVector_Callback(hObject, eventdata, handles)
398%------------------------------------------------------------------------
399val=get(handles.CheckVector,'Value');
400if isequal(val,0)
401    set(handles.PanelVectors,'Visible','off')
402else
403    set(handles.Panel1Dplot,'Visible','off')
404    set(handles.CheckPlot1D,'Value',0)
405    set(handles.PanelScalar,'Visible','off')
406    set(handles.CheckScalar,'Value',0)
407    set(handles.PanelVectors,'Visible','on')
408end
409
410
411%------------------------------------------------------------------------
412% --- Executes on selection change in scalar menu.
413function scalar_Callback(hObject, eventdata, handles)
414%------------------------------------------------------------------------
415index=get(handles.scalar,'Value');
416string=get(handles.scalar,'String');
417VarName=string{index};
418update_field(hObject, eventdata, handles,VarName)
419
420%eliminate time
421TimeDimName='';%default
422if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on')
423    TimeDimList=get(handles.TimeDimensionMenu,'String');
424    TimeDimIndex=get(handles.TimeDimensionMenu,'Value');
425    TimeDimName=TimeDimList{TimeDimIndex};
426end
427
428%check possible coordinates
429Field=get(handles.get_field,'UserData');
430dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar
431test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate
432for ilist=1:numel(Field.VarDimName)
433    dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist
434    if isequal(dimnames,{TimeDimName})
435        test_coord(ilist)=0;%mark time variables fo elimination
436    end
437    for idim=1:numel(dimnames)
438        if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable
439            test_coord(ilist)=0;
440            break
441        end
442    end
443end
444test_coord(index)=0;%the coordinate variable must be different from the scalar
445
446string_coord=[{''};string(test_coord==1)];
447val=get(handles.XVarName,'Value');
448if val>numel(string_coord)
449    set(handles.XVarName,'Value',1)
450end
451set(handles.XVarName,'String',string_coord);
452val=get(handles.ZVarName,'Value');
453if val>numel(string_coord)
454    set(handles.ZVarName,'Value',1)
455end
456set(handles.ZVarName,'String',string_coord);
457val=get(handles.ZVarName,'Value');
458if val>numel(string_coord)
459    set(handles.ZVarName,'Value',1)
460end
461set(handles.YVarName,'String',string_coord);
462
463
464%------------------------------------------------------------------------
465% --- Executes on selection change in abscissa.
466function abscissa_Callback(hObject, eventdata, handles)
467%------------------------------------------------------------------------
468 hselect_field=get(handles.inputfile,'parent');
469 Field=get(hselect_field,'UserData');%current input field
470 xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa
471% test_2D=get(handles.CheckVector,'Value');% =1 for vector fields
472% test_scalar=get(handles.CheckScalar,'Value');% =1 for scalar fields
473%if isequal(xdispindex,1)% blank selection, no selected TimeVariable for abscissa
474%     Txt=Field.ListVarName;
475%     set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates
476%     xindex=[];
477% else
478     xlist=get(handles.abscissa,'String');%list of abscissa
479     VarName=xlist{xdispindex}; %selected variable name
480     update_field(hObject, eventdata, handles,VarName)
481%      xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables
482%      if ~isempty(xindex)
483%         set(handles.variables,'Value',xindex+1)
484%         variables_Callback(hObject, eventdata, handles)
485%      end
486%     set(handles.variables,'Value',xindex+1)%outline  in the list of variables
487%     variables_Callback(hObject, eventdata, handles)  %display properties of the TimeVariable (dim, attributes)
488%     if  ~test_2D &  ~test_scalar% look for possible varaibles to OK in ordinate   
489%         index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa
490%         VarIndex=[];
491%         for ilist=1:length(Field.VarDimIndex)%detect
492%             index_i=Field.VarDimIndex{ilist};
493%             if ~isempty(index_i)
494%                 if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible
495%                     VarIndex=[VarIndex ilist];
496%                 end
497%             end
498%         end
499% %         set(handles.ordinate,'Value',1)
500%         set(handles.ordinate,'String',Field.ListVarName(VarIndex))
501%     end
502% end
503%
504% update_UserData(handles)
505
506
507
508%------------------------------------------------------------------------
509% --- Executes on selection change in XVarName.
510function XVarName_Callback(hObject, eventdata, handles)
511%------------------------------------------------------------------------
512index=get(handles.XVarName,'Value');
513string=get(handles.XVarName,'String');
514VarName=string{index};
515update_field(hObject, eventdata, handles,VarName)
516
517%------------------------------------------------------------------------
518% --- Executes on selection change in ZVarName.
519function ZVarName_Callback(hObject, eventdata, handles)
520%------------------------------------------------------------------------
521index=get(handles.ZVarName,'Value');
522string=get(handles.ZVarName,'String');
523VarName=string{index};
524update_field(hObject, eventdata, handles,VarName)
525
526%------------------------------------------------------------------------
527% --- Executes on selection change in YVarName.
528function YVarName_Callback(hObject, eventdata, handles)
529%------------------------------------------------------------------------
530index=get(handles.YVarName,'Value');
531string=get(handles.YVarName,'String');
532VarName=string{index};
533update_field(hObject, eventdata, handles,VarName)
534
535%------------------------------------------------------------------------
536% --- Executes on selection change in vector_x.
537function vector_x_Callback(hObject, eventdata, handles)
538%------------------------------------------------------------------------
539index=get(handles.vector_x,'Value');
540string=get(handles.vector_x,'String');
541VarName=string{index};
542
543%check possible coordinates
544Field=get(handles.get_field,'UserData');
545dim_var=Field.VarDimName{index};%list of dimensions of the selected variable
546test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate
547test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component
548for ilist=1:numel(Field.VarDimName)
549    dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist
550    if ~isequal(dimnames,dim_var)
551        test_component(ilist)=0;
552    end
553    for idim=1:numel(dimnames)
554        if isempty(find(strcmp(dimnames{idim},dim_var),1))%dimension not found in the scalar variable
555            test_coord(ilist)=0;
556            break
557        end
558    end
559end
560%eliminate time
561if get(handles.TimeVariable,'Value')
562    TimeName=get(handles.TimeName,'String');
563    index_time=find(strcmp( TimeName,Field.ListVarName));
564    test_coord(index_time)=0;
565end
566vlength=numel(string(test_component==1));
567val=get(handles.vector_y,'Value');
568if val>vlength
569    set(handles.vector_y,'Value',1)
570end
571set(handles.vector_y,'String',[string(test_component==1)])
572val=get(handles.vector_z,'Value');
573if val>vlength+1
574    set(handles.vector_z,'Value',1)
575end
576set(handles.vector_z,'String',[{''};string(test_component==1)])
577val=get(handles.vec_color,'Value');
578if val>vlength+1
579    set(handles.vec_color,'Value',1)
580end
581set(handles.vec_color,'String',[{''};string(test_component==1)])
582string_coord=[{''};string(test_coord==1)];
583val=get(handles.XVarName,'Value');
584if val>numel(string_coord)
585    set(handles.XVarName,'Value',1)
586end
587set(handles.XVarName,'Visible','on');
588set(handles.XVarName,'String',string_coord);
589val=get(handles.YVarName,'Value');
590if val>numel(string_coord)
591    set(handles.YVarName,'Value',1)
592end
593set(handles.YVarName,'Visible','on');
594set(handles.YVarName,'String',string_coord);
595val=get(handles.TimeVarName,'Value');
596if val>numel(string_coord)
597    set(handles.TimeVarName,'Value',1)
598end
599set(handles.TimeVarName,'String',string_coord);
600
601update_field(hObject, eventdata, handles,VarName)
602
603%------------------------------------------------------------------------
604% --- Executes on selection change in vector_y.
605function vector_y_Callback(hObject, eventdata, handles)
606%------------------------------------------------------------------------
607index=get(handles.vector_y,'Value');
608string=get(handles.vector_y,'String');
609VarName=string{index};
610update_field(hObject, eventdata, handles,VarName)
611
612%------------------------------------------------------------------------
613% --- Executes on selection change in vector_z.
614function vector_z_Callback(hObject, eventdata, handles)
615%------------------------------------------------------------------------
616index=get(handles.vector_z,'Value');
617string=get(handles.vector_z,'String');
618VarName=Astring{index};
619update_field(hObject, eventdata, handles,VarName)
620
621%------------------------------------------------------------------------
622% --- Executes on selection change in coord_x_vectors.
623function coord_x_vectors_Callback(hObject, eventdata, handles)
624%------------------------------------------------------------------------
625index=get(handles.coord_x_vectors,'Value');
626string=get(handles.coord_x_vectors,'String');
627VarName=string{index};
628update_field(hObject, eventdata, handles,VarName)
629
630%------------------------------------------------------------------------
631% --- Executes on selection change in coord_y_vectors.
632function coord_y_vectors_Callback(hObject, eventdata, handles)
633%------------------------------------------------------------------------
634index=get(handles.coord_y_vectors,'Value');
635string=get(handles.coord_y_vectors,'String');
636VarName=string{index};
637update_field(hObject, eventdata, handles,VarName)
638
639%------------------------------------------------------------------------
640% --- Executes on selection change in YVarName.
641function TimeVarName_Callback(hObject, eventdata, handles)
642%------------------------------------------------------------------------
643index=get(handles.TimeVarName,'Value');
644string=get(handles.TimeVarName,'String');
645VarName=string{index};
646update_field(hObject, eventdata, handles,VarName)
647
648%------------------------------------------------------------------------
649% --- Executes on selection change in vec_color.
650function vec_color_Callback(hObject, eventdata, handles)
651%------------------------------------------------------------------------
652index=get(handles.vec_color,'Value');
653string=get(handles.vec_color,'String');
654VarName=string{index};
655update_field(hObject, eventdata, handles,VarName)
656
657%-----------------------------------------------------------------------
658function update_field(hObject, eventdata, handles,VarName)
659%-----------------------------------------------------------------------
660Field=get(handles.get_field,'UserData');
661index=name2index(VarName,Field.ListVarName);
662if ~isempty(index)
663    set(handles.variables,'Value',index+1)
664    variables_Callback(hObject, eventdata, handles)
665end
666
667%------------------------------------------------------------------------
668% update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback)
669function update_UserData(handles)
670%------------------------------------------------------------------------
671return
672% global SubField
673hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface
674Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface
675if isfield(Field,'VarAttribute')
676    VarAttribute=Field.VarAttribute;
677else
678    VarAttribute={};
679end
680
681
682% select the indices of field variables for 2D plots
683test_CheckPlot1D=get(handles.CheckPlot1D,'Value');
684test_scalar=get(handles.CheckScalar,'Value');
685test_vector=get(handles.CheckVector,'Value');
686
687%transform if needed (calibration)
688list=get(handles.menu_coord,'String');
689index=get(handles.menu_coord,'Value');
690transform=list{index};
691if ~isequal(transform,'')
692    Field=feval(transform,Field);
693end
694VarIndex.u=[];
695VarIndex.v=[];
696VarIndex.w=[];
697VarIndex.A=[];
698VarIndex_tot=[];
699iuA=[];
700if test_scalar
701    Astring=get(handles.scalar,'String');
702    Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox
703    list_var=Astring(Aindex);
704    VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName
705    VarIndex_tot= [VarIndex_tot VarIndex.A];
706    DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable
707    DimValue=Field.DimValue(DimIndex);
708    ind=find(DimValue==1);
709    DimIndex(ind)=[];%Mremove singleton
710end
711if test_vector
712    Ustring=get(handles.vector_x,'String');
713    Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox
714    list_var=Ustring{Uindex};%name of the selected scalar
715    VarIndex.u=name2index(list_var,Field.ListVarName);
716    Vstring=get(handles.vector_y,'String');
717    Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox
718    list_var=Ustring{Vindex};%name of the selected scalar
719    VarIndex.v=name2index(list_var,Field.ListVarName);
720    if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A)
721        iuA=VarIndex.A; %same variable used for vector and scalar
722        VarIndex_tot(iuA)=[];
723    end
724    VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v];
725    %dimensions
726    DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable
727    DimValue=Field.DimValue(DimIndex_u);
728    ind=find(DimValue==1);
729    DimIndex_u(ind)=[];%Mremove singleton
730    DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable
731    DimValue=Field.DimValue(DimIndex_v);
732    ind=find(DimValue==1);
733    DimIndex_v(ind)=[];%Mremove singleton
734    if ~isequal(DimIndex_u,DimIndex_v)
735        msgbox_uvmat('ERROR','inconsistent dimensions for u and v')
736        set(handles.vector_y,'Value',1);
737        return
738    elseif  test_scalar & ~isequal(DimIndex_u,DimIndex)
739         msgbox_uvmat('ERROR','inconsistent dimensions for vector and scalar represented as vector color')
740         set(handles.scalar,'Value',1);
741         return
742    end
743    DimIndex=DimIndex_u;
744    %TODO possibility of selecting 3 times the same TimeVariable for u, v, w components
745end
746
747
748% select the TimeVariable  index (or indices) for z coordinates
749test_grid=0;
750if test_scalar | test_vector
751    nbdim=length(DimIndex);
752    if nbdim > 3
753        msgbox_uvmat('ERROR','array with more than three dimensions, not supported')
754        return
755    else
756        perm_ind=1:nbdim;
757    end
758    if nbdim==3
759        zstring=get(handles.coord_z_vectors_scalar,'String');
760        zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox
761        list_var=zstring(zindex);
762        VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable
763        if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z)
764            if zindex ~= 1
765                set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components
766                return
767            end
768        else
769            VarIndex_tot=[VarIndex_tot VarIndex_z];
770            DimIndex_z=Field.VarDimIndex{VarIndex_z};
771            DimValue=Field.DimValue(DimIndex_z);
772            ind=find(DimValue==1);         
773            DimIndex_z(ind)=[];%Mremove singleton
774            if isequal(DimIndex_z,DimIndex)
775                VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates
776            elseif length(DimIndex_z)==1
777                VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};  %dimension variable
778                ind_z=find(DimIndex==DimIndex_z(1));
779                perm_ind(ind_z)=1;
780                test_grid=1;
781            else
782                msgbox_uvmat('ERROR','multiple dimensions for the z coordinate')
783                return
784            end
785        end
786%         if ~isempty(VarIndex_z)
787%             DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the TimeVariable   
788%             if length(DimIndex_z)==1 & nbdim==3 %dimension TimeVariable
789%                 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z};
790%                 ind_z=find(DimIndex==DimIndex_z(1));
791%                 perm_ind(ind_z)=1;
792%                 test_grid=1;
793%             end
794%         end
795    end
796end
797
798% select the TimeVariable  index (or indices) for ordinate
799ystring=get(handles.ordinate,'String');
800yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox
801list_var=ystring(yindex);
802VarIndex.y=name2index(list_var,Field.ListVarName);
803if isequal(VarIndex.A,VarIndex.y)
804    set(handles.ZVarName,'Value',1)
805elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y)
806   set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components
807else
808    for ivar=1:length(VarIndex.y)
809        VarAttribute{VarIndex.y(ivar)}.Role='coord_y';
810    end
811    VarIndex_tot=[VarIndex_tot VarIndex.y];
812end
813if (test_scalar | test_vector) &  ~isempty(VarIndex.y)
814    DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable
815    if length(DimIndex_y)==1
816        ind_y=find(DimIndex==DimIndex_y(1));
817        test_grid=1;
818        if nbdim==3
819            VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
820            perm_ind(ind_y)=2;
821        elseif nbdim==2
822            VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y};
823             perm_ind(ind_y)=1;
824        end
825    elseif test_grid
826        msgbox_uvmat('ERROR','the dimension of the y coordinate variable should be 1')   
827    end
828end
829
830%select the TimeVariable index for the abscissa
831xstring=get(handles.abscissa,'String');
832xindex=get(handles.abscissa,'Value');
833list_var=xstring(xindex);
834VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var
835if length(VarIndex.x)==1   
836    DimIndex_x=Field.VarDimIndex{VarIndex.x};
837    DimValue=Field.DimValue(DimIndex_x);
838    ind=find(DimValue==1);         
839    DimIndex_x(ind)=[];%Mremove singleton                     
840    VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};  %dimension variable           
841%     VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified)
842    index_detect=find(VarIndex_tot==VarIndex.x);
843else
844    index_detect=[];%coord x variable not already used
845end
846if isempty(index_detect)
847    VarIndex_tot=[VarIndex_tot VarIndex.x];
848elseif ~test_CheckPlot1D
849    VarIndex.x=[];
850    set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa
851end
852
853if (test_scalar | test_vector) &  ~isempty(VarIndex.x)
854    DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable
855    if length(DimIndex_x)==1
856        ind_x=find(DimIndex==DimIndex_x(1));
857        if nbdim==3
858            %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
859            perm_ind(ind_x)=3;
860        elseif nbdim==2
861            %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x};
862             perm_ind(ind_x)=2;
863        end
864        if isequal(perm_ind,1:nbdim)
865            test_grid=0;
866        end
867        DimIndex=DimIndex(perm_ind);
868    elseif test_grid
869        msgbox_uvmat('ERROR','the dimension of the x coordinate variable should be 1')   
870    end
871    if isequal(DimIndex_x,DimIndex)
872                VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates
873    end
874end
875
876%defined the selected sub-field SubField
877SubField.ListGlobalAttribute{1}='InputFile';
878SubField.InputFile=get(handles.inputfile,'String');
879SubField.ListDimName=Field.ListDimName;
880SubField.DimValue=Field.DimValue;
881SubField.ListVarName=Field.ListVarName(VarIndex_tot);
882SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot);
883
884testperm=0;
885testattr=0;
886for ivar=VarIndex.u
887    VarAttribute{ivar}.Role='vector_x';
888    testattr=1;
889    if test_grid
890        VarDimIndex{ivar}=DimIndex; %permute dimensions
891        testperm=1;
892    end
893end
894for ivar=VarIndex.v
895    VarAttribute{ivar}.Role='vector_y';
896    testattr=1;
897     if test_grid
898        VarDimIndex{ivar}=DimIndex;%permute dimensions
899        testperm=1;
900    end
901end
902for ivar=VarIndex.A
903    if test_grid
904        VarDimIndex{ivar}=DimIndex;%permute dimensions
905        testperm=1;
906    end
907    if isempty(iuA)
908        VarAttribute{ivar}.Role='scalar';%Role =scalar
909        testattr=1;
910    else
911       VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable
912       nbattr=length(VarAttribute);
913       VarAttribute{nbattr}.Role='scalar';
914       testattr=1;
915    end
916end
917if testperm
918    SubField.VarDimIndex=VarDimIndex(VarIndex_tot);
919end
920if testattr
921    SubField.VarAttribute=VarAttribute(VarIndex_tot);
922end
923set(hselect_field,'UserData',Field)
924
925%---------------------------------------------------------
926% --- Executes on button press in OK.
927
928function OK_Callback(hObject, eventdata, handles)
929%---------------------------------------------------------
930
931handles.output=read_GUI(handles.get_field);
932guidata(hObject, handles);% Update handles structure
933uiresume(handles.get_field);
934drawnow
935return
936
937%%%% SKIPPED %%%%
938hfield=[];
939huvmat=findobj(allchild(0),'tag','uvmat');
940hseries=findobj(allchild(0),'tag','series');
941check_series=0;
942% look for the status of the GUI uvmat
943if ~isempty(huvmat)
944    hh=guidata(huvmat);
945    FieldMenu=get(hh.FieldName,'String');
946    FieldName=FieldMenu{get(hh.FieldName,'Value')};
947    if strcmp(FieldName,'get_field...')
948        hfield=hh.FieldName; %FieldName on uvmat
949    elseif strcmp(get(hh.FieldName_1,'Visible'),'on')
950        FieldMenu=get(hh.FieldName_1,'String');
951        if ~isempty(FieldMenu)
952            FieldName=FieldMenu{get(hh.FieldName_1,'Value')};
953            if strcmp(FieldName,'get_field...')
954                hfield=hh.FieldName_1; %FieldName_1 on uvmat
955            end
956        end
957    end
958end
959% if no filed data is concerned on uvmat, look at the GUI series
960if isempty(hfield) && ~isempty(hseries)
961    check_series=1;
962    hh=guidata(hseries);
963    FieldMenu=get(hh.FieldName,'String');
964    FieldName=FieldMenu{get(hh.FieldName,'Value')};
965    if strcmp(FieldName,'get_field...')
966        hfield=hh.FieldName; %FieldName on series
967    else
968       FieldMenu=get(hh.FieldName_1,'String');
969       FieldName=FieldMenu{get(hh.FieldName_1,'Value')};
970       if strcmp(FieldName,'get_field...')
971            hfield=hh.FieldName_1; %FieldName_1 on series
972       end
973    end
974end
975if ~isempty(hfield)
976    get_field_GUI=read_GUI(handles.get_field);
977    if isfield(get_field_GUI,'PanelVectors')
978        set(hh.Coord_x,'value',1)
979        set(hh.Coord_y,'value',1)
980        set(hh.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors})
981        set(hh.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors})
982        UName=get_field_GUI.PanelVectors.vector_x;
983        VName=get_field_GUI.PanelVectors.vector_y;
984        menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}];
985        menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}];
986        set(hfield,'Value',1)
987        set(hfield,'String',menu_str)
988        if ~check_series
989            ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color));
990            if ~isempty(ind_menu)
991                set(hh.ColorScalar,'Value',ind_menu)
992            else
993                set(hh.ColorScalar,'Value',1)
994            end
995            set(hh.ColorScalar,'String',menu_color)
996        end
997    elseif isfield(get_field_GUI,'PanelScalar')
998        set(hh.Coord_x,'value',1)
999        set(hh.Coord_y,'value',1)
1000        set(hh.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar})
1001        set(hh.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar})
1002        AName=get_field_GUI.PanelScalar.scalar;
1003        menu=get(hfield,'String');
1004        ind_select=find(strcmp(AName,menu));
1005        if isempty(ind_select)
1006            menu=[menu(1:end-1);{AName};{'get_field...'}];
1007            ind_select=numel(menu)-1;
1008        end
1009        set(hfield,'Value',ind_select);
1010        set(hfield,'String',menu);
1011    elseif isfield(get_field_GUI,'Panel1Dplot')
1012        set(hh.Coord_x,'Value',1)
1013        set(hh.Coord_x,'String',{get_field_GUI.Panel1Dplot.abscissa})
1014        set(hh.Coord_y,'String',get_field_GUI.Panel1Dplot.ordinate)
1015        set(hh.Coord_y,'Max', numel(get_field_GUI.Panel1Dplot.ordinate))
1016        set(hh.Coord_y,'Value',1:numel(get_field_GUI.Panel1Dplot.ordinate))
1017        set(hfield,'Value',1)
1018        set(hfield,'String',[{''};{'get_field...'}])
1019    end
1020    if  ~check_series && strcmp(get(gcbf,'tag'),'get_field')%get_field is not called by another GUI (uvmat)
1021        uvmat('run0_Callback',hObject,eventdata,hh); %refresh uvmat
1022    end
1023end
1024delete(handles.get_field)
1025
1026
1027
1028% %------------------------------------------------------------------------
1029% function mouse_up_gui(ggg,eventdata,handles)
1030% %------------------------------------------------------------------------
1031% if isequal(get(ggg,'SelectionType'),'alt')
1032%     message=''; 
1033%     global CurData
1034%     inputfield=get(handles.inputfile,'String');
1035%     if exist(inputfield,'file')
1036%         CurData=nc2struct(inputfield);
1037%     else
1038%         CurData=get(ggg,'UserData');% get_field opened from a input field, not a file
1039%     end
1040%   %%%% TODO: put the matalb command window in front
1041%     evalin('base','global CurData')%make CurData global in the workspace
1042%     evalin('base','CurData') %display CurData in the workspace
1043% end
1044
1045%------------------------------------------------------------------------
1046% --- Executes on selection change in ACTION.
1047%------------------------------------------------------------------------
1048function ACTION_Callback(hObject, eventdata, handles)
1049global nb_builtin
1050list_ACTION=get(handles.ACTION,'String');% list menu fields
1051index_ACTION=get(handles.ACTION,'Value');% selected string index
1052ACTION= list_ACTION{index_ACTION}; % selected string
1053list_func_handles=get(handles.ACTION,'UserData');% get list of function handles (full address of the function, including name and path)
1054ff=functions(list_func_handles{end});
1055% add a new function to the menu
1056if isequal(ACTION,'more...')
1057    [FileName, PathName] = uigetfile( ...
1058       {'*.m', ' (*.m)';
1059        '*.m',  '.m files '; ...
1060        '*.*', 'All Files (*.*)'}, ...
1061        'Pick a file',ff.file);
1062    if length(FileName)<2
1063        return
1064    end
1065    [pp,ACTION,ext_fct]=fileparts(FileName);
1066    if ~isequal(ext_fct,'.m')
1067        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
1068        return
1069    end
1070
1071    % insert the choice in the action menu
1072   menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
1073   index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list
1074   addpath(PathName)
1075   list_func_handles{index_ACTION}=str2func(ACTION);% create the function handle corresponding to the newly seleced function
1076   set(handles.ACTION,'UserData',list_func_handles)
1077   set(handles.path_action,'enable','inactive')% indicate that the current path is accessible (not 'off')
1078   %list_path{index_ACTION}=PathName;
1079   if length(menu_str)>nb_builtin+5;
1080       nbremove=length(menu_str)-nb_builtin-5;
1081       menu_str(nb_builtin+1:end-5)=[];
1082       list_func_handles(nb_builtin+1:end-4)=[];
1083       index_ACTION=index_ACTION-nbremove;
1084       set(handles.ACTION,'Value',index_ACTION)
1085       set(handles.ACTION,'String',menu_str)
1086   end   
1087   %record the current menu in personal file profil_perso
1088   dir_perso=prefdir;
1089   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
1090   get_field_fct={};
1091   for ilist=nb_builtin+1:length(menu_str)-1
1092       ff=functions(list_func_handles{ilist});
1093       get_field_fct{ilist-nb_builtin}=ff.file;
1094   end
1095   if exist(profil_perso,'file')
1096        save(profil_perso,'get_field_fct','-append')
1097   else
1098     txt=ver('MATLAB');
1099    Release=txt.Release;
1100       relnumb=str2num(Release(3:4));
1101        if relnumb >= 14
1102            save(profil_perso,'get_field_fct','-V6')
1103        else
1104            save(profil_perso, 'get_field_fct')
1105        end
1106   end
1107end
1108
1109%check the current path to the selected function
1110h_fun=list_func_handles{index_ACTION};
1111if isa(h_fun,'function_handle')
1112    func=functions(h_fun);
1113    set(handles.path_action,'String',fileparts(func.file)); %show the path to the senlected function
1114    GUI_input=h_fun();%handles.figure1 =handles of the GUI get_field
1115else
1116    set(handles.path_action,'String','')
1117    msgbox_uvmat('ERROR','unknown path to ACTION function, reload it')
1118    return
1119end
1120
1121%prepare the GUI options for the selected ACTION
1122test_1Dplot=0;
1123test_scalar=0;
1124test_vector=0;
1125if iscell(GUI_input)
1126    for ilist=1:size(GUI_input,1)
1127        switch GUI_input{ilist,1}
1128                           %RootFile always visible
1129            case 'CheckPlot1D'   
1130                 test_1Dplot=isequal(GUI_input{ilist,2},'on');
1131            case 'CheckScalar'
1132                 test_scalar=isequal(GUI_input{ilist,2},'on');   
1133            case 'CheckVector'   
1134                 test_vector=isequal(GUI_input{ilist,2},'on');
1135        end
1136    end
1137end
1138set(handles.CheckPlot1D,'Value',test_1Dplot);
1139set(handles.CheckScalar,'Value',test_scalar);
1140set(handles.CheckVector,'Value',test_vector);
1141CheckPlot1D_Callback(hObject, eventdata, handles)
1142CheckScalar_Callback(hObject, eventdata, handles)
1143CheckVector_Callback(hObject, eventdata, handles)
1144
1145
1146%-----------------------------------------------------
1147% --- browse existing figures
1148%-----------------------------------------------------
1149function browse_fig(menu_handle)
1150hh=findobj(allchild(0),'Type','figure');
1151ilist=0;
1152list={};
1153for ifig=1:length(hh)  %look for all existing figures
1154    name=get(hh(ifig),'Name');
1155     if ~strcmp(name,'uvmat')&& ~strcmp(name,'view_field') %case of uvmat GUI
1156        hchild=get(hh(ifig),'children');% look for axes contained in each figure
1157        nbaxe=0;
1158        for ichild=1:length(hchild)           
1159            Type=get(hchild(ichild),'Type');
1160            Tag=get(hchild(ichild),'Tag');
1161            if isequal(Type,'axes')
1162                if ~isequal(Tag,'Colorbar')& ~isequal(Tag,'legend')% don't select colorbars for plotting
1163                     nbaxe=nbaxe+1;%count the existing axis
1164                end
1165            end
1166        end   
1167        if nbaxe==1
1168             ilist=ilist+1;%add a line in the list of axis
1169            list{ilist,1}=num2str(hh(ifig));
1170        elseif nbaxe>1
1171            for iaxe=1:nbaxe
1172               ilist=ilist+1;%add a line in the list of axis
1173               list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)];
1174            end
1175        end
1176     end
1177end
1178list=['uvmat';list];
1179set(menu_handle,'Value',1)
1180set(menu_handle,'String',list)
1181
1182
1183%-----------------------------------------------------
1184function list_fig_Callback(hObject, eventdata, handles)
1185%-----------------------------------------------------
1186list_fig=get(handles.list_fig,'String');
1187fig_val=get(handles.list_fig,'Value');
1188plot_fig=list_fig{fig_val};
1189if strcmp(plot_fig,'view_field')
1190%     huvmat=findobj(allchild(0),'name','uvmat');
1191%     if ~isempty(huvmat)
1192%         uistack(huvmat,'top')
1193%     end   
1194else%if ~isequal(plot_fig,'new fig...') & ~isequal(plot_fig,'uvmat')
1195    sep=regexp(plot_fig,'_');
1196    if ~isempty(sep)
1197        plot_fig=plot_fig([1:sep-1]);
1198    end
1199    if ishandle(str2num(plot_fig))
1200        figure(str2num(plot_fig))% display existing figure
1201    else
1202        browse_fig(handles.list_fig); %reset the current list of figures
1203    end
1204end
1205
1206
1207%-------------------------------------------------
1208% give index numbers of the strings str in the list ListvarName
1209function VarIndex_y=name2index(cell_str,ListVarName)
1210VarIndex_y=[];
1211if ischar(cell_str)
1212    for ivar=1:length(ListVarName)
1213        varlist=ListVarName{ivar};
1214        if isequal(varlist,cell_str)
1215            VarIndex_y= ivar;
1216            break
1217        end
1218    end
1219elseif iscell(cell_str)
1220    for isel=1:length(cell_str)
1221        varsel=cell_str{isel};
1222        for ivar=1:length(ListVarName)
1223            varlist=ListVarName{ivar};
1224            if isequal(varlist,varsel)
1225                VarIndex_y=[VarIndex_y ivar];
1226            end
1227        end
1228    end
1229end
1230
1231% --------------------------------------------------------------------
1232function MenuOpen_Callback(hObject, eventdata, handles)
1233% hObject    handle to MenuOpen (see GCBO)
1234% eventdata  reserved - to be defined in a future version of MATLAB
1235% handles    structure with handles and user data (see GUIDATA)
1236
1237
1238% --------------------------------------------------------------------
1239function MenuExport_Callback(hObject, eventdata, handles)
1240% hObject    handle to MenuExport (see GCBO)
1241% eventdata  reserved - to be defined in a future version of MATLAB
1242% handles    structure with handles and user data (see GUIDATA)
1243
1244
1245% --------------------------------------------------------------------
1246function MenuBrowse_Callback(hObject, eventdata, handles)
1247
1248oldfile=get(handles.inputfile,'String');
1249testrootfile=0;
1250testsubdir=0;
1251if isempty(oldfile)|isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
1252        oldfile='';
1253        dir_perso=prefdir;
1254         profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
1255         if exist(profil_perso,'file')
1256              h=load (profil_perso);
1257             if isfield(h,'RootPath')
1258                  RootPath=h.RootPath;
1259             end
1260             if isfield(h,'SubDir')
1261                  SubDir=h.SubDir;
1262                  if ~isempty(SubDir)
1263                    testsubdir=1;
1264                  end
1265             end
1266             if isfield(h,'RootFile')
1267                  RootFile=h.RootFile;
1268                  if ~isempty(RootFile)
1269                    testrootfile=1;
1270                  end
1271             end
1272         end
1273end
1274if testrootfile
1275    if ~testsubdir
1276        oldfile=fullfile(RootPath,RootFile);
1277    else
1278        oldfile=fullfile(RootPath,SubDir,RootFile);
1279    end
1280end
1281[FileName, PathName] = uigetfile( ...
1282       {'*.nc', ' *.nc';...
1283       '*.cdf', ' *.cdf';...
1284        '*.*',  'All Files (*.*)'}, ...
1285        'Pick a file',oldfile);
1286
1287%global inputfile
1288fileinput=[PathName FileName];%complete file name
1289sizf=size(fileinput);
1290if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
1291set(handles.inputfile,'String',fileinput)
1292inputfile_Callback(hObject, eventdata, handles)
1293
1294%update list of recent files in the menubar
1295MenuFile_1=fileinput;
1296MenuFile_2=get(handles.MenuFile_1,'Label');
1297MenuFile_3=get(handles.MenuFile_2,'Label');
1298MenuFile_4=get(handles.MenuFile_3,'Label');
1299MenuFile_5=get(handles.MenuFile_4,'Label');
1300set(handles.MenuFile_1,'Label',MenuFile_1)
1301set(handles.MenuFile_2,'Label',MenuFile_2)
1302set(handles.MenuFile_3,'Label',MenuFile_3)
1303set(handles.MenuFile_4,'Label',MenuFile_4)
1304set(handles.MenuFile_5,'Label',MenuFile_5)
1305dir_perso=prefdir;
1306profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
1307display(profil_perso)
1308if exist(profil_perso,'file')
1309    save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
1310else
1311    txt=ver('MATLAB');
1312    Release=txt.Release;
1313    relnumb=str2double(Release(3:4));
1314    if relnumb >= 14
1315        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
1316    else
1317        save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
1318    end
1319end
1320
1321% --------------------------------------------------------------------
1322function MenuFile_1_Callback(hObject, eventdata, handles)
1323fileinput=get(handles.MenuFile_1,'Label');
1324set(handles.inputfile,'String',fileinput)
1325inputfile_Callback(hObject, eventdata, handles)
1326
1327% --------------------------------------------------------------------
1328function MenuFile_2_Callback(hObject, eventdata, handles)
1329fileinput=get(handles.MenuFile_2,'Label');
1330set(handles.inputfile,'String',fileinput)
1331inputfile_Callback(hObject, eventdata, handles)
1332
1333% -----------------------------------------------------------------------
1334function MenuFile_3_Callback(hObject, eventdata, handles)
1335% -----------------------------------------------------------------------
1336fileinput=get(handles.MenuFile_3,'Label');
1337set(handles.inputfile,'String',fileinput)
1338inputfile_Callback(hObject, eventdata, handles)
1339
1340% -----------------------------------------------------------------------
1341function MenuFile_4_Callback(hObject, eventdata, handles)
1342% -----------------------------------------------------------------------
1343fileinput=get(handles.MenuFile_4,'Label');
1344set(handles.inputfile,'String',fileinput)
1345inputfile_Callback(hObject, eventdata, handles)
1346
1347% -----------------------------------------------------------------------
1348function MenuFile_5_Callback(hObject, eventdata, handles)
1349% -----------------------------------------------------------------------
1350fileinput=get(handles.MenuFile_5,'Label');
1351set(handles.inputfile,'String',fileinput)
1352inputfile_Callback(hObject, eventdata, handles)
1353
1354%------------------------------------------------------------------------
1355function MenuExportField_Callback(hObject, eventdata, handles)
1356%------------------------------------------------------------------------
1357global Data_get_field
1358% huvmat=findobj(allchild(0),'Name','uvmat');
1359inputfile=get(handles.inputfile,'String');
1360Data_get_field=nc2struct(inputfile);
1361% Data_view_field=UvData.ProjField_2;
1362evalin('base','global Data_get_field')%make CurData global in the workspace
1363display(['content of ' inputfile ':'])
1364evalin('base','Data_get_field') %display CurData in the workspace
1365commandwindow;
1366
1367%------------------------------------------------------------------------
1368function MenuHelp_Callback(hObject, eventdata, handles)
1369%------------------------------------------------------------------------
1370path_to_uvmat=which ('uvmat');% check the path of uvmat
1371pathelp=fileparts(path_to_uvmat);
1372helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
1373if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
1374else
1375web([helpfile '#get_field'])   
1376end
1377
1378% -----------------------------------------------------------------------
1379function TimeName_Callback(hObject, eventdata, handles)
1380
1381scalar_Callback(hObject, eventdata, handles)% suppress time variable from possible spatial coordinates
1382vector_x_Callback(hObject, eventdata, handles)
1383
1384%------------------------------------------------------------------------
1385% --- Executes on button press in TimeAttribute.
1386function TimeAttribute_Callback(hObject, eventdata, handles)
1387%------------------------------------------------------------------------
1388val=get(handles.TimeAttribute,'Value');
1389if val
1390    set(handles.TimeAttributeMenu,'Visible','on')
1391    Field=get(handles.get_field,'UserData');
1392    time_value=zeros(size(Field.ListGlobalAttribute));
1393    test_time=zeros(size(Field.ListGlobalAttribute));
1394    for ilist=1:numel(Field.ListGlobalAttribute)
1395        if isnumeric(eval(['Field.' Field.ListGlobalAttribute{ilist}]))
1396            eval(['time_val=Field.' Field.ListGlobalAttribute{ilist} ';'])
1397            if ~isempty(time_val)
1398                time_value(ilist)=time_val;
1399                test_time(ilist)=1;
1400            end
1401        end
1402    end
1403    ListTimeAttribute=Field.ListGlobalAttribute(test_time==1);
1404    attr_index=get(handles.TimeAttributeMenu,'Value');
1405    if attr_index>numel(ListTimeAttribute)
1406        attr_index=1;
1407        set(handles.TimeAttributeMenu,'Value',1);
1408    end
1409    if isempty(ListTimeAttribute)
1410        set(handles.TimeAttributeMenu,'String',{''})
1411        set(handles.TimeValue,'Visible','off')
1412    else
1413        set(handles.TimeValue,'Visible','on')
1414        set(handles.TimeAttributeMenu,'String',ListTimeAttribute)
1415        set(handles.TimeValue,'String',num2str(time_value(attr_index)))
1416    end
1417    set(handles.TimeDimension,'Value',0)
1418    TimeDimension_Callback(hObject, eventdata, handles)
1419    set(handles.TimeVariable,'Value',0)
1420    TimeVariable_Callback(hObject, eventdata, handles)
1421else
1422    set(handles.TimeAttributeMenu,'Visible','off')
1423    set(handles.TimeValue,'Visible','off')
1424end
1425
1426%------------------------------------------------------------------------
1427% --- Executes on selection change in TimeAttributeMenu.
1428function TimeAttributeMenu_Callback(hObject, eventdata, handles)
1429 ListTimeAttribute=get(handles.TimeAttributeMenu,'String');
1430 index=get(handles.TimeAttributeMenu,'Value');
1431 AttrName=ListTimeAttribute{index};
1432 Field=get(handles.get_field,'UserData');
1433 eval(['time_val=Field.' AttrName ';'])
1434 set(handles.TimeValue,'String',num2str(time_val))
1435%------------------------------------------------------------------------
1436
1437%------------------------------------------------------------------------
1438% --- Executes on button press in TimeVariable.
1439function TimeDimension_Callback(hObject, eventdata, handles)
1440%------------------------------------------------------------------------
1441val=get(handles.TimeDimension,'Value');%=1 if check box TimeDimension is selected
1442if val  %if check box TimeDimension is selected
1443    Field=get(handles.get_field,'UserData');% structure describing the currently opened field
1444    previous_menu=get(handles.TimeDimensionMenu,'String');
1445    if ~isequal(previous_menu,Field.ListDimName)%update the list of available dimensions in the menu
1446        ind_select=find(strcmpi('time',Field.ListDimName),1);% look for a dimension named 'time' or 'Time'
1447        if isempty(ind_select)
1448            ind_select=1;% select the first item in the list if 'time' is not found
1449        end
1450        set(handles.TimeDimensionMenu,'Value',ind_select);
1451        set(handles.TimeDimensionMenu,'String',Field.ListDimName)% put the list of available dimensions in the menu
1452    end   
1453    set(handles.TimeDimensionMenu,'Visible','on')% the menu is made visible
1454    set(handles.TimeIndexValue,'Visible','on')% the time matrix index value selected is made visible
1455    TimeDimensionMenu_Callback(hObject, eventdata, handles) 
1456    set(handles.TimeAttribute,'Value',0) %deselect alternative options for time
1457    set(handles.TimeVariable,'Value',0)
1458    TimeAttribute_Callback(hObject, eventdata, handles)
1459else
1460    set(handles.TimeDimensionMenu,'Visible','off')
1461    set(handles.TimeIndexValue,'Visible','off')
1462end
1463%
1464% %------------------------------------------------------------------------
1465% % --- Executes on selection change in TimeDimensionMenu.
1466% function TimeDimensionMenu_Callback(hObject, eventdata, handles)
1467% %------------------------------------------------------------------------
1468% index=get(handles.TimeDimensionMenu,'Value');
1469% DimList=get(handles.TimeDimensionMenu,'String');
1470% DimName=DimList{index};
1471% Field=get(handles.get_field,'UserData');
1472% DimIndex=find(strcmp(DimName,Field.ListDimName),1);
1473% ref_index=round(Field.DimValue(DimIndex)/2);   
1474% set(handles.TimeIndexValue,'String',num2str(ref_index))
1475% scalar_Callback(hObject, eventdata, handles)
1476% vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)
1477%  % look for a corresponding time variable and value
1478%  time_test=zeros(size(Field.VarDimName));
1479%  for ilist=1:numel(Field.VarDimName)
1480%      if isequal(Field.VarDimName{ilist},{DimName})
1481%          time_test(ilist)=1;
1482%      end
1483%  end
1484%  ListVariable=Field.ListVarName(time_test==1);
1485%  set(handles.TimeVariableMenu,'Value',1)
1486%  if isempty(ListVariable)     
1487%      set(handles.TimeVariableMenu,'String',{''})
1488%      set(handles.TimeVarValue,'String','')
1489%  else
1490%     set(handles.TimeVariableMenu,'String',ListVariable)
1491%     TimeVarName=ListVariable{1};
1492%     VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables
1493%     inputfile=get(handles.inputfile,'String');% read the input file
1494%     SubField=nc2struct(inputfile,{TimeVarName});
1495%     eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])
1496%     set(handles.TimeVarValue,'Visible','on')
1497%     set(handles.TimeVariableMenu,'Visible','on')
1498%     set(handles.TimeVarValue,'String',num2str(TimeValue))
1499%  end
1500%
1501%
1502% % % -----------------------------------------------------------------------
1503% % % --- Executes on button press in TimeVariable.
1504% % function TimeVariable_Callback(hObject, eventdata, handles)
1505% % % -----------------------------------------------------------------------
1506% % val=get(handles.TimeVariable,'Value');
1507% % if val
1508% %     Field=get(handles.get_field,'UserData');
1509% %     time_test=zeros(size(Field.VarDimName));
1510% %     for ilist=1:numel(Field.VarDimName)
1511% %         if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension
1512% %             time_test(ilist)=1;
1513% %         end
1514% %     end
1515% %     ind_test=find(time_test);
1516% %     if isempty(time_test)
1517% %         set(handles.TimeVariable,'Value',0)
1518% %         set(handles.TimeVariableMenu,'Visible','off')
1519% %         set(handles.TimeVarValue,'Visible','off')
1520% %     else
1521% %         set(handles.TimeVariableMenu,'Visible','on')
1522% %         set(handles.TimeVarValue,'Visible','on')
1523% %         if get(handles.TimeVariableMenu,'Value')>numel(ind_test)
1524% %             set(handles.TimeVariableMenu,'Value',1)
1525% %         end
1526% %         set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))
1527% %         TimeVariableMenu_Callback(hObject, eventdata, handles)
1528% %         set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time
1529% %         set(handles.TimeAttribute,'Value',0)
1530% %         TimeAttribute_Callback(hObject, eventdata, handles)
1531% %     end
1532% % else
1533% %     set(handles.TimeVariableMenu,'Visible','off')
1534% %     set(handles.TimeVarValue,'Visible','off')
1535% % end
1536%
1537% % -----------------------------------------------------------------------
1538% % --- Executes on selection change in TimeVariableMenu.
1539% function TimeVariableMenu_Callback(hObject, eventdata, handles)
1540% % -----------------------------------------------------------------------
1541% ListVar=get(handles.TimeVariableMenu,'String');
1542% index=get(handles.TimeVariableMenu,'Value');
1543% TimeVariable=ListVar{index};% name of the selected variable
1544% if isempty(TimeVariable)% case of blank selection
1545%     return
1546% end
1547% Field=get(handles.get_field,'UserData'); %index of
1548% VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables
1549% DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable
1550% set(handles.TimeDimensionMenu,'Value',1)
1551% set(handles.TimeDimensionMenu,'String',DimName)
1552% inputfile=get(handles.inputfile,'String');% read the input file
1553% SubField=nc2struct(inputfile,{TimeVariable});
1554% eval(['TimeDimension=numel(SubField.' TimeVariable ');'])
1555% ref_index=round(TimeDimension/2);
1556% eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])
1557% set(handles.TimeIndexValue,'String',num2str(ref_index))
1558% set(handles.TimeVarValue,'String',num2str(TimeValue))
1559
1560
1561% --- Executes on button press in check_rgb.
1562function check_rgb_Callback(hObject, eventdata, handles)
1563
1564
1565% --- Executes when user attempts to close get_field.
1566function get_field_CloseRequestFcn(hObject, eventdata, handles)
1567if isequal(get(handles.get_field, 'waitstatus'), 'waiting')
1568    % The GUI is still in UIWAIT, us UIRESUME
1569    uiresume(handles.get_field);
1570else
1571    % The GUI is no longer waiting, just close it
1572    delete(handles.get_field);
1573end
1574
1575
1576
1577
1578
1579% --- Executes on selection change in listbox30.
1580function listbox30_Callback(hObject, eventdata, handles)
1581% hObject    handle to listbox30 (see GCBO)
1582% eventdata  reserved - to be defined in a future version of MATLAB
1583% handles    structure with handles and user data (see GUIDATA)
1584
1585% Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array
1586%        contents{get(hObject,'Value')} returns selected item from listbox30
1587
1588
1589% --- Executes on selection change in SwitchVarIndexX.
1590function SwitchVarIndexX_Callback(hObject, eventdata, handles)
1591% hObject    handle to SwitchVarIndexX (see GCBO)
1592% eventdata  reserved - to be defined in a future version of MATLAB
1593% handles    structure with handles and user data (see GUIDATA)
1594
1595% Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array
1596%        contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX
1597
1598
1599% --- Executes on selection change in SwitchVarIndexTime.
1600function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
1601menu=get(handles.SwitchVarIndexTime,'String');
1602option=menu{get(handles.SwitchVarIndexTime,'Value')};
1603Field=get(handles.get_field,'UserData');
1604switch option
1605    case 'file index'
1606        set(handles.TimeVarName, 'Visible','off')
1607    case 'attribute'
1608        set(handles.TimeVarName, 'Visible','on')
1609        time_index=[];
1610        PreviousList=get(handles.TimeVarName, 'String');
1611         index=[];
1612        if ~isempty(PreviousList)
1613        PreviousAttr=PreviousList{get(handles.TimeVarName, 'Value')};
1614        index=find(strcmp(PreviousAttr,Field.ListNumAttributes));
1615        end
1616        if isempty(index)
1617            time_index=find(~cellfun('isempty',regexp(Field.ListNumAttributes,'Time')));% index of the attributes containing the string 'Time'
1618        end
1619        if ~isempty(time_index)
1620            set(handles.TimeVarName,'Value',time_index(1))
1621        else
1622            set(handles.TimeVarName,'Value',1)
1623        end
1624        set(handles.TimeVarName, 'String',Field.ListNumAttributes)
1625    case 'variable'
1626        set(handles.TimeVarName, 'Visible','on')
1627        TimeVarName=Field.SingleVarName;
1628        List=get(handles.TimeVarName,'String');
1629        option=List{get(handles.TimeVarName,'Value')};
1630        ind=find(strcmp(option,TimeVarName));
1631        if isempty(ind)
1632            set(handles.TimeVarName, 'Value',1);
1633        else
1634            set(handles.TimeVarName, 'Value',ind);
1635        end
1636        set(handles.TimeVarName, 'String',TimeVarName)
1637    case 'dim index'
1638        set(handles.TimeVarName, 'Visible','on')
1639        TimeVarName=Field.SingleDimName;
1640        List=get(handles.TimeVarName,'String');
1641        option=List{get(handles.TimeVarName,'Value')};
1642        ind=find(strcmp(option,TimeVarName));
1643        if isempty(ind)
1644            set(handles.TimeVarName, 'Value',1);
1645        else
1646            set(handles.TimeVarName, 'Value',ind);
1647        end
1648        set(handles.TimeVarName, 'String',TimeVarName)
1649end
1650
1651
Note: See TracBrowser for help on using the repository browser.