- Timestamp:
- May 29, 2012, 11:02:08 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r363 r434 56 56 %% Update handles structure 57 57 guidata(hObject, handles); 58 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}) 58 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 61 59 62 60 %% prepare the list of RUN fcts and set their paths … … 144 142 end 145 143 end 144 145 %% put the GUI on the lower right of the sceen 146 pos_view_field=get(hObject,'Position'); 147 ScreenSize=get(0,'ScreenSize'); 148 pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); 149 pos_view_field(2)=ScreenSize(2); 150 set(hObject,'Position',pos_view_field) 146 151 147 152 %% remove already opened get_field GUI with name get_field -
trunk/src/plot_field.m
r429 r434 227 227 if ~isempty(htext) 228 228 if isempty(index_0D) 229 set(htext,'String',{''}) 229 if strcmp(get(htext,'Type'),'uitable') 230 set(htext,'Data',{}) 231 else 232 set(htext,'String',{''}) 233 end 230 234 else 231 235 [errormsg]=plot_text(Data,CellVarIndex(index_0D),VarType(index_0D),htext); -
trunk/src/read_get_field.m
r404 r434 768 768 for ilist=1:numel(VarIndex_y) 769 769 VarName=Field.ListVarName{VarIndex_y(ilist)}; 770 eval(['npxy=size(SubField.' VarName ');'])770 npxy=size(SubField.(VarName)); 771 771 ind_select=find(npxy~=1); 772 772 SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}(ind_select); 773 eval(['SubField.' VarName '=squeeze(SubField.' VarName ');'])%remove singleton dimensions773 SubField.(VarName)=squeeze(SubField.(VarName));%remove singleton dimensions 774 774 if testpermute(ilist) 775 eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])775 SubField.(VarName)=permute(SubField.(VarName),[2 1]); 776 776 SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]); 777 777 end -
trunk/src/tps_coeff.m
r362 r434 9 9 % EMDX and EMDY are obtained from the function tps_eval_dxy. 10 10 %------------------------------------------------------------------------ 11 % [U_smooth,U_tps]=tps_coeff(ctrs,U, rho)11 % [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing) 12 12 %------------------------------------------------------------------------ 13 13 % OUPUT: … … 16 16 17 17 %INPUT: 18 % ctrs: Nxs matrix representing the postions of the Mcenters, sources of the tps (s=space dimension)19 % U: Nx1 column vector representing the initial values of the considered scalarat the centres ctrs20 % rho: smoothing parameter: the result is smoother for larger rho.18 % ctrs: Nxs matrix representing the postions of the N centers, sources of the tps (s=space dimension) 19 % U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs 20 % Smoothing: smoothing parameter: the result is smoother for larger Smoothing. 21 21 22 22 23 function [U_smooth,U_tps]=tps_coeff(ctrs,U, rho)23 function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing) 24 24 %------------------------------------------------------------------------ 25 % rhosmoothing parameter25 %Smoothing smoothing parameter 26 26 % X=reshape(X,[],1); 27 27 % Y=reshape(Y,[],1); … … 31 31 % ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites 32 32 EM = tps_eval(ctrs,ctrs); 33 RhoMat=rho*eye(N,N);% rho=1/(2*omega) , omega given by fasshauer;34 RhoMat=[RhoMat zeros(N,3)];33 SmoothingMat=Smoothing*eye(N,N);% Smoothing=1/(2*omega) , omega given by fasshauer; 34 SmoothingMat=[SmoothingMat zeros(N,3)]; 35 35 PM=[ones(N,1) ctrs]; 36 IM=[EM+ RhoMat; [PM' zeros(3,3)]];36 IM=[EM+SmoothingMat; [PM' zeros(3,3)]]; 37 37 U_tps=(IM\U); 38 38 U_smooth=EM *U_tps; -
trunk/src/tps_eval.m
r356 r434 1 1 %'tps_eval': calculate the thin plate spline (tps) interpolation at a set of points 2 % see tps_c eff for more information2 % see tps_coeff.m for more information and test_tps.m for an example 3 3 %------------------------------------------------------------------------ 4 4 % function EM = tps_eval(dsites,ctrs) … … 8 8 % from unit sources located at each of the N centers, + (s+1) columns 9 9 % representing the contribution of the linear gradient part. 10 % use : U_interp=EM*U_tps 10 11 % 11 12 %INPUT: 12 %dsites: Nxs matrix representing the postions of the N'observation' sites, with s the space dimension13 %ctrs: Mxs matrix representing the postions of the Mcenters, sources of the tps,13 %dsites: Mxs matrix representing the postions of the M 'observation' sites, with s the space dimension 14 %ctrs: Nxs matrix representing the postions of the N centers, sources of the tps, 14 15 % 15 16 % related functions: -
trunk/src/tps_eval_dxy.m
r356 r434 31 31 32 32 [Dsites,Ctrs] = ndgrid(dsites(:,1),ctrs(:,1));%d coordinates of interpolation points (Dsites) and initial points (Ctrs) 33 DX=Dsites-Ctrs; 33 DX=Dsites-Ctrs;% set of x wise distances between sites and centres 34 34 [Dsites,Ctrs] = ndgrid(dsites(:,2),ctrs(:,2));%d coordinates of interpolation points (Dsites) and initial points (Ctrs) 35 DY=Dsites-Ctrs; 35 DY=Dsites-Ctrs;% set of y wise distances between sites and centres 36 36 DM = DX.*DX + DY.*DY;% add d component squared 37 37 … … 40 40 41 41 DMX=[DX.*DM zeros(M,1) ones(M,1) zeros(M,1)];% effect of mean gradient 42 DMY=[DY.*DM zeros(M,1) ones(M,1) zeros(M,1)];% effect of mean gradient42 DMY=[DY.*DM zeros(M,1) zeros(M,1) ones(M,1)];% effect of mean gradient 43 43 -
trunk/src/uvmat.m
r432 r434 2170 2170 2171 2171 %% update the display menu for the second velocity type (second menuline) 2172 2173 2172 test_veltype_1=0; 2174 2173 if isempty(filename_1) … … 2235 2234 end 2236 2235 2237 2238 2239 2236 %% display time 2240 2237 testimedoc=0; … … 2390 2387 %UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation 2391 2388 2392 2393 %% get bounds and mesh (needed for mouse action and to open set_object) 2389 %% analyse input field 2394 2390 test_x=0; 2395 2391 test_z=0;% test for unstructured z coordinate 2396 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field); 2392 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure 2397 2393 if ~isempty(errormsg) 2398 errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg]; 2394 errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error 2399 2395 return 2400 2396 end 2401 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field); 2397 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);% analyse the input field structure 2402 2398 if ~isempty(errormsg) 2403 errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg]; 2399 errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];% display error 2404 2400 return 2405 2401 end … … 2408 2404 NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates 2409 2405 end 2406 2407 %% get bounds and mesh (needed for mouse action and to open set_object) 2410 2408 XName=''; %default 2411 2409 YName=''; 2412 if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates2410 if ~isempty(VarType{imax}.coord_x) 2413 2411 XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; 2414 YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; 2415 nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors) 2416 test_x=1;%test for unstructured coordinates 2417 if ~isempty(VarType{imax}.coord_z) 2418 ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; 2419 else 2420 NbDim=2; 2421 end 2422 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate 2412 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2413 nbpoints_x=DimValue(DimIndex(NbDim)); 2414 %unstructured coordinates 2415 if ~isempty(VarType{imax}.coord_y) 2416 YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; 2417 %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors) 2418 test_x=1;%test for unstructured coordinates 2419 if ~isempty(VarType{imax}.coord_z) 2420 ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; 2421 else 2422 NbDim=2; 2423 end 2424 end 2425 %structured coordinate 2426 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 2423 2427 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2424 2428 if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 2425 2429 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2426 2430 end 2427 VarIndex=CellVarIndex{imax}; % list of variable indices2428 DimIndex=VarDimIndex{ VarIndex(1)}; %list of dim indices for the variable2431 % VarIndex=CellVarIndex{imax}; % list of variable indices 2432 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2429 2433 nbpoints_x=DimValue(DimIndex(NbDim)); 2430 2434 XMax=nbpoints_x;%default 2431 2435 XMin=1;%default 2432 2436 end 2433 %% object visibility 2434 if NbDim>=2 2435 set(handles.Objects,'Visible','on') 2436 set(handles.ListObject_1_title,'Visible','on') 2437 set(handles.ListObject_1,'Visible','on') 2438 else% usual (x,y) plots: no projection object 2439 set(handles.Objects,'Visible','off') 2440 set(handles.ListObject_title,'Visible','off') 2441 set(handles.ListObject_1,'Visible','off') 2442 end 2437 2443 2438 if NbDim==3 2444 2439 if ~test_x 2445 2440 ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D 2446 2441 end 2447 eval(['ZMax=max(UvData.Field.' ZName ');'])2448 eval(['ZMin=min(UvData.Field.' ZName ');'])2442 ZMax=max(UvData.Field.(ZName)); 2443 ZMin=min(UvData.Field.(ZName)); 2449 2444 UvData.Field.ZMax=ZMax; 2450 2445 UvData.Field.ZMin=ZMin; … … 2455 2450 end 2456 2451 end 2457 2458 2452 if ~isempty (XName) 2459 2453 XMax=max(max(UvData.Field.(XName))); … … 2478 2472 end 2479 2473 end 2474 % case of structured coordinates 2480 2475 if ~test_x 2481 % VarIndex=CellVarIndex{imax}; % list of variable indices2482 % DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable2483 % nbpoints_x=DimValue(DimIndex(NbDim));2484 2476 DX=(XMax-XMin)/(nbpoints_x-1); 2485 2477 if NbDim >1 … … 2512 2504 UvData.Field.Mesh=ord; 2513 2505 end 2514 2515 2516 2517 2506 UvData.Object{1}.Type='plane';%main plotting plane 2507 UvData.Object{1}.ProjMode='projection';%main plotting plane 2508 UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2509 UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat 2518 2510 2519 2511 %% 3D case (menuvolume) … … 2528 2520 if test_set_object% reinitiate the GUI set_object 2529 2521 delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 2530 % UvData.Object{1}.Type='plane';%main plotting plane2531 % UvData.Object{1}.ProjMode='projection';%main plotting plane2532 % UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat2533 % UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat2534 2522 UvData.Object{1}.NbDim=NbDim;%test for 3D objects 2535 2523 UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane … … 2560 2548 UvData.Object{1}.ZObject=UvData.ZIndex; 2561 2549 end 2562 else2563 % % create a default projection2564 % UvData.Object{1}.ProjMode='projection';%main plotting plane2565 % UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat2566 % set(handles.ListObject,'Value',1);2567 % list_object=get(handles.ListObject,'String');2568 % if isempty(list_object)2569 % list_object={''};2570 % elseif ~isempty(list_object{1})2571 % list_object=[{''};list_object];2572 % end2573 % set(handles.ListObject,'String',list_object);2574 % % set(handles.list_object_2,'String',list_object);2575 2550 end 2576 2551 testnewseries=UvData.NewSeries; … … 2584 2559 % end 2585 2560 2586 %% Plot the projections on the selected projection objects 2587 % main projection object (uvmat display) 2588 list_object=get(handles.ListObject_1,'String'); 2589 if isequal(list_object,{''})%refresh list of objects if the menu is empty 2590 UvData.Object={[]}; 2591 set(handles.ListObject_1,'Value',1) 2592 end 2593 IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view 2594 if IndexObj(1)> numel(UvData.Object) 2595 IndexObj(1)=1;%select the first object if the selected one does not exist 2596 set(handles.ListObject_1,'Value',1) 2597 end 2598 IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view 2599 if isequal(IndexObj(2),IndexObj(1)) 2600 IndexObj(2)=[]; 2601 end 2602 plot_handles{1}=handles; 2603 if isfield(UvData,'plotaxes')%case of movies 2604 haxes(1)=UvData.plotaxes; 2605 else 2606 haxes(1)=handles.axes3; 2607 end 2608 %PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac 2609 PlotParam{1}=read_GUI(handles.uvmat); 2610 %default settings if vectors not visible 2611 if ~isfield(PlotParam{1},'Vectors') 2612 PlotParam{1}.Vectors.MaxVec=1; 2613 PlotParam{1}.Vectors.MinVec=0; 2614 PlotParam{1}.Vectors.CheckFixVecColor=1; 2615 PlotParam{1}.Vectors.ColCode1=0.33; 2616 PlotParam{1}.Vectors.ColCode2=0.66; 2617 PlotParam{1}.Vectors.ColorScalar={'ima_cor'}; 2618 PlotParam{1}.Vectors.ColorCode= {'rgb'}; 2619 end 2620 %keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits 2621 PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface 2622 2623 % second projection object (view_field display) 2624 if length( IndexObj)>=2 2625 view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI 2626 if ~isempty(view_field_handle) 2627 plot_handles{2}=guidata(view_field_handle); 2628 haxes(2)=plot_handles{2}.axes3; 2629 PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface 2630 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2631 end 2632 end 2633 2634 %% loop on the projection objects: one or two 2635 for imap=1:numel(IndexObj) 2636 iobj=IndexObj(imap); 2637 % if imap==2 || check_proj==0 % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) 2638 % % [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field); 2639 % % else 2561 %% usual 1D (x,y) plots 2562 if NbDim<=1 2563 set(handles.Objects,'Visible','off') 2564 set(handles.ListObject_1_title,'Visible','off') 2565 set(handles.ListObject_1,'Visible','off') 2566 [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.axes3,read_GUI(handles.uvmat)); 2567 write_plot_param(handles,PlotParamOut) %update the auto plot parameters 2568 % if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 2569 % ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) 2570 % end 2571 2572 %% 2D or 3D fields are generally projected 2573 else 2574 set(handles.Objects,'Visible','on') 2575 set(handles.ListObject_1_title,'Visible','on') 2576 set(handles.ListObject_1,'Visible','on') 2577 2578 %% Plot the projections on the selected projection objects 2579 % main projection object (uvmat display) 2580 list_object=get(handles.ListObject_1,'String'); 2581 if isequal(list_object,{''})%refresh list of objects if the menu is empty 2582 UvData.Object={[]}; 2583 set(handles.ListObject_1,'Value',1) 2584 end 2585 IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view 2586 if IndexObj(1)> numel(UvData.Object) 2587 IndexObj(1)=1;%select the first object if the selected one does not exist 2588 set(handles.ListObject_1,'Value',1) 2589 end 2590 IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view 2591 if isequal(IndexObj(2),IndexObj(1)) 2592 IndexObj(2)=[]; 2593 end 2594 plot_handles{1}=handles; 2595 if isfield(UvData,'plotaxes')%case of movies 2596 haxes(1)=UvData.plotaxes; 2597 else 2598 haxes(1)=handles.axes3; 2599 end 2600 PlotParam{1}=read_GUI(handles.uvmat); 2601 %default settings if vectors not visible 2602 if ~isfield(PlotParam{1},'Vectors') 2603 PlotParam{1}.Vectors.MaxVec=1; 2604 PlotParam{1}.Vectors.MinVec=0; 2605 PlotParam{1}.Vectors.CheckFixVecColor=1; 2606 PlotParam{1}.Vectors.ColCode1=0.33; 2607 PlotParam{1}.Vectors.ColCode2=0.66; 2608 PlotParam{1}.Vectors.ColorScalar={'ima_cor'}; 2609 PlotParam{1}.Vectors.ColorCode= {'rgb'}; 2610 end 2611 PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface 2612 2613 %% second projection object (view_field display) 2614 if length( IndexObj)>=2 2615 view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI 2616 if ~isempty(view_field_handle) 2617 plot_handles{2}=guidata(view_field_handle); 2618 haxes(2)=plot_handles{2}.axes3; 2619 PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface 2620 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2621 end 2622 end 2623 2624 %% loop on the projection objects: one or two 2625 2626 for imap=1:numel(IndexObj) 2627 iobj=IndexObj(imap); 2628 % if imap==2 || check_proj==0 % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) 2629 % % [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field); 2630 % % else 2640 2631 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object 2641 % end 2642 if ~isempty(errormsg) 2643 return 2644 end 2645 if testnewseries 2646 PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) 2647 if isfield(ObjectData,'CoordUnit') 2648 PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) 2649 PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 2650 end 2651 end 2652 %use of mask (TODO: check) 2653 if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') 2654 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions 2655 AX=ObjectData.AX;%x coordiantes for the scalar field 2656 AY=ObjectData.AY;%y coordinates for the scalar field 2657 MaskX=ObjectData.MaskX;%x coordiantes for the mask 2658 MaskY=ObjectData.MaskY;%y coordiantes for the mask 2659 if ~isequal(MaskX,AX)||~isequal(MaskY,AY) 2660 nxy=size(flag_mask); 2661 sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel 2662 sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); 2663 x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 2664 y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display 2665 %project on the positions of the scalar 2666 npxy=size(ObjectData.A); 2667 dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y 2668 dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x 2669 xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); 2670 yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); 2671 [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates 2672 flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); 2673 end 2674 AClass=class(ObjectData.A); 2675 ObjectData.A=flag_mask.*double(ObjectData.A); 2676 ObjectData.A=feval(AClass,ObjectData.A); 2677 ind_off=[]; 2678 if isfield(ObjectData,'ListVarName') 2679 for ilist=1:length(ObjectData.ListVarName) 2680 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2681 ind_off=[ind_off ilist]; 2632 % end 2633 if ~isempty(errormsg) 2634 return 2635 end 2636 if testnewseries 2637 PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) 2638 if isfield(ObjectData,'CoordUnit') 2639 PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) 2640 PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 2641 end 2642 end 2643 %use of mask (TODO: check) 2644 if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') 2645 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions 2646 AX=ObjectData.AX;%x coordiantes for the scalar field 2647 AY=ObjectData.AY;%y coordinates for the scalar field 2648 MaskX=ObjectData.MaskX;%x coordiantes for the mask 2649 MaskY=ObjectData.MaskY;%y coordiantes for the mask 2650 if ~isequal(MaskX,AX)||~isequal(MaskY,AY) 2651 nxy=size(flag_mask); 2652 sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel 2653 sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); 2654 x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 2655 y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display 2656 %project on the positions of the scalar 2657 npxy=size(ObjectData.A); 2658 dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y 2659 dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x 2660 xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); 2661 yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); 2662 [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates 2663 flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); 2664 end 2665 AClass=class(ObjectData.A); 2666 ObjectData.A=flag_mask.*double(ObjectData.A); 2667 ObjectData.A=feval(AClass,ObjectData.A); 2668 ind_off=[]; 2669 if isfield(ObjectData,'ListVarName') 2670 for ilist=1:length(ObjectData.ListVarName) 2671 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2672 ind_off=[ind_off ilist]; 2673 end 2674 end 2675 ObjectData.ListVarName(ind_off)=[]; 2676 VarDimIndex(ind_off)=[]; 2677 ind_off=[]; 2678 for ilist=1:length(ListDimName) 2679 if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') 2680 ind_off=[ind_off ilist]; 2681 end 2682 end 2683 ListDimName(ind_off)=[]; 2684 DimValue(ind_off)=[]; 2685 end 2686 end 2687 if ~isempty(ObjectData) 2688 PlotType='none'; %default 2689 if imap==2 && isempty(view_field_handle) 2690 view_field(ObjectData) 2691 else 2692 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); 2693 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters 2694 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 2695 ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) 2682 2696 end 2683 2697 end 2684 ObjectData.ListVarName(ind_off)=[]; 2685 VarDimIndex(ind_off)=[]; 2686 ind_off=[]; 2687 for ilist=1:length(ListDimName) 2688 if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') 2689 ind_off=[ind_off ilist]; 2698 if isequal(PlotType,'none') 2699 hget_field=findobj(allchild(0),'name','get_field'); 2700 if isempty(hget_field) 2701 get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) 2690 2702 end 2703 errormsg='The field defined by get_field cannot be plotted'; 2704 return 2691 2705 end 2692 ListDimName(ind_off)=[]; 2693 DimValue(ind_off)=[]; 2694 end 2695 end 2696 if ~isempty(ObjectData) 2697 2698 PlotType='none'; %default 2699 if imap==2 && isempty(view_field_handle) 2700 view_field(ObjectData) 2701 else 2702 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); 2703 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters 2704 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 2705 ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) 2706 end 2707 end 2708 2709 %% update the mask 2710 if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on 2711 update_mask(handles,num_i1,num_i2); 2712 end 2713 2714 %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) 2715 menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display 2716 ind_skip=[]; 2717 % nb_histo=1; 2718 Ustring=''; 2719 Vstring=''; 2720 % suppress coordinates from the histogram menu 2721 for ivar=1:numel(menu_histo)%l loop on field variables: 2722 if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') 2723 Role=UvData.Field.VarAttribute{ivar}.Role; 2724 switch Role 2725 case {'coord_x','coord_y','coord_z','dimvar'} 2726 ind_skip=[ind_skip ivar]; 2727 case {'vector_x'} 2728 Ustring=UvData.Field.ListVarName{ivar}; 2729 ind_skip=[ind_skip ivar]; 2730 case {'vector_y'} 2731 Vstring=UvData.Field.ListVarName{ivar}; 2732 ind_skip=[ind_skip ivar]; 2706 2733 end 2707 2734 end 2708 if isequal(PlotType,'none') 2709 hget_field=findobj(allchild(0),'name','get_field'); 2710 if isempty(hget_field) 2711 get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) 2712 end 2713 errormsg='The field defined by get_field cannot be plotted'; 2714 return 2715 end 2716 end 2717 end 2718 2719 %% update the mask 2720 if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on 2721 update_mask(handles,num_i1,num_i2); 2722 end 2723 2724 %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) 2725 menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display 2726 ind_skip=[]; 2727 % nb_histo=1; 2728 Ustring=''; 2729 Vstring=''; 2730 % suppress coordinates from the histogram menu 2731 for ivar=1:numel(menu_histo)%l loop on field variables: 2732 if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') 2733 Role=UvData.Field.VarAttribute{ivar}.Role; 2734 switch Role 2735 case {'coord_x','coord_y','coord_z','dimvar'} 2736 ind_skip=[ind_skip ivar]; 2737 case {'vector_x'} 2738 Ustring=UvData.Field.ListVarName{ivar}; 2739 ind_skip=[ind_skip ivar]; 2740 case {'vector_y'} 2741 Vstring=UvData.Field.ListVarName{ivar}; 2742 ind_skip=[ind_skip ivar]; 2743 end 2744 end 2745 DimCell=UvData.Field.VarDimName{ivar}; 2746 DimName=''; 2747 if ischar(DimCell) 2748 DimName=DimCell; 2749 elseif iscell(DimCell)&& numel(DimCell)==1 2750 DimName=DimCell{1}; 2751 end 2752 if strcmp(DimName,menu_histo{ivar}) 2753 ind_skip=[ind_skip ivar]; 2754 end 2755 end 2756 menu_histo(ind_skip)=[];% remove skipped items 2757 if ~isempty(Ustring) 2758 menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist 2759 end 2760 2761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2762 % display menus and plot histograms 2763 test_v=0; 2764 if ~isempty(menu_histo) 2765 set(handles.histo1_menu,'Value',1) 2766 set(handles.histo1_menu,'String',menu_histo) 2767 histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram 2768 % case of more than one variables (eg vector components) 2769 % if nb_histo > 1 2770 % test_v=1; 2771 % set(handles.histo2_menu,'Visible','on') 2772 % set(handles.histo_v,'Visible','on') 2773 % set(handles.histo2_menu,'String',menu_histo) 2774 % set(handles.histo2_menu,'Value',2) 2775 % histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram 2776 % end 2777 end 2778 % if ~test_v 2779 % set(handles.histo2_menu,'Visible','off') 2780 % set(handles.histo_v,'Visible','off') 2781 % cla(handles.histo_v) 2782 % set(handles.histo2_menu,'Value',1) 2783 % end 2784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2735 DimCell=UvData.Field.VarDimName{ivar}; 2736 DimName=''; 2737 if ischar(DimCell) 2738 DimName=DimCell; 2739 elseif iscell(DimCell)&& numel(DimCell)==1 2740 DimName=DimCell{1}; 2741 end 2742 if strcmp(DimName,menu_histo{ivar}) 2743 ind_skip=[ind_skip ivar]; 2744 end 2745 end 2746 menu_histo(ind_skip)=[];% remove skipped items 2747 if ~isempty(Ustring) 2748 menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist 2749 end 2750 2751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2752 % display menus and plot histograms 2753 test_v=0; 2754 if ~isempty(menu_histo) 2755 set(handles.histo1_menu,'Value',1) 2756 set(handles.histo1_menu,'String',menu_histo) 2757 histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram 2758 end 2759 end 2760 2785 2761 %------------------------------------------------------------------------ 2786 2762 function histo1_menu_Callback(hObject, eventdata, handles)
Note: See TracChangeset
for help on using the changeset viewer.