Changeset 227 for trunk/src/get_field.m
- Timestamp:
- Mar 31, 2011, 1:42:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r213 r227 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 06-Feb-2010 09:58:1324 % Last Modified by GUIDE v2.5 27-Mar-2011 19:13:26 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 49 49 global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN 50 50 51 %% look at the existing figures in the work space 52 browse_fig(handles.list_fig) 51 53 52 54 53 %% Choose default command line output for get_field … … 58 57 guidata(hObject, handles); 59 58 60 %% 61 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})59 %%activate the mouse action function: visualise the current field on work space by right click action 60 %set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) 62 61 63 62 %% prepare the list of RUN fcts and set their paths … … 112 111 %% settings for 'slave' mode, called by uvamt, or 'master' mode 113 112 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 114 set(handles.inputfile,'String',filename)% prefill the input file name 115 Field=nc2struct(filename );% reads the whole field113 set(handles.inputfile,'String',filename)% prefill the input file name 114 Field=nc2struct(filename,[]);% reads the whole field 116 115 if isfield(Field,'Txt') 117 116 msgbox_uvmat('ERROR',Field.Txt) 118 117 else 119 set(handles. figure1,'UserData',Field);118 set(handles.get_field,'UserData',Field); 120 119 Field_input(eventdata,handles,Field); 121 120 end 122 121 else %master mode 123 set(handles.inputfile,'String','') 124 % set(handles.RUN,'String','RUN')% 125 % load the list of previously browsed files for the upper bar menu Open 126 dir_perso=prefdir; 127 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% 128 if exist(profil_perso,'file') 129 h=load (profil_perso); 130 if isfield(h,'MenuFile_1')131 set(handles.MenuFile_1,'Label',h.MenuFile_1);132 end133 if isfield(h,'MenuFile_1')134 set(handles.MenuFile_2,'Label',h.MenuFile_2);135 end136 if isfield(h,'MenuFile_1')137 set(handles.MenuFile_3,'Label',h.MenuFile_3);138 end139 if isfield(h,'MenuFile_1')140 set(handles.MenuFile_4,'Label',h.MenuFile_4);141 end142 if isfield(h,'MenuFile_1')143 set(handles.MenuFile_5,'Label',h.MenuFile_5);144 end122 set(handles.inputfile,'String','') 123 end 124 125 %% load the list of previously browsed files for the upper bar menu Open 126 dir_perso=prefdir; 127 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% 128 if exist(profil_perso,'file') 129 h=load (profil_perso); 130 if isfield(h,'MenuFile_1') 131 set(handles.MenuFile_1,'Label',h.MenuFile_1); 132 end 133 if isfield(h,'MenuFile_1') 134 set(handles.MenuFile_2,'Label',h.MenuFile_2); 135 end 136 if isfield(h,'MenuFile_1') 137 set(handles.MenuFile_3,'Label',h.MenuFile_3); 138 end 139 if isfield(h,'MenuFile_1') 140 set(handles.MenuFile_4,'Label',h.MenuFile_4); 141 end 142 if isfield(h,'MenuFile_1') 143 set(handles.MenuFile_5,'Label',h.MenuFile_5); 145 144 end 146 145 end … … 168 167 %------------------------------------------------------------------------ 169 168 inputfile=get(handles.inputfile,'String'); 170 Field=nc2struct(inputfile);% reads the whole field 169 Field=nc2struct(inputfile,[]);% reads the field description, without data 170 Field.ListGlobalAttribute 171 171 if isfield(Field,'Txt') 172 172 msgbox_uvmat('ERROR',Field.Txt) 173 173 else 174 set(handles. figure1,'UserData',Field);174 set(handles.get_field,'UserData',Field); 175 175 Field_input(eventdata,handles,Field); 176 176 end … … 189 189 Tabcell{iline,2}=num2str(Field.DimValue(iline)); 190 190 end 191 Tabchar=cell2tab(Tabcell,' =');191 Tabchar=cell2tab(Tabcell,' = '); 192 192 set(handles.dimensions,'String',Tabchar) 193 193 end … … 212 212 set(handles.coord_z_vectors,'String',[{''} Txt ]) 213 213 set(handles.scalar,'Value',1) 214 214 215 set(handles.scalar,'String', Txt ) 215 216 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field); … … 218 219 return 219 220 end 221 for icell=1:numel(CellVarIndex) 222 NbDim(icell)=max(NbDim(icell),numel(CellVarIndex{icell})); 223 end 220 224 [maxdim,imax]=max(NbDim); 221 225 … … 278 282 check_vector_Callback(handles.check_vector, eventdata, handles) 279 283 end 284 %scalar_Callback(handles.get_field, eventdata, handles) 285 %vector_x_Callback(handles.get_field, eventdata, handles) 280 286 281 287 %------------------------------------------------------------------------ … … 315 321 % test_2D=get(handles.check_vector,'Value');% =1 for vector fields 316 322 % test_scalar=get(handles.check_scalar,'Value');% =1 for scalar fields 317 %if isequal(xdispindex,1)% blank selection, no selected variable for abscissa323 %if isequal(xdispindex,1)% blank selection, no selected TimeVariable for abscissa 318 324 % Txt=Field.ListVarName; 319 325 % set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates … … 329 335 % end 330 336 % set(handles.variables,'Value',xindex+1)%outline in the list of variables 331 % variables_Callback(hObject, eventdata, handles) %display properties of the variable (dim, attributes)337 % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) 332 338 % if ~test_2D & ~test_scalar% look for possible varaibles to RUN in ordinate 333 % index=Field.VarDimIndex{xindex};%dimension indices of the variable selected for abscissa339 % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa 334 340 % VarIndex=[]; 335 341 % for ilist=1:length(Field.VarDimIndex)%detect 336 342 % index_i=Field.VarDimIndex{ilist}; 337 343 % if ~isempty(index_i) 338 % if isequal(index_i(1),index(1))%if the first dimension of the variable coincide with the selected one, RUN is possible344 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, RUN is possible 339 345 % VarIndex=[VarIndex ilist]; 340 346 % end … … 352 358 function scalar_Callback(hObject, eventdata, handles) 353 359 %------------------------------------------------------------------------ 354 Aindex=get(handles.scalar,'Value');355 Astring=get(handles.scalar,'String');356 VarName= Astring{Aindex};360 index=get(handles.scalar,'Value'); 361 string=get(handles.scalar,'String'); 362 VarName=string{index}; 357 363 update_field(hObject, eventdata, handles,VarName) 364 365 %eliminate time 366 TimeDimName='';%default 367 if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on') 368 TimeDimList=get(handles.TimeDimensionMenu,'String'); 369 TimeDimIndex=get(handles.TimeDimensionMenu,'Value'); 370 TimeDimName=TimeDimList{TimeDimIndex}; 371 end 372 373 %check possible coordinates 374 Field=get(handles.get_field,'UserData'); 375 dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar 376 test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate 377 for ilist=1:numel(Field.VarDimName) 378 dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist 379 if isequal(dimnames,{TimeDimName}) 380 test_coord(ilist)=0;%mark time variables fo elimination 381 end 382 for idim=1:numel(dimnames) 383 if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable 384 test_coord(ilist)=0; 385 break 386 end 387 end 388 end 389 test_coord(index)=0;%the coordinate variable must be different from the scalar 390 391 string_coord=[{''};string(test_coord==1)]; 392 val=get(handles.coord_x_scalar,'Value'); 393 if val>numel(string_coord) 394 set(handles.coord_x_scalar,'Value',1) 395 end 396 set(handles.coord_x_scalar,'String',string_coord); 397 val=get(handles.coord_y_scalar,'Value'); 398 if val>numel(string_coord) 399 set(handles.coord_y_scalar,'Value',1) 400 end 401 set(handles.coord_y_scalar,'String',string_coord); 402 val=get(handles.coord_y_scalar,'Value'); 403 if val>numel(string_coord) 404 set(handles.coord_y_scalar,'Value',1) 405 end 406 set(handles.coord_z_scalar,'String',string_coord); 407 358 408 359 409 %------------------------------------------------------------------------ … … 391 441 string=get(handles.vector_x,'String'); 392 442 VarName=string{index}; 443 444 %check possible coordinates 445 Field=get(handles.get_field,'UserData'); 446 dim_var=Field.VarDimName{index};%list of dimensions of the selected scalar 447 test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate 448 test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component 449 for ilist=1:numel(Field.VarDimName) 450 dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist 451 if ~isequal(dimnames,dim_var) 452 test_component(ilist)=0; 453 end 454 for idim=1:numel(dimnames) 455 if isempty(find(strcmp(dimnames{idim},dim_var),1))%dimension not found in the scalar variable 456 test_coord(ilist)=0; 457 break 458 end 459 end 460 end 461 %eliminate time 462 if get(handles.TimeVariable,'Value') 463 TimeName=get(handles.TimeName,'String'); 464 index_time=find(strcmp( TimeName,Field.ListVarName)); 465 test_coord(index_time)=0; 466 end 467 vlength=numel(string(test_component==1)); 468 val=get(handles.vector_y,'Value'); 469 if val>vlength 470 set(handles.vector_y,'Value',1) 471 end 472 set(handles.vector_y,'String',[string(test_component==1)]) 473 val=get(handles.vector_z,'Value'); 474 if val>vlength+1 475 set(handles.vector_z,'Value',1) 476 end 477 set(handles.vector_z,'String',[{''};string(test_component==1)]) 478 val=get(handles.vec_color,'Value'); 479 if val>vlength+1 480 set(handles.vec_color,'Value',1) 481 end 482 set(handles.vec_color,'String',[{''};string(test_component==1)]) 483 string_coord=[{''};string(test_coord==1)]; 484 val=get(handles.coord_x_vectors,'Value'); 485 if val>numel(string_coord) 486 set(handles.coord_x_vectors,'Value',1) 487 end 488 set(handles.coord_x_vectors,'String',string_coord); 489 val=get(handles.coord_y_vectors,'Value'); 490 if val>numel(string_coord) 491 set(handles.coord_y_vectors,'Value',1) 492 end 493 set(handles.coord_y_vectors,'String',string_coord); 494 val=get(handles.coord_z_vectors,'Value'); 495 if val>numel(string_coord) 496 set(handles.coord_z_vectors,'Value',1) 497 end 498 set(handles.coord_z_vectors,'String',string_coord); 499 393 500 update_field(hObject, eventdata, handles,VarName) 394 501 … … 420 527 update_field(hObject, eventdata, handles,VarName) 421 528 422 %------------------------------------------------------- 529 %------------------------------------------------------------------------ 423 530 % --- Executes on selection change in coord_y_vectors. 424 %-------------------------------------------------------425 531 function coord_y_vectors_Callback(hObject, eventdata, handles) 532 %------------------------------------------------------------------------ 426 533 index=get(handles.coord_y_vectors,'Value'); 427 534 string=get(handles.coord_y_vectors,'String'); … … 429 536 update_field(hObject, eventdata, handles,VarName) 430 537 431 %------------------------------------------------------- 538 %------------------------------------------------------------------------ 432 539 % --- Executes on selection change in coord_z_scalar. 433 540 function coord_z_vectors_Callback(hObject, eventdata, handles) 434 %------------------------------------------------------- 541 %------------------------------------------------------------------------ 435 542 index=get(handles.coord_z_vectors,'Value'); 436 543 string=get(handles.coord_z_vectors,'String'); … … 438 545 update_field(hObject, eventdata, handles,VarName) 439 546 440 %------------------------------------------------------- 547 %------------------------------------------------------------------------ 441 548 % --- Executes on selection change in vec_color. 442 549 function vec_color_Callback(hObject, eventdata, handles) 443 %------------------------------------------------------- 550 %------------------------------------------------------------------------ 444 551 index=get(handles.vec_color,'Value'); 445 552 string=get(handles.vec_color,'String'); … … 447 554 update_field(hObject, eventdata, handles,VarName) 448 555 449 %--------------------------------- 556 %----------------------------------------------------------------------- 450 557 function update_field(hObject, eventdata, handles,VarName) 451 % VarName= input variable name for scalar or vector plots 452 hselect_field=get(handles.inputfile,'parent'); 453 Field=get(hselect_field,'UserData'); 558 %----------------------------------------------------------------------- 559 Field=get(handles.get_field,'UserData'); 454 560 index=name2index(VarName,Field.ListVarName); 455 561 if ~isempty(index) … … 457 563 variables_Callback(hObject, eventdata, handles) 458 564 end 459 % 460 % 461 % hselect_field=get(handles.inputfile,'parent'); 462 % Field=get(hselect_field,'UserData'); 463 % ivar_sel=[];%default 464 % for ivar=1:length(Field.ListVarName)%detect 465 % if isequal(Field.ListVarName{ivar},VarName) 466 % ivar_sel=ivar; %ivar_sel = index of the input variable in the list ListVarName 467 % break 468 % end 469 % end 470 % if isempty(ivar_sel) 471 % return 472 % end 473 % set(handles.variables,'Value',ivar_sel+1)%select the corresponding item in the displayed list 'variables' 474 % variables_Callback(hObject, eventdata, handles)%show the dimensions and attributes of the input variable 475 % 476 % index=Field.VarDimIndex{ivar_sel};%dimension indices of the input variable 477 % DimValue=Field.DimValue(index);%dimension values of the input variable 478 % ind_1=find(DimValue==1); 479 % index(ind_1)=[];%Mremove singletons 480 % 481 % 482 % % detect possible variables for abscissa and ordinate 483 % VarIndex=[];%initiate list of selected variable indices 484 % ind_coordvar=[]; %initiate list of coordinate variables 485 % for ilist=1:length(Field.VarDimIndex) 486 % if ~isequal(ilist,ivar_sel) 487 % index_i=Field.VarDimIndex{ilist};%indices of dimensions associated with variable #ilist 488 % if length(index_i)>1 489 % DimValue=Field.DimValue(index_i); 490 % ind_1=find(DimValue==1); 491 % index_i(ind_1)=[];%Mremove singletons 492 % if isequal(index,index_i) 493 % VarIndex=[VarIndex ilist]; %selected variable withb the same dimensions of the input variable 494 % end 495 % else 496 % idim=find(index==index_i(1)); 497 % if ~isempty(idim) 498 % VarIndex=[VarIndex ilist]; %possible dimension variable 499 % if isequal(Field.ListDimName{index_i(1)},Field.ListVarName{ilist}) 500 % ind_coordvar=[ind_coordvar length(VarIndex)]; 501 % end 502 % end 503 % end 504 % end 505 % end 506 % % val=get(handles.abscissa,'Value'); 507 % % if val>length(Field.ListVarName(VarIndex))+1 508 % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) 509 % % end 510 % % val=get(handles.ordinate,'Value'); 511 % % if val>length(Field.ListVarName(VarIndex))+1 512 % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) 513 % % end 514 % % val=get(handles.coord_z_vectors_scalar,'Value'); 515 % % if val>length(Field.ListVarName(VarIndex))+1 516 % % set(handles.abscissa,'Value',length(Field.ListVarName(VarIndex))+1) 517 % % end 518 % set(handles.abscissa,'Value',1)%default 519 % set(handles.ordinate,'Value',1)%default 520 % set(handles.coord_z_scalar,'Value',1)%default 521 % set(handles.abscissa,'String',[{''} Field.ListVarName(VarIndex) ]) 522 % set(handles.ordinate,'String',[{''} Field.ListVarName(VarIndex) ]) 523 % set(handles.coord_z_scalar,'String',[{''} Field.ListVarName(VarIndex) ]) 524 % if length(ind_coordvar)>=1 525 % set(handles.abscissa,'Value',ind_coordvar(1)+1) 526 % elseif length(index)==1 && length(VarIndex)>=1 527 % set(handles.abscissa,'Value',2) 528 % end 529 % if length(ind_coordvar)>=2 530 % set(handles.ordinate,'Value',ind_coordvar(2)+1) 531 % elseif length(index)==1 && length(VarIndex)>=2 532 % set(handles.ordinate,'Value',3) 533 % end 534 % if length(ind_coordvar)>=3 535 % set(handles.coord_z_scalar,'Value',ind_coordvar(3)+1) 536 % elseif length(index)==1 && length(VarIndex)>=3 537 % set(handles.coord_z_scalar,'Value',4) 538 % end 539 540 %--------------------------------------------------------- 565 566 %------------------------------------------------------------------------ 541 567 % update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback) 542 568 function update_UserData(handles) 543 %--------------------------------------------------------- 569 %------------------------------------------------------------------------ 544 570 return 545 571 % global SubField … … 615 641 end 616 642 DimIndex=DimIndex_u; 617 %TODO possibility of selecting 3 times the same variable for u, v, w components618 end 619 620 621 % select the variable index (or indices) for z coordinates643 %TODO possibility of selecting 3 times the same TimeVariable for u, v, w components 644 end 645 646 647 % select the TimeVariable index (or indices) for z coordinates 622 648 test_grid=0; 623 649 if test_scalar | test_vector … … 658 684 end 659 685 % if ~isempty(VarIndex_z) 660 % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the variable661 % if length(DimIndex_z)==1 & nbdim==3 %dimension variable686 % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the TimeVariable 687 % if length(DimIndex_z)==1 & nbdim==3 %dimension TimeVariable 662 688 % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; 663 689 % ind_z=find(DimIndex==DimIndex_z(1)); … … 669 695 end 670 696 671 % select the variable index (or indices) for ordinate697 % select the TimeVariable index (or indices) for ordinate 672 698 ystring=get(handles.ordinate,'String'); 673 699 yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox … … 701 727 end 702 728 703 %select the variable index for the abscissa729 %select the TimeVariable index for the abscissa 704 730 xstring=get(handles.abscissa,'String'); 705 731 xindex=get(handles.abscissa,'Value'); … … 801 827 function RUN_Callback(hObject, eventdata, handles) 802 828 %--------------------------------------------------------- 803 figcell=get(handles.list_fig,'String'); 804 index=get(handles.list_fig,'value'); 805 figstring=figcell{index}; 829 set(handles.RUN,'BackgroundColor',[1 1 0])% mark use of RUN action 830 test_fig=get(handles.SelectFigure,'Value'); 806 831 807 832 % plot requested in uvmat 808 if isequal(figstring,'uvmat')833 if ~test_fig 809 834 inputfile=get(handles.inputfile,'String'); 810 835 huvmat=findobj(allchild(0),'tag','uvmat'); … … 814 839 set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases) 815 840 hhuvmat=guidata(huvmat); 841 set(hhuvmat.Fields,'Value',1) 842 set(hhuvmat.Fields,'String',{'get_field...'}) 816 843 uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat 817 844 end 818 845 819 846 % other kind of plot 820 else 847 else %TODO: check and update: add plot on an existing axes 848 figcell=get(handles.list_fig,'String'); 849 index=get(handles.list_fig,'value'); 850 figstring=figcell{index}; 821 851 index=get(handles.ACTION,'Value'); 822 852 list_func=get(handles.ACTION,'UserData'); … … 824 854 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) 825 855 drawnow 826 SubField=h_fun(handles. figure1);%handles.figure1 =handles of the GUI get_field856 SubField=h_fun(handles.get_field);%handles.figure1 =handles of the GUI get_field 827 857 if ~isempty(SubField) 828 858 plot_get_field(SubField,handles) … … 869 899 % % handles structure with handles and user data (see GUIDATA) 870 900 % 871 % %time plots901 % %timename plots 872 902 % leg={}; 873 903 % n=0; … … 1042 1072 Tabcell=[]; 1043 1073 hselect_field=get(handles.variables,'parent'); 1044 Field=get(h select_field,'UserData');1074 Field=get(handles.get_field,'UserData'); 1045 1075 index=get(handles.variables,'Value');%index in the list 'variables' 1046 1076 if isequal(index,1) 1047 1077 set(handles.attributes_txt,'String','global attributes') 1048 % list global attribute names and values if index=1 (blank variable display) is selected1078 % list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected 1049 1079 if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) 1050 1080 for iline=1:length(Field.ListGlobalAttribute) … … 1062 1092 end 1063 1093 else 1064 %list attribute names and values associated to the variable # injdex-11094 %list TimeAttribute names and values associated to the TimeVariable # injdex-1 1065 1095 list_var=get(handles.variables,'String'); 1066 1096 var_select=list_var{index}; … … 1115 1145 Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); 1116 1146 end 1117 Tabchar=cell2tab(Tabdim,' =');1147 Tabchar=cell2tab(Tabdim,' = '); 1118 1148 Tabchar=[{''} ;Tabchar]; 1149 set(handles.dimensions,'Value',1) 1119 1150 set(handles.dimensions,'String',Tabchar) 1120 1151 end … … 1153 1184 end 1154 1185 1155 % ------------------------------------------------------------------------1156 function mouse_up_gui(ggg,eventdata,handles)1157 % ------------------------------------------------------------------------1158 if isequal(get(ggg,'SelectionType'),'alt')1159 message='';1160 global CurData1161 inputfield=get(handles.inputfile,'String');1162 if exist(inputfield,'file')1163 CurData=nc2struct(inputfield);1164 else1165 CurData=get(ggg,'UserData');% get_field opened from a input field, not a file1166 end1167 %%%% TODO: put the matalb command window in front1168 evalin('base','global CurData')%make CurData global in the workspace1169 evalin('base','CurData') %display CurData in the workspace1170 end1186 % %------------------------------------------------------------------------ 1187 % function mouse_up_gui(ggg,eventdata,handles) 1188 % %------------------------------------------------------------------------ 1189 % if isequal(get(ggg,'SelectionType'),'alt') 1190 % message=''; 1191 % global CurData 1192 % inputfield=get(handles.inputfile,'String'); 1193 % if exist(inputfield,'file') 1194 % CurData=nc2struct(inputfield); 1195 % else 1196 % CurData=get(ggg,'UserData');% get_field opened from a input field, not a file 1197 % end 1198 % %%%% TODO: put the matalb command window in front 1199 % evalin('base','global CurData')%make CurData global in the workspace 1200 % evalin('base','CurData') %display CurData in the workspace 1201 % end 1171 1202 1172 1203 %------------------------------------------------------------------------ … … 1414 1445 %global inputfile 1415 1446 fileinput=[PathName FileName];%complete file name 1416 testblank=findstr(fileinput,' ');%look for blanks1417 if ~isempty(testblank)1418 msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])1419 return1420 end1421 1447 sizf=size(fileinput); 1422 if (~ischar(fileinput)| ~isequal(sizf(1),1)),return;end1448 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end 1423 1449 set(handles.inputfile,'String',fileinput) 1424 1450 inputfile_Callback(hObject, eventdata, handles) 1425 1426 1451 1427 1452 %update list of recent files in the menubar … … 1464 1489 inputfile_Callback(hObject, eventdata, handles) 1465 1490 1466 % -------------------------------------------------------------------- 1491 % ----------------------------------------------------------------------- 1467 1492 function MenuFile_3_Callback(hObject, eventdata, handles) 1493 % ----------------------------------------------------------------------- 1468 1494 fileinput=get(handles.MenuFile_3,'Label'); 1469 1495 set(handles.inputfile,'String',fileinput) 1470 1496 inputfile_Callback(hObject, eventdata, handles) 1471 1497 1472 % -------------------------------------------------------------------- 1498 % ----------------------------------------------------------------------- 1473 1499 function MenuFile_4_Callback(hObject, eventdata, handles) 1500 % ----------------------------------------------------------------------- 1474 1501 fileinput=get(handles.MenuFile_4,'Label'); 1475 1502 set(handles.inputfile,'String',fileinput) 1476 1503 inputfile_Callback(hObject, eventdata, handles) 1477 1504 1478 % -------------------------------------------------------------------- 1505 % ----------------------------------------------------------------------- 1479 1506 function MenuFile_5_Callback(hObject, eventdata, handles) 1507 % ----------------------------------------------------------------------- 1480 1508 fileinput=get(handles.MenuFile_5,'Label'); 1481 1509 set(handles.inputfile,'String',fileinput) 1482 1510 inputfile_Callback(hObject, eventdata, handles) 1483 1511 1484 % 1512 %------------------------------------------------------------------------ 1485 1513 function MenuExportField_Callback(hObject, eventdata, handles) 1514 %------------------------------------------------------------------------ 1486 1515 global Data_get_field 1487 1516 % huvmat=findobj(allchild(0),'Name','uvmat'); … … 1494 1523 commandwindow; 1495 1524 1496 % 1525 %------------------------------------------------------------------------ 1497 1526 function MenuHelp_Callback(hObject, eventdata, handles) 1498 % hObject handle to MenuHelp (see GCBO) 1499 % eventdata reserved - to be defined in a future version of MATLAB 1500 % handles structure with handles and user data (see GUIDATA) 1527 %------------------------------------------------------------------------ 1501 1528 path_to_uvmat=which ('uvmat');% check the path of uvmat 1502 1529 pathelp=fileparts(path_to_uvmat); … … 1507 1534 end 1508 1535 1536 % ----------------------------------------------------------------------- 1537 function TimeName_Callback(hObject, eventdata, handles) 1538 1539 scalar_Callback(hObject, eventdata, handles)% suppress time variable from possible spatial coordinates 1540 vector_x_Callback(hObject, eventdata, handles) 1541 1542 %------------------------------------------------------------------------ 1543 % --- Executes on button press in TimeAttribute. 1544 function TimeAttribute_Callback(hObject, eventdata, handles) 1545 %------------------------------------------------------------------------ 1546 val=get(handles.TimeAttribute,'Value'); 1547 if val 1548 set(handles.TimeAttributeMenu,'Visible','on') 1549 Field=get(handles.get_field,'UserData'); 1550 time_value=zeros(size(Field.ListGlobalAttribute)); 1551 test_time=zeros(size(Field.ListGlobalAttribute)); 1552 for ilist=1:numel(Field.ListGlobalAttribute) 1553 if isnumeric(eval(['Field.' Field.ListGlobalAttribute{ilist}])) 1554 eval(['time_val=Field.' Field.ListGlobalAttribute{ilist} ';']) 1555 if ~isempty(time_val) 1556 time_value(ilist)=time_val; 1557 test_time(ilist)=1; 1558 end 1559 end 1560 end 1561 ListTimeAttribute=Field.ListGlobalAttribute(test_time==1); 1562 attr_index=get(handles.TimeAttributeMenu,'Value'); 1563 if attr_index>numel(ListTimeAttribute) 1564 attr_index=1; 1565 set(handles.TimeAttributeMenu,'Value',1); 1566 end 1567 if isempty(ListTimeAttribute) 1568 set(handles.TimeAttributeMenu,'String',{''}) 1569 set(handles.TimeValue,'Visible','off') 1570 else 1571 set(handles.TimeValue,'Visible','on') 1572 set(handles.TimeAttributeMenu,'String',ListTimeAttribute) 1573 set(handles.TimeValue,'String',num2str(time_value(attr_index))) 1574 end 1575 set(handles.TimeDimension,'Value',0) 1576 TimeDimension_Callback(hObject, eventdata, handles) 1577 set(handles.TimeVariable,'Value',0) 1578 TimeVariable_Callback(hObject, eventdata, handles) 1579 else 1580 set(handles.TimeAttributeMenu,'Visible','off') 1581 set(handles.TimeValue,'Visible','off') 1582 end 1583 1584 %------------------------------------------------------------------------ 1585 % --- Executes on selection change in TimeAttributeMenu. 1586 function TimeAttributeMenu_Callback(hObject, eventdata, handles) 1587 ListTimeAttribute=get(handles.TimeAttributeMenu,'String'); 1588 index=get(handles.TimeAttributeMenu,'Value'); 1589 AttrName=ListTimeAttribute{index}; 1590 Field=get(handles.get_field,'UserData'); 1591 eval(['time_val=Field.' AttrName ';']) 1592 set(handles.TimeValue,'String',num2str(time_val)) 1593 %------------------------------------------------------------------------ 1594 1595 %------------------------------------------------------------------------ 1596 % --- Executes on button press in TimeVariable. 1597 function TimeDimension_Callback(hObject, eventdata, handles) 1598 %------------------------------------------------------------------------ 1599 val=get(handles.TimeDimension,'Value');%=1 if check box TimeDimension is selected 1600 if val %if check box TimeDimension is selected 1601 Field=get(handles.get_field,'UserData');% structure describing the currently opened field 1602 previous_menu=get(handles.TimeDimensionMenu,'String'); 1603 if ~isequal(previous_menu,Field.ListDimName)%update the list of available dimensions in the menu 1604 ind_select=find(strcmpi('time',Field.ListDimName),1);% look for a dimension named 'time' or 'Time' 1605 if isempty(ind_select) 1606 ind_select=1;% select the first item in the list if 'time' is not found 1607 end 1608 set(handles.TimeDimensionMenu,'Value',ind_select); 1609 set(handles.TimeDimensionMenu,'String',Field.ListDimName)% put the list of available dimensions in the menu 1610 end 1611 set(handles.TimeDimensionMenu,'Visible','on')% the menu is made visible 1612 set(handles.TimeIndexValue,'Visible','on')% the time matrix index value selected is made visible 1613 TimeDimensionMenu_Callback(hObject, eventdata, handles) 1614 set(handles.TimeAttribute,'Value',0) %deselect alternative options for time 1615 set(handles.TimeVariable,'Value',0) 1616 TimeAttribute_Callback(hObject, eventdata, handles) 1617 else 1618 set(handles.TimeDimensionMenu,'Visible','off') 1619 set(handles.TimeIndexValue,'Visible','off') 1620 end 1621 1622 %------------------------------------------------------------------------ 1623 % --- Executes on selection change in TimeDimensionMenu. 1624 function TimeDimensionMenu_Callback(hObject, eventdata, handles) 1625 %------------------------------------------------------------------------ 1626 index=get(handles.TimeDimensionMenu,'Value'); 1627 DimList=get(handles.TimeDimensionMenu,'String'); 1628 DimName=DimList{index}; 1629 Field=get(handles.get_field,'UserData'); 1630 DimIndex=find(strcmp(DimName,Field.ListDimName),1); 1631 ref_index=round(Field.DimValue(DimIndex)/2); 1632 set(handles.TimeIndexValue,'String',num2str(ref_index)) 1633 scalar_Callback(hObject, eventdata, handles) 1634 vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) 1635 % look for a corresponding time variable and value 1636 time_test=zeros(size(Field.VarDimName)); 1637 for ilist=1:numel(Field.VarDimName) 1638 if isequal(Field.VarDimName{ilist},{DimName}) 1639 time_test(ilist)=1; 1640 end 1641 end 1642 ListVariable=Field.ListVarName(time_test==1); 1643 set(handles.TimeVariableMenu,'Value',1) 1644 if isempty(ListVariable) 1645 set(handles.TimeVariableMenu,'String',{''}) 1646 set(handles.TimeVarValue,'String','') 1647 else 1648 set(handles.TimeVariableMenu,'String',ListVariable) 1649 TimeVarName=ListVariable{1}; 1650 VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables 1651 inputfile=get(handles.inputfile,'String');% read the input file 1652 SubField=nc2struct(inputfile,{TimeVarName}); 1653 eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) 1654 set(handles.TimeVarValue,'Visible','on') 1655 set(handles.TimeVariableMenu,'Visible','on') 1656 set(handles.TimeVarValue,'String',num2str(TimeValue)) 1657 end 1658 1659 1660 % % ----------------------------------------------------------------------- 1661 % % --- Executes on button press in TimeVariable. 1662 % function TimeVariable_Callback(hObject, eventdata, handles) 1663 % % ----------------------------------------------------------------------- 1664 % val=get(handles.TimeVariable,'Value'); 1665 % if val 1666 % Field=get(handles.get_field,'UserData'); 1667 % time_test=zeros(size(Field.VarDimName)); 1668 % for ilist=1:numel(Field.VarDimName) 1669 % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension 1670 % time_test(ilist)=1; 1671 % end 1672 % end 1673 % ind_test=find(time_test); 1674 % if isempty(time_test) 1675 % set(handles.TimeVariable,'Value',0) 1676 % set(handles.TimeVariableMenu,'Visible','off') 1677 % set(handles.TimeVarValue,'Visible','off') 1678 % else 1679 % set(handles.TimeVariableMenu,'Visible','on') 1680 % set(handles.TimeVarValue,'Visible','on') 1681 % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) 1682 % set(handles.TimeVariableMenu,'Value',1) 1683 % end 1684 % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) 1685 % TimeVariableMenu_Callback(hObject, eventdata, handles) 1686 % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time 1687 % set(handles.TimeAttribute,'Value',0) 1688 % TimeAttribute_Callback(hObject, eventdata, handles) 1689 % end 1690 % else 1691 % set(handles.TimeVariableMenu,'Visible','off') 1692 % set(handles.TimeVarValue,'Visible','off') 1693 % end 1694 1695 % ----------------------------------------------------------------------- 1696 % --- Executes on selection change in TimeVariableMenu. 1697 function TimeVariableMenu_Callback(hObject, eventdata, handles) 1698 % ----------------------------------------------------------------------- 1699 ListVar=get(handles.TimeVariableMenu,'String'); 1700 index=get(handles.TimeVariableMenu,'Value'); 1701 TimeVariable=ListVar{index};% name of the selected variable 1702 if isempty(TimeVariable)% case of blank selection 1703 return 1704 end 1705 Field=get(handles.get_field,'UserData'); %index of 1706 VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables 1707 DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable 1708 set(handles.TimeDimensionMenu,'Value',1) 1709 set(handles.TimeDimensionMenu,'String',DimName) 1710 inputfile=get(handles.inputfile,'String');% read the input file 1711 SubField=nc2struct(inputfile,{TimeVariable}); 1712 eval(['TimeDimension=numel(SubField.' TimeVariable ');']) 1713 ref_index=round(TimeDimension/2); 1714 eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) 1715 set(handles.TimeIndexValue,'String',num2str(ref_index)) 1716 set(handles.TimeVarValue,'String',num2str(TimeValue)) 1717 1718 1719 function TimeValue_Callback(hObject, eventdata, handles) 1720 %TO suppress 1721 1722 % ----------------------------------------------------------------------- 1723 function TimeIndexValue_Callback(hObject, eventdata, handles) 1724 % ----------------------------------------------------------------------- 1725 TimeIndex=str2double(get(handles.TimeIndexValue,'String')); 1726 TimeVarName=Field.ListVarName{time_index}; 1727 set(handles.TimeVariable,'Value',1) 1728 set(handles.TimeName,'String',TimeVarName) 1729 fileinput=get(handles.inputfile,'String'); 1730 SubField=nc2struct(fileinput,{TimeVarName}); 1731 eval(['TimeValue=SubField.' TimeVarName '(ref_index);']); 1732 set(handles.TimeValue,'Visible','on') 1733 set(handles.TimeValue,'String',num2str(TimeValue)) 1734 1735 % ----------------------------------------------------------------------- 1736 function SelectFigure_Callback(hObject, eventdata, handles) 1737 % ----------------------------------------------------------------------- 1738 val=get(handles.SelectFigure,'Value'); 1739 if val 1740 set(handles.list_fig,'Visible','on') 1741 %% look at the existing figures in the work space 1742 browse_fig(handles.list_fig) 1743 else 1744 set(handles.list_fig,'Visible','off') 1745 end 1746 1747 1748 function TimeVarValue_Callback(hObject, eventdata, handles) 1749 1750 1751 1752 % --- Executes on button press in check_rgb. 1753 function check_rgb_Callback(hObject, eventdata, handles) 1754 1755 1756
Note: See TracChangeset
for help on using the changeset viewer.