Changeset 747 for trunk/src/get_field.m


Ignore:
Timestamp:
Apr 22, 2014, 9:44:39 AM (10 years ago)
Author:
sommeria
Message:

adpatations to 3D fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r701 r747  
    3434function varargout = get_field(varargin)
    3535
    36 % Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17
     36% Last Modified by GUIDE v2.5 21-Apr-2014 15:03:19
    3737
    3838% Begin initialization code - DO NOT EDIT
     
    8686Field.Display=Field;
    8787Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value
    88 NbVar=numel(Field.VarDimName);
     88NbVar=numel(Field.VarDimName);%nbre of variables in the input data
    8989for ilist=1:NbVar
    9090    if ischar(Field.VarDimName{ilist})
     
    9292    end
    9393    NbDim=numel(Field.VarDimName{ilist});
    94     check_singleton=false(1,NbDim);
     94    check_singleton=false(1,NbDim);%  check singleton, false by default
    9595    for idim=1:NbDim
    9696        dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions
     
    101101    Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions
    102102    end
    103     %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons
    104103end
    105104if ~isfield(Field,'VarAttribute')
     
    109108    Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute));
    110109end
    111 % Field.Display = list of variables and corresponding properties obtained after removal of singletons
    112 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D);
     110% Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions
     111Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value
    113112Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D);
    114113Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D);
    115 Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);
    116 Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);
     114Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names
     115Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values
     116
    117117
    118118%% analyse the input field cells
     
    159159set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components
    160160set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components
    161 set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
     161set(handles.vector_z,'String',Field.Display.ListVarName)% fill the menu of y vector components
    162162set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components
    163163set(handles.scalar,'Value',1)% fill the menu of y vector components
    164 set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components
     164set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar
    165165set(handles.ordinate,'Value',1)% fill the menu of y vector components
    166 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components
     166set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots
    167167if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
    168     set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})
     168    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata
    169169else
    170170    set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
     
    238238set(hObject,'Position',pos_view_field)
    239239set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
     240
     241%% set z coordinate menu if relevant
     242if Field.MaxDim>=3
     243    set(handles.Check3D,'Value',1)
     244else
     245    set(handles.Check3D,'Value',0)
     246end
     247Check3D_Callback(hObject, eventdata, handles)
    240248drawnow
    241249uiwait(handles.get_field);
    242 
    243 return
    244 
    245 %% set z coordinate menu if relevant
    246 if Field.MaxDim>=3
    247     set(handles.vector_z,'Visible','on')
    248     set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D))
    249     set(handles.Coord_z,'Visible','on')
    250     set(handles.SwitchVarIndexZ,'Visible','on')
    251     set(handles.Z_title,'Visible','on')
    252 else
    253     set(handles.vector_z,'Visible','off')
    254     set(handles.Coord_z,'Visible','off')
    255     set(handles.Z_title,'Visible','off')
    256 end
    257 
    258 %% make selections according to ParamIn
    259 if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')
    260    
    261 end
    262250
    263251%------------------------------------------------------------------------
     
    431419            end
    432420        end
    433         scalar_index=find(~test_coord,1);%get the first variable not a coordiante
     421        scalar_index=find(~test_coord,1);%get the first variable not a coordinate
    434422        if isempty(scalar_index)
    435423            set(handles.scalar,'Value',1)
     
    589577test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
    590578dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
    591 CheckDimensionX=get(handles.CheckDimensionX,'Value');
    592 CheckDimensionY=get(handles.CheckDimensionY,'Value');
    593 if ~CheckDimensionX  || ~CheckDimensionY
     579if ~get(handles.CheckDimensionX,'Value')  || ~get(handles.CheckDimensionY,'Value')
    594580    %look for coordinate variables among the other variables
    595581    for ilist=1:numel(Field.Display.VarDimName)
     
    616602    SwitchVarIndexTime_Callback([], [], handles)
    617603end
    618 % if numel(var_component)<2
    619 %     if numel(test_coord)<2
    620 %         ListCoord={''};
    621 %     else
    622 %         set(handles.Coord_x,'Value',2)
    623 %         set(handles.Coord_y,'Value',1)
    624 %     end
    625 % else
     604
    626605coord_val=[0 0];
    627606% look for labelled unstructured coordinates
     
    644623    end
    645624end
    646 if  CheckDimensionX
     625if  get(handles.CheckDimensionX,'Value')
    647626    set(handles.Coord_x,'Value',2)
    648627    set(handles.Coord_x,'String',dim_var')
     
    651630    set(handles.Coord_x,'String',ListCoord)
    652631end
    653 if  CheckDimensionY
     632if  get(handles.CheckDimensionY,'Value')
    654633    set(handles.Coord_y,'Value',1)
    655634    set(handles.Coord_y,'String',dim_var')
     
    657636    set(handles.Coord_y,'Value',coord_val(2))
    658637    set(handles.Coord_y,'String',ListCoord)
     638end
     639if  get(handles.CheckDimensionZ,'Value')
     640    set(handles.Coord_z,'Value',1)
     641    set(handles.Coord_z,'String',dim_var')
     642else
     643    set(handles.Coord_z,'Value',coord_val(2))
     644    set(handles.Coord_z,'String',ListCoord)
    659645end
    660646
     
    860846% --- Executes on selection change in SwitchVarIndexTime.
    861847%------------------------------------------------------------------------
     848
    862849function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
    863850
     
    891878    case 'variable'% TimeName menu represents the available variables
    892879        set(handles.TimeName, 'Visible','on')
    893         TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time)
    894         List=get(handles.TimeName,'String');
    895         option=List{get(handles.TimeName,'Value')};
    896         ind=find(strcmp(option,TimeVarName));
    897         if isempty(ind)
    898             set(handles.TimeName, 'Value',1);
    899         else
    900             set(handles.TimeName, 'Value',ind);
    901         end
    902         set(handles.TimeName, 'String',TimeVarName)
    903     case 'matrix_index'% TimeName menu represents the available dimensions
     880        VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable
     881        TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time)
     882        List=get(handles.TimeName,'String');% list of names on the menu for time
     883        if isempty(List)
     884            ind=1;
     885        else
     886            option=List{get(handles.TimeName,'Value')};% previous selected option
     887            ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist
     888            if isempty(ind)
     889                ind=1;
     890            end
     891        end
     892        if ~isempty(TimeVarName)
     893            set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found
     894            set(handles.TimeName, 'String',TimeVarName)% update the menu for time name
     895        end
     896    case 'matrix index'% TimeName menu represents the available dimensions
    904897        set(handles.TimeName, 'Visible','on')     
    905898        set(handles.TimeName, 'Value',1);
     
    966959    case 'vectors'
    967960end
    968 % hObject    handle to CheckDimensionY (see GCBO)
    969 % eventdata  reserved - to be defined in a future version of MATLAB
    970 % handles    structure with handles and user data (see GUIDATA)
    971 
    972 % Hint: get(hObject,'Value') returns toggle state of CheckDimensionY
     961
     962
     963% --- Executes on button press in CheckDimensionZ.
     964function CheckDimensionZ_Callback(hObject, eventdata, handles)
     965FieldList=get(handles.FieldOption,'String');
     966FieldOption=FieldList{get(handles.FieldOption,'Value')};
     967switch FieldOption
     968    case '1D plot'
     969       
     970    case 'scalar'
     971       scalar_Callback(hObject, eventdata, handles)
     972    case 'vectors'
     973end
     974
     975% --- Executes on selection change in TimeName.
     976function TimeName_Callback(hObject, eventdata, handles)
     977index=get(handles.SwitchVarIndexTime,'Value');
     978if index==3 ; % TimeName is used to chose a variable
     979    index=get(handles.TimeName,'Value');
     980    string=get(handles.TimeName,'String');
     981    VarName=string{index};
     982end
     983update_field(handles,VarName)
     984
     985
     986% --- Executes on button press in Check3D.
     987function Check3D_Callback(hObject, eventdata, handles)
     988if get(handles.Check3D,'Value')
     989    status='on';
     990else
     991    status='off';
     992end
     993set(handles.Coord_z,'Visible',status)
     994set(handles.CheckDimensionZ,'Visible',status)
     995set(handles.Z_title,'Visible',status)
     996set(handles.vector_z,'Visible',status)
     997set(handles.W_title,'Visible',status)   
     998
     999
Note: See TracChangeset for help on using the changeset viewer.