Changeset 1040 for trunk/src/get_field.m


Ignore:
Timestamp:
May 4, 2018, 10:57:13 PM (7 years ago)
Author:
sommeria
Message:

get_field improved to select variables, uvmat rationalized with respect to input file types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r1028 r1040  
    335335        return
    336336    end
    337     var_select=list_var{index};
    338     set(handles.attributes_txt,'String', ['attributes of ' var_select])
     337    VarName=list_var{index};
     338    set(handles.attributes_txt,'String', ['attributes of ' VarName])
    339339    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
    340         %         nbline=0;
    341340        VarAttr=Field.VarAttribute{index-1};
    342341        if isstruct(VarAttr)
     
    356355if ~isempty(Tabcell)
    357356    Tabchar=cell2tab(Tabcell,'=');
    358     %     Tabchar=[{''};Tabchar];
    359357end
    360358set(handles.attributes,'Value',1);% select the first item
     
    364362if isfield(Field,'ListDimName')
    365363    Tabdim={};%default
    366     if isequal(index,1)%list all dimensions
     364    if isequal(index,1)%list all dimensions if '*' is selected as the variable
    367365        dim_indices=1:length(Field.ListDimName);
    368366        set(handles.dimensions_txt,'String', 'dimensions')
    369     else
     367    else   % a specific variable has been selected
    370368        DimCell=Field.VarDimName{index-1};
    371369        if ischar(DimCell)
    372             DimCell={DimCell};
     370            DimCell={DimCell};% transform into a cell for a single dimension defined by a char string
    373371        end
    374372        dim_indices=[];
     
    378376            dim_indices=[dim_indices dim_index];
    379377        end
    380         set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
     378        set(handles.dimensions_txt,'String', ['dimensions of ' VarName])
    381379    end
    382380    for iline=1:length(dim_indices)
     
    390388end
    391389
     390%% propose a plot by default if a variable has been selected
     391if ~isequal(index,1)
     392    if numel(DimCell)==1
     393        set(handles.FieldOption,'Value',1)%propose 1D plot
     394    else
     395        set(handles.FieldOption,'Value',2)%propose scalar plot
     396    end
     397    if numel(DimCell)<=2
     398        set(handles.Check3D,'Value',0)
     399    else
     400        set(handles.Check3D,'Value',1)
     401    end
     402    FieldOption_Callback(hObject, VarName, handles)
     403end
     404
    392405%------------------------------------------------------------------------
    393406% --- Executes on selection change in FieldOption.
    394407%------------------------------------------------------------------------
    395 function FieldOption_Callback(hObject, eventdata, handles)
     408function FieldOption_Callback(hObject, VarName, handles)
    396409
    397410Field=get(handles.get_field,'UserData');
     
    414427        set(handles.Coord_z,'Visible','off')
    415428        set(handles.Z_title,'Visible','off')
    416         ordinate_Callback(hObject, eventdata, handles)
     429        ordinate_Callback(hObject, VarName, handles)
    417430       
    418431    case {'scalar'}
     
    428441        set(handles.Coord_y,'Visible','on')
    429442        set(handles.Y_title,'Visible','on')
     443       
     444        if ~ischar(VarName)
     445           
    430446        %default scalar selection
    431447        test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
     
    447463        else
    448464            set(handles.scalar,'Value',scalar_index)
    449         end       
    450         scalar_Callback(hObject, eventdata, handles)
     465        end     
     466        end
     467        scalar_Callback(hObject,VarName, handles)
     468       
    451469             
    452470    case 'vectors'
     
    501519
    502520%------------------------------------------------------------------------
    503 function ordinate_Callback(hObject, eventdata, handles)
     521function ordinate_Callback(hObject, DimCell, handles)
    504522%------------------------------------------------------------------------
    505523Field=get(handles.get_field,'UserData');
     
    584602        set(handles.TimeName,'String',ListTime)
    585603end 
     604if ~ischar(DimCell)
    586605update_field(handles,YName)
     606end
    587607         
    588608%------------------------------------------------------------------------
    589609% --- Executes on selection change in scalar menu.
    590610%------------------------------------------------------------------------
    591 function scalar_Callback(hObject, eventdata, handles)
     611function scalar_Callback(hObject, VarName, handles)
    592612
    593613Field=get(handles.get_field,'UserData');
    594 scalar_index=get(handles.scalar,'Value');
    595614scalar_menu=get(handles.scalar,'String');
    596 ScalarName=scalar_menu{scalar_index};
     615if ischar(VarName)
     616    ScalarName=VarName;
     617    scalar_index=find(strcmp(VarName,scalar_menu));
     618    set(handles.scalar,'Value',scalar_index)
     619else
     620    scalar_index=get(handles.scalar,'Value');
     621        ScalarName=scalar_menu{scalar_index};
     622end
    597623
    598624%% set list of possible coordinates
     
    696722        set(handles.TimeName,'String',ListTime)
    697723end 
     724if ~ischar(VarName)
    698725update_field(handles,ScalarName)
     726end
    699727
    700728% --- Executes on button press in check_rgb.
     
    705733% --- Executes on selection change in vector_x.
    706734%------------------------------------------------------------------------
    707 function vector_x_Callback(hObject, eventdata, handles)
     735function vector_x_Callback(hObject, DimCell, handles)
    708736
    709737vector_x_menu=get(handles.vector_x,'String');
     
    711739vector_x=vector_x_menu{vector_x_index};
    712740vector_Callback(handles)
     741if ~ischar(DimCell)
    713742update_field(handles,vector_x)
     743end
    714744
    715745%------------------------------------------------------------------------
    716746% --- Executes on selection change in vector_x.
    717 function vector_y_Callback(hObject, eventdata, handles)
    718 %------------------------------------------------------------------------
     747%------------------------------------------------------------------------
     748function vector_y_Callback(hObject, DimCell, handles)
     749
    719750vector_y_menu=get(handles.vector_x,'String');
    720751vector_y_index=get(handles.vector_x,'Value');
    721752vector_y=vector_y_menu{vector_y_index};
    722753vector_Callback(handles)
     754if ~ischar(DimCell)
    723755update_field(handles,vector_y)
     756end
    724757
    725758%------------------------------------------------------------------------
    726759% --- Executes on selection change in vector_z.
    727 function vector_z_Callback(hObject, eventdata, handles)
     760function vector_z_Callback(hObject, DimCell, handles)
    728761%------------------------------------------------------------------------
    729762vector_z_menu=get(handles.vector_z,'String');
     
    731764vector_z=vector_z_menu{vector_z_index};
    732765vector_Callback(handles)
     766if ~ischar(DimCell)
    733767update_field(handles,vector_z)
    734 
     768end
    735769%------------------------------------------------------------------------
    736770% --- Executes on selection change in vec_color.
    737 function vec_color_Callback(hObject, eventdata, handles)
     771function vec_color_Callback(hObject, DimCell, handles)
    738772%------------------------------------------------------------------------
    739773index=get(handles.vec_color,'Value');
     
    741775VarName=string{index};
    742776vector_Callback(handles)
     777if ~ischar(DimCell)
    743778update_field(handles,VarName)
    744 
     779end
    745780%------------------------------------------------------------------------
    746781% --- Executes on selection change in vector_x or vector_y
     
    860895% --- Executes on selection change in Coord_x.
    861896%------------------------------------------------------------------------
    862 function Coord_x_Callback(hObject, eventdata, handles)
     897function Coord_x_Callback(hObject, DimCell, handles)
    863898
    864899index=get(handles.Coord_x,'Value');
    865900string=get(handles.Coord_x,'String');
    866901VarName=string{index};
     902if ~ischar(DimCell)
    867903update_field(handles,VarName)
    868 
     904end
    869905%------------------------------------------------------------------------
    870906% --- Executes on selection change in Coord_y.
    871907%------------------------------------------------------------------------
    872 function Coord_y_Callback(hObject, eventdata, handles)
     908function Coord_y_Callback(hObject, DimCell, handles)
    873909
    874910index=get(handles.Coord_y,'Value');
    875911string=get(handles.Coord_y,'String');
    876912VarName=string{index};
     913if ~ischar(DimCell)
    877914update_field(handles,VarName)
     915end
    878916
    879917%------------------------------------------------------------------------
    880918% --- Executes on selection change in Coord_z.
    881919%------------------------------------------------------------------------
    882 function Coord_z_Callback(hObject, eventdata, handles)
     920function Coord_z_Callback(hObject, DimCell, handles)
    883921
    884922index=get(handles.Coord_z,'Value');
    885923string=get(handles.Coord_z,'String');
    886924VarName=string{index};
     925if ~ischar(DimCell)
    887926update_field(handles,VarName)
     927end
    888928
    889929%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.