Changeset 672 for trunk/src/get_field.m
- Timestamp:
- Aug 6, 2013, 3:47:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r669 r672 93 93 Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); 94 94 end 95 % Field.Display = list of variables and corresponding properties obtained after removal of singletons 95 96 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); 96 97 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); … … 137 138 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components 138 139 set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components 139 set(handles.vector_z,'String',[{''} Field. ListVarName])% fill the menu of y vector components140 set(handles.vec_color,'String',[{''} Field. ListVarName])% fill the menu of y vector components140 set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components 141 set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components 141 142 set(handles.scalar,'Value',1)% fill the menu of y vector components 142 set(handles.scalar,'String',Field. ListVarName)% fill the menu of y vector components143 set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components 143 144 set(handles.ordinate,'Value',1)% fill the menu of y vector components 144 set(handles.ordinate,'String',Field. ListVarName)% fill the menu of y vector components145 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components 145 146 if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') 146 147 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'}) 147 148 else 148 149 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) 149 150 end 150 151 if Field.MaxDim>=2 % case of 2D (or 3D) fields … … 157 158 set(handles.FieldOption,'Value',2) 158 159 end 159 160 160 else % case of 1D fields 161 161 set(handles.FieldOption,'Value',1) … … 182 182 % end 183 183 184 %% Make choices in menus from input 185 % if exist('ParamIn','var')&&~isempty(ParamIn) 186 % fill_GUI(ParamIn,handles.get_field); 187 % end 188 %FieldOption_Callback([],[],handles) 189 184 %% Make choices of coordinates from input 185 if isfield(CellInfo{imax},'CoordIndex') 186 CoordIndex=CellInfo{imax}.CoordIndex; 187 if numel(CoordIndex)==2 188 YName=Field.ListVarName{CoordIndex(1)}; 189 XName=Field.ListVarName{CoordIndex(2)}; 190 ListCoord=get(handles.Coord_x,'String'); 191 XIndex=find(strcmp(XName,ListCoord)); 192 if ~isempty(XIndex) 193 set(handles.Coord_x,'Value',XIndex) 194 end 195 YIndex=find(strcmp(YName,ListCoord)); 196 if ~isempty(YIndex) 197 set(handles.Coord_y,'Value',YIndex) 198 end 199 end 200 end 190 201 191 202 %% put the GUI on the lower right of the sceen … … 218 229 end 219 230 220 221 222 %------------------------------------------------------------------------223 224 231 %------------------------------------------------------------------------ 225 232 % --- Outputs from this function are returned to the command line. 233 %------------------------------------------------------------------------ 226 234 function varargout = get_field_OutputFcn(hObject, eventdata, handles) 227 %------------------------------------------------------------------------ 235 228 236 varargout{1} = handles.output; 229 237 delete(handles.get_field) … … 242 250 end 243 251 244 %--------------------------------------------------------- 252 %------------------------------------------------------------------------ 245 253 % --- Executes on button press in OK. 246 254 %------------------------------------------------------------------------ … … 254 262 % ----------------------------------------------------------------------- 255 263 % --- Activated by selection in the list of variables 264 % ---------------------------------------------------------------------- 256 265 function variables_Callback(hObject, eventdata, handles) 257 % ----------------------------------------------------------------------- 266 258 267 Tabchar={''};%default 259 268 Tabcell=[]; … … 263 272 264 273 %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected 265 if isequal(index,1) 274 if isequal(index,1) 266 275 set(handles.attributes_txt,'String','global attributes') 267 276 if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) 268 277 for iline=1:length(Field.ListGlobalAttribute) 269 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 278 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 270 279 if isfield(Field, Field.ListGlobalAttribute{iline}) 271 280 val=Field.(Field.ListGlobalAttribute{iline}); … … 279 288 Tabchar=cell2tab(Tabcell,'='); 280 289 end 281 %% list Attribute names and values associated to the Variable # index-1 290 %% list Attribute names and values associated to the Variable # index-1 282 291 else 283 292 list_var=get(handles.variables,'String'); … … 285 294 set(handles.attributes_txt,'String', ['attributes of ' var_select]) 286 295 if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 287 % nbline=0;296 % nbline=0; 288 297 VarAttr=Field.VarAttribute{index-1}; 289 298 if isstruct(VarAttr) … … 291 300 for iline=1:length(attr_list) 292 301 Tabcell{iline,1}=attr_list{iline}; 293 eval(['val=VarAttr.' attr_list{iline} ';']) 302 eval(['val=VarAttr.' attr_list{iline} ';']) 294 303 if ischar(val); 295 304 Tabcell{iline,2}=val; 296 305 else 297 306 Tabcell{iline,2}=num2str(val); 298 307 end 299 308 end 300 309 end 301 310 end 302 311 303 312 end 304 313 if ~isempty(Tabcell) 305 314 Tabchar=cell2tab(Tabcell,'='); 306 % Tabchar=[{''};Tabchar];315 % Tabchar=[{''};Tabchar]; 307 316 end 308 317 set(handles.attributes,'Value',1);% select the first item … … 319 328 if ischar(DimCell) 320 329 DimCell={DimCell}; 321 end 330 end 322 331 dim_indices=[]; 323 332 for idim=1:length(DimCell) 324 dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 333 dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 325 334 dim_index=find(dim_index,1); 326 335 dim_indices=[dim_indices dim_index]; … … 335 344 Tabchar=[{''} ;Tabchar]; 336 345 set(handles.dimensions,'Value',1) 337 set(handles.dimensions,'String',Tabchar) 338 end 346 set(handles.dimensions,'String',Tabchar) 347 end 339 348 340 349 %------------------------------------------------------------------------ … … 343 352 function FieldOption_Callback(hObject, eventdata, handles) 344 353 354 Field=get(handles.get_field,'UserData'); 345 355 FieldList=get(handles.FieldOption,'String'); 346 356 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 347 357 switch FieldOption 358 348 359 case '1D plot' 349 360 set(handles.Coordinates,'Visible','on') … … 361 372 set(handles.Z_title,'Visible','off') 362 373 ordinate_Callback(hObject, eventdata, handles) 374 363 375 case 'scalar' 364 376 set(handles.Coordinates,'Visible','on') … … 373 385 set(handles.Coord_y,'Visible','on') 374 386 set(handles.Y_title,'Visible','on') 387 %default scalar selection 388 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 389 for ilist=1:numel(Field.Display.VarDimName) 390 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') 391 Role=Field.Display.VarAttribute{ilist}.Role; 392 if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') 393 test_coord(ilist)=1; 394 end 395 end 396 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 397 if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable 398 test_coord(ilist)=1; 399 end 400 end 401 scalar_index=find(~test_coord,1);%get the first variable not a coordiante 402 if isempty(scalar_index) 403 set(handles.scalar,'Value',1) 404 else 405 set(handles.scalar,'Value',scalar_index) 406 end 375 407 scalar_Callback(hObject, eventdata, handles) 408 376 409 case 'vectors' 377 410 set(handles.Coordinates,'Visible','on') … … 385 418 set(handles.PanelVectors,'Position',pos) 386 419 set(handles.Coord_y,'Visible','on') 387 set(handles.Y_title,'Visible','on') 420 set(handles.Y_title,'Visible','on') 421 %default vector selection 422 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 423 for ilist=1:numel(Field.Display.VarDimName) 424 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') 425 Role=Field.Display.VarAttribute{ilist}.Role; 426 if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') 427 test_coord(ilist)=1; 428 end 429 end 430 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 431 if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable 432 test_coord(ilist)=1; 433 end 434 end 435 vector_index=find(~test_coord,2);%get the first variable not a coordiante 436 if isempty(vector_index) 437 set(handles.vector_x,'Value',1) 438 set(handles.vector_y,'Value',2) 439 else 440 set(handles.vector_x,'Value',vector_index(1)) 441 set(handles.vector_y,'Value',vector_index(2)) 442 end 388 443 vector_Callback(handles) 444 389 445 case 'civdata...' 390 446 set(handles.PanelOrdinate,'Visible','off') … … 483 539 test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate 484 540 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 485 ListCoord={''};486 541 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable 487 488 542 for ilist=1:numel(Field.Display.VarDimName) 489 543 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist … … 494 548 end 495 549 end 496 var_component=find(test_component);% list of variable indices elligible as unstructured coordi antes550 var_component=find(test_component);% list of variable indices elligible as unstructured coordinates 497 551 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 498 552 ListCoord=Field.Display.ListVarName([var_component var_coord]); … … 502 556 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 503 557 end 504 if numel(var_component)<2 505 if numel(test_coord)<2 506 ListCoord={''}; 558 % if numel(var_component)<2 559 % if numel(test_coord)<2 560 % ListCoord={''}; 561 % else 562 % set(handles.Coord_x,'Value',2) 563 % set(handles.Coord_y,'Value',1) 564 % end 565 % else 566 coord_val=[0 0]; 567 % look for labelled unstructured coordinates 568 for ilist=1:numel(var_component) 569 ivar=var_component(ilist); 570 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') 571 Role=Field.Display.VarAttribute{ivar}.Role; 572 if strcmp(Role,'coord_x') 573 coord_val(1)=ilist; 574 elseif strcmp(Role,'coord_y') 575 coord_val(2)=ilist; 576 end 577 end 578 end 579 if numel(find(coord_val))<2 580 if numel(var_coord)>=2 581 coord_val=[numel(var_component)+2 numel(var_component)+1]; 507 582 else 508 set(handles.Coord_x,'Value',2) 509 set(handles.Coord_y,'Value',1) 510 end 511 else 512 coord_val=[1 2]; 513 for ilist=1:numel(var_component) 514 ivar=var_component(ilist); 515 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') 516 Role=Field.Display.VarAttribute{ivar}.Role; 517 if strcmp(Role,'coord_x') 518 coord_val(1)=ilist; 519 elseif strcmp(Role,'coord_y') 520 coord_val(2)=ilist; 521 end 522 end 523 end 524 set(handles.Coord_x,'Value',coord_val(1)) 525 set(handles.Coord_y,'Value',coord_val(2)) 526 end 527 583 coord_val=[1 2]; 584 end 585 end 586 set(handles.Coord_x,'Value',coord_val(1)) 587 set(handles.Coord_y,'Value',coord_val(2)) 528 588 set(handles.Coord_y,'String',ListCoord) 529 589 set(handles.Coord_x,'String',ListCoord) … … 559 619 %------------------------------------------------------------------------ 560 620 % --- Executes on selection change in vector_x. 621 %------------------------------------------------------------------------ 561 622 function vector_x_Callback(hObject, eventdata, handles) 562 %------------------------------------------------------------------------ 623 563 624 vector_x_menu=get(handles.vector_x,'String'); 564 625 vector_x_index=get(handles.vector_x,'Value'); … … 617 678 check_consistent=0; 618 679 end 680 % the two vector components have consistent dimensions 619 681 if check_consistent 620 682 for ilist=1:numel(Field.Display.VarDimName) … … 642 704 end 643 705 else 644 coord_val=[ 1 2];706 coord_val=[0 0]; 645 707 for ilist=1:numel(var_component) 646 708 ivar=var_component(ilist); … … 654 716 end 655 717 end 718 if isempty(coord_val) 719 coord_val=var_coord;% case of dimension coordinates 720 end 721 if numel(find(coord_val))<2 722 coord_val=[numel(var_component)+2 numel(var_component)+1]; 723 end 656 724 set(handles.Coord_x,'Value',coord_val(1)) 657 725 set(handles.Coord_y,'Value',coord_val(2)) … … 691 759 %------------------------------------------------------------------------ 692 760 % --- Executes on selection change in Coord_x. 761 %------------------------------------------------------------------------ 693 762 function Coord_x_Callback(hObject, eventdata, handles) 694 %------------------------------------------------------------------------ 763 695 764 index=get(handles.Coord_x,'Value'); 696 765 string=get(handles.Coord_x,'String'); … … 700 769 %------------------------------------------------------------------------ 701 770 % --- Executes on selection change in Coord_y. 771 %------------------------------------------------------------------------ 702 772 function Coord_y_Callback(hObject, eventdata, handles) 703 %------------------------------------------------------------------------ 773 704 774 index=get(handles.Coord_y,'Value'); 705 775 string=get(handles.Coord_y,'String'); … … 709 779 %------------------------------------------------------------------------ 710 780 % --- Executes on selection change in Coord_z. 781 %------------------------------------------------------------------------ 711 782 function Coord_z_Callback(hObject, eventdata, handles) 712 %------------------------------------------------------------------------ 783 713 784 index=get(handles.Coord_z,'Value'); 714 785 string=get(handles.Coord_z,'String'); … … 720 791 %------------------------------------------------------------------------ 721 792 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 793 722 794 Field=get(handles.get_field,'UserData'); 723 795 menu=get(handles.SwitchVarIndexTime,'String'); … … 781 853 end 782 854 783 %------------------------------------------------- 784 % give index numbers of the strings str in the list ListvarName 855 %------------------------------------------------------------------------ 856 % --- give index numbers of the strings str in the list ListvarName 857 % ----------------------------------------------------------------------- 785 858 function VarIndex_y=name2index(cell_str,ListVarName) 859 786 860 VarIndex_y=[]; 787 861 if ischar(cell_str)
Note: See TracChangeset
for help on using the changeset viewer.