Changeset 693 for trunk/src/get_field.m
- Timestamp:
- Oct 29, 2013, 12:28:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r675 r693 34 34 function varargout = get_field(varargin) 35 35 36 % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:5436 % Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17 37 37 38 38 % Begin initialization code - DO NOT EDIT … … 97 97 check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton 98 98 end 99 Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim))) ;% =1 if the variable reduces to a single value99 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 100 100 if ~Field.Check0D(ilist) 101 101 Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions … … 137 137 end 138 138 if Field.MaxDim>=2 139 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{' dimindex'}];% the time can be chosen as a dim index139 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index 140 140 end 141 141 … … 144 144 time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); 145 145 else 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' 147 147 end 148 148 if ~isempty(time_index) … … 517 517 %% set default coord selection 518 518 if 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 519 524 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 525 SwitchVarIndexTime_Callback([], [], handles) 520 526 end 521 527 if numel(var_component)<2 … … 554 560 set(handles.TimeName,'Value',1) 555 561 set(handles.TimeName,'String',ListTime) 556 case ' dimindex'562 case 'matrix index' 557 563 if numel(find(test_coord))<3 558 564 ListTime={''}; … … 579 585 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 580 586 dim_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; 587 CheckDimensionX=get(handles.CheckDimensionX,'Value'); 588 CheckDimensionY=get(handles.CheckDimensionY,'Value'); 589 if ~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 587 598 end 588 599 end … … 593 604 %% set default coord selection 594 605 if 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 595 611 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 612 SwitchVarIndexTime_Callback([], [], handles) 596 613 end 597 614 % if numel(var_component)<2 … … 623 640 end 624 641 end 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 642 if CheckDimensionX 643 set(handles.Coord_x,'Value',2) 644 set(handles.Coord_x,'String',dim_var') 645 else 646 set(handles.Coord_x,'Value',coord_val(1)) 647 set(handles.Coord_x,'String',ListCoord) 648 end 649 if CheckDimensionY 650 set(handles.Coord_y,'Value',1) 651 set(handles.Coord_y,'String',dim_var') 652 else 653 set(handles.Coord_y,'Value',coord_val(2)) 654 set(handles.Coord_y,'String',ListCoord) 655 end 630 656 631 657 %% set list of time coordinates … … 871 897 end 872 898 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) 885 903 end 886 904 … … 920 938 end 921 939 end 940 941 % --- Executes on button press in CheckDimensionY. 942 function CheckDimensionX_Callback(hObject, eventdata, handles) 943 FieldList=get(handles.FieldOption,'String'); 944 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 945 switch FieldOption 946 case '1D plot' 947 948 case 'scalar' 949 scalar_Callback(hObject, eventdata, handles) 950 case 'vectors' 951 end 952 953 % --- Executes on button press in CheckDimensionY. 954 function CheckDimensionY_Callback(hObject, eventdata, handles) 955 FieldList=get(handles.FieldOption,'String'); 956 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 957 switch FieldOption 958 case '1D plot' 959 960 case 'scalar' 961 scalar_Callback(hObject, eventdata, handles) 962 case 'vectors' 963 end 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.