Changeset 434 for trunk


Ignore:
Timestamp:
May 29, 2012, 11:02:08 PM (12 years ago)
Author:
sommeria
Message:

corrections in the use of get_field
test_tps introduced, to test thin plate shell functions
tps-eval_dxy corrected (bug on the calculation of the derivatives fixed)

Location:
trunk/src
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r363 r434  
    5656%% Update handles structure
    5757guidata(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})
     58set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
    6159
    6260%% prepare the list of RUN fcts and set their paths
     
    144142    end
    145143end
     144
     145%% put the GUI on the lower right of the sceen
     146pos_view_field=get(hObject,'Position');
     147ScreenSize=get(0,'ScreenSize');
     148pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
     149pos_view_field(2)=ScreenSize(2);
     150set(hObject,'Position',pos_view_field)
    146151
    147152%% remove already opened get_field GUI with name get_field
  • trunk/src/plot_field.m

    r429 r434  
    227227if ~isempty(htext)
    228228    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
    230234    else
    231235        [errormsg]=plot_text(Data,CellVarIndex(index_0D),VarType(index_0D),htext);
  • trunk/src/read_get_field.m

    r404 r434  
    768768    for ilist=1:numel(VarIndex_y)
    769769        VarName=Field.ListVarName{VarIndex_y(ilist)};
    770         eval(['npxy=size(SubField.' VarName ');'])
     770        npxy=size(SubField.(VarName));
    771771        ind_select=find(npxy~=1);
    772772        SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}(ind_select);
    773         eval(['SubField.' VarName '=squeeze(SubField.' VarName ');'])%remove singleton dimensions
     773        SubField.(VarName)=squeeze(SubField.(VarName));%remove singleton dimensions
    774774        if testpermute(ilist)
    775             eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])
     775            SubField.(VarName)=permute(SubField.(VarName),[2 1]);
    776776            SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]);
    777777        end
  • trunk/src/tps_coeff.m

    r362 r434  
    99% EMDX and EMDY are obtained from the function tps_eval_dxy.
    1010%------------------------------------------------------------------------
    11 % [U_smooth,U_tps]=tps_coeff(ctrs,U,rho)
     11% [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
    1212%------------------------------------------------------------------------
    1313% OUPUT:
     
    1616
    1717%INPUT:
    18 % ctrs: Nxs matrix  representing the postions of the M centers, sources of the tps (s=space dimension)
    19 % U: Nx1 column vector representing the initial values of the considered scalar at the centres ctrs
    20 % 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.
    2121
    2222
    23 function [U_smooth,U_tps]=tps_coeff(ctrs,U,rho)
     23function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
    2424%------------------------------------------------------------------------
    25 %rho smoothing parameter
     25%Smoothing smoothing parameter
    2626% X=reshape(X,[],1);
    2727% Y=reshape(Y,[],1);
     
    3131% ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites
    3232EM = tps_eval(ctrs,ctrs);
    33 RhoMat=rho*eye(N,N);%  rho=1/(2*omega) , omega given by fasshauer;
    34 RhoMat=[RhoMat zeros(N,3)];
     33SmoothingMat=Smoothing*eye(N,N);%  Smoothing=1/(2*omega) , omega given by fasshauer;
     34SmoothingMat=[SmoothingMat zeros(N,3)];
    3535PM=[ones(N,1) ctrs];
    36 IM=[EM+RhoMat; [PM' zeros(3,3)]];
     36IM=[EM+SmoothingMat; [PM' zeros(3,3)]];
    3737U_tps=(IM\U);
    3838U_smooth=EM *U_tps;
  • trunk/src/tps_eval.m

    r356 r434  
    11%'tps_eval': calculate the thin plate spline (tps) interpolation at a set of points
    2 % see tps_ceff for more information
     2% see tps_coeff.m for more information and test_tps.m for an example
    33%------------------------------------------------------------------------
    44% function EM = tps_eval(dsites,ctrs)
     
    88%   from unit sources located at each of the N centers, + (s+1) columns
    99%   representing the contribution of the linear gradient part.
     10%  use : U_interp=EM*U_tps
    1011%
    1112%INPUT:
    12 %dsites:  Nxs matrix representing the postions of the N 'observation' sites, with s the space dimension
    13 %ctrs: Mxs matrix  representing the postions of the M centers, 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,
    1415%
    1516% related functions:
  • trunk/src/tps_eval_dxy.m

    r356 r434  
    3131 
    3232[Dsites,Ctrs] = ndgrid(dsites(:,1),ctrs(:,1));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
    33 DX=Dsites-Ctrs;
     33DX=Dsites-Ctrs;% set of x wise distances between sites and centres
    3434[Dsites,Ctrs] = ndgrid(dsites(:,2),ctrs(:,2));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
    35 DY=Dsites-Ctrs;
     35DY=Dsites-Ctrs;% set of y wise distances between sites and centres
    3636DM = DX.*DX + DY.*DY;% add d component squared
    3737
     
    4040
    4141DMX=[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 gradient
     42DMY=[DY.*DM zeros(M,1)  zeros(M,1) ones(M,1)];% effect of mean gradient
    4343
  • trunk/src/uvmat.m

    r432 r434  
    21702170
    21712171%% update the display menu for the second velocity type (second menuline)
    2172 
    21732172test_veltype_1=0;
    21742173if isempty(filename_1)
     
    22352234end           
    22362235
    2237 
    2238 
    22392236%% display time
    22402237testimedoc=0;
     
    23902387%UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
    23912388
    2392 
    2393 %% get bounds and mesh (needed for mouse action and to open set_object)
     2389%% analyse input field
    23942390test_x=0;
    23952391test_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
    23972393if ~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
    23992395    return
    24002396end
    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
    24022398if ~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
    24042400    return
    24052401end
     
    24082404    NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
    24092405end
     2406
     2407%% get bounds and mesh (needed for mouse action and to open set_object)
    24102408XName=''; %default
    24112409YName='';
    2412 if ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinates
     2410if ~isempty(VarType{imax}.coord_x)
    24132411    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   
     2426elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0
    24232427    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
    24242428    if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
    24252429        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
    24262430    end
    2427     VarIndex=CellVarIndex{imax}; % list of variable indices
    2428     DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2431   % VarIndex=CellVarIndex{imax}; % list of variable indices
     2432    DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
    24292433    nbpoints_x=DimValue(DimIndex(NbDim));
    24302434    XMax=nbpoints_x;%default
    24312435    XMin=1;%default
    24322436end
    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
    24432438if NbDim==3
    24442439    if ~test_x
    24452440        ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
    24462441    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));
    24492444    UvData.Field.ZMax=ZMax;
    24502445    UvData.Field.ZMin=ZMin;
     
    24552450    end
    24562451end
    2457 
    24582452if ~isempty (XName)
    24592453    XMax=max(max(UvData.Field.(XName)));
     
    24782472    end
    24792473end
     2474% case of structured coordinates
    24802475if ~test_x
    2481     %         VarIndex=CellVarIndex{imax}; % list of variable indices
    2482     %         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2483     %         nbpoints_x=DimValue(DimIndex(NbDim));
    24842476    DX=(XMax-XMin)/(nbpoints_x-1);
    24852477    if NbDim >1
     
    25122504    UvData.Field.Mesh=ord;
    25132505end
    2514         UvData.Object{1}.Type='plane';%main plotting plane
    2515         UvData.Object{1}.ProjMode='projection';%main plotting plane
    2516         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    2517         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     2506UvData.Object{1}.Type='plane';%main plotting plane
     2507UvData.Object{1}.ProjMode='projection';%main plotting plane
     2508UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2509UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25182510
    25192511%% 3D case (menuvolume)
     
    25282520    if test_set_object% reinitiate the GUI set_object
    25292521        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 plane
    2531 %         UvData.Object{1}.ProjMode='projection';%main plotting plane
    2532 %         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    2533 %         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25342522        UvData.Object{1}.NbDim=NbDim;%test for 3D objects
    25352523        UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
     
    25602548        UvData.Object{1}.ZObject=UvData.ZIndex;
    25612549    end
    2562 else
    2563 %     % create a default projection
    2564 %     UvData.Object{1}.ProjMode='projection';%main plotting plane
    2565 %     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    2566 %     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 %     end
    2573 %     set(handles.ListObject,'String',list_object);
    2574 % %     set(handles.list_object_2,'String',list_object);
    25752550end
    25762551testnewseries=UvData.NewSeries;
     
    25842559% end
    25852560
    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
     2562if 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
     2573else
     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
    26402631        [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)
    26822696                end
    26832697            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)
    26902702                end
     2703                errormsg='The field defined by get_field cannot be plotted';
     2704                return
    26912705            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];
    27062733            end
    27072734        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
     2759end
     2760
    27852761%------------------------------------------------------------------------
    27862762function histo1_menu_Callback(hObject, eventdata, handles)
Note: See TracChangeset for help on using the changeset viewer.