source: trunk/src/get_field.m @ 1033

Last change on this file since 1033 was 1028, checked in by sommeria, 6 years ago

option for reading fields in terms of matrix index

File size: 45.9 KB
Line 
1%'get_field': display variables and attributes from a Netcdf file, and OK selected fields
2%------------------------------------------------------------------------
3% GetFieldData=get_field(FileName,ParamIn)
4% associated with the GUI get_field.fig
5%
6% OUTPUT:
7% GetFieldData: structure containing the information on the selected
8%      fields, obtained by applying the fct red_GUI to the GUI get_field
9%   .FieldOption='vectors': variables are used for vector plot
10%                  'scalar': variables are used for scalar plot,
11%                  '1Dplot': variables are used for usual x-y plot,
12%                  'civdata...': go back to automatic reading of civ data
13%   .PanelVectors: sub-structure variables used as vector components
14%   .PanelScalar:
15% INPUT:
16% FileName: name (including path) of the netcdf file to open
17% ParmIn: structure containing parameters for preselecting menus:
18%   .Title: set the title of the GUI get_field
19%   .SwitchVarIndexTime='file index','variable' or 'matrix index': select the default option for 'time'
20%   .TimeAttrName: preselect the name of a global attribute for time
21%   .SeriesInput=1 if get_field is called by the GUI series,=0 otherwise (plot options provided in the latter case)
22%   .Coord_x,.Coord_y,.Coord_z, names of the variables used as the three coordinates
23%   .scalar : set the default choise of the scale variable
24%   .vector_x, .vector_y : set the default choise for the variables used for the x and y vector components
25
26%=======================================================================
27% Copyright 2008-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
28%   http://www.legi.grenoble-inp.fr
29%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
30%
31%     This file is part of the toolbox UVMAT.
32%
33%     UVMAT is free software; you can redistribute it and/or modify
34%     it under the terms of the GNU General Public License as published
35%     by the Free Software Foundation; either version 2 of the license,
36%     or (at your option) any later version.
37%
38%     UVMAT is distributed in the hope that it will be useful,
39%     but WITHOUT ANY WARRANTY; without even the implied warranty of
40%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41%     GNU General Public License (see LICENSE.txt) for more details.
42%=======================================================================
43
44function varargout = get_field(varargin)
45
46% Last Modified by GUIDE v2.5 18-Feb-2015 23:42:12
47
48% Begin initialization code - DO NOT EDIT
49gui_Singleton = 1;
50gui_State = struct('gui_Name',       mfilename, ...
51                   'gui_Singleton',  gui_Singleton, ...
52                   'gui_OpeningFcn', @get_field_OpeningFcn, ...
53                   'gui_OutputFcn',  @get_field_OutputFcn, ...
54                   'gui_LayoutFcn',  [] , ...
55                   'gui_Callback',   []);
56if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
57    gui_State.gui_Callback = str2func(varargin{1});
58end
59
60if nargout
61    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
62else
63    gui_mainfcn(gui_State, varargin{:});
64end
65% End initialization code - DO NOT EDIT
66     
67%------------------------------------------------------------------------
68% --- Executes just before get_field is made visible.
69%------------------------------------------------------------------------
70function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn)
71
72%% GUI settings
73handles.output = 'Cancel';
74guidata(hObject, handles);
75set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
76set(hObject,'CloseRequestFcn',{@closefcn,handles})
77
78%% enter input data
79if ischar(filename) % input file name
80    set(handles.inputfile,'String',filename)% fill the input file name
81    [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the  field structure, without the variables
82else
83    msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading
84    return
85end
86if ~isempty(errormsg)
87    msgbox_uvmat('ERROR',['get_field/nc2struct/' errormsg])% display error message for input file reading
88    return
89end
90if ~isfield(Field,'ListVarName')
91    msgbox_uvmat('ERROR',['no variable found in ' filename])% display error message for input file reading
92    return
93end
94if ~exist('ParamIn','var')
95    ParamIn.Coord_z='';
96end
97
98%% look at singletons and variables with a single dimension
99Field.Display=Field;
100Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value
101NbVar=numel(Field.VarDimName);%nbre of variables in the input data
102for ilist=1:NbVar
103    if ischar(Field.VarDimName{ilist})
104        Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell
105    end
106    NbDim=numel(Field.VarDimName{ilist});
107    check_singleton=false(1,NbDim);%  check singleton, false by default
108    for idim=1:NbDim
109        dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions
110        check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton
111    end
112    Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)))||(~isequal(Field.VarType(ilist),4)&&~isequal(Field.VarType(ilist),5)&&~isequal(Field.VarType(ilist),6));% =1 if the variable reduces to a single value
113    if ~Field.Check0D(ilist)
114    Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions
115    end
116end
117if ~isfield(Field,'VarAttribute')
118    Field.VarAttribute={};
119end
120if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded
121    Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute));
122end
123% Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions
124Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value
125Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D);
126Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D);
127Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names
128Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values
129
130
131%% analyse the input field cells
132[CellInfo,NbDim,errormsg]=find_field_cells(Field.Display);
133if ~isempty(errormsg)
134    msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg])
135    return
136end
137[Field.MaxDim,imax]=max(NbDim);
138
139%% set time mode
140ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index
141% look at global attributes with numerical values
142check_numvalue=false(1,numel(Field.ListGlobalAttribute));
143for ilist=1:numel(Field.ListGlobalAttribute)
144    Value=Field.(Field.ListGlobalAttribute{ilist});
145    check_numvalue(ilist)=isnumeric(Value);
146end
147Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value
148if ~isempty(Field.Display.ListGlobalAttribute)
149    ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute
150end
151
152Check_index=0;
153if Field.MaxDim>=2
154    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index
155else
156    for ilist=1:numel(Field.Display.VarDimName)
157        NbComponent=numel(Field.Display.VarDimName{ilist});
158        if NbComponent>=2% multicomponent matrices without coordinate variables (thus not considered in the fct find_field_cell)
159            ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'matrix index'}];% the time can be chosen as a dim index
160            Check_index=1;
161            break
162        end
163    end
164end
165
166%% select the Time attribute from input
167if isfield(ParamIn,'TimeAttrName')
168    time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1);
169else
170    time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time'
171end
172if isempty(time_index)
173    set(handles.SwitchVarIndexTime,'Value',1);
174else
175    set(handles.SwitchVarIndexTime,'Value',2);
176    set(handles.TimeName,'UserData',time_index)
177end
178set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime)
179set(handles.SwitchVarIndexTime,'UserData',ListSwitchVarIndexTime); % keep string in memory for check3D
180set(handles.get_field,'UserData',Field);% record the finput field structure
181SwitchVarIndexTime_Callback([], [], handles)
182
183%% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields
184set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components
185set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components
186set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
187set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
188set(handles.scalar,'Value',1)% fill the menu of y vector components
189set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar
190set(handles.ordinate,'Value',1)% fill the menu of y vector components
191set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots
192checkseries=0;
193if isfield(ParamIn,'SeriesInput') && ParamIn.SeriesInput% case of call by series
194    set(handles.FieldOption,'value',1)
195    if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
196    set(handles.FieldOption,'String',{'scalar';'vectors';'civdata...'})
197    else
198       set(handles.FieldOption,'String',{'scalar';'vectors'})
199    end
200    checkseries=1;
201    set(handles.scalar,'Max',2)
202elseif isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
203    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata
204    set(handles.scalar,'Max',1)
205else
206    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
207    set(handles.scalar,'Max',1)
208end
209
210%% set default field options
211checknbdim=cellfun('size',Field.Display.VarDimName,2);
212if max(checknbdim)<=1
213    Field.MaxDim=1;% only 1D fields, considered as a time series by default
214end
215if Field.MaxDim>=2 && ~checkseries% case of 2D (or 3D) fields
216    check_vec_input=0;
217    if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y')
218        ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1);
219        ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1);
220        if ~isempty(ichoice_x)&&~isempty(ichoice_y)
221            set(handles.vector_x,'UserData',ichoice_x)
222            set(handles.vector_y,'UserData',ichoice_y)
223            check_vec_input=1;
224        end
225    end
226    if ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
227        set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1))
228        set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1))
229        check_vec_input=1;
230    end
231    if check_vec_input
232        set(handles.FieldOption,'Value',3)% set vector selection option
233    else     
234        set(handles.FieldOption,'Value',2)% set scalar selection option
235    end
236else % case of 1D fields
237    set(handles.FieldOption,'Value',1)
238end
239
240%% fill the general list of dimensions, variables, attributes
241if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
242    Tabcell(:,1)=Field.ListDimName;
243    for iline=1:length(Field.ListDimName)
244        Tabcell{iline,2}=num2str(Field.DimValue(iline));
245    end
246    Tabchar=cell2tab(Tabcell,' = ');
247    set(handles.dimensions,'String',Tabchar)
248end
249
250%% fill menus for coordinates and time
251FieldOption_Callback(handles.variables,[], handles)% list the global attributes
252
253%% Make choices of coordinates from input
254if isfield(CellInfo{imax},'CoordIndex')
255    CoordIndex=CellInfo{imax}.CoordIndex;
256    if numel(CoordIndex)==2
257        if isfield(ParamIn,'Coord_x')&& isfield(ParamIn,'Coord_y')
258            YName=ParamIn.Coord_y;
259            XName=ParamIn.Coord_x;
260        else
261        YName=Field.ListVarName{CoordIndex(1)};
262        XName=Field.ListVarName{CoordIndex(2)};
263        end
264        ListCoord=get(handles.Coord_x,'String');
265        XIndex=find(strcmp(XName,ListCoord));
266        if ~isempty(XIndex)
267            set(handles.Coord_x,'Value',XIndex)
268        end
269        YIndex=find(strcmp(YName,ListCoord));
270        if ~isempty(YIndex)
271            set(handles.Coord_y,'Value',YIndex)
272        end
273    end
274end
275
276%% put the GUI on the lower right of the sceen
277set(hObject,'Unit','pixels')
278%pos_view_field=get(hObject,'Position');
279set(0,'Unit','pixels')
280ScreenSize=get(0,'ScreenSize');
281pos_view_field(3:4)=[955 648];
282pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
283pos_view_field(2)=ScreenSize(2);
284set(hObject,'Position',pos_view_field)
285set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
286if isfield(ParamIn,'Title')
287    set(hObject,'Name',ParamIn.Title)
288end
289
290%% set z coordinate menu if relevant
291if Field.MaxDim>=3 && prod(Field.DimValue)<10^8 && ~isempty(ParamIn.Coord_z); % 3D field (with memory content smaller than 400 Mo)
292    set(handles.Check3D,'Value',1)
293else
294    set(handles.Check3D,'Value',0)
295end
296Check3D_Callback(hObject, eventdata, handles)
297set(handles.variables,'Value',1)
298set(handles.variables,'String',[{'*'} Field.ListVarName])
299variables_Callback(handles.variables,[], handles)% list the global attributes
300drawnow
301uiwait(handles.get_field);
302
303% -----------------------------------------------------------------------
304% --- Activated by selection in the list of variables
305% ----------------------------------------------------------------------
306function variables_Callback(hObject, eventdata, handles)
307
308Tabchar={''};%default
309Tabcell=[];
310hselect_field=get(handles.variables,'parent');
311Field=get(handles.get_field,'UserData');
312index=get(handles.variables,'Value');%index in the list 'variables'
313
314%% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected
315if isequal(index,1)
316    set(handles.attributes_txt,'String','global attributes')
317    if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute)
318        for iline=1:length(Field.ListGlobalAttribute)
319            Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
320            if isfield(Field, Field.ListGlobalAttribute{iline})
321                val=Field.(Field.ListGlobalAttribute{iline});
322                if ischar(val);% attribute value is char string
323                    Tabcell{iline,2}=val;
324                elseif size(val,1)==1 %attribute value is a number or matlab vector
325                    Tabcell{iline,2}=num2str(val);
326                end
327            end
328        end
329        Tabchar=cell2tab(Tabcell,'=');
330    end
331    %% list Attribute names and values associated to the Variable # index-1
332else
333    list_var=get(handles.variables,'String');
334    if index>numel(list_var)
335        return
336    end
337    var_select=list_var{index};
338    set(handles.attributes_txt,'String', ['attributes of ' var_select])
339    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
340        %         nbline=0;
341        VarAttr=Field.VarAttribute{index-1};
342        if isstruct(VarAttr)
343            attr_list=fieldnames(VarAttr);
344            for iline=1:length(attr_list)
345                Tabcell{iline,1}=attr_list{iline};
346                val=VarAttr.(attr_list{iline}) ;
347                if ischar(val);
348                    Tabcell{iline,2}=val;
349                else
350                    Tabcell{iline,2}=num2str(val);
351                end
352            end
353        end
354    end
355end
356if ~isempty(Tabcell)
357    Tabchar=cell2tab(Tabcell,'=');
358    %     Tabchar=[{''};Tabchar];
359end
360set(handles.attributes,'Value',1);% select the first item
361set(handles.attributes,'String',Tabchar);
362
363%% update dimensions;
364if isfield(Field,'ListDimName')
365    Tabdim={};%default
366    if isequal(index,1)%list all dimensions
367        dim_indices=1:length(Field.ListDimName);
368        set(handles.dimensions_txt,'String', 'dimensions')
369    else
370        DimCell=Field.VarDimName{index-1};
371        if ischar(DimCell)
372            DimCell={DimCell};
373        end
374        dim_indices=[];
375        for idim=1:length(DimCell)
376            dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0
377            dim_index=find(dim_index,1);
378            dim_indices=[dim_indices dim_index];
379        end
380        set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
381    end
382    for iline=1:length(dim_indices)
383        Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)};
384        Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline)));
385    end
386    Tabchar=cell2tab(Tabdim,' = ');
387    Tabchar=[{''} ;Tabchar];
388    set(handles.dimensions,'Value',1)
389    set(handles.dimensions,'String',Tabchar)
390end
391
392%------------------------------------------------------------------------
393% --- Executes on selection change in FieldOption.
394%------------------------------------------------------------------------
395function FieldOption_Callback(hObject, eventdata, handles)
396
397Field=get(handles.get_field,'UserData');
398FieldList=get(handles.FieldOption,'String');
399FieldOption=FieldList{get(handles.FieldOption,'Value')};
400switch FieldOption
401   
402    case '1D plot'
403        set(handles.Coordinates,'Visible','on')
404        set(handles.PanelOrdinate,'Visible','on')
405        pos=get(handles.PanelOrdinate,'Position');
406        pos(1)=2;
407        pos_coord=get(handles.Coordinates,'Position');
408        pos(2)=pos_coord(2)-pos(4)-2;
409        set(handles.PanelOrdinate,'Position',pos)
410        set(handles.PanelScalar,'Visible','off')
411        set(handles.PanelVectors,'Visible','off')
412        set(handles.Coord_y,'Visible','off')
413        set(handles.Y_title,'Visible','off')
414        set(handles.Coord_z,'Visible','off')
415        set(handles.Z_title,'Visible','off')
416        ordinate_Callback(hObject, eventdata, handles)
417       
418    case {'scalar'}
419        set(handles.Coordinates,'Visible','on')
420        set(handles.PanelOrdinate,'Visible','off')
421        set(handles.PanelScalar,'Visible','on')
422        set(handles.PanelVectors,'Visible','off')
423        pos=get(handles.PanelScalar,'Position');
424        pos(1)=2;
425        pos_coord=get(handles.Coordinates,'Position');
426        pos(2)=pos_coord(2)-pos(4)-2;
427        set(handles.PanelScalar,'Position',pos)
428        set(handles.Coord_y,'Visible','on')
429        set(handles.Y_title,'Visible','on')
430        %default scalar selection
431        test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
432        for ilist=1:numel(Field.Display.VarDimName)
433            if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
434                Role=Field.Display.VarAttribute{ilist}.Role;
435                if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
436                    test_coord(ilist)=1;
437                end
438            end
439            dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
440            if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
441                test_coord(ilist)=1;
442            end
443        end
444        scalar_index=find(~test_coord,1);%get the first variable not a coordinate
445        if isempty(scalar_index)
446            set(handles.scalar,'Value',1)
447        else
448            set(handles.scalar,'Value',scalar_index)
449        end       
450        scalar_Callback(hObject, eventdata, handles)
451             
452    case 'vectors'
453        set(handles.PanelVectors,'Visible','on')
454        set(handles.Coordinates,'Visible','on')
455        set(handles.PanelOrdinate,'Visible','off')
456        set(handles.PanelScalar,'Visible','off')
457        pos=get(handles.PanelVectors,'Position');
458        pos(1)=2;
459        pos_coord=get(handles.Coordinates,'Position');
460        pos(2)=pos_coord(2)-pos(4)-2;
461        set(handles.PanelVectors,'Position',pos)
462        set(handles.Coord_y,'Visible','on')
463        set(handles.Y_title,'Visible','on')
464        %default vector selection
465        vector_x_value=get(handles.vector_x,'UserData');
466        vector_y_value=get(handles.vector_y,'UserData');
467        if ~isempty(vector_x_value)&&~isempty(vector_y_value)
468            set(handles.vector_x,'Value',vector_x_value)
469            set(handles.vector_y,'Value',vector_y_value)
470        else
471            test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate
472            for ilist=1:numel(Field.Display.VarDimName)
473                if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
474                    Role=Field.Display.VarAttribute{ilist}.Role;
475                    if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
476                        test_coord(ilist)=1;
477                    end
478                end
479                dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
480                if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
481                    test_coord(ilist)=1;
482                end
483            end
484            vector_index=find(~test_coord,2);%get the two first variables not a coordinate
485            if isempty(vector_index)
486                set(handles.vector_x,'Value',1)
487                set(handles.vector_y,'Value',2)
488            else
489                set(handles.vector_x,'Value',vector_index(1))
490                set(handles.vector_y,'Value',vector_index(2))
491            end
492        end
493        vector_Callback(handles)
494       
495    case 'civdata...'
496        set(handles.PanelOrdinate,'Visible','off')
497        set(handles.PanelScalar,'Visible','off')
498        set(handles.PanelVectors,'Visible','off')
499        set(handles.Coordinates,'Visible','off')
500end
501
502%------------------------------------------------------------------------
503function ordinate_Callback(hObject, eventdata, handles)
504%------------------------------------------------------------------------
505Field=get(handles.get_field,'UserData');
506y_index=get(handles.ordinate,'Value');
507y_menu=get(handles.ordinate,'String');
508if isempty(y_menu)
509    return
510else
511YName=y_menu{y_index};
512end
513
514%% set list of possible coordinates
515test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
516test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
517ListCoord={''};
518dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable
519
520for ilist=1:numel(Field.Display.VarDimName)
521    dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
522    if isequal(dimnames,dim_var)
523        test_component(ilist)=1;
524    elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable
525        test_coord(ilist)=1;
526    end
527end
528var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
529var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
530ListCoord=Field.Display.ListVarName([var_component var_coord]);
531
532%% set default coord selection
533if numel(find(test_coord))>3
534     SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');
535    if numel(SwitchVarIndexTime)<3
536        SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index'];
537        set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime)
538    end
539    set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time
540    SwitchVarIndexTime_Callback([], [], handles)
541end
542if numel(var_component)<2
543    if numel(test_coord)<2
544        ListCoord={''};
545    else
546        set(handles.Coord_x,'Value',2)
547        set(handles.Coord_y,'Value',1)
548    end
549else
550    coord_val=1;
551    for ilist=1:numel(var_component)
552        ivar=var_component(ilist);
553        if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role')
554            Role=Field.Display.VarAttribute{ivar}.Role;
555            if strcmp(Role,'coord_x')
556                coord_val=ilist;
557            end
558        end
559    end
560    set(handles.Coord_x,'Value',coord_val)
561end
562set(handles.Coord_x,'String',ListCoord)
563
564
565%% set list of time coordinates
566menu=get(handles.SwitchVarIndexTime,'String');
567TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')};
568switch TimeOption
569    case 'variable'
570        if numel(find(test_coord))<3
571            ListTime={''};
572        else
573            ListTime=Field.Display.ListVarName(find(test_coord,end));
574        end
575        set(handles.TimeName,'Value',1)
576        set(handles.TimeName,'String',ListTime)
577    case 'matrix index'
578        if numel(find(test_coord))<3
579            ListTime={''};
580        else
581            ListTime=Field.Display.VarDimName{find(test_coord,end)};
582        end
583        set(handles.TimeName,'Value',1)
584        set(handles.TimeName,'String',ListTime)
585end 
586update_field(handles,YName)
587         
588%------------------------------------------------------------------------
589% --- Executes on selection change in scalar menu.
590%------------------------------------------------------------------------
591function scalar_Callback(hObject, eventdata, handles)
592
593Field=get(handles.get_field,'UserData');
594scalar_index=get(handles.scalar,'Value');
595scalar_menu=get(handles.scalar,'String');
596ScalarName=scalar_menu{scalar_index};
597
598%% set list of possible coordinates
599test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
600test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
601dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
602if ~get(handles.CheckDimensionX,'Value') 
603    %look for coordinate variables among the other variables
604    for ilist=1:numel(Field.Display.VarDimName)
605        dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
606        if isequal(dimnames,dim_var)
607            test_component(ilist)=1;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate
608        elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var), 1))%variable ilist is a 1D array which can be coordinate variable
609            test_coord(ilist)=1;
610        end
611    end
612end
613var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
614var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
615var_coord(var_coord==scalar_index)=[];
616var_component(var_component==scalar_index)=[];
617ListCoord=Field.Display.ListVarName([var_coord var_component]);
618
619%% set default coord selection
620% if numel(find(test_coord))>3
621%     SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');
622%     if numel(SwitchVarIndexTime)<3
623%         SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index'];
624%         set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime)
625%     end
626%     set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time
627%     SwitchVarIndexTime_Callback([], [], handles)
628% end
629
630coord_val=[0 0];
631% look for labelled unstructured coordinates
632for ilist=1:numel(var_component)
633    ivar=var_component(ilist);
634    if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role')
635        Role=Field.Display.VarAttribute{ivar}.Role;
636        if strcmp(Role,'coord_x')
637            coord_val(1)=ilist;
638        elseif strcmp(Role,'coord_y')
639            coord_val(2)=ilist;
640            elseif strcmp(Role,'coord_z')
641            coord_val(3)=ilist;
642        end
643    end
644end
645if numel(find(coord_val))<2
646    if numel(var_coord)>=3
647         coord_val=[3 2 1];
648    elseif numel(var_coord)>=2
649       % coord_val=[numel(var_component)+2 numel(var_component)+1];
650       coord_val=[2 1];
651    else
652        coord_val=[1 2];
653    end
654end
655if  get(handles.CheckDimensionX,'Value')
656    set(handles.Coord_x,'Value',2)
657    set(handles.Coord_x,'String',dim_var')
658else
659    set(handles.Coord_x,'Value',coord_val(1))
660    set(handles.Coord_x,'String',ListCoord)
661end
662if  get(handles.CheckDimensionX,'Value')
663    set(handles.Coord_y,'Value',1)
664    set(handles.Coord_y,'String',dim_var')
665else
666    set(handles.Coord_y,'Value',coord_val(2))
667    set(handles.Coord_y,'String',ListCoord)
668end
669if  get(handles.CheckDimensionX,'Value')
670    set(handles.Coord_z,'Value',1)
671    set(handles.Coord_z,'String',dim_var')
672else
673    set(handles.Coord_z,'Value',coord_val(2))
674    set(handles.Coord_z,'String',ListCoord)
675end
676
677%% set list of time coordinates
678menu=get(handles.SwitchVarIndexTime,'String');
679TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')};
680switch TimeOption
681    case 'variable'
682        if numel(find(test_coord))<3
683            ListTime={''};
684        else
685            ListTime=Field.Display.ListVarName(find(test_coord,end));
686        end
687        set(handles.TimeName,'Value',1)
688        set(handles.TimeName,'String',ListTime)
689    case 'dim index'
690        if numel(find(test_coord))<3
691            ListTime={''};
692        else
693            ListTime=Field.Display.VarDimName{find(test_coord,end)};
694        end
695        set(handles.TimeName,'Value',1)
696        set(handles.TimeName,'String',ListTime)
697end 
698update_field(handles,ScalarName)
699
700% --- Executes on button press in check_rgb.
701function check_rgb_Callback(hObject, eventdata, handles)
702
703
704%------------------------------------------------------------------------
705% --- Executes on selection change in vector_x.
706%------------------------------------------------------------------------
707function vector_x_Callback(hObject, eventdata, handles)
708
709vector_x_menu=get(handles.vector_x,'String');
710vector_x_index=get(handles.vector_x,'Value');
711vector_x=vector_x_menu{vector_x_index};
712vector_Callback(handles)
713update_field(handles,vector_x)
714
715%------------------------------------------------------------------------
716% --- Executes on selection change in vector_x.
717function vector_y_Callback(hObject, eventdata, handles)
718%------------------------------------------------------------------------
719vector_y_menu=get(handles.vector_x,'String');
720vector_y_index=get(handles.vector_x,'Value');
721vector_y=vector_y_menu{vector_y_index};
722vector_Callback(handles)
723update_field(handles,vector_y)
724
725%------------------------------------------------------------------------
726% --- Executes on selection change in vector_z.
727function vector_z_Callback(hObject, eventdata, handles)
728%------------------------------------------------------------------------
729vector_z_menu=get(handles.vector_z,'String');
730vector_z_index=get(handles.vector_z,'Value');
731vector_z=vector_z_menu{vector_z_index};
732vector_Callback(handles)
733update_field(handles,vector_z)
734
735%------------------------------------------------------------------------
736% --- Executes on selection change in vec_color.
737function vec_color_Callback(hObject, eventdata, handles)
738%------------------------------------------------------------------------
739index=get(handles.vec_color,'Value');
740string=get(handles.vec_color,'String');
741VarName=string{index};
742vector_Callback(handles)
743update_field(handles,VarName)
744
745%------------------------------------------------------------------------
746% --- Executes on selection change in vector_x or vector_y
747function vector_Callback( handles)
748%------------------------------------------------------------------------
749Field=get(handles.get_field,'UserData');
750vector_x_index=get(handles.vector_x,'Value');
751vector_y_index=get(handles.vector_y,'Value');
752vec_color_index=get(handles.vec_color,'Value');
753
754%% set list of possible coordinates
755test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
756test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate
757check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn
758ListCoord={''};
759dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable
760if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index})
761    check_consistent=0;
762elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index})
763    check_consistent=0;
764end
765% the two vector components have consistent dimensions
766if check_consistent
767    for ilist=1:numel(Field.Display.VarDimName)
768        dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
769        if isequal(dimnames,dim_var)
770            test_component(ilist)=1;
771        elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable
772            test_coord(ilist)=1;
773        end
774    end
775    var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
776    var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
777    var_component(var_component==vector_x_index|var_component==vector_y_index)=[];
778    var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components form te possible list of coordinates
779    ListCoord=Field.Display.ListVarName([var_coord var_component]);
780   
781    %% set default coord selection
782    if numel(find(test_coord))>3
783        set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time
784    end
785    if numel(var_component)<2
786        if numel(find(test_coord))<2
787            ListCoord={''};
788        else
789            if numel(find(test_coord))>=3
790                set(handles.Coord_x,'Value',3)
791                set(handles.Coord_y,'Value',2)
792                set(handles.Coord_z,'Value',1)
793            else
794                set(handles.Coord_x,'Value',2)
795                set(handles.Coord_y,'Value',1)
796            end
797        end
798    else
799        coord_val=[0 0 0];
800        for ilist=1:numel(var_component)
801            ivar=var_component(ilist);
802            if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role')
803                Role=Field.Display.VarAttribute{ivar}.Role;
804                if strcmp(Role,'coord_x')
805                    coord_val(1)=ilist;
806                elseif strcmp(Role,'coord_y')
807                    coord_val(2)=ilist;
808                elseif strcmp(Role,'coord_z')
809                    coord_val(3)=ilist;
810                end
811            end
812        end
813        if isempty(find(coord_val))
814            coord_val=var_coord;% case of dimension coordinates
815        end
816        if numel(find(coord_val))<2
817            %coord_val=[numel(var_component)+2 numel(var_component)+1];
818            coord_val=[1 2 3];
819        end
820        set(handles.Coord_x,'Value',coord_val(1))
821        set(handles.Coord_y,'Value',coord_val(2))
822        if numel(coord_val)>=3
823            set(handles.Coord_z,'Value',coord_val(3))
824        end
825    end
826end
827set(handles.Coord_z,'String',ListCoord)
828set(handles.Coord_y,'String',ListCoord)
829set(handles.Coord_x,'String',ListCoord)
830
831
832%% set list of time coordinates
833menu=get(handles.SwitchVarIndexTime,'String');
834TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')};
835switch TimeOption
836    case 'variable'
837        if numel(find(test_coord))<3
838            ListTime={''};
839        else
840            ListTime=Field.Display.ListVarName(find(test_coord,end));
841        end
842        set(handles.TimeName,'Value',1)
843        set(handles.TimeName,'String',ListTime)
844    case 'dim index'
845        if numel(find(test_coord))<3
846            ListTime={''};
847        else
848            ListTime=Field.Display.VarDimName{find(test_coord,end)};
849        end
850        set(handles.TimeName,'Value',1)
851        set(handles.TimeName,'String',ListTime)
852end 
853
854%------------------------------------------------------------------------
855% --- Executes on selection change in SwitchVarIndexX.
856%------------------------------------------------------------------------
857function SwitchVarIndexX_Callback(hObject, eventdata, handles)
858
859%------------------------------------------------------------------------
860% --- Executes on selection change in Coord_x.
861%------------------------------------------------------------------------
862function Coord_x_Callback(hObject, eventdata, handles)
863
864index=get(handles.Coord_x,'Value');
865string=get(handles.Coord_x,'String');
866VarName=string{index};
867update_field(handles,VarName)
868
869%------------------------------------------------------------------------
870% --- Executes on selection change in Coord_y.
871%------------------------------------------------------------------------
872function Coord_y_Callback(hObject, eventdata, handles)
873
874index=get(handles.Coord_y,'Value');
875string=get(handles.Coord_y,'String');
876VarName=string{index};
877update_field(handles,VarName)
878
879%------------------------------------------------------------------------
880% --- Executes on selection change in Coord_z.
881%------------------------------------------------------------------------
882function Coord_z_Callback(hObject, eventdata, handles)
883
884index=get(handles.Coord_z,'Value');
885string=get(handles.Coord_z,'String');
886VarName=string{index};
887update_field(handles,VarName)
888
889%------------------------------------------------------------------------
890% --- Executes on selection change in SwitchVarIndexTime.
891%------------------------------------------------------------------------
892
893function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
894
895Field=get(handles.get_field,'UserData');
896menu=get(handles.SwitchVarIndexTime,'String');
897option=menu{get(handles.SwitchVarIndexTime,'Value')};
898
899switch option
900    case 'file index'
901        set(handles.TimeName, 'Visible','off')% the time is taken as the file index
902    case 'attribute'
903        set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes
904        time_index=get(handles.TimeName,'UserData');    %select the input data
905        if isempty(time_index)
906            PreviousList=get(handles.TimeName, 'String');
907            if ~isempty(PreviousList)
908                PreviousAttr=PreviousList{get(handles.TimeName, 'Value')};
909                index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1);
910            end
911        end
912        if isempty(time_index)
913            time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time'
914        end     
915        if ~isempty(time_index)
916            set(handles.TimeName,'Value',time_index)
917        else
918            set(handles.TimeName,'Value',1)
919        end
920        set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute)
921
922    case 'variable'% TimeName menu represents the available variables
923        set(handles.TimeName, 'Visible','on')
924        VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable
925        TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time)
926        List=get(handles.TimeName,'String');% list of names on the menu for time
927        if isempty(List)
928            ind=1;
929        else
930            option=List{get(handles.TimeName,'Value')};% previous selected option
931            ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist
932            if isempty(ind)
933                ind=1;
934            end
935        end
936        if ~isempty(TimeVarName)
937            set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found
938            set(handles.TimeName, 'String',TimeVarName)% update the menu for time name
939        end
940    case 'matrix index'% TimeName menu represents the available dimensions
941        set(handles.TimeName, 'Visible','on')     
942        set(handles.TimeName, 'Value',1);
943        set(handles.TimeName, 'String',Field.Display.ListDimName)
944end
945TimeName_Callback(hObject, [], handles)
946
947%-----------------------------------------------------------------------
948function update_field(handles,VarName)
949%-----------------------------------------------------------------------
950Field=get(handles.get_field,'UserData');
951index=name2index(VarName,Field.ListVarName);
952if ~isempty(index)
953    set(handles.variables,'Value',index+1)
954    variables_Callback(handles.variables, [], handles)
955end
956
957%------------------------------------------------------------------------
958% --- give index numbers of the strings str in the list ListvarName
959% -----------------------------------------------------------------------
960function VarIndex_y=name2index(cell_str,ListVarName)
961
962VarIndex_y=[];
963if ischar(cell_str)
964    for ivar=1:length(ListVarName)
965        varlist=ListVarName{ivar};
966        if isequal(varlist,cell_str)
967            VarIndex_y= ivar;
968            break
969        end
970    end
971elseif iscell(cell_str)
972    for isel=1:length(cell_str)
973        varsel=cell_str{isel};
974        for ivar=1:length(ListVarName)
975            varlist=ListVarName{ivar};
976            if isequal(varlist,varsel)
977                VarIndex_y=[VarIndex_y ivar];
978            end
979        end
980    end
981end
982
983% --- Executes on button press in CheckDimensionY.
984function CheckDimensionX_Callback(hObject, eventdata, handles)
985CheckDimensionX=get(handles.CheckDimensionX,'value')
986if CheckDimensionX
987    set(handles.Coordinates,'visible','off')
988else
989    set(handles.Coordinates,'visible','on')
990end
991% FieldList=get(handles.FieldOption,'String');
992% FieldOption=FieldList{get(handles.FieldOption,'Value')};
993% switch FieldOption
994%     case '1D plot'
995%         
996%     case {'scalar'}
997%        scalar_Callback(hObject, eventdata, handles)
998%     case 'vectors'
999% end
1000
1001% % --- Executes on button press in CheckDimensionY.
1002% function CheckDimensionY_Callback(hObject, eventdata, handles)
1003% FieldList=get(handles.FieldOption,'String');
1004% FieldOption=FieldList{get(handles.FieldOption,'Value')};
1005% switch FieldOption
1006%     case '1D plot'
1007%         
1008%     case {'scalar','pick variables'}
1009%        scalar_Callback(hObject, eventdata, handles)
1010%     case 'vectors'
1011% end
1012%
1013%
1014% % --- Executes on button press in CheckDimensionZ.
1015% function CheckDimensionZ_Callback(hObject, eventdata, handles)
1016% FieldList=get(handles.FieldOption,'String');
1017% FieldOption=FieldList{get(handles.FieldOption,'Value')};
1018% switch FieldOption
1019%     case '1D plot'
1020%         
1021%     case 'scalar'
1022%        scalar_Callback(hObject, eventdata, handles)
1023%     case 'vectors'
1024% end
1025
1026% --- Executes on selection change in TimeName.
1027function TimeName_Callback(hObject, eventdata, handles)
1028Field=get(handles.get_field,'UserData');
1029index=get(handles.SwitchVarIndexTime,'Value');
1030MenuIndex=get(handles.TimeName,'Value');
1031string=get(handles.TimeName,'String');
1032TimeName='';%default
1033if ~isempty(string)&&iscell(string)
1034TimeName=string{MenuIndex};
1035end
1036switch index
1037    case 1
1038        set(handles.num_TimeDimension,'String','')
1039        set(handles.TimeUnit,'String','index')
1040    case 2
1041        set(handles.num_TimeDimension,'String','')
1042        attr_index=find(strcmpi([TimeName 'Unit'],Field.ListGlobalAttribute));% look for time unit
1043        if ~isempty(attr_index)
1044            AttrName=Field.ListGlobalAttribute{attr_index};
1045            set(handles.TimeUnit,'String',Field.(AttrName))
1046        else
1047            set(handles.TimeUnit,'String','')
1048        end
1049    case {3 ,4}
1050        if index==3  % TimeName is used to chose a variable
1051            VarIndex=name2index(TimeName,Field.ListVarName);
1052            DimName=Field.VarDimName{VarIndex};
1053            DimIndex=name2index(DimName,Field.ListDimName);
1054            DimValue=Field.DimValue(DimIndex);
1055            set(handles.num_TimeDimension,'String',num2str(DimValue))
1056            unit='';
1057            if isfield(Field,'VarAttribute')&& isfield(Field.VarAttribute{VarIndex},'Unit')
1058                unit=Field.VarAttribute{VarIndex}.Unit;
1059            end
1060            set(handles.TimeUnit,'String',unit)
1061            update_field(handles,TimeName)
1062        elseif index==4% TimeName is used to chose a dimension
1063            DimName=string{MenuIndex};
1064            DimIndex=name2index(DimName,Field.ListDimName);
1065            DimValue=Field.DimValue(DimIndex);
1066            set(handles.num_TimeDimension,'String',num2str(DimValue))
1067            set(handles.TimeUnit,'String','index')
1068        end
1069end
1070
1071
1072% --- Executes on button press in Check3D.
1073function Check3D_Callback(hObject, eventdata, handles)
1074if get(handles.Check3D,'Value')% 3D fields
1075    status='on';
1076else% fields studied as 2D
1077    status='off';
1078end
1079
1080set(handles.Coord_z,'Visible',status)
1081% set(handles.CheckDimensionZ,'Visible',status)
1082set(handles.Z_title,'Visible',status)
1083set(handles.vector_z,'Visible',status)
1084set(handles.W_title,'Visible',status)
1085if strcmp(status,'on')% ask for 3D input   
1086    Field=get(handles.get_field,'UserData');
1087    if Field.MaxDim>3% for 4D fields, propose to use the fourth variable as time
1088        %set(handles.Time,'Visible','on')
1089        menu=get(handles.SwitchVarIndexTime,'String');
1090        val=find(strcmp('variable',menu));
1091        if ~isempty(val)
1092            set(handles.SwitchVarIndexTime,'Value',val)
1093        end
1094    else
1095        set(handles.SwitchVarIndexTime,'Value',1)
1096        set(handles.SwitchVarIndexTime,'String',{'file index'})
1097    end
1098else
1099   set(handles.SwitchVarIndexTime,'String',get(handles.SwitchVarIndexTime,'UserData'))
1100end
1101SwitchVarIndexTime_Callback(handles.SwitchVarIndexTime,[], handles)
1102
1103%------------------------------------------------------------------------
1104% --- Executes on button press in OK.
1105%------------------------------------------------------------------------
1106function OK_Callback(hObject, eventdata, handles)
1107handles.output=read_GUI(handles.get_field);
1108guidata(hObject, handles);% Update handles structure
1109uiresume(handles.get_field);
1110drawnow
1111% this function then activate get_field_OutputFcn
1112
1113%------------------------------------------------------------------------
1114% --- Executes when the GUI is closed by the mouse on upper right corner.
1115%------------------------------------------------------------------------
1116function closefcn(hObject, eventdata, handles)
1117handles.output=[];
1118guidata(hObject, handles);% Update handles structure
1119uiresume(handles.get_field);
1120drawnow
1121
1122%------------------------------------------------------------------------
1123% --- Outputs from this function are returned to the command line.
1124%------------------------------------------------------------------------
1125function varargout = get_field_OutputFcn(hObject, eventdata, handles)
1126
1127varargout{1} =handles.output;
1128delete(handles.get_field)
Note: See TracBrowser for help on using the repository browser.