- Timestamp:
- May 28, 2013, 11:30:01 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r579 r644 17 17 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) 18 18 19 %% initialization 19 20 VarVal={}; 20 21 ListVarName={}; … … 25 26 check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated 26 27 Operator=cell(size(FieldName)); 28 29 %% analyse the list of input fields: needed variables and requested operations 27 30 for ilist=1:numel(FieldName) 28 31 Operator{ilist}='';%default empty operator (vec, norm,...) … … 66 69 end 67 70 end 68 %create interpolator for linear interpolation 71 72 %% create interpolator for each variable to interpolate 69 73 if exist('XI','var') 70 74 for ilist=1:numel(InputVarList) … … 72 76 end 73 77 end 78 79 %% perform the linear interpolation for the requested variables 74 80 for ilist=1:numel(FieldName) 75 81 if ~check_skipped(ilist) … … 120 126 end 121 127 end 122 % put an error flag to indicate NaN data 128 129 %% put an error flag to indicate NaN data 123 130 if exist('XI','var')&&~isempty(VarVal) 124 131 nbvar=numel(ListVarName); … … 128 135 end 129 136 130 % Attr_FF.Role='errorflag';131 % VarAttribute=[VarAttribute {Attr_FF}];132 137 133 138 134 139 135 140 136 -
trunk/src/get_field.m
r630 r644 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 05-May-2013 23:54:3224 % Last Modified by GUIDE v2.5 28-May-2013 01:55:25 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 186 186 option=1; 187 187 end 188 set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime)189 set(handles.SwitchVarIndexTime,'Value',option)188 %set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) 189 %set(handles.SwitchVarIndexTime,'Value',option) 190 190 set(handles.get_field,'UserData',Field);% record the finput field structure 191 SwitchVarIndexTime_Callback([],[], handles)191 %SwitchVarIndexTime_Callback([],[], handles) 192 192 193 193 %% set z coordinate menu if relevant … … 201 201 set(handles.vector_z,'Visible','off') 202 202 set(handles.ZVarName,'Visible','off') 203 set(handles.SwitchVarIndexZ,'Visible','off')203 % set(handles.SwitchVarIndexZ,'Visible','off') 204 204 set(handles.Z_title,'Visible','off') 205 205 end … … 207 207 %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields 208 208 if Field.MaxDim>=2 % case of 2D (or 3D) fields 209 set(handles.CheckPlot1D,'Value',0)210 209 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 211 210 set(handles.CheckVector,'Value',1) … … 213 212 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) 214 213 set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) 214 set(handles.FieldOption,'Value',3) 215 215 else 216 set(handles.CheckScalar,'Value',1) 217 set(handles.CheckVector,'Value',0) 216 set(handles.FieldOption,'Value',2) 218 217 end 219 218 else % case of 1D fields 220 set(handles.CheckPlot1D,'Value',1) 221 set(handles.CheckScalar,'Value',0) 222 set(handles.CheckVector,'Value',0) 223 end 219 set(handles.FieldOption,'Value',1) 220 end 221 224 222 225 223 %% Make choices in menus from input … … 227 225 fill_GUI(ParamIn,handles.get_field); 228 226 end 229 CheckPlot1D_Callback(handles.CheckPlot1D, [], handles) 230 CheckScalar_Callback(handles.CheckScalar, [], handles) 231 CheckVector_Callback(handles.CheckVector, [], handles) 227 FieldOption_Callback([],[],handles) 232 228 233 229 %------------------------------------------------------------------------ … … 335 331 set(handles.Panel1Dplot,'Visible','off') 336 332 else 337 set(handles.Panel1Dplot,'Visible','on') 338 set(handles.PanelScalar,'Visible','off') 339 set(handles.CheckScalar,'Value',0) 340 set(handles.PanelVectors,'Visible','off') 341 set(handles.CheckVector,'Value',0) 342 set(handles.XVarName,'Visible','on') 343 set(handles.SwitchVarIndexX,'Visible','on') 344 set(handles.X_title,'Visible','on') 345 set(handles.YVarName,'Visible','off') 346 set(handles.SwitchVarIndexY,'Visible','off') 347 set(handles.Y_title,'Visible','off') 348 set(handles.ZVarName,'Visible','off') 349 set(handles.SwitchVarIndexZ,'Visible','off') 350 set(handles.Z_title,'Visible','off') 351 ordinate_Callback(hObject, eventdata, handles) 333 352 334 end 353 335 … … 386 368 set(handles.PanelScalar,'Visible','off') 387 369 else 388 set(handles.Panel1Dplot,'Visible','off') 389 set(handles.CheckPlot1D,'Value',0) 390 set(handles.PanelScalar,'Visible','on') 391 set(handles.PanelVectors,'Visible','off') 392 set(handles.CheckVector,'Value',0) 370 393 371 end 394 372 … … 401 379 set(handles.PanelVectors,'Visible','off') 402 380 else 403 set(handles.Panel1Dplot,'Visible','off') 404 set(handles.CheckPlot1D,'Value',0) 405 set(handles.PanelScalar,'Visible','off') 406 set(handles.CheckScalar,'Value',0) 407 set(handles.PanelVectors,'Visible','on') 408 set(handles.XVarName,'Visible','on') 409 set(handles.YVarName,'Visible','on') 410 set(handles.X_title,'Visible','on') 411 set(handles.Y_title,'Visible','on') 381 412 382 end 413 383 … … 425 395 %eliminate time 426 396 TimeDimName='';%default 427 SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');428 TimeVarOption=SwitchVarIndexTime{get(handles.SwitchVarIndexTime,'Value')};397 % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); 398 % TimeVarOption=SwitchVarIndexTime{get(handles.SwitchVarIndexTime,'Value')}; 429 399 if strcmp(TimeVarOption,'variable') 430 400 List=get(handles.TimeVarName,'String'); … … 1415 1385 1416 1386 1417 1418 % --- Executes on selection change in listbox30.1419 function listbox30_Callback(hObject, eventdata, handles)1420 % hObject handle to listbox30 (see GCBO)1421 % eventdata reserved - to be defined in a future version of MATLAB1422 % handles structure with handles and user data (see GUIDATA)1423 1424 % Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array1425 % contents{get(hObject,'Value')} returns selected item from listbox301426 1427 1428 1387 % --- Executes on selection change in SwitchVarIndexX. 1429 1388 function SwitchVarIndexX_Callback(hObject, eventdata, handles) … … 1488 1447 end 1489 1448 1490 1491 % --- Executes on button press in CheckScalar. 1492 function checkbox22_Callback(hObject, eventdata, handles) 1493 % hObject handle to CheckScalar (see GCBO) 1449 % --- Executes on selection change in FieldOption. 1450 function FieldOption_Callback(hObject, eventdata, handles) 1451 FieldList=get(handles.FieldOption,'String'); 1452 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 1453 switch FieldOption 1454 case '1D plot' 1455 set(handles.Panel1Dplot,'Visible','on') 1456 pos=get(handles.Panel1Dplot,'Position'); 1457 pos(1)=2; 1458 pos_coord=get(handles.Coordinates,'Position'); 1459 pos(2)=pos_coord(2)-pos(4)-2; 1460 set(handles.Panel1Dplot,'Position',pos) 1461 set(handles.PanelScalar,'Visible','off') 1462 set(handles.PanelVectors,'Visible','off') 1463 set(handles.YVarName,'Visible','off') 1464 % set(handles.SwitchVarIndexY,'Visible','off') 1465 set(handles.Y_title,'Visible','off') 1466 set(handles.ZVarName,'Visible','off') 1467 % set(handles.SwitchVarIndexZ,'Visible','off') 1468 set(handles.Z_title,'Visible','off') 1469 % ordinate_Callback(hObject, eventdata, handles) 1470 % set(handles.get_field,'Units','pixels') 1471 % size_fig=get(handles.get_field,'Position'); 1472 % Data=get(handles.view_field,'UserData'); 1473 % Data.GUISize=size_fig; 1474 % set(handles.view_field,'UserData',Data) 1475 % 1476 % %% reset position of text_display or TableDisplay 1477 % if strcmp(get(handles.TableDisplay,'Visible'),'off') 1478 % pos_1=get(handles.text_display,'Position'); 1479 % pos_1(1)=size_fig(3)-pos_1(3); 1480 % pos_1(2)=size_fig(4)-pos_1(4); 1481 % set(handles.text_display,'Position',pos_1) 1482 % % reset position of TableDisplay 1483 % else 1484 % pos_1=get(handles.TableDisplay,'Position'); 1485 % pos_1(1)=size_fig(3)-pos_1(3); 1486 % pos_1(2)=size_fig(4)-pos_1(4); 1487 % set(handles.TableDisplay,'Position',pos_1) 1488 % end 1489 % 1490 % %% reset position of Coordinates 1491 % pos_2=get(handles.Coordinates,'Position'); 1492 % pos_2(1)=size_fig(3)-pos_1(3); 1493 % pos_2(2)=pos_1(2)-pos_2(4); 1494 % set(handles.Coordinates,'Position',pos_2) 1495 case 'scalar' 1496 set(handles.Panel1Dplot,'Visible','off') 1497 set(handles.PanelScalar,'Visible','on') 1498 set(handles.PanelVectors,'Visible','off') 1499 pos=get(handles.PanelScalar,'Position'); 1500 pos(1)=2; 1501 pos_coord=get(handles.Coordinates,'Position'); 1502 pos(2)=pos_coord(2)-pos(4)-2; 1503 set(handles.PanelScalar,'Position',pos) 1504 set(handles.YVarName,'Visible','on') 1505 set(handles.Y_title,'Visible','on') 1506 case 'vectors' 1507 set(handles.Panel1Dplot,'Visible','off') 1508 set(handles.PanelScalar,'Visible','off') 1509 set(handles.PanelVectors,'Visible','on') 1510 pos=get(handles.PanelVectors,'Position'); 1511 pos(1)=2; 1512 pos_coord=get(handles.Coordinates,'Position'); 1513 pos(2)=pos_coord(2)-pos(4)-2; 1514 set(handles.PanelVectors,'Position',pos) 1515 set(handles.YVarName,'Visible','on') 1516 set(handles.Y_title,'Visible','on') 1517 end 1518 % hObject handle to FieldOption (see GCBO) 1494 1519 % eventdata reserved - to be defined in a future version of MATLAB 1495 1520 % handles structure with handles and user data (see GUIDATA) 1496 1521 1497 % Hint: get(hObject,'Value') returns toggle state of CheckScalar 1498 1499 1500 % --- Executes on button press in checkbox23. 1501 function checkbox23_Callback(hObject, eventdata, handles) 1502 % hObject handle to checkbox23 (see GCBO) 1522 % Hints: contents = get(hObject,'String') returns FieldOption contents as cell array 1523 % contents{get(hObject,'Value')} returns selected item from FieldOption 1524 1525 1526 % --- Executes on button press in CheckDimensionX. 1527 function CheckDimensionX_Callback(hObject, eventdata, handles) 1528 % hObject handle to CheckDimensionX (see GCBO) 1503 1529 % eventdata reserved - to be defined in a future version of MATLAB 1504 1530 % handles structure with handles and user data (see GUIDATA) 1505 1531 1506 % Hint: get(hObject,'Value') returns toggle state of checkbox23 1532 % Hint: get(hObject,'Value') returns toggle state of CheckDimensionX 1533 1534 1535 % --- Executes on button press in checkbox25. 1536 function checkbox25_Callback(hObject, eventdata, handles) 1537 % hObject handle to checkbox25 (see GCBO) 1538 % eventdata reserved - to be defined in a future version of MATLAB 1539 % handles structure with handles and user data (see GUIDATA) 1540 1541 % Hint: get(hObject,'Value') returns toggle state of checkbox25 1542 1543 1544 % --- Executes on button press in checkbox26. 1545 function checkbox26_Callback(hObject, eventdata, handles) 1546 % hObject handle to checkbox26 (see GCBO) 1547 % eventdata reserved - to be defined in a future version of MATLAB 1548 % handles structure with handles and user data (see GUIDATA) 1549 1550 % Hint: get(hObject,'Value') returns toggle state of checkbox26 1551 1552 1553 % --- Executes on button press in checkbox27. 1554 function checkbox27_Callback(hObject, eventdata, handles) 1555 % hObject handle to checkbox27 (see GCBO) 1556 % eventdata reserved - to be defined in a future version of MATLAB 1557 % handles structure with handles and user data (see GUIDATA) 1558 1559 % Hint: get(hObject,'Value') returns toggle state of checkbox27 1560 1561 1562 % --- Executes on button press in checkbox29. 1563 function checkbox29_Callback(hObject, eventdata, handles) 1564 % hObject handle to checkbox29 (see GCBO) 1565 % eventdata reserved - to be defined in a future version of MATLAB 1566 % handles structure with handles and user data (see GUIDATA) 1567 1568 % Hint: get(hObject,'Value') returns toggle state of checkbox29 -
trunk/src/plot_field.m
r625 r644 197 197 end 198 198 else %plot 1D field (usual graph y vs x) 199 PlotParamOut.Coordinates=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Coordinates);% 199 CheckHold=0; 200 if isfield(PlotParam,'CheckHold') 201 CheckHold= PlotParam.CheckHold; 202 end 203 PlotParamOut.Coordinates=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Coordinates,CheckHold);% 200 204 if testzoomaxes 201 [zoomaxes,PlotParamOut.Coordinates]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParamOut.Coordinates );205 [zoomaxes,PlotParamOut.Coordinates]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParamOut.Coordinates,CheckHold); 202 206 AxeData.ZoomAxes=zoomaxes; 203 207 end 204 % if ~isempty(Coordinates)205 % PlotParamOut.Coordinates=Coordinates;206 % end207 208 PlotType='line'; 208 209 end … … 327 328 328 329 %------------------------------------------------------------------- 329 function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates )330 function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates,CheckHold) 330 331 %------------------------------------------------------------------- 331 332 333 %% initialization 332 334 if ~exist('Coordinates','var') 333 335 Coordinates=[]; … … 335 337 CoordinatesOut=Coordinates; %default 336 338 hfig=get(haxes,'parent'); 337 %suppress existing plot isf empty data 339 legend_str={}; 340 341 %% suppress existing plot if empty data 338 342 if isempty(data) 339 343 hplot=findobj(haxes,'tag','plot_line'); … … 348 352 end 349 353 354 %% set the colors of the successive plots (designed to produce rgb for the three components of color images) 350 355 ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25]; 351 356 set(haxes,'ColorOrder',ColorOrder) 352 if isfield(Coordinates,'NextPlot') 353 set(haxes,'NextPlot',Coordinates.NextPlot) 354 end 355 % adjust the size of the plot to include the whole field, 356 357 legend_str={}; 357 % if isfield(Coordinates,'NextPlot') 358 % set(haxes,'NextPlot',Coordinates.NextPlot) 359 % end 360 if CheckHold 361 set(haxes,'NextPlot','add') 362 else 363 set(haxes,'NextPlot','replace') 364 end 358 365 359 366 %% prepare the string for plot command 360 367 plotstr='hhh=plot('; 361 coord_x_index=[];368 % coord_x_index=[]; 362 369 xtitle=''; 363 370 ytitle=''; 364 test_newplot= 1;371 test_newplot=~CheckHold; 365 372 MinX=[]; 366 373 MaxX=[]; … … 421 428 end 422 429 eval(['data.' VarName '=squeeze(data.' VarName ');']) 423 %eval(['min(data.' VarName ')'])424 430 MinY(ivar)=min(min(data.(VarName))); 425 431 MaxY(ivar)=max(max(data.(VarName))); … … 446 452 447 453 %% activate the plot 448 if test_newplot &&~isequal(plotstr,'hhh=plot(')454 if ~isequal(plotstr,'hhh=plot(') 449 455 set(hfig,'CurrentAxes',haxes) 450 456 tag=get(haxes,'tag'); -
trunk/src/proj_field.m
r630 r644 564 564 VarIndex=find(check_proj); 565 565 566 % identify vector components566 %% identify vector components 567 567 testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors 568 568 if testU … … 578 578 errorflag=FieldData.(FFName); 579 579 end 580 % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 580 581 %% check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 581 582 if strcmp(CellInfo{icell}.CoordType,'scattered') 582 if ~isequal(ProjMode,'interp_lin')583 if strcmp(ProjMode,'projection') 583 584 if width==0 584 585 errormsg='range of the projection object is missing'; 585 return 586 e lse587 lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line588 end 589 end590 if ~isequal(ProjMode,'projection')591 if isfield(ObjectData,'DX') &~isempty(ObjectData.DX)586 return 587 end 588 % else 589 % lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line 590 % end 591 else 592 if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX) 592 593 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 593 594 else … … 601 602 coord_y=FieldData.(YName); 602 603 end 603 %initiate projection 604 605 %% initiate projection 604 606 for ivar=1:length(VarIndex) 605 607 ProjLine{ivar}=[]; … … 612 614 %%%%%%% % A FAIRE CALCULER MEAN DES QUANTITES %%%%%% 613 615 %case of unstructured coordinates 614 if strcmp(CellInfo{icell}.CoordType,'scattered') 615 for ip=1:siz_line(1)-1 %Loop on the segments of the polyline 616 linelength=sqrt(dlinx(ip)*dlinx(ip)+dliny(ip)*dliny(ip)); 617 %select the vector indices in the range of action 618 if testfalse 619 flagsel=(errorflag==0); % keep only non false vectors 620 else 621 flagsel=ones(size(coord_x)); 622 end 623 if isequal(ProjMode,'projection') %|| isequal(ProjMode,'interp_tps') 624 flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ... 625 & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ... 626 & ((coord_y -yinf(ip+1))*(xsup(ip+1)-xinf(ip+1))>(coord_x-xinf(ip+1))*(ysup(ip+1)-yinf(ip+1))) ... 627 & ((coord_y -yinf(ip))*(xsup(ip)-xinf(ip))<(coord_x-xinf(ip))*(ysup(ip)-yinf(ip))); 628 end 629 indsel=find(flagsel);%indsel =indices of good vectors 630 X_sel=coord_x(indsel); 631 Y_sel=coord_y(indsel); 632 nbvar=0; 633 for iselect=1:numel(VarIndex)-2*testU 634 VarName=FieldData.ListVarName{VarIndex(iselect)}; 635 ProjVar{iselect}=FieldData.(VarName)(indsel);%scalar value 636 end 637 if testU 638 ProjVar{numel(VarIndex)-1}=cos(theta(ip))*vector_x(indsel)+sin(theta(ip))*vector_y(indsel);% longitudinal component 639 ProjVar{numel(VarIndex)}=-sin(theta(ip))*vector_x(indsel)+cos(theta(ip))*vector_y(indsel);%transverse component 640 end 641 if isequal(ProjMode,'projection') 642 sintheta=sin(theta(ip)); 643 costheta=cos(theta(ip)); 644 Xproj=(X_sel-ObjectData.Coord(ip,1))*costheta + (Y_sel-ObjectData.Coord(ip,2))*sintheta; %projection on the line 645 [Xproj,indsort]=sort(Xproj); 646 for ivar=1:numel(ProjVar) 647 if ~isempty(ProjVar{ivar}) 648 ProjVar{ivar}=ProjVar{ivar}(indsort); 649 end 650 end 651 elseif isequal(ProjMode,'interp_lin') %linear interpolation: 652 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 653 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 654 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1); 655 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2); 656 for ivar=1:numel(ProjVar) 657 if ~isempty(ProjVar{ivar}) 658 ProjVar{ivar}=griddata_uvmat(X_sel,Y_sel,ProjVar{ivar},xreg,yreg); 659 end 660 end 661 elseif isequal(ProjMode,'interp_tps') %filtering 662 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 663 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 664 siz=size(X_sel); 665 xregij=cos(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,1); 666 yregij=sin(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,2); 667 xij=X_sel*ones(1,npoint); 668 yij=Y_sel*ones(1,npoint); 669 Aij=exp(-lambda*((xij-xregij).*(xij-xregij)+(yij-yregij).*(yij-yregij))); 670 norm=Aij'*ones(siz(1),1); 671 for ivar=1:numel(ProjVar) 672 if ~isempty(ProjVar{ivar}) 673 ProjVar{ivar}=Aij'*ProjVar{ivar}./norm; 674 end 675 end 676 end 677 %prolongate the total record 678 for ivar=1:numel(ProjVar) 679 if ~isempty(ProjVar{ivar}) 680 ProjLine{ivar}=[ProjLine{ivar}; ProjVar{ivar}]; 681 end 682 end 683 XLine=[XLine ;(Xproj+linelengthtot)];%along line abscissa 684 linelengthtot=linelengthtot+linelength; 685 % circul=circul+(sum(U_sel))*linelength/npoint; 686 % flux=flux+(sum(V_sel))*linelength/npoint; 687 end 688 ProjData.X=XLine'; 689 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 690 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 691 ProjData.VarAttribute{1}.long_name='abscissa along line'; 692 for iselect=1:numel(VarIndex) 693 VarName=FieldData.ListVarName{VarIndex(iselect)}; 694 eval(['ProjData.' VarName '=ProjLine{iselect};']) 695 ProjData.ListVarName=[ProjData.ListVarName {VarName}]; 696 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 697 ProjData.VarAttribute{iselect}=FieldData.VarAttribute{VarIndex(iselect)}; 698 if strcmp(ProjMode,'projection') 699 ProjData.VarAttribute{iselect}.Role='discrete'; 700 else 701 ProjData.VarAttribute{iselect}.Role='continuous'; 702 end 703 end 704 705 %case of structured coordinates 706 elseif strcmp(CellInfo{icell}.CoordType,'grid') 707 if ~isequal(ObjectData.Type,'line')% exclude polyline 708 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; % 709 else 710 test_Amat=1;%image or 2D matrix 711 test_interp2=0;%default 712 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 713 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 714 eval(['AX=FieldData.' AXName ';']);% set of x positions 715 eval(['AY=FieldData.' AYName ';']);% set of y positions 716 AName=FieldData.ListVarName{VarIndex(1)}; 717 eval(['A=FieldData.' AName ';']);% scalar 718 npxy=size(A); 719 npx=npxy(2); 720 npy=npxy(1); 721 if numel(AX)==2 722 DX=(AX(2)-AX(1))/(npx-1); 723 else 724 DX_vec=diff(AX); 725 DX=max(DX_vec); 726 DX_min=min(DX_vec); 727 if (DX-DX_min)>0.0001*abs(DX) 728 test_interp2=1; 729 DX=DX_min; 730 end 731 end 732 if numel(AY)==2 733 DY=(AY(2)-AY(1))/(npy-1); 734 else 735 DY_vec=diff(AY); 736 DY=max(DY_vec); 737 DY_min=min(DY_vec); 738 if (DY-DY_min)>0.0001*abs(DY) 616 if strcmp(CellInfo{icell}.CoordType,'scattered') 617 for ip=1:siz_line(1)-1 %Loop on the segments of the polyline 618 linelength=sqrt(dlinx(ip)*dlinx(ip)+dliny(ip)*dliny(ip)); 619 %select the vector indices in the range of action 620 if testfalse 621 flagsel=(errorflag==0); % keep only non false vectors 622 else 623 flagsel=ones(size(coord_x)); 624 end 625 if isequal(ProjMode,'projection') %|| isequal(ProjMode,'interp_tps') 626 flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ... 627 & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ... 628 & ((coord_y -yinf(ip+1))*(xsup(ip+1)-xinf(ip+1))>(coord_x-xinf(ip+1))*(ysup(ip+1)-yinf(ip+1))) ... 629 & ((coord_y -yinf(ip))*(xsup(ip)-xinf(ip))<(coord_x-xinf(ip))*(ysup(ip)-yinf(ip))); 630 end 631 indsel=find(flagsel);%indsel =indices of good vectors 632 X_sel=coord_x(indsel); 633 Y_sel=coord_y(indsel); 634 nbvar=0; 635 for iselect=1:numel(VarIndex)-2*testU 636 VarName=FieldData.ListVarName{VarIndex(iselect)}; 637 ProjVar{iselect}=FieldData.(VarName)(indsel);%scalar value 638 end 639 if testU 640 ProjVar{numel(VarIndex)-1}=cos(theta(ip))*vector_x(indsel)+sin(theta(ip))*vector_y(indsel);% longitudinal component 641 ProjVar{numel(VarIndex)}=-sin(theta(ip))*vector_x(indsel)+cos(theta(ip))*vector_y(indsel);%transverse component 642 end 643 if isequal(ProjMode,'projection') 644 sintheta=sin(theta(ip)); 645 costheta=cos(theta(ip)); 646 Xproj=(X_sel-ObjectData.Coord(ip,1))*costheta + (Y_sel-ObjectData.Coord(ip,2))*sintheta; %projection on the line 647 [Xproj,indsort]=sort(Xproj); 648 for ivar=1:numel(ProjVar) 649 if ~isempty(ProjVar{ivar}) 650 ProjVar{ivar}=ProjVar{ivar}(indsort); 651 end 652 end 653 elseif isequal(ProjMode,'interp_lin')||isequal(ProjMode,'interp_tps') %filtering %linear interpolation: 654 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 655 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 656 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1); 657 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2); 658 if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') 659 VarName_x=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 660 VarName_y=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 661 if isfield(CellInfo{icell},'VarIndex_errorflag') 662 FieldData.(VarName_x)=FieldData.(VarName_x)(indsel); 663 FieldData.(VarName_y)=FieldData.(VarName_y)(indsel); 664 end 665 if ~isfield(CellInfo{icell},'CheckSub') || ~CellInfo{icell}.CheckSub 666 vector_x_proj=numel(ProjData.ListVarName)+1; 667 vector_y_proj=numel(ProjData.ListVarName)+2; 668 end 669 end 670 if isfield(CellInfo{icell},'VarIndex_scalar') 671 VarName_scalar=FieldData.ListVarName{CellInfo{icell}.VarIndex_scalar}; 672 if isfield(CellInfo{icell},'errorflag') && ~isempty(CellInfo{icell}.errorflag) 673 FieldData.(VarName_scalar)=FieldData.(VarName_scalar)(indsel); 674 end 675 end 676 if isfield(CellInfo{icell},'VarIndex_ancillary')% do not project ancillary data with interp 677 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_ancillary}); 678 end 679 if isfield(CellInfo{icell},'VarIndex_warnflag')% do not project ancillary data with interp 680 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag}); 681 end 682 if isfield(CellInfo{icell},'VarIndex_errorflag')% do not project ancillary data with interp 683 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag}); 684 end 685 if isequal(ProjMode,'interp_lin') 686 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([X_sel Y_sel],FieldData,CellInfo{icell}.FieldName,xreg',yreg'); 687 else 688 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_tps([X_sel Y_sel],FieldData,CellInfo{icell}.FieldName,xreg',yreg'); 689 end 690 ivar_vector_x=[]; 691 ivar_vector_y=[]; 692 for ivar=1:numel(VarAttribute) 693 if isfield(VarAttribute{ivar},'Role') 694 if strcmp(VarAttribute{ivar}.Role,'vector_x') 695 ivar_vector_x=ivar; 696 elseif strcmp(VarAttribute{ivar}.Role,'vector_y') 697 ivar_vector_y=ivar; 698 end 699 end 700 end 701 if ~isempty(ivar_vector_x)&&~isempty(ivar_vector_y) 702 ProjVar{ivar_vector_x}=cos(theta(ip))*ProjVar{ivar_vector_x}+sin(theta(ip))*ProjVar{ivar_vector_y};% longitudinal component 703 ProjVar{ivar_vector_y}=-sin(theta(ip))*ProjVar{ivar_vector_x}+cos(theta(ip))*ProjVar{ivar_vector_y};%transverse component 704 end 705 elseif isequal(ProjMode,'interp_tps') %filtering 706 % TODO 707 % npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 708 % Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 709 % siz=size(X_sel); 710 % xregij=cos(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,1); 711 % yregij=sin(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,2); 712 % xij=X_sel*ones(1,npoint); 713 % yij=Y_sel*ones(1,npoint); 714 % Aij=exp(-lambda*((xij-xregij).*(xij-xregij)+(yij-yregij).*(yij-yregij))); 715 % norm=Aij'*ones(siz(1),1); 716 % for ivar=1:numel(ProjVar) 717 % if ~isempty(ProjVar{ivar}) 718 % ProjVar{ivar}=Aij'*ProjVar{ivar}./norm; 719 % 720 % end 721 % end 722 end 723 %prolongate the total record 724 for ivar=1:numel(ProjVar) 725 if ~isempty(ProjVar{ivar}) 726 if numel(ProjLine)>=ivar 727 ProjLine{ivar}=[ProjLine{ivar}; ProjVar{ivar}]; 728 else 729 ProjLine{ivar}=ProjVar{ivar}; 730 end 731 end 732 end 733 XLine=[XLine ;(Xproj+linelengthtot)];%along line abscissa 734 linelengthtot=linelengthtot+linelength; 735 % circul=circul+(sum(U_sel))*linelength/npoint; 736 % flux=flux+(sum(V_sel))*linelength/npoint; 737 end 738 ProjData.X=XLine'; 739 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 740 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 741 ProjData.VarAttribute{1}.long_name='abscissa along line'; 742 for iselect=1:numel(VarIndex) 743 VarName=FieldData.ListVarName{VarIndex(iselect)}; 744 eval(['ProjData.' VarName '=ProjLine{iselect};']) 745 ProjData.ListVarName=[ProjData.ListVarName {VarName}]; 746 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 747 ProjData.VarAttribute{iselect}=FieldData.VarAttribute{VarIndex(iselect)}; 748 if strcmp(ProjMode,'projection') 749 ProjData.VarAttribute{iselect}.Role='discrete'; 750 else 751 ProjData.VarAttribute{iselect}.Role='continuous'; 752 end 753 end 754 755 %case of structured coordinates 756 elseif strcmp(CellInfo{icell}.CoordType,'grid') 757 if ~isequal(ObjectData.Type,'line')% exclude polyline 758 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; % 759 else 760 test_Amat=1;%image or 2D matrix 761 test_interp2=0;%default 762 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 763 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 764 eval(['AX=FieldData.' AXName ';']);% set of x positions 765 eval(['AY=FieldData.' AYName ';']);% set of y positions 766 AName=FieldData.ListVarName{VarIndex(1)}; 767 eval(['A=FieldData.' AName ';']);% scalar 768 npxy=size(A); 769 npx=npxy(2); 770 npy=npxy(1); 771 if numel(AX)==2 772 DX=(AX(2)-AX(1))/(npx-1); 773 else 774 DX_vec=diff(AX); 775 DX=max(DX_vec); 776 DX_min=min(DX_vec); 777 if (DX-DX_min)>0.0001*abs(DX) 739 778 test_interp2=1; 740 DY=DY_min; 741 end 742 end 743 AXI=linspace(AX(1),AX(end), npx);%set of x positions for the interpolated input data 744 AYI=linspace(AY(1),AY(end), npy);%set of x positions for the interpolated input data 745 if isfield(ObjectData,'DX') 746 DXY_line=ObjectData.DX;%mesh on the projection line 747 else 748 DXY_line=sqrt(abs(DX*DY));% mesh on the projection line 749 end 750 dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1); 751 dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2); 752 linelength=sqrt(dlinx*dlinx+dliny*dliny); 753 theta=angle(dlinx+i*dliny);%angle of the line 754 if isfield(FieldData,'RangeX') 755 XMin=min(FieldData.RangeX);%shift of the origin on the line 756 else 757 XMin=0; 758 end 759 eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line 760 y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line) 761 eval(['npX=length(ProjData.' AXName ');']) 762 npY=length(y); %TODO: utiliser proj_grid 763 eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates 764 XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta); 765 YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta); 766 XIMA=(XIMA-AX(1))/DX+1;% index of the original image along x 767 YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y 768 XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 769 YIMA=reshape(round(YIMA),1,npX*npY); 770 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 771 ind_in=find(flagin); 772 ind_out=find(~flagin); 773 ICOMB=(XIMA-1)*npy+YIMA; 774 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 775 nbcolor=1; %color images 776 if numel(npxy)==2 777 nbcolor=1; 778 elseif length(npxy)==3 779 nbcolor=npxy(3); 780 else 781 errormsg='multicomponent field not projected'; 782 display(errormsg) 783 return 784 end 785 nbvar=length(ProjData.ListVarName);% number of var from previous cells 786 ProjData.ListVarName=[ProjData.ListVarName {AXName}]; 787 ProjData.VarDimName=[ProjData.VarDimName {AXName}]; 788 for ivar=VarIndex 789 %VarName{ivar}=FieldData.ListVarName{ivar}; 790 if test_interp2% interpolate on new grid 791 FieldData.(FieldData.ListVarName{ivar})=interp2(FieldData.(AXName),FieldData.(AYName),FieldData.(FieldData.ListVarName{ivar}),AXI,AYI);%TO TEST 792 end 793 vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum 794 if nbcolor==1 795 vec_B(ind_in)=vec_A(ICOMB); 796 vec_B(ind_out)=zeros(size(ind_out)); 797 A_out=reshape(vec_B,npY,npX); 798 ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY; 799 elseif nbcolor==3 800 vec_B(ind_in,1:3)=vec_A(ICOMB,:); 801 vec_B(ind_out,1)=zeros(size(ind_out)); 802 vec_B(ind_out,2)=zeros(size(ind_out)); 803 vec_B(ind_out,3)=zeros(size(ind_out)); 804 A_out=reshape(vec_B,npY,npX,nbcolor); 805 ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY); 806 end 807 ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}]; 808 ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate 809 ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line 810 end 811 if testU 812 vector_x =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 813 vector_y =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}); 814 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y; 815 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y; 816 end 817 ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line'; 818 if nbcolor==3 819 ProjData.VarDimName{end}={AXName,'rgb'}; 820 end 821 end 822 elseif strcmp(CellInfo{icell}.CoordType,'tps') 823 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX) 824 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 825 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 826 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1) 827 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2) 828 % coord_x_proj=XMin:DX:XMax; 829 % coord_y_proj=YMin:DY:YMax; 830 DataOut=calc_field_tps(FieldData.FieldList,FieldData,cat(3,xreg,yreg)); 831 ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName]; 832 ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName]; 833 ProjData.VarAttribute=[ProjData.VarAttribute DataOut.VarAttribute]; 834 DataOut.ListVarName(1)=[]; 835 DataOut.VarDimName(1)=[]; 836 DataOut.VarAttribute(1)=[]; 837 for ilist=2:length(DataOut.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise 838 VarName=DataOut.ListVarName{ilist}; 839 ProjData.(VarName)=DataOut.(VarName); 840 end 841 ProjData.coord_x=Xproj; 842 end 843 end 779 DX=DX_min; 780 end 781 end 782 if numel(AY)==2 783 DY=(AY(2)-AY(1))/(npy-1); 784 else 785 DY_vec=diff(AY); 786 DY=max(DY_vec); 787 DY_min=min(DY_vec); 788 if (DY-DY_min)>0.0001*abs(DY) 789 test_interp2=1; 790 DY=DY_min; 791 end 792 end 793 AXI=linspace(AX(1),AX(end), npx);%set of x positions for the interpolated input data 794 AYI=linspace(AY(1),AY(end), npy);%set of x positions for the interpolated input data 795 if isfield(ObjectData,'DX') 796 DXY_line=ObjectData.DX;%mesh on the projection line 797 else 798 DXY_line=sqrt(abs(DX*DY));% mesh on the projection line 799 end 800 dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1); 801 dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2); 802 linelength=sqrt(dlinx*dlinx+dliny*dliny); 803 theta=angle(dlinx+i*dliny);%angle of the line 804 if isfield(FieldData,'RangeX') 805 XMin=min(FieldData.RangeX);%shift of the origin on the line 806 else 807 XMin=0; 808 end 809 eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line 810 y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line) 811 eval(['npX=length(ProjData.' AXName ');']) 812 npY=length(y); %TODO: utiliser proj_grid 813 eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates 814 XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta); 815 YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta); 816 XIMA=(XIMA-AX(1))/DX+1;% index of the original image along x 817 YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y 818 XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 819 YIMA=reshape(round(YIMA),1,npX*npY); 820 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 821 ind_in=find(flagin); 822 ind_out=find(~flagin); 823 ICOMB=(XIMA-1)*npy+YIMA; 824 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 825 nbcolor=1; %color images 826 if numel(npxy)==2 827 nbcolor=1; 828 elseif length(npxy)==3 829 nbcolor=npxy(3); 830 else 831 errormsg='multicomponent field not projected'; 832 display(errormsg) 833 return 834 end 835 nbvar=length(ProjData.ListVarName);% number of var from previous cells 836 ProjData.ListVarName=[ProjData.ListVarName {AXName}]; 837 ProjData.VarDimName=[ProjData.VarDimName {AXName}]; 838 for ivar=VarIndex 839 %VarName{ivar}=FieldData.ListVarName{ivar}; 840 if test_interp2% interpolate on new grid 841 FieldData.(FieldData.ListVarName{ivar})=interp2(FieldData.(AXName),FieldData.(AYName),FieldData.(FieldData.ListVarName{ivar}),AXI,AYI);%TO TEST 842 end 843 vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum 844 if nbcolor==1 845 vec_B(ind_in)=vec_A(ICOMB); 846 vec_B(ind_out)=zeros(size(ind_out)); 847 A_out=reshape(vec_B,npY,npX); 848 ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY; 849 elseif nbcolor==3 850 vec_B(ind_in,1:3)=vec_A(ICOMB,:); 851 vec_B(ind_out,1)=zeros(size(ind_out)); 852 vec_B(ind_out,2)=zeros(size(ind_out)); 853 vec_B(ind_out,3)=zeros(size(ind_out)); 854 A_out=reshape(vec_B,npY,npX,nbcolor); 855 ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY); 856 end 857 ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}]; 858 ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate 859 ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line 860 end 861 if testU 862 vector_x =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 863 vector_y =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}); 864 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y; 865 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y; 866 end 867 ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line'; 868 if nbcolor==3 869 ProjData.VarDimName{end}={AXName,'rgb'}; 870 end 871 end 872 elseif strcmp(CellInfo{icell}.CoordType,'tps') 873 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX) 874 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 875 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 876 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1) 877 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2) 878 % coord_x_proj=XMin:DX:XMax; 879 % coord_y_proj=YMin:DY:YMax; 880 DataOut=calc_field_tps(FieldData.FieldList,FieldData,cat(3,xreg,yreg)); 881 ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName]; 882 ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName]; 883 ProjData.VarAttribute=[ProjData.VarAttribute DataOut.VarAttribute]; 884 DataOut.ListVarName(1)=[]; 885 DataOut.VarDimName(1)=[]; 886 DataOut.VarAttribute(1)=[]; 887 for ilist=2:length(DataOut.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise 888 VarName=DataOut.ListVarName{ilist}; 889 ProjData.(VarName)=DataOut.(VarName); 890 end 891 ProjData.coord_x=Xproj; 892 end 893 end 844 894 end 845 895 -
trunk/src/series.m
r643 r644 1073 1073 1074 1074 %% set the waitbar position with respect to the min and max in the series 1075 for iview=1:numel(SeriesData.i1_series) 1076 pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index 1077 if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) 1078 pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index 1079 end 1080 pair_max{iview}=reshape(pair_max{iview},1,[]); 1081 index_min(iview)=find(pair_max{iview}>0, 1 ); 1082 index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); 1083 end 1084 [index_min,iview_min]=min(index_min); 1085 [index_max,iview_max]=min(index_max); 1086 if size(SeriesData.i1_series{iview_min},2)==1% movie 1087 index_first=ref_i(1); 1088 index_last=ref_i(2); 1089 else 1090 index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; 1091 index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; 1092 end 1093 range=index_max-index_min+1; 1094 coeff_min=(index_first-index_min)/range; 1095 coeff_max=(index_last-index_min+1)/range; 1075 MinIndex_i=min(get(handles.MinIndex_i,'Data')); 1076 MaxIndex_i=max(get(handles.MaxIndex_i,'Data')); 1077 pos_first=(ref_i(1)-MinIndex_i)/(MaxIndex_i-MinIndex_i+1); 1078 pos_last=(ref_i(2)-MinIndex_i+1)/(MaxIndex_i-MinIndex_i+1); 1096 1079 Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] 1097 1080 Position_status=get(handles.FileStatus,'Position'); 1098 Position(1)= coeff_min*Position_status(3)+Position_status(1);1099 Position(3)=Position_status(3)*( coeff_max-coeff_min);1081 Position(1)=Position_status(1)+Position_status(3)*pos_first; 1082 Position(3)=Position_status(3)*(pos_last-pos_first); 1100 1083 set(handles.Waitbar,'Position',Position) 1101 1084 update_waitbar(handles.Waitbar,0) 1085 1086 % for iview=1:numel(SeriesData.i1_series) 1087 % pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index 1088 % if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1) 1089 % pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index 1090 % end 1091 % pair_max{iview}=reshape(pair_max{iview},1,[]); 1092 % index_min(iview)=find(pair_max{iview}>0, 1 ); 1093 % index_max(iview)=find(pair_max{iview}>0, 1, 'last' ); 1094 % end 1095 % [index_min,iview_min]=min(index_min); 1096 % [index_max,iview_max]=min(index_max); 1097 % if size(SeriesData.i1_series{iview_min},2)==1% movie 1098 % index_first=ref_i(1); 1099 % index_last=ref_i(2); 1100 % else 1101 % index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; 1102 % index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; 1103 % end 1104 % range=index_max-index_min+1; 1105 % coeff_min=(index_first-index_min)/range; 1106 % coeff_max=(index_last-index_min+1)/range; 1107 % Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] 1108 % Position_status=get(handles.FileStatus,'Position'); 1109 % Position(1)=coeff_min*Position_status(3)+Position_status(1); 1110 % Position(3)=Position_status(3)*(coeff_max-coeff_min); 1111 % set(handles.Waitbar,'Position',Position) 1112 % update_waitbar(handles.Waitbar,0) 1102 1113 1103 1114 %------------------------------------------------------------------------ … … 1370 1381 set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color 1371 1382 drawnow 1383 set(handles.status,'Value',0)% desable status display if relevant 1384 status_Callback(hObject, eventdata, handles) 1372 1385 1373 1386 %% read the data on the GUI series … … 1832 1845 end 1833 1846 set(handles.ActionName,'BackgroundColor',[1 1 0]) 1847 huigetfile=findobj(allchild(0),'tag','status_display') 1848 if ~isempty(huigetfile) 1849 delete(huigetfile) 1850 end 1834 1851 drawnow 1835 1852 … … 2598 2615 OutputDir=fullfile(RootPath,OutputSubDir); 2599 2616 uigetfile_uvmat('status_display',OutputDir) 2600 2601 % hfig=findobj(allchild(0),'name','series_status');2602 % if isempty(hfig)2603 % ScreenSize=get(0,'ScreenSize');2604 % hfig=figure('DeleteFcn',@stop_status,'Position',[ScreenSize(3)-600 ScreenSize(4)-640 560 600]);2605 % set(hfig,'MenuBar','none')% suppress the menu bar2606 % set(hfig,'NumberTitle','off')%suppress the fig number in the title2607 % set(hfig,'name','series_status')2608 % set(hfig,'tag','series_status')2609 % uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @view_file,'tag','list','UserData',OutputDir);2610 % uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',OutputDir);2611 % uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);2612 % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);2613 % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);2614 % %set(hrefresh,'UserData',StatusData)2615 % BarPosition=[0.05 0.81 0.01 0.05];2616 % uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');2617 % drawnow2618 % end2619 % refresh_GUI(hfig)2620 2617 else 2621 2618 %% delete current display fig if selection is off 2622 2619 set(handles.status,'BackgroundColor',[0 1 0]) 2623 hfig=findobj(allchild(0),'name','s eries_status');2620 hfig=findobj(allchild(0),'name','status_display'); 2624 2621 if ~isempty(hfig) 2625 2622 delete(hfig) -
trunk/src/uigetfile_uvmat.m
r641 r644 128 128 NbOutputFile_str=num2str(NbOutputFile); 129 129 end 130 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart ,FilterExt);% list the directory content130 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 131 131 132 132 %% update the waitbar -
trunk/src/uvmat.m
r641 r644 194 194 195 195 %UvData.OpenParam.PosColorbar=[0.8450 0.0900 0.0190 0.3600]; 196 UvData.OpenParam.PosColorbar=[0.80 5 0.022 0.0190.445];196 UvData.OpenParam.PosColorbar=[0.80 0.02 0.018 0.445]; 197 197 %UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object 198 198 UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE) … … 210 210 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) 211 211 set(hObject,'DeleteFcn',{@closefcn})% 212 set(hObject,'ResizeFcn',{@ResizeFcn,handles})% 212 213 213 214 %% initialisation … … 334 335 set(hhh,'enable','off') 335 336 end 337 338 %------------------------------------------------------------------------ 339 %--- activated when resizing the GUI view_field 340 function ResizeFcn(gcbo,eventdata,handles) 341 %------------------------------------------------------------------------ 342 set(handles.uvmat,'Units','pixels') 343 size_fig=get(handles.uvmat,'Position'); 344 ColumnWidth=max(150,0.18*size_fig(3)); 345 ColumnWidth=min(ColumnWidth,250); % width of the right side display column, between 150 and 250, depending on the fig width 346 % Data=get(handles.uvmat,'UserData'); 347 % Data.GUISize=size_fig; 348 % set(handles.uvmat,'UserData',Data) 349 350 351 %% position of panel InputFile 352 %set(handles.InputFile,'Units','pixels') 353 pos_InputFile=get(handles.InputFile,'Position');% [lower x lower y width height] for text_display 354 pos_InputFile(1)=0; 355 pos_InputFile(2)=size_fig(4)-pos_InputFile(4); % set frame InputFile to the top of the fig 356 pos_InputFile(3)=size_fig(3); 357 358 set(handles.InputFile,'Position',pos_InputFile);% [lower x lower y width height] for text_display 359 360 %% reset position of text_display or TableDisplay 361 if strcmp(get(handles.TableDisplay,'Visible'),'off') 362 pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display 363 pos_1(3)=1.2*ColumnWidth; 364 pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig 365 pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); % set text display to the top of the fig 366 set(handles.text_display,'Position',pos_1) 367 % reset position of TableDisplay 368 else 369 pos_1=get(handles.TableDisplay,'Position'); 370 pos_1(3)=1.2*ColumnWidth; 371 pos_1(1)=size_fig(3)-pos_1(3); 372 pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); 373 set(handles.TableDisplay,'Position',pos_1) 374 end 375 376 %% reset position of CheckHold 377 % pos_CheckHold=get(handles.CheckHold,'Position');% [lower x lower y width height] for CheckHold 378 % pos_CheckHold(1)=size_fig(3)-pos_CheckHold(3); % set 'CheckHold' to the right of the fig 379 % pos_CheckHold(2)=pos_1(2)-pos_CheckHold(4); % set 'CheckHold' to the lower edge of text display 380 % set(handles.CheckHold,'Position',pos_CheckHold) 381 382 %% reset position of Coordinates 383 pos_2=get(handles.Coordinates,'Position');% [lower x lower y width height] for frame 'Coordinates' 384 pos_2(3)=ColumnWidth; 385 pos_2(1)=size_fig(3)-pos_2(3); % set 'Coordinates' to the right of the fig 386 pos_2(2)=pos_1(2)-pos_2(4); % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold 387 set(handles.Coordinates,'Position',pos_2) 388 389 %% reset position of Scalar 390 pos_3=get(handles.Scalar,'Position'); % [lower x lower y width height] for frame 'Scalar' 391 pos_3(3)=ColumnWidth; 392 pos_3(1)=size_fig(3)-pos_3(3); % set 'Scalar' to the right of the fig 393 if strcmp(get(handles.Scalar,'Visible'),'on') 394 pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 395 else 396 pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if unvisible 397 end 398 set(handles.Scalar,'Position',pos_3) 399 400 %% reset position of Vectors 401 set(handles.Vectors,'Units','pixels') 402 pos_4=get(handles.Vectors,'Position'); 403 pos_4(3)=ColumnWidth; 404 pos_4(1)=size_fig(3)-pos_4(3); 405 if strcmp(get(handles.Vectors,'visible'),'on') 406 pos_4(2)=pos_3(2)-pos_4(4); 407 else 408 pos_4(2)=pos_3(2); 409 end 410 set(handles.Vectors,'Position',pos_4) 411 412 %% reset position and scale of axis 413 pos(1)=0.2*size_fig(3)+35; 414 pos(2)=35; 415 pos(3)=0.77*size_fig(3)-1.2*ColumnWidth; 416 pos(4)=size_fig(4)-60; 417 set(handles.PlotAxes,'Position',pos) 418 336 419 337 420 %------------------------------------------------------------------------ … … 1103 1186 set(handles.j2,'Visible',state_j) 1104 1187 set(handles.last_j,'Visible',state_j); 1105 set(handles.frame_j,'Visible',state_j);1188 %set(handles.frame_j,'Visible',state_j); 1106 1189 set(handles.j_text,'Visible',state_j); 1107 1190 if ~isempty(i2_series)||~isempty(j2_series) … … 2749 2832 end 2750 2833 end 2834 ResizeFcn(handles.uvmat,[],handles) 2751 2835 2752 2836 %------------------------------------------------------------------------ … … 2984 3068 if strcmp(transform_fct,'sub_field') 2985 3069 set(handles.TransformName,'Value',1)%suppress the sub_field transform 2986 transform_fct_Callback(hObject, eventdata, handles); 3070 T 3071 3072 3073 ransformName_Callback(hObject, eventdata, handles); 2987 3074 else 2988 3075 run0_Callback(hObject, eventdata, handles) … … 4175 4262 set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing 4176 4263 else 4177 set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size4264 % set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size 4178 4265 end 4179 4266 end … … 4349 4436 else 4350 4437 Data=get(hview_field,'UserData'); 4351 set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots4438 % set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots 4352 4439 end 4353 4440 else -
trunk/src/view_field.m
r625 r644 101 101 %put the GUI on the lower right of the sceen 102 102 pos_view_field=get(hObject,'Position'); 103 set(0,'Unit','pixel') 103 104 ScreenSize=get(0,'ScreenSize'); 104 105 pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); … … 118 119 %% reset position of text_display or TableDisplay 119 120 if strcmp(get(handles.TableDisplay,'Visible'),'off') 120 pos_1=get(handles.text_display,'Position'); 121 pos_1(1)=size_fig(3)-pos_1(3); 122 pos_1(2)=size_fig(4)-pos_1(4); 121 pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display 122 pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig 123 pos_1(2)=size_fig(4)-pos_1(4); % set text display to the top of the fig 123 124 set(handles.text_display,'Position',pos_1) 124 125 % reset position of TableDisplay … … 130 131 end 131 132 133 %% reset position of CheckHold 134 pos_CheckHold=get(handles.CheckHold,'Position');% [lower x lower y width height] for CheckHold 135 pos_CheckHold(1)=size_fig(3)-pos_CheckHold(3); % set 'CheckHold' to the right of the fig 136 pos_CheckHold(2)=pos_1(2)-pos_CheckHold(4); % set 'CheckHold' to the lower edge of text display 137 set(handles.CheckHold,'Position',pos_CheckHold) 138 132 139 %% reset position of Coordinates 133 pos_2=get(handles.Coordinates,'Position'); 134 pos_2(1)=size_fig(3)-pos_ 1(3);135 pos_2(2)=pos_ 1(2)-pos_2(4);140 pos_2=get(handles.Coordinates,'Position');% [lower x lower y width height] for frame 'Coordinates' 141 pos_2(1)=size_fig(3)-pos_2(3); % set 'Coordinates' to the right of the fig 142 pos_2(2)=pos_CheckHold(2)-pos_2(4); % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold 136 143 set(handles.Coordinates,'Position',pos_2) 137 144 138 145 %% reset position of Scalar 139 pos_3=get(handles.Scalar,'Position'); 140 pos_3(1)=size_fig(3)-pos_3(3); 146 pos_3=get(handles.Scalar,'Position'); % [lower x lower y width height] for frame 'Scalar' 147 pos_3(1)=size_fig(3)-pos_3(3); % set 'Scalar' to the right of the fig 141 148 if strcmp(get(handles.Scalar,'visible'),'on') 142 pos_3(2)=pos_2(2)-pos_3(4); 149 pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 143 150 else 144 pos_3(2)=pos_2(2); 151 pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if unvisible 145 152 end 146 153 set(handles.Scalar,'Position',pos_3) … … 834 841 function num_ColCode2_Callback(hObject, eventdata, handles) 835 842 836 837 838 %839 %840 % % --- Executes when view_field is resized.841 % function view_field_ResizeFcn(hObject, eventdata, handles)842 % % hObject handle to view_field (see GCBO)843 % % eventdata reserved - to be defined in a future version of MATLAB844 % % handles structure with handles and user data (see GUIDATA)845 846 847 848
Note: See TracChangeset
for help on using the changeset viewer.