Changeset 693 for trunk/src/get_field.m


Ignore:
Timestamp:
Oct 29, 2013, 12:28:57 PM (11 years ago)
Author:
sommeria
Message:

bug repaired geometry_calib/Detect grid, + corrections in get_field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r675 r693  
    3434function varargout = get_field(varargin)
    3535
    36 % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54
     36% Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17
    3737
    3838% Begin initialization code - DO NOT EDIT
     
    9797        check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton
    9898    end
    99     Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)));% =1 if the variable reduces to a single value
     99    Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)))||(~isequal(Field.VarType(ilist),4)&&~isequal(Field.VarType(ilist),5));% =1 if the variable reduces to a single value
    100100    if ~Field.Check0D(ilist)
    101101    Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions
     
    137137end
    138138if Field.MaxDim>=2
    139     ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index
     139    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index
    140140end
    141141
     
    144144    time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1);
    145145else
    146     time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);
     146    time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time'
    147147end
    148148if ~isempty(time_index)
     
    517517%% set default coord selection
    518518if numel(find(test_coord))>3
     519     SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');
     520    if numel(SwitchVarIndexTime)<3
     521        SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index'];
     522        set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime)
     523    end
    519524    set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time
     525    SwitchVarIndexTime_Callback([], [], handles)
    520526end
    521527if numel(var_component)<2
     
    554560        set(handles.TimeName,'Value',1)
    555561        set(handles.TimeName,'String',ListTime)
    556     case 'dim index'
     562    case 'matrix index'
    557563        if numel(find(test_coord))<3
    558564            ListTime={''};
     
    579585test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
    580586dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
    581 for ilist=1:numel(Field.Display.VarDimName)
    582     dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
    583     if isequal(dimnames,dim_var)
    584         test_component(ilist)=1;
    585     elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable
    586         test_coord(ilist)=1;
     587CheckDimensionX=get(handles.CheckDimensionX,'Value');
     588CheckDimensionY=get(handles.CheckDimensionY,'Value');
     589if ~CheckDimensionX  || ~CheckDimensionY
     590    %look for coordinate variables among the other variables
     591    for ilist=1:numel(Field.Display.VarDimName)
     592        dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
     593        if isequal(dimnames,dim_var)
     594            test_component(ilist)=1;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate
     595        elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var), 1))%variable ilist is a 1D array which can be coordinate variable
     596            test_coord(ilist)=1;
     597        end
    587598    end
    588599end
     
    593604%% set default coord selection
    594605if numel(find(test_coord))>3
     606    SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');
     607    if numel(SwitchVarIndexTime)<3
     608        SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index'];
     609        set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime)
     610    end
    595611    set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time
     612    SwitchVarIndexTime_Callback([], [], handles)
    596613end
    597614% if numel(var_component)<2
     
    623640    end
    624641end
    625 set(handles.Coord_x,'Value',coord_val(1))
    626 set(handles.Coord_y,'Value',coord_val(2))
    627 set(handles.Coord_y,'String',ListCoord)
    628 set(handles.Coord_x,'String',ListCoord)
    629 
     642if  CheckDimensionX
     643    set(handles.Coord_x,'Value',2)
     644    set(handles.Coord_x,'String',dim_var')
     645else
     646    set(handles.Coord_x,'Value',coord_val(1))
     647    set(handles.Coord_x,'String',ListCoord)
     648end
     649if  CheckDimensionY
     650    set(handles.Coord_y,'Value',1)
     651    set(handles.Coord_y,'String',dim_var')
     652else
     653    set(handles.Coord_y,'Value',coord_val(2))
     654    set(handles.Coord_y,'String',ListCoord)
     655end
    630656
    631657%% set list of time coordinates
     
    871897        end
    872898        set(handles.TimeName, 'String',TimeVarName)
    873     case 'dim index'% TimeName menu represents the available dimensions
    874         set(handles.TimeName, 'Visible','on')
    875         TimeVarName=Field.Display.SingleDimName;
    876         List=get(handles.TimeName,'String');
    877         option=List{get(handles.TimeName,'Value')};
    878         ind=find(strcmp(option,TimeVarName));
    879         if isempty(ind)
    880             set(handles.TimeName, 'Value',1);
    881         else
    882             set(handles.TimeName, 'Value',ind);
    883         end
    884         set(handles.TimeName, 'String',TimeVarName)
     899    case 'matrix_index'% TimeName menu represents the available dimensions
     900        set(handles.TimeName, 'Visible','on')     
     901        set(handles.TimeName, 'Value',1);
     902        set(handles.TimeName, 'String',Field.Display.ListDimName)
    885903end
    886904
     
    920938    end
    921939end
     940
     941% --- Executes on button press in CheckDimensionY.
     942function CheckDimensionX_Callback(hObject, eventdata, handles)
     943FieldList=get(handles.FieldOption,'String');
     944FieldOption=FieldList{get(handles.FieldOption,'Value')};
     945switch FieldOption
     946    case '1D plot'
     947       
     948    case 'scalar'
     949       scalar_Callback(hObject, eventdata, handles)
     950    case 'vectors'
     951end
     952
     953% --- Executes on button press in CheckDimensionY.
     954function CheckDimensionY_Callback(hObject, eventdata, handles)
     955FieldList=get(handles.FieldOption,'String');
     956FieldOption=FieldList{get(handles.FieldOption,'Value')};
     957switch FieldOption
     958    case '1D plot'
     959       
     960    case 'scalar'
     961       scalar_Callback(hObject, eventdata, handles)
     962    case 'vectors'
     963end
     964% hObject    handle to CheckDimensionY (see GCBO)
     965% eventdata  reserved - to be defined in a future version of MATLAB
     966% handles    structure with handles and user data (see GUIDATA)
     967
     968% Hint: get(hObject,'Value') returns toggle state of CheckDimensionY
Note: See TracChangeset for help on using the changeset viewer.