Changeset 1080 for trunk/src/get_field.m
- Timestamp:
- Apr 17, 2020, 5:58:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r1072 r1080 136 136 end 137 137 if isempty(CellInfo) 138 Field.MaxDim=max(cellfun(@numel,Field.Display.VarDimName)); 138 [Field.MaxDim,imax]=max(cellfun(@numel,Field.Display.VarDimName));% maximum number of dimensions for the input fields 139 ListDim=Field.Display.VarDimName{imax}; 139 140 check_cellinfo=false; 140 141 else 141 [Field.MaxDim,imax]=max(NbDim); 142 [Field.MaxDim,imax]=max(NbDim);% maximum number of dimensions for the input fields identified by attributes 142 143 check_cellinfo=true; 143 144 end … … 171 172 172 173 %% select the Time attribute from input 173 if isfield(ParamIn,'TimeAttrName') 174 time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); 174 if Field.MaxDim >=2 175 variable_index=find(strcmp('variable',ListSwitchVarIndexTime),1); 176 set(handles.SwitchVarIndexTime,'Value',variable_index); 175 177 else 176 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time' 177 end 178 if isempty(time_index) 179 set(handles.SwitchVarIndexTime,'Value',1); 180 else 181 set(handles.SwitchVarIndexTime,'Value',2); 182 set(handles.TimeName,'UserData',time_index) 178 if isfield(ParamIn,'TimeAttrName') 179 time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); 180 else 181 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time' 182 end 183 if isempty(time_index) 184 set(handles.SwitchVarIndexTime,'Value',1); 185 else 186 set(handles.SwitchVarIndexTime,'Value',2); 187 set(handles.TimeName,'UserData',time_index) 188 end 183 189 end 184 190 set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) … … 258 264 %% fill menus for coordinates and time 259 265 FieldOption_Callback(handles.variables,[], handles)% list the global attributes 260 261 %% Make choices of coordinates from input262 % check_menu=false(1,numel(Data.ListVarName));263 % ListCoordMenu=1:numel(Data.ListVarName);264 % CoordIndex=CellInfo{icell}.CoordIndex(CellInfo{icell}.CoordIndex~=0);265 %266 % for ivar=find(check_coord_names)267 % check_dim=strcmp(Data.VarDimName{ivar},DimCell_var);268 % if ~isempty(find(check_dim))269 % check_menu(ivar)=true;270 % end271 % end272 % CellInfo{icell}.CoordMenu=[CoordIndex find(check_menu)];273 % ListCoordMenu(CoordIndex)=[];274 % for ivar=ListCoordMenu275 % DimCell=Data.VarDimName{ivar};276 % if isequal(DimCell,DimCell_var)277 % check_menu(ivar)=true;278 % end279 % end280 % CellInfo{icell}.CoordMenu=[CellInfo{icell}.CoordMenu find(check_menu)];281 %282 % if isfield(CellInfo{imax},'CoordIndex')283 % CoordIndex=CellInfo{imax}.CoordIndex;284 % if numel(CoordIndex)==2285 % if isfield(ParamIn,'Coord_x')&& isfield(ParamIn,'Coord_y')286 % YName=ParamIn.Coord_y;287 % XName=ParamIn.Coord_x;288 % else289 % YName=Field.ListVarName{CoordIndex(1)};290 % XName=Field.ListVarName{CoordIndex(2)};291 % end292 % ListCoord=get(handles.Coord_x,'String');293 % XIndex=find(strcmp(XName,ListCoord));294 % if ~isempty(XIndex)295 % set(handles.Coord_x,'Value',XIndex)296 % end297 % YIndex=find(strcmp(YName,ListCoord));298 % if ~isempty(YIndex)299 % set(handles.Coord_y,'Value',YIndex)300 % end301 % end302 % end303 266 304 267 %% put the GUI on the lower right of the sceen … … 663 626 var_component(var_component==scalar_index)=[]; 664 627 ListCoord=Field.Display.ListVarName([var_coord var_component]); 665 666 %% set default coord selection 628 coord_val=zeros(size(ListCoord)); 629 630 %% set default selection for grid coordinates 631 coord_val(1)=var_coord(end); 632 coord_val(2)=var_coord(end-1); 633 if numel(var_coord)>=3 634 coord_val(3)=var_coord(end-2); 635 end 667 636 % if numel(find(test_coord))>3 668 637 % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); … … 675 644 % end 676 645 677 coord_val=[0 0]; 678 % look for labelled unstructured coordinates 646 %% default selection for labelled unstructured coordinates 679 647 for ilist=1:numel(var_component) 680 648 ivar=var_component(ilist); … … 696 664 coord_val([1 2])=[1 2]; 697 665 end 666 667 %% set menu and default selection for coordinates 698 668 set(handles.Coord_x,'Value',coord_val(1)) 699 669 set(handles.Coord_x,'String',ListCoord) 700 701 670 set(handles.Coord_y,'Value',coord_val(2)) 702 671 set(handles.Coord_y,'String',ListCoord) 703 704 672 if numel(coord_val)>=3 705 673 set(handles.Coord_z,'Value',coord_val(3)) … … 956 924 if ~isempty(PreviousList) 957 925 PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; 958 index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttribute s),1);926 index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttribute),1); 959 927 end 960 928 end … … 1011 979 VarIndex_y=[]; 1012 980 if ischar(cell_str) 1013 for ivar=1:length(ListVarName) 1014 varlist=ListVarName{ivar}; 1015 if isequal(varlist,cell_str) 1016 VarIndex_y= ivar; 1017 break 1018 end 1019 end 981 VarIndex_y=find(strcmp(cell_str,ListVarName),1); 1020 982 elseif iscell(cell_str) 1021 983 for isel=1:length(cell_str) … … 1030 992 end 1031 993 1032 % --- Executes on button press in CheckDimensionY. 1033 % function CheckDimensionX_Callback(hObject, eventdata, handles) 1034 % CheckDimensionX=get(handles.CheckDimensionX,'value') 1035 % if CheckDimensionX 1036 % set(handles.Coordinates,'visible','off') 1037 % else 1038 % set(handles.Coordinates,'visible','on') 1039 % end 1040 % FieldList=get(handles.FieldOption,'String'); 1041 % FieldOption=FieldList{get(handles.FieldOption,'Value')}; 1042 % switch FieldOption 1043 % case '1D plot' 1044 % 1045 % case {'scalar'} 1046 % scalar_Callback(hObject, eventdata, handles) 1047 % case 'vectors' 1048 % end 994 1049 995 1050 996 % % --- Executes on button press in CheckDimensionY. … … 1118 1064 end 1119 1065 1120 1066 %----------------------------------------------------------------------- 1121 1067 % --- Executes on button press in Check3D. 1068 %----------------------------------------------------------------------- 1122 1069 function Check3D_Callback(hObject, eventdata, handles) 1123 1070 if get(handles.Check3D,'Value')% 3D fields … … 1132 1079 set(handles.vector_z,'Visible',status) 1133 1080 set(handles.W_title,'Visible',status) 1134 if strcmp(status,'on')% ask for 3D input 1135 Field=get(handles.get_field,'UserData'); 1081 Field=get(handles.get_field,'UserData'); 1082 if strcmp(status,'on')% ask for 3D input 1136 1083 if Field.MaxDim>3% for 4D fields, propose to use the fourth variable as time 1137 1084 %set(handles.Time,'Visible','on') … … 1143 1090 else 1144 1091 set(handles.SwitchVarIndexTime,'Value',1) 1145 set(handles.SwitchVarIndexTime,'String',{'file index' })1146 end 1147 else 1092 set(handles.SwitchVarIndexTime,'String',{'file index';'attribute'}) 1093 end 1094 else 1148 1095 set(handles.SwitchVarIndexTime,'String',get(handles.SwitchVarIndexTime,'UserData')) 1096 if Field.MaxDim >=3 1097 var_index=find(strcmp('variable',get(handles.SwitchVarIndexTime,'UserData'))); 1098 set(handles.SwitchVarIndexTime,'Value',var_index) 1099 end 1149 1100 end 1150 1101 SwitchVarIndexTime_Callback(handles.SwitchVarIndexTime,[], handles)
Note: See TracChangeset
for help on using the changeset viewer.