source: trunk/src/get_field.m @ 919

Last change on this file since 919 was 911, checked in by sommeria, 9 years ago

bug repaired in civ_series (mask problem) and clarification of output for OAR in series

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