Changeset 747 for trunk/src/get_field.m
- Timestamp:
- Apr 22, 2014, 9:44:39 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r701 r747 34 34 function varargout = get_field(varargin) 35 35 36 % Last Modified by GUIDE v2.5 2 3-Oct-2013 23:44:1736 % Last Modified by GUIDE v2.5 21-Apr-2014 15:03:19 37 37 38 38 % Begin initialization code - DO NOT EDIT … … 86 86 Field.Display=Field; 87 87 Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value 88 NbVar=numel(Field.VarDimName); 88 NbVar=numel(Field.VarDimName);%nbre of variables in the input data 89 89 for ilist=1:NbVar 90 90 if ischar(Field.VarDimName{ilist}) … … 92 92 end 93 93 NbDim=numel(Field.VarDimName{ilist}); 94 check_singleton=false(1,NbDim); 94 check_singleton=false(1,NbDim);% check singleton, false by default 95 95 for idim=1:NbDim 96 96 dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions … … 101 101 Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions 102 102 end 103 %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons104 103 end 105 104 if ~isfield(Field,'VarAttribute') … … 109 108 Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); 110 109 end 111 % Field.Display = list of variables and corresponding properties obtained after removal of singletons112 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 111 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value 113 112 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); 114 113 Field.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); 114 Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names 115 Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values 116 117 117 118 118 %% analyse the input field cells … … 159 159 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components 160 160 set(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 components161 set(handles.vector_z,'String',Field.Display.ListVarName)% fill the menu of y vector components 162 162 set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components 163 163 set(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 components164 set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar 165 165 set(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 components166 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots 167 167 if 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 169 169 else 170 170 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) … … 238 238 set(hObject,'Position',pos_view_field) 239 239 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 240 241 %% set z coordinate menu if relevant 242 if Field.MaxDim>=3 243 set(handles.Check3D,'Value',1) 244 else 245 set(handles.Check3D,'Value',0) 246 end 247 Check3D_Callback(hObject, eventdata, handles) 240 248 drawnow 241 249 uiwait(handles.get_field); 242 243 return244 245 %% set z coordinate menu if relevant246 if Field.MaxDim>=3247 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 else253 set(handles.vector_z,'Visible','off')254 set(handles.Coord_z,'Visible','off')255 set(handles.Z_title,'Visible','off')256 end257 258 %% make selections according to ParamIn259 if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')260 261 end262 250 263 251 %------------------------------------------------------------------------ … … 431 419 end 432 420 end 433 scalar_index=find(~test_coord,1);%get the first variable not a coordi ante421 scalar_index=find(~test_coord,1);%get the first variable not a coordinate 434 422 if isempty(scalar_index) 435 423 set(handles.scalar,'Value',1) … … 589 577 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 590 578 dim_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 579 if ~get(handles.CheckDimensionX,'Value') || ~get(handles.CheckDimensionY,'Value') 594 580 %look for coordinate variables among the other variables 595 581 for ilist=1:numel(Field.Display.VarDimName) … … 616 602 SwitchVarIndexTime_Callback([], [], handles) 617 603 end 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 626 605 coord_val=[0 0]; 627 606 % look for labelled unstructured coordinates … … 644 623 end 645 624 end 646 if CheckDimensionX625 if get(handles.CheckDimensionX,'Value') 647 626 set(handles.Coord_x,'Value',2) 648 627 set(handles.Coord_x,'String',dim_var') … … 651 630 set(handles.Coord_x,'String',ListCoord) 652 631 end 653 if CheckDimensionY632 if get(handles.CheckDimensionY,'Value') 654 633 set(handles.Coord_y,'Value',1) 655 634 set(handles.Coord_y,'String',dim_var') … … 657 636 set(handles.Coord_y,'Value',coord_val(2)) 658 637 set(handles.Coord_y,'String',ListCoord) 638 end 639 if get(handles.CheckDimensionZ,'Value') 640 set(handles.Coord_z,'Value',1) 641 set(handles.Coord_z,'String',dim_var') 642 else 643 set(handles.Coord_z,'Value',coord_val(2)) 644 set(handles.Coord_z,'String',ListCoord) 659 645 end 660 646 … … 860 846 % --- Executes on selection change in SwitchVarIndexTime. 861 847 %------------------------------------------------------------------------ 848 862 849 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 863 850 … … 891 878 case 'variable'% TimeName menu represents the available variables 892 879 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 904 897 set(handles.TimeName, 'Visible','on') 905 898 set(handles.TimeName, 'Value',1); … … 966 959 case 'vectors' 967 960 end 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. 964 function CheckDimensionZ_Callback(hObject, eventdata, handles) 965 FieldList=get(handles.FieldOption,'String'); 966 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 967 switch FieldOption 968 case '1D plot' 969 970 case 'scalar' 971 scalar_Callback(hObject, eventdata, handles) 972 case 'vectors' 973 end 974 975 % --- Executes on selection change in TimeName. 976 function TimeName_Callback(hObject, eventdata, handles) 977 index=get(handles.SwitchVarIndexTime,'Value'); 978 if 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}; 982 end 983 update_field(handles,VarName) 984 985 986 % --- Executes on button press in Check3D. 987 function Check3D_Callback(hObject, eventdata, handles) 988 if get(handles.Check3D,'Value') 989 status='on'; 990 else 991 status='off'; 992 end 993 set(handles.Coord_z,'Visible',status) 994 set(handles.CheckDimensionZ,'Visible',status) 995 set(handles.Z_title,'Visible',status) 996 set(handles.vector_z,'Visible',status) 997 set(handles.W_title,'Visible',status) 998 999
Note: See TracChangeset
for help on using the changeset viewer.