Changeset 1078 for trunk/src


Ignore:
Timestamp:
Mar 30, 2020, 3:48:19 PM (5 years ago)
Author:
sommeria
Message:

various updates

Location:
trunk/src
Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_interp.m

    r1071 r1078  
    5454        if isempty(ivar)% the requested variable does not exist
    5555            check_skipped(ilist)=1; %variable not found
    56         elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));% the variable exists and has not been already selected
     56        elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1))% the variable exists and has not been already selected
    5757            if exist('XI','var')&& isfield(Data.VarAttribute{ivar},'Role') &&...
    5858                    (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag'))
     
    8686            UName{ilist}=r.UName;
    8787            VName{ilist}=r.VName;
    88             if isempty(find(strcmp(r.UName,InputVarList)));
     88            if isempty(find(strcmp(r.UName,InputVarList)))
    8989                InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list
    9090            end
    91             if isempty(find(strcmp(r.VName,InputVarList), 1));
     91            if isempty(find(strcmp(r.VName,InputVarList), 1))
    9292                InputVarList=[InputVarList VName{ilist}]; %the variable is added to the list if it is not already in the list
    9393            end
     
    162162end
    163163
    164 %% put an error flag to indicate NaN data
    165 % if exist('XI','var')&&~isempty(VarVal)
    166 %     nbvar=numel(VarVal);
    167 %     ListVarName{nbvar+1}='FF';
    168 %     VarVal{nbvar+1}=isnan(VarVal{nbvar});
    169 %     VarAttribute{nbvar+1}.Role='errorflag';
    170 % end
    171164
    172165
  • trunk/src/find_field_bounds.m

    r1071 r1078  
    134134end
    135135% adjust the mesh to a value 1, 2 , 5 *10^n
    136 ord=10^(floor(log10(Mesh)));%order of magnitude
    137 if Mesh/ord>=5
    138     FieldOut.CoordMesh=5*ord;
    139 elseif Mesh/ord>=2
    140     FieldOut.CoordMesh=2*ord;
    141 else
    142     FieldOut.CoordMesh=ord;
    143 end
     136FieldOut.CoordMesh = round_uvmat(Mesh);
     137
     138
  • trunk/src/find_field_cells.m

    r1071 r1078  
    294294            end
    295295        else
    296             if isfield(CellInfo{icell},'XName'); % only one coordinate x, switch vector field to 1D plot
     296            if isfield(CellInfo{icell},'XName') % only one coordinate x, switch vector field to 1D plot
    297297                for ind=1:numel(CellInfo{icell}.VarIndex)
    298298                    Role{CellInfo{icell}.VarIndex(ind)}='coord_y';
     
    502502for icell=1:numel(CellInfo)
    503503    if isfield(CellInfo{icell},'VarIndex')
     504        check_fieldname=0;
    504505        VarIndex=CellInfo{icell}.VarIndex;
    505506        for ivar=VarIndex
     
    514515            if ~isempty(FieldName{ivar})
    515516                CellInfo{icell}.FieldName=FieldName{ivar};
     517                check_fieldname=1;
    516518            end
    517519            if CheckSub(ivar)==1
    518520                CellInfo{icell}.CheckSub=1;
     521            end
     522        end
     523        if ~check_fieldname% default FieldName
     524            if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
     525                UName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_x};
     526                VName=Data.ListVarName{CellInfo{icell}.VarIndex_vector_y};       
     527                CellInfo{icell}.FieldName=['vec(' UName ',' VName ')'];
    519528            end
    520529        end
  • trunk/src/mouse_down.m

    r1072 r1078  
    390390        IndexObj=IndexObj+1;%start new object
    391391        ObjectData.Coord=[];
    392         ObjectNameNew=ObjectData.Name;
    393         if isempty(ObjectNameNew)
    394             ObjectNameNew=ObjectData.Type;
     392        ObjectName=ObjectData.Name;
     393        if isempty(ObjectName)
     394            ObjectName=ObjectData.Type;
    395395        end
    396396        % add an index to the object name if the proposed name already exists
    397         vers=0;% index of the name
     397        %vers=0;% index of the name
    398398        ListObject=get(hhuvmat.ListObject,'String');
    399         detectname=1;
    400         while ~isempty(detectname)
    401             detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    402             if detectname% if the object name already exists
    403                 indstr=regexp(ObjectNameNew,'\D');
    404                 if indstr(end)<length(ObjectNameNew) %object name ends by a number
    405                     vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
    406                     ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
    407                 else
    408                     vers=vers+1;
    409                     ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    410                 end
    411             end
    412         end
    413         ObjectName=ObjectNameNew;
     399        ObjectName=rename_indexing(ObjectName,ListObject);% add an index or upgrade it if the object naem already exists
    414400        set(sethandles.Name,'String',ObjectName)% display the default name in set_object
    415401        ListObject=[ListObject;{ObjectName}];
  • trunk/src/mouse_motion.m

    r1077 r1078  
    220220                pos=[xy(1,1) xy(1,2) 0];%coordinates on the graph
    221221                if isfield(Field,'ProjObjectAngle')&&~isequal(Field.ProjObjectAngle,[0 0 0])
    222                     om=norm(Field.ProjObjectAngle);%norm of rotation angle in radians
    223                     OmAxis=Field.ProjObjectAngle/om; %unit vector marking the rotation axis
    224                     cos_om=cos(pi*om/180);
    225                     sin_om=sin(pi*om/180);
    226                     pos=[xy(1,1) xy(1,2) 0];
    227                     %pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
    228                     coeff=OmAxis(3)*(1-cos_om);
    229                     norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    230                     norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    231                     norm_plane(3)=OmAxis(3)*coeff+cos_om;
    232                     %Z0=norm_plane*Field.ProjObjectCoord'/norm_plane(3);
    233                     pos(3)=-(norm_plane(1)*pos(1)+norm_plane(2)*pos(2))/norm_plane(3);                               
    234                 end
    235                 pos=pos+Field.ProjObjectCoord;
     222                    norm_plane=angle2normal(Field.ProjObjectAngle);
     223                    pos(3)=-(norm_plane(1)*(pos(1)-Field.ProjObjectCoord(1))+norm_plane(2)*(pos(2)-Field.ProjObjectCoord(2)))/norm_plane(3);                               
     224                end
     225                pos(3)=pos(3)+Field.ProjObjectCoord(3);
    236226                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
    237227            end
  • trunk/src/phys_XYZ.m

    r1071 r1078  
    11%------------------------------------------------------------------------
    22%'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters
    3 % function [Xphys,Yphys]=phys_XYZ(Calib,X,Y,Z)
     3% function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Zindex)
    44%
    55%OUTPUT:
     
    3030testangle=0;
    3131test_refraction=0;
     32Zphys=0; %default output
    3233if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Calib,'SliceCoord')&&size(Calib.SliceCoord,1)>=Zindex
    33     if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0]) && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0])
     34    if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=Zindex && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0])
    3435        testangle=1;
    35         om=norm(Calib.SliceAngle(Zindex,:));%norm of rotation angle in radians
    36         OmAxis=Calib.SliceAngle(Zindex,:)/om; %unit vector marking the rotation axis
    37         cos_om=cos(pi*om/180);
    38         sin_om=sin(pi*om/180);
    39         coeff=OmAxis(3)*(1-cos_om);
    40         norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    41         norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    42         norm_plane(3)=OmAxis(3)*coeff+cos_om;
    43 %         Z0=norm_plane*Calib.SliceCoord(Zindex,:)'/norm_plane(3);
     36        norm_plane=angle2normal(Calib.SliceAngle(Zindex,:));
    4437    end
    4538    Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte
    46 %     end
    4739    Z0virt=Z0;
    4840    if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
     
    134126end
    135127
    136 %'px_XYZ': transform phys coordinates to image coordinates (px)
    137 %
    138 % OUTPUT:
    139 % X,Y: array of coordinates in the image cooresponding to the input physical positions
    140 %                    (origin at lower leftcorner, unit=pixel)
    141 
    142 % INPUT:
    143 % Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)
    144 % Xphys, Yphys: array of x,y physical coordinates
    145 % [Z0]: corresponding array of z physical coordinates (0 by default)
  • trunk/src/phys_ima.m

    r972 r1078  
    2222    XmlData={XmlData};
    2323end
     24
    2425for icell=1:numel(A)
    2526    siz=size(A{icell});
     
    2728    npy=[npy siz(1)];
    2829    Calib=XmlData{icell}.GeometryCalib;
    29     xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners
    30     yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
    31     [xcorner_new,ycorner_new]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
     30    coord_x=[0.5 siz(2)-0.5];
     31    coord_y=[0.5 siz(1)-0.5];
     32    x_edge=[linspace(coord_x(1),coord_x(end),npx(icell)) coord_x(end)*ones(1,npy(icell))...
     33        linspace(coord_x(end),coord_x(1),npx(icell)) coord_x(1)*ones(1,npy(icell))];%x coordinates of the image edge(four sides)
     34    y_edge=[coord_y(1)*ones(1,npx(icell)) linspace(coord_y(1),coord_y(end),npy(icell))...
     35        coord_y(end)*ones(1,npx(icell)) linspace(coord_y(end),coord_y(1),npy(icell))];%y coordinates of the image edge(four sides)
     36    [xcorner_new,ycorner_new]=phys_XYZ(Calib,x_edge,y_edge,ZIndex);%corresponding physical coordinates
    3237    dx(icell)=(max(xcorner_new)-min(xcorner_new))/(siz(2)-1);
    3338    dy(icell)=(max(ycorner_new)-min(ycorner_new))/(siz(1)-1);
     
    4045Rangy(1)=max(ycorner);
    4146test_multi=(max(npx)~=min(npx)) || (max(npy)~=min(npy)); %different image lengths
    42 % npX=1+round((Rangx(2)-Rangx(1))/min(dx));% nbre of pixels in the new image (use the finest resolution min(dx) in the set of images)
    43 % npY=1+round((Rangy(1)-Rangy(2))/min(dy));
    4447
    4548npX=1+round((Rangx(2)-Rangx(1))/max(dx));% nbre of pixels in the new image (use the largest resolution max(dx) in the set of images)
    4649npY=1+round((Rangy(1)-Rangy(2))/max(dy));
    4750
    48 
    4951x=linspace(Rangx(1),Rangx(2),npX);
    5052y=linspace(Rangy(1),Rangy(2),npY);
    51 [X,Y]=meshgrid(x,y);%grid in physical coordiantes
    52 %vec_B=[];
     53[X,Y]=meshgrid(x,y);%grid in physical coordinates
    5354A_out=cell(1,numel(A));
    54 for icell=1:length(A)
     55
     56for icell=1:length(A)
    5557    Calib=XmlData{icell}.GeometryCalib;
    5658    % rescaling of the image coordinates without change of the image array
     
    6062        Rangy=[npy-0.5 0.5];
    6163        [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation
    62         [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);
     64        [~,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);
    6365    else
    6466        % the image needs to be interpolated to the new coordinates
    65         zphys=0; %default
     67        Z=0; %default
    6668        if isfield(Calib,'SliceCoord') %.Z= index of plane
    6769            SliceCoord=Calib.SliceCoord(ZIndex,:);
    68             zphys=SliceCoord(3); %to generalize for non-parallel planes
    69             if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0]) && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0])
    70                 testangle=1;
    71                 om=norm(Calib.SliceAngle(ZIndex,:));%norm of rotation angle in radians
    72                 OmAxis=Calib.SliceAngle(ZIndex,:)/om; %unit vector marking the rotation axis
    73                 cos_om=cos(pi*om/180);
    74                 sin_om=sin(pi*om/180);
    75                 coeff=OmAxis(3)*(1-cos_om);
    76                 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    77                 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    78                 norm_plane(3)=OmAxis(3)*coeff+cos_om;
    79                 %Z0=norm_plane*Calib.SliceCoord(ZIndex,:)'/norm_plane(3);
    80                 Z0=Calib.SliceCoord(ZIndex,3);
    81                 zphys=Z0-(norm_plane(1)*X-norm_plane(2)*Y)/norm_plane(3);
     70            Z=SliceCoord(3);
     71            if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=ZIndex && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0])
     72                norm_plane=angle2normal(Calib.SliceAngle(ZIndex,:));
     73                Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3);
    8274            end
    83 %             if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
    84 %                 H=Calib.InterfaceCoord(3);
    85 %                 if H>zphys
    86 %                     zphys=H-(H-zphys)/Calib.RefractionIndex; %corrected z (virtual object)
    87 %                 end
    88 %             end
    8975        end
    9076        xima=0.5:npx(icell)-0.5;%image coordinates of corners
    9177        yima=npy(icell)-0.5:-1:0.5;
    9278        [XIMA_init,YIMA_init]=meshgrid(xima,yima);%grid of initial image in px coordinates
    93         [XIMA,YIMA]=px_XYZ(XmlData{icell}.GeometryCalib,X,Y,zphys);% image coordinates for each point in the real
     79        [XIMA,YIMA]=px_XYZ(XmlData{icell}.GeometryCalib,X,Y,Z);% image coordinates for each point in the real
    9480        testuint8=isa(A{icell},'uint8');
    9581        testuint16=isa(A{icell},'uint16');
    96         if ndims(A{icell})==2 %(B/W images)
    97         A_out{icell}=interp2(XIMA_init,YIMA_init,double(A{icell}),XIMA,YIMA);
    98          elseif ndims(A{icell})==3     
    99              for icolor=1:size(A{icell},3)
    100                  A{icell}=double(A{icell});
    101                  A_out{icell}(:,:,icolor)=interp2(XIMA_init,YIMA_init,A{icell}(:,:,icolor),XIMA,YIMA);
    102              end
    103          end
     82        if ismatrix(A{icell}) %(B/W images)
     83            A_out{icell}=interp2(XIMA_init,YIMA_init,double(A{icell}),XIMA,YIMA);
     84        elseif ndims(A{icell})==3
     85            for icolor=1:size(A{icell},3)
     86                A{icell}=double(A{icell});
     87                A_out{icell}(:,:,icolor)=interp2(XIMA_init,YIMA_init,A{icell}(:,:,icolor),XIMA,YIMA);
     88            end
     89        end
    10490        if testuint8
    10591            A_out{icell}=uint8(A_out{icell});
     
    10793        if testuint16
    10894            A_out{icell}=uint16(A_out{icell});
    109         end     
     95        end
    11096    end
    11197end
  • trunk/src/proj_field.m

    r1077 r1078  
    985985
    986986%-----------------------------------------------------------------
    987 %project on a plane
    988 % AJOUTER flux,circul,error
     987% proj_plane: project on a plane defined by the structure ObjectData containing:
     988%    .Type : = 'plane'
     989%    .ProjMode (mode of projection) = 'projection'|'interp_lin'|'interp_tps' ;
     990%    .CoordUnit: (for instance 'px','cm') units for the coordinates defining the plane  (the program checks that it fits with the unit of the input Field)
     991%    .Angle : angles of rotation of the plane expressed in degrees. The first element
     992%         ObjectData.Angle(1) represents a rotation in the plane (x,y) (around the
     993%         vertical axis), which can be followed by a rotation with angle ObjectData.Angle(2) around the new (rotated) x axis.
     994%    .Coord(1,3): coordinates (x,y,z) of the origin of the new coordinates in the projection plane;
     995%    .DX,.DY,.DZ : increments along each coordinate for the projected data (for 'interp_lin' and 'interp_tps')
     996%    .RangeX,RangeY: vectors with two elements defining the lower and upper bounds of the respectively X and Y coordinates in the projection plane
     997%    .RangeInterp: maximum distance of interpolation from the known data. Interpolation yields NaN beyond this distance.
     998
     999% TODO: AJOUTER flux,circul,error
    9891000function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
    9901001%-----------------------------------------------------------------
    9911002
    992 %% rotation angles
     1003%% rotation matrix
    9931004PlaneAngle=[0 0];
    9941005norm_plane=[0 0 1];
    995 %cos_om=1;
    996 %sin_om=0;
    9971006test90x=0;%=1 for 90 degree rotation alround x axis
    9981007test90y=0;%=1 for 90 degree rotation alround y axis
    999 % if strcmp(ObjectData.Type,'plane_z')
    1000 %     Delta_x=ObjectData.Coord(2,1)-ObjectData.Coord(1,1);
    1001 %     Delta_y=ObjectData.Coord(2,2)-ObjectData.Coord(1,2);
    1002 %     Delta_mod=sqrt(Delta_x*Delta_x+Delta_y*Delta_y);
    1003 %     ObjectData.Angle=[0 0 0];
    1004 %     ObjectData.Angle(1)=90*Delta_x/Delta_mod;
    1005 %     ObjectData.0(2)=90*Delta_y/Delta_mod;
    1006 % end
     1008
    10071009if isfield(ObjectData,'Angle')
    10081010    checkM2=0;
     
    10141016    if PlaneAngle==0
    10151017        PlaneAngle=[0 0];
    1016     end
    1017     %     om=norm(PlaneAngle);%norm of rotation angle in radians
    1018     %     OmAxis=PlaneAngle/om; %unit vector marking the rotation axis
    1019     %     cos_om=cos(om);
    1020     %     sin_om=sin(om);
    1021     %     coeff=OmAxis(3)*(1-cos_om);
    1022     %     %components of the unity vector norm_plane normal to the projection plane
    1023     %     norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    1024     %     norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    1025     %     norm_plane(3)=OmAxis(3)*coeff+cos_om;
    1026    
     1018    end   
    10271019    M1=[cos(PlaneAngle(1)) -sin(PlaneAngle(1)) 0;sin(PlaneAngle(1)) cos(PlaneAngle(1)) 0;0 0 1];
    10281020    M=M1;
     
    10311023        M=M1*M2;% first rotate in the x,y plane with angle PlaneAngle(1), then slant around the new x axis0 with angle PlaneAngle(2)
    10321024    end
    1033     norm_plane=M*[0 0 1]';
    1034    
     1025    norm_plane=M*[0 0 1]'; 
    10351026end
    10361027testangle=~isequal(PlaneAngle,[0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane
     
    14251416                %rotate coordinates if needed: coord_X,coord_Y= = coordinates in the new plane
    14261417                Phi=PlaneAngle(1);
    1427                 if testangle && ~test90y && ~test90x;%=1 for slanted plane
     1418                if testangle && ~test90y && ~test90x %=1 for slanted plane
    14281419                    new_XI=XI *cos(Phi) - YI* sin(Phi)+ObjectData.Coord(1);
    14291420                    YI=XI *sin(Phi) + YI *cos(Phi)+ObjectData.Coord(2);
  • trunk/src/series.m

    r1072 r1078  
    14591459    return
    14601460end
    1461 if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,'get_field...')
    1462     errormsg='input field name(s) not defined, select get_field...';
     1461if isfield(Param,'InputFields')&& isfield(Param.InputFields,'FieldName')&& isequal(Param.InputFields.FieldName,'add_field...')
     1462    errormsg='input field name(s) not defined, select add_field...';
    14631463    return
    14641464end
     
    24502450        set(handles.VelType_1,'Visible','on')
    24512451        set(handles.VelType_title_1,'Visible','on')
    2452         FieldList_1=[set_field_list('U','V');{'C'};{'get_field...'}]; % standard menu for civx data
     2452        FieldList_1=[set_field_list('U','V');{'C'};{'add_field...'}]; % standard menu for civx data
    24532453        CheckList_1=1;
    24542454        set(handles.FieldName_1,'Value',1); % velocity vector choice by default
     
    24672467    if FieldNameRequest && isfield(SeriesData.FileInfo{iview_netcdf(1)},'ListVarName')
    24682468        set(handles.FieldName,'Visible','on')
     2469        set(handles.Field_text,'Visible','on')
    24692470        ListVarName=SeriesData.FileInfo{iview_netcdf(1)}.ListVarName;
    24702471        ind_var=get(handles.FieldName,'Value'); % indices of previously selected variables
     
    24912492    else
    24922493        set(handles.FieldName,'Visible','off')
     2494        set(handles.Field_text,'Visible','off')
    24932495    end
    24942496   
    24952497    set(handles_coord,'Visible','on')
    2496     if isempty(find(strcmp('get_field...',FieldList)))
    2497     FieldList=[FieldList;{'get_field...'}];%add 'get_field...' to the menu FieldName if it is not already
     2498    if isempty(find(strcmp('add_field...',FieldList)))
     2499    FieldList=[FieldList;{'add_field...'}];%add 'add_field...' to the menu FieldName if it is not already
    24982500    end
    24992501    if FieldNameRequest_1 && numel(iview_netcdf)>=2
     
    25302532    end
    25312533    if isempty(FieldList)
     2534        set(handles.Field_text,'Visible','off')
    25322535        set(handles.FieldName,'Visible','off')
    25332536    else
     2537        set(handles.Field_text,'Visible','on')
    25342538        set(handles.FieldName,'Visible','on')
    25352539        set(handles.FieldName,'String',FieldList)
     
    27572761set(handles.ActionInput,'BackgroundColor',[1 0 0])
    27582762
     2763
     2764%------------------------------------------------------------------------
     2765% --- Executes on button press in RefreshField.
     2766function RefreshField_Callback(hObject, eventdata, handles)
     2767%------------------------------------------------------------------------
     2768set(handles.FieldName,'String',{'add_field...'});
     2769set(handles.FieldName,'Value',1);
     2770FieldName_Callback(hObject, eventdata, handles)
     2771
     2772
    27592773%------------------------------------------------------------------------
    27602774% --- Executes on selection change in FieldName.
    27612775function FieldName_Callback(hObject, eventdata, handles)
    27622776%------------------------------------------------------------------------
    2763 field_str=get(handles.FieldName,'String');
     2777FieldListInit=get(handles.FieldName,'String');
    27642778field_index=get(handles.FieldName,'Value');
    2765 field=field_str{field_index(1)};
    2766 if isequal(field,'get_field...')
     2779field=FieldListInit{field_index(1)};
     2780if isequal(field,'add_field...')
     2781    FieldListInit(field_index(1))=[];
    27672782    SeriesData=get(handles.series,'UserData');
    27682783    % input line for which the field choice is relevant
     
    27762791    % check the existence of the first file in the series
    27772792    first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1; % default setting for index j
    2778     if isfield(Param.IndexRange,'first_j'); % if index j is used     
     2793    if isfield(Param.IndexRange,'first_j') % if index j is used     
    27792794        first_j=Param.IndexRange.first_j;
    27802795        last_j=Param.IndexRange.last_j;
     
    27892804        answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
    27902805        LineIndex=str2num(answer);
    2791 %         InputLine=str2num(get(handles.InputLine,'String'));
    2792 %         if ismember(InputLine,iview)
    2793 %             LineIndex=InputLine;
    2794 %         end
    27952806    end
    27962807    FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
     
    28262837        end
    28272838        set(handles.FieldName,'Value',1)
    2828         set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     2839        set(handles.FieldName,'String',[FieldListInit; FieldList; {'add_field...'}]);
    28292840        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    28302841           if ~isempty(regexp(FieldList{1},'^vec'))
     
    29132924field_index=get(handles.FieldName_1,'Value');
    29142925field=field_str{field_index(1)};
    2915 if isequal(field,'get_field...')
     2926if isequal(field,'add_field...')
    29162927    hget_field=findobj(allchild(0),'name','get_field');
    29172928    if ~isempty(hget_field)
     
    29732984        end
    29742985        set(handles.FieldName_1,'Value',1)
    2975         set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]);
     2986        set(handles.FieldName_1,'String',[FieldList; {'add_field...'}]);
    29762987    end
    29772988end   
     
    33783389    ListField=Param.InputFields.FieldName;
    33793390    if ischar(ListField),ListField={ListField}; end
    3380     set(handles.FieldName,'String',[ListField;{'get-field...'}])
     3391    set(handles.FieldName,'String',[ListField;{'add_field...'}])
    33813392     set(handles.FieldName,'Value',1:numel(ListField))
    33823393     set(handles.FieldName,'Visible','on')
     
    38663877
    38673878
    3868 
    38693879% --- Executes on button press in Replicate.
    38703880function Replicate_Callback(hObject, eventdata, handles)
     
    38823892end
    38833893
    3884 
    3885 
  • trunk/src/series/merge_proj.m

    r1071 r1078  
    320320        check_proj_tps= strcmp(FileType{iview},'civdata') && isfield(Param,'ProjObject')&&~isempty(Param.ProjObject)...
    321321            && strcmp(Param.ProjObject.ProjMode,'interp_tps')&&~isfield(Data{iview},'Coord_tps');
     322        if check_proj_tps
    322323        Data{iview}=tps_coeff_field(Data{iview},check_proj_tps);
     324        end
    323325       
    324326        %% projection on object (gridded plane)
  • trunk/src/transform_field/phys_polar.m

    r1071 r1078  
    33%%%%  Use the general syntax for transform fields %%%%
    44% OUTPUT:
    5 % DataOut:   output field structure
     5% Data:   output field structure
    66%      .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
    77%
     
    1414%         .GeometryCalib: substructure of the calibration parameters
    1515% transform image coordinates (px) to polar physical coordinates
    16 %[DataOut,DataOut_1]=phys_polar(varargin)
     16%[Data,Data_1]=phys_polar(varargin)
    1717%
    1818% OUTPUT:
    19 % DataOut: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
    20 % DataOut_1:  second data field (if two fields are in input)
     19% Data: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
     20% Data_1:  second data field (if two fields are in input)
    2121%
    2222%INPUT:
     
    4444%=======================================================================
    4545
    46 function DataOut=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1)
     46function Data=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1)
    4747%------------------------------------------------------------------------
     48
    4849%% request input parameters
    4950if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
     
    6465    end
    6566    answer = inputdlg(prompt,dlg_title,num_lines,def);
    66     DataOut.TransformInput.PolarCentre=str2num(answer{1});
    67     DataOut.TransformInput.PolarReferenceRadius=str2num(answer{2});
    68     DataOut.TransformInput.PolarReferenceAngle=str2num(answer{3});
    69     if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
    70         DataOut.CoordUnit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units
    71     end
     67    Data.TransformInput.PolarCentre=str2num(answer{1});
     68    Data.TransformInput.PolarReferenceRadius=str2num(answer{2});
     69    Data.TransformInput.PolarReferenceAngle=str2num(answer{3});
     70%     if isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
     71%         Data.CoordUnit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units
     72%     end
    7273    return
    7374end
    7475
     76%% default outputs
     77Data=DataIn; %default output
     78if isfield(Data,'CoordUnit')
     79Data=rmfield(Data,'CoordUnit');
     80end
     81Data.ListVarName = {};
     82Data.VarDimName={};
     83Data.VarAttribute={};
     84DataCell{1}=DataIn;
    7585Calib{1}=[];
     86DataCell{2}=[];%default
     87checkpixel(1)=0;
     88if isfield(DataCell{1},'CoorUnit')&& strcmp(DataCell{1}.CoorUnit,'px')
     89    checkpixel(1)=1;
     90end
    7691if nargin==2||nargin==4
    77     DataOut=DataIn;%default
    78     DataOut_1=[];%default
    79     if isfield(XmlData,'GeometryCalib')
     92    if isfield(XmlData,'GeometryCalib') && ~isempty(XmlData.GeometryCalib)&& checkpixel(1)
    8093        Calib{1}=XmlData.GeometryCalib;
    8194    end
    8295    Calib{2}=Calib{1};
    8396else
    84     DataOut.Txt='wrong input: need two or four structures';
    85 end
    86 test_1=0;
     97    Data.Txt='wrong input: need two or four structures';
     98end
     99nbinput=1;
    87100if nargin==4% case of two input fields
    88     test_1=1;
    89     DataOut_1=DataIn_1;%default
    90     if isfield(XmlData_1,'GeometryCalib')
     101    checkpixel(2)=0;
     102if isfield(DataCell{2},'CoorUnit')&& strcmp(DataCell{2}.CoorUnit,'px')
     103    checkpixel(2)=1;
     104end
     105    DataCell{2}=DataIn_1;%default
     106    if isfield(XmlData_1,'GeometryCalib')&& ~isempty(XmlData_1.GeometryCalib) && checkpixel(2)
    91107        Calib{2}=XmlData_1.GeometryCalib;
    92108    end
    93 end
    94 
    95 %parameters for polar coordinates (taken from the calibration data of the first field)
     109    nbinput=2;
     110end
     111
     112%% parameters for polar coordinates (taken from the calibration data of the first field)
    96113%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    97 XmlData.PolarReferenceRadius=0;%450;
    98 XmlData.PolarReferenceAngle=0;%450*pi/2;
    99114origin_xy=[0 0];%center for the polar coordinates in the original x,y coordinates
    100115radius_offset=0;%reference radius used to offset the radial coordinate r
    101116angle_offset=0; %reference angle used as new origin of the polar angle (= axis Ox by default)
    102 angle_scale=180/pi;
     117angle_scale=180/pi;
     118check_degree=1;%angle expressed in degrees by default
    103119if isfield(XmlData,'TransformInput')
    104120    if isfield(XmlData.TransformInput,'PolarCentre') && isnumeric(XmlData.TransformInput.PolarCentre)
    105         if isequal(length(XmlData.TransformInput.PolarCentre),2);
     121        if isequal(length(XmlData.TransformInput.PolarCentre),2)
    106122            origin_xy= XmlData.TransformInput.PolarCentre;
    107123        end
     
    112128    if radius_offset > 0
    113129        angle_scale=radius_offset; %the azimuth is rescale in terms of the length along the reference radius
     130        check_degree=0; %the output has the same unit asthe input
    114131    else
    115132        angle_scale=180/pi; %polar angle in degrees
     133        check_degree=1;%angle expressed in degrees
    116134    end
    117135    if isfield(XmlData.TransformInput,'PolarReferenceAngle') && isnumeric(XmlData.TransformInput.PolarReferenceAngle)
     
    121139
    122140%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    123 
    124 iscalar=0;
    125 %transform first field to cartesian phys coordiantes
    126 if  ~isempty(Calib{1})
    127     DataOut=phys_1(DataIn,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale);
    128     %case of images or scalar
    129     if isfield(DataIn,'A')&isfield(DataIn,'Coord_x')&~isempty(DataIn.Coord_x) & isfield(DataIn,'Coord_y')&...
    130                                            ~isempty(DataIn.Coord_y)&length(DataIn.A)>1
    131         iscalar=1;
    132         A{1}=DataIn.A;
    133     end
     141%% get fields
     142check_scalar=0;
     143check_vector=0;
     144nbvar=0;%counter for the number of output variables
     145nbcoord=0;%counter for the number of variables for radial coordiantes (case of multiple field inputs)
     146nbgrid=0;%counter for the number of gridded fields (all linearly interpolated on the same output polar grid)
     147nbscattered=0;%counter of scattered fields
     148radius_name='radius';
     149theta_name='theta';
     150U_r_name='U_r';
     151U_theta_name='U_theta';
     152for ifield=1:nbinput %1 or 2 input fields
     153    [CellInfo,NbDim,errormsg]=find_field_cells(DataCell{ifield});
     154    if ~isempty(errormsg)
     155        Data.Txt=['bad input to phys_polar: ' errormsg];
     156        return
     157    end
     158    % end
    134159    %transform of X,Y coordinates for vector fields
    135     if isfield(DataIn,'ZIndex')&~isempty(DataIn.ZIndex)
    136         ZIndex=DataIn.ZIndex;
     160    if isfield(DataCell{ifield},'ZIndex')&& ~isempty(DataCell{ifield}.ZIndex)
     161        ZIndex=DataCell{ifield}.ZIndex;
    137162    else
    138163        ZIndex=0;
    139164    end
    140 end
    141 
    142 %transform second field (if exists) to cartesian phys coordiantes
    143 if test_1
    144     DataOut_1=phys_1(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale);
    145     if isfield(Data_1,'A')&isfield(Data_1,'Coord_x')&~isempty(Data_1.Coord_x) & isfield(Data_1,'Coord_y')&...
    146                                        ~isempty(Data_1.Coord_y)&length(Data_1.A)>1
    147           iscalar=iscalar+1;
    148           Calib{iscalar}=Calib{2};
    149           A{iscalar}=Data_1.A;
    150           if isfield(Data_1,'ZIndex')&~isequal(Data_1.ZIndex,ZIndex)
    151               DataOut.Txt='inconsistent plane indexes in the two input fields';
    152           end
    153           if iscalar==1% case for which only the second field is a scalar
    154                [A,Coord_x,Coord_y]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);
    155                DataOut_1.A=A{1};
    156                DataOut_1.Coord_x=Coord_x;
    157                DataOut_1.Coord_y=Coord_y;
    158                return
    159           end
    160     end
    161 end
    162 if iscalar~=0
    163     [A,Coord_x,Coord_y]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);%
    164     DataOut.A=A{1};
    165     DataOut.Coord_x=Coord_x;
    166     DataOut.Coord_y=Coord_y;
    167     if iscalar==2
    168         DataOut_1.A=A{2};
    169         DataOut_1.Coord_x=Coord_x;
    170         DataOut_1.Coord_y=Coord_y;
    171     end
    172 end
    173 
    174 
     165    for icell=1:numel(CellInfo)
     166        if NbDim(icell)==2
     167            % case of input field with scattered coordinates
     168            if strcmp(CellInfo{icell}.CoordType,'scattered')
     169                nbscattered=nbscattered+1;
     170                nbcoord=nbcoord+1;
     171                radius_name = rename_indexing(radius_name,Data.ListVarName);
     172                theta_name = rename_indexing(theta_name,Data.ListVarName);
     173                Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}];
     174                dim_name = rename_indexing('nb_point',Data.VarDimName);
     175                Data.VarDimName=[Data.VarDimName {dim_name} {dim_name}];
     176                nbvar=nbvar+2;
     177                Data.VarAttribute{nbvar-1}.Role='coord_x';
     178                check_unit=1;
     179                if isfield(DataCell{ifield},'CoordUnit')
     180                    Data=rmfield(Data,'CoordUnit');
     181                    Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;
     182                elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
     183                    Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units
     184                else
     185                    check_unit=0;
     186                end
     187                Data.VarAttribute{nbvar}.Role='coord_y';
     188                if check_degree
     189                Data.VarAttribute{nbvar}.unit='degree';
     190                elseif check_unit
     191                    Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;
     192                end
     193 
     194                %transform u,v into polar coordinates
     195                X=DataCell{ifield}.(CellInfo{icell}.XName);
     196                Y=DataCell{ifield}.(CellInfo{icell}.YName);
     197                if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
     198                    UName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_x};
     199                    VName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_y};
     200                    if ~isempty(Calib{ifield})
     201                        [X,Y,Z,DataCell{ifield}.(UName),DataCell{ifield}.(VName)]=...
     202                            phys_XYUV(DataCell{ifield},Calib{ifield},ZIndex);
     203                    end
     204                end
     205                [Theta,Radius] = cart2pol(X-origin_xy(1),Y-origin_xy(2));
     206                Data.(radius_name)=Radius-radius_offset;
     207                Data.(theta_name)=Theta*angle_scale-angle_offset;
     208                if Z~=0
     209                    Data.Z=Z;
     210                    nbvar=nbvar+1;
     211                    Data.ListVarName = [Data.ListVarName {'Z'}];
     212                    Data.VarDimName=[Data.VarDimName {dim_name}];
     213                    Data.VarAttribute{nbvar}.Role='coord_z';
     214                end
     215                if isfield(CellInfo{icell},'VarIndex_scalar')
     216                    ScalarName=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar};
     217                    ScalarName=rename_indexing(ScalarName,Data.ListVarName);
     218                    Data.(ScalarName)=DataCell{ifield}.(ScalarName);
     219                    nbvar=nbvar+1;
     220                    Data.ListVarName = [Data.ListVarName {ScalarName}];
     221                    Data.VarDimName=[Data.VarDimName {dim_name}];
     222                    Data.VarAttribute{nbvar}.Role='scalar';
     223                end
     224                if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
     225                    U_r_name= rename_indexing(U_r_name,Data.ListVarName);
     226                    U_theta_name= rename_indexing(U_theta_name,Data.ListVarName);
     227                    Data.(U_r_name)=DataCell{ifield}.(UName).*cos(Theta)+DataCell{ifield}.(VName).*sin(Theta);%radial velocity
     228                    Data.(U_theta_name)=(-DataCell{ifield}.(UName).*sin(Theta)+DataCell{ifield}.(VName).*cos(Theta));%./(Data.X)%+radius_ref);% azimuthal velocity component
     229                    Data.ListVarName = [Data.ListVarName {U_r_name} {U_theta_name}];
     230                    Data.VarDimName=[Data.VarDimName {dim_name} {dim_name}];
     231                    Data.VarAttribute{nbvar+1}.Role='vector_x';
     232                    Data.VarAttribute{nbvar+2}.Role='vector_y';
     233                    nbvar=nbvar+2;
     234                end
     235                if isfield(CellInfo{icell},'VarIndex_errorflag')
     236                    error_flag_name=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_errorflag};
     237                    error_flag_newname= rename_indexing(error_flag_name,Data.ListVarName);
     238                    Data.(error_flag_newname)=DataCell{ifield}.(error_flag_name);
     239                    Data.ListVarName = [Data.ListVarName {error_flag_newname}];
     240                    Data.VarDimName=[Data.VarDimName {dim_name}];
     241                    nbvar=nbvar+1;
     242                    Data.VarAttribute{nbvar}.Role='errorflag';
     243                end
     244               
     245           %caseof input fields on gridded coordinates (matrix)
     246            elseif strcmp(CellInfo{icell}.CoordType,'grid')
     247                if nbgrid==0% no gridded data yet, introduce the coordinate variables common to all gridded data
     248                    nbcoord=nbcoord+1;%add new radial coordinates for the first gridded field
     249                    radius_name = rename_indexing(radius_name,Data.ListVarName);
     250                    theta_name = rename_indexing(theta_name,Data.ListVarName);
     251                    Data.ListVarName = [Data.ListVarName {radius_name} {theta_name}];
     252                    Data.VarDimName=[Data.VarDimName {radius_name} {theta_name}];
     253                    nbvar=nbvar+2;
     254                    Data.VarAttribute{nbvar-1}.Role='coord_x';
     255                    Data.VarAttribute{nbvar}.Role='coord_y';
     256                    check_unit=1;
     257                    if isfield(DataCell{ifield},'CoordUnit')
     258                        Data.VarAttribute{nbvar-1}.unit=DataCell{ifield}.CoordUnit;
     259                    elseif isfield(XmlData,'GeometryCalib')&& isfield(XmlData.GeometryCalib,'CoordUnit')
     260                        Data.VarAttribute{nbvar-1}.unit=XmlData.GeometryCalib.CoordUnit;% states that the output is in unit defined by GeometryCalib, then erased all projection objects with different units
     261                    else
     262                        check_unit=0;
     263                    end
     264                    if check_degree
     265                        Data.VarAttribute{nbvar}.unit='degree';
     266                    elseif check_unit
     267                        Data.VarAttribute{nbvar}.unit=Data.VarAttribute{nbvar-1}.unit;
     268                    end
     269                end
     270                if isfield(CellInfo{icell},'VarIndex_scalar')
     271                    nbgrid=nbgrid+1;
     272                    nbvar=nbvar+1;
     273                    Data.VarAttribute{nbvar}.Role='scalar';
     274                    FieldName{nbgrid}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_scalar};
     275                    A{nbgrid}=DataCell{ifield}.(FieldName{nbgrid});
     276%                     Data.ListVarName=[Data.ListVarName {FieldName{nbgrid}}];
     277%                     Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}];
     278                    nbpoint(nbgrid)=numel(A{nbgrid});
     279                    check_scalar(nbgrid)=1;
     280                    coord_x{nbgrid}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex});
     281                    coord_y{nbgrid}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex});
     282                    ZInd(nbgrid)=ZIndex;
     283                    Calib_new{nbgrid}=Calib{ifield};
     284                end
     285                if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
     286                    FieldName{nbgrid+1}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_x};
     287                    FieldName{nbgrid+2}=DataCell{ifield}.ListVarName{CellInfo{icell}.VarIndex_vector_y};
     288                    A{nbgrid+1}=DataCell{ifield}.(FieldName{nbgrid+1});
     289                    A{nbgrid+2}=DataCell{ifield}.(FieldName{nbgrid+2});
     290                   % Data.ListVarName=[Data.ListVarName {'U_r','U_theta'}];
     291                    %Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}];
     292                    Data.VarAttribute{nbvar+1}.Role='vector_x';
     293                    Data.VarAttribute{nbvar+2}.Role='vector_y';
     294                    nbpoint([nbgrid+1 nbgrid+2])=numel(A{nbgrid+1});
     295                    check_vector(nbgrid+1)=1;
     296                    check_vector(nbgrid+2)=1;
     297                    coord_x{nbgrid+1}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex});
     298                    coord_y{nbgrid+1}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex});
     299                    coord_x{nbgrid+2}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.XIndex});
     300                    coord_y{nbgrid+2}=DataCell{ifield}.(DataCell{ifield}.ListVarName{CellInfo{icell}.YIndex});
     301                    ZInd(nbgrid+1)=ZIndex;
     302                    ZInd(nbgrid+2)=ZIndex;
     303                    Calib_new{nbgrid+1}=Calib{ifield};
     304                    Calib_new{nbgrid+2}=Calib{ifield};
     305                    nbgrid=nbgrid+2;
     306                    nbvar=nbvar+2;
     307                end
     308            end
     309        end
     310    end
     311end
     312
     313%% tranform cartesian to polar coordinates for gridded data
     314if nbgrid~=0
     315    [A,Data.radius,Data.theta]=phys_Ima_polar(A,coord_x,coord_y,Calib_new,ZInd,origin_xy,radius_offset,angle_offset,angle_scale);
     316    for icell=1:numel(A)
     317        if icell<=numel(A)-1 && check_vector(icell)==1 && check_vector(icell+1)==1   %transform u,v into polar coordiantes
     318            theta=Data.theta/angle_scale-angle_offset;
     319            [~,Theta]=meshgrid(Data.radius,theta);%grid in physical coordinates
     320            U_r_name= rename_indexing(U_r_name,Data.ListVarName);
     321            U_theta_name= rename_indexing(U_theta_name,Data.ListVarName);
     322            Data.ListVarName=[Data.ListVarName {U_r_name,U_theta_name}];
     323            Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}} {{theta_name,radius_name}}];
     324            Data.(U_r_name)=A{icell}.*cos(Theta)+A{icell+1}.*sin(Theta);%radial velocity
     325            Data.(U_theta_name)=(-A{icell}.*sin(Theta)+A{icell+1}.*cos(Theta));%./(Data.X)%+radius_ref);% azimuthal velocity component
     326        elseif ~check_vector(icell)% for scalar fields
     327            FieldName{icell}= rename_indexing(FieldName{icell},Data.ListVarName);
     328            Data.ListVarName=[Data.ListVarName {FieldName{icell}}];
     329            Data.VarDimName=[Data.VarDimName {{theta_name,radius_name}}];
     330            Data.(FieldName{icell})=A{icell};
     331        end
     332    end
     333end
    175334
    176335
    177336%------------------------------------------------
    178 function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)
    179 
    180 DataOut=Data;
    181 % DataOut.CoordUnit=Calib.CoordUnit; %put flag for physical coordinates
    182 if isfield(Calib,'SliceCoord')
    183     DataOut.PlaneCoord=Calib.SliceCoord;%to generalise for any plane
    184 end
    185 
    186 if isfield(Data,'CoordUnit')%&& isequal(Data.CoordType,'px')&& ~isempty(Calib)
    187     if isfield(Calib,'CoordUnit')
    188         DataOut.CoordUnit=Calib.CoordUnit;
    189     else
    190         DataOut.CoordUnit='cm'; %default
    191     end
    192     DataOut.TimeUnit='s';
    193     %transform of X,Y coordinates for vector fields
    194     if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)&&~isnan(Data.ZIndex)
    195         Z=Data.ZIndex;
    196     else
    197         Z=0;
    198     end
    199     if isfield(Data,'X') &isfield(Data,'Y')&~isempty(Data.X) & ~isempty(Data.Y)
    200         [DataOut.X,DataOut.Y,DataOut.Z]=phys_XYZ(Calib,Data.X,Data.Y,Z); %transform from pixels to physical
    201         DataOut.X=DataOut.X-origin_xy(1);%origin of coordinates at the tank center
    202         DataOut.Y=DataOut.Y-origin_xy(2);%origin of coordinates at the tank center
    203         [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);%theta  and X are the polar coordinates angle and radius
    204           %shift and renormalize the polar coordinates
    205         DataOut.X=DataOut.X-radius_offset;%shift the origin of radius, taken as the new X coordinate
    206         DataOut.Y=(theta-angle_offset)*angle_scale;% normalized angle: distance along reference radius,taken as the new Y coordinate
    207         %transform velocity field if exists
    208         if isfield(Data,'U') & isfield(Data,'V') & ~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,'Dt')
    209             if ~isempty(Data.Dt)
    210             [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z);% X,Y positions of the vector origin in phys
    211             [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z);% X,Y positions of the vector end in phys
    212             UX=(XOut_2-XOut_1)/Data.Dt;% phys velocity u component
    213             VY=(YOut_2-YOut_1)/Data.Dt; % phys velocity v component     
    214             %transform u,v into polar coordiantes
    215             DataOut.U=UX.*cos(theta)+VY.*sin(theta);%radial velocity
    216             DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);% azimuthal velocity component
    217             %shift and renormalize the angular velocity
    218             end
    219         end
    220         %transform of spatial derivatives
    221         if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)...
    222                 && isfield(Data,'Dt')
    223             if ~isempty(Data.Dt)
    224                 % estimate the Jacobian matrix DXpx/DXphys
    225                 for ip=1:length(Data.X)
    226                     [Xp1,Yp1]=phys_XYZ(Calib,Data.X(ip)+0.5,Data.Y(ip),Z);
    227                     [Xm1,Ym1]=phys_XYZ(Calib,Data.X(ip)-0.5,Data.Y(ip),Z);
    228                     [Xp2,Yp2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)+0.5,Z);
    229                     [Xm2,Ym2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)-0.5,Z);
    230                     %Jacobian matrix DXpphys/DXpx
    231                     DjXi(1,1)=(Xp1-Xm1);
    232                     DjXi(2,1)=(Yp1-Ym1);
    233                     DjXi(1,2)=(Xp2-Xm2);
    234                     DjXi(2,2)=(Yp2-Ym2);
    235                     DjUi(:,:)=Data.DjUi(ip,:,:);
    236                     DjUi=(DjXi*DjUi')/DjXi;% =J-1*M*J , curvature effects (derivatives of J) neglected
    237                     DataOut.DjUi(ip,:,:)=DjUi';
    238                 end
    239                 DataOut.DjUi =  DataOut.DjUi/Data.Dt;   %     min(Data.DjUi(:,1,1))=DUDX
    240             end
    241         end
    242     end
    243 end
    244 
     337%--- transform a single field into phys coordiantes
     338function [X,Y,Z,U,V]=phys_XYUV(Data,Calib,ZIndex)
     339%------------------------------------------------
     340%% set default output
     341%DataOut=Data;%default
     342%DataOut.CoordUnit=Calib.CoordUnit;% the output coord unit is set by the calibration parameters
     343X=[];%default output
     344Y=[];
     345Z=0;
     346U=[];
     347V=[];
     348%% transform  X,Y coordinates for velocity fields (transform of an image or scalar done in phys_ima)
     349if isfield(Data,'X') &&isfield(Data,'Y')&&~isempty(Data.X) && ~isempty(Data.Y)
     350    [X,Y,Z]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex);
     351    Dt=1; %default
     352    if isfield(Data,'dt')&&~isempty(Data.dt)
     353        Dt=Data.dt;
     354    end
     355    if isfield(Data,'Dt')&&~isempty(Data.Dt)
     356        Dt=Data.Dt;
     357    end
     358    if isfield(Data,'U')&&isfield(Data,'V')&&~isempty(Data.U) && ~isempty(Data.V)
     359        [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,ZIndex);
     360        [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,ZIndex);
     361        U=(XOut_2-XOut_1)/Dt;
     362        V=(YOut_2-YOut_1)/Dt;
     363    end
     364end
    245365
    246366%%%%%%%%%%%%%%%%%%%%
    247 function [A_out,Rangx,Rangy]=phys_Ima_polar(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
    248 xcorner=[];
    249 ycorner=[];
     367% tranform gridded field into polar coordiantes on a regular polar grid,
     368% transform to phys coordiantes if requested by calibration input
     369function [A_out,radius,theta]=phys_Ima_polar(A,coord_x,coord_y,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
     370rcorner=[];
     371thetacorner=[];
    250372npx=[];
    251373npy=[];
    252 NbPoints=20; % nbre of points used to determine the image edge
    253374for icell=1:length(A)
    254375    siz=size(A{icell});
    255     npx=[npx siz(2)];
    256     npy=[npy siz(1)];
    257     zphys=0; %default
    258     if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane
    259         if ZIndex==0
    260             ZIndex=1;
    261         end
    262        SliceCoord=CalibIn{icell}.SliceCoord(ZIndex,:);
    263        zphys=SliceCoord(3); %to generalize for non-parallel planes
    264     end
    265 %     xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners
    266 %     yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
    267       edge_x=linspace(0.5,siz(1)-0.5,NbPoints);     
    268       edge_y=linspace(0.5,siz(2)-0.5,NbPoints);
    269       xima=[edge_y (siz(2)-0.5)*ones(1,NbPoints) edge_y 0.5*ones(1,NbPoints)];%image coordinates of corners
    270       yima=[0.5*ones(1,NbPoints) edge_x (siz(1)-0.5)*ones(1,NbPoints) edge_x];%image coordinates of corners
    271     [xcorner_new,ycorner_new]=phys_XYZ(CalibIn{icell},xima,yima,ZIndex);%corresponding physical coordinates
    272     %transform the corner coordinates into polar ones   
    273     xcorner_new=xcorner_new-origin_xy(1);%shift to the origin of the polar coordinates
    274     ycorner_new=ycorner_new-origin_xy(2);%shift to the origin of the polar coordinates       
    275     [theta,xcorner_new] = cart2pol(xcorner_new,ycorner_new);%theta  and X are the polar coordinates angle and radius
    276     if (max(theta)-min(theta))>pi   %if the polar origin is inside the image
    277         xcorner_new=[0 max(xcorner_new)];
    278         theta=[-pi pi];
    279     end
    280           %shift and renormalize the polar coordinates
    281     xcorner_new=xcorner_new-radius_offset;%
    282     ycorner_new=theta*angle_scale-angle_offset;% normalized angle: distance along reference radius
    283     xcorner=[xcorner xcorner_new];
    284     ycorner=[ycorner ycorner_new];
    285 end
    286 Rangx(1)=min(xcorner);
    287 Rangx(2)=max(xcorner);
    288 Rangy(2)=min(ycorner);
    289 Rangy(1)=max(ycorner);
    290 % test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));
    291 npx=max(npx);
    292 npy=max(npy);
    293 x=linspace(Rangx(1),Rangx(2),npx);
    294 y=linspace(Rangy(1),Rangy(2),npy);
    295 [X,Y]=meshgrid(x,y);%grid in physical coordinates
     376    npx(icell)=siz(2);
     377    npy(icell)=siz(1);
     378    x_edge=[linspace(coord_x{icell}(1),coord_x{icell}(end),npx(icell)) coord_x{icell}(end)*ones(1,npy(icell))...
     379        linspace(coord_x{icell}(end),coord_x{icell}(1),npx(icell)) coord_x{icell}(1)*ones(1,npy(icell))];%x coordinates of the image edge(four sides)
     380    y_edge=[coord_y{icell}(1)*ones(1,npx(icell)) linspace(coord_y{icell}(1),coord_y{icell}(end),npy(icell))...
     381        coord_y{icell}(end)*ones(1,npx(icell)) linspace(coord_y{icell}(end),coord_y{icell}(1),npy(icell))];%y coordinates of the image edge(four sides)
     382   
     383    % transform edges into phys coordinates if requested
     384    if ~isempty(CalibIn{icell})
     385        [x_edge,y_edge]=phys_XYZ(CalibIn{icell},x_edge,y_edge,ZIndex(icell));% physical coordinates of the image edge
     386    end
     387   
     388    %transform the corner coordinates into polar ones
     389    x_edge=x_edge-origin_xy(1);%shift to the origin of the polar coordinates
     390    y_edge=y_edge-origin_xy(2);%shift to the origin of the polar coordinates
     391    [theta_edge,r_edge] = cart2pol(x_edge,y_edge);%theta  and X are the polar coordinates angle and radius
     392    if (max(theta_edge)-min(theta_edge))>pi   %if the polar origin is inside the image
     393        r_edge=[0 max(r_edge)];
     394        theta_edge=[-pi pi];
     395    end
     396    rcorner=[rcorner r_edge];
     397    thetacorner=[thetacorner theta_edge];
     398end
     399nbpoint=max(npx.*npy);
     400Min_r=min(rcorner);
     401Max_r=max(rcorner);
     402Min_theta=min(thetacorner)*angle_scale;
     403Max_theta=max(thetacorner)*angle_scale;
     404Dr=round_uvmat((Max_r-Min_r)/sqrt(nbpoint));
     405Dtheta=round_uvmat((Max_theta-Min_theta)/sqrt(nbpoint));% get a simple mesh for the rescaled angle
     406radius=Min_r:Dr:Max_r;% polar coordinates for projections
     407theta=Min_theta:Dtheta:Max_theta;
     408[Radius,Theta]=meshgrid(radius,theta/angle_scale);%grid in polar coordinates (angles in radians)
    296409%transform X, Y in cartesian
    297 X=X+radius_offset;%
    298 Y=(Y+angle_offset)/angle_scale;% normalized angle: distance along reference radius
    299 [X,Y] = pol2cart(Y,X);
    300 X=X+origin_xy(1);%shift to the origin of the polar coordinates
    301 Y=Y+origin_xy(2);%shift to the origin of the polar coordinates
    302 for icell=1:length(A)
     410[X,Y] = pol2cart(Theta,Radius);% cartesian coordinates associated to the grid in polar coordinates
     411X=X+origin_xy(1);%shift to the origin of the polar coordinates
     412Y=Y+origin_xy(2);%shift to the origin of the polar coordinates
     413radius=radius-radius_offset;
     414theta=theta-angle_offset*angle_scale;
     415[np_theta,np_r]=size(Radius);
     416
     417for icell=1:length(A)
     418    XIMA=X;
     419    YIMA=Y;
     420    if ~isempty(CalibIn{icell})%transform back to pixel if calibration parameters are introduced
     421        Z=0; %default
     422        if isfield(CalibIn{icell},'SliceCoord') %.Z= index of plane
     423            if ZIndex(icell)==0
     424                ZIndex(icell)=1;
     425            end
     426            SliceCoord=CalibIn{icell}.SliceCoord(ZIndex(icell),:);
     427            Z=SliceCoord(3); %to generalize for non-parallel planes
     428            if isfield(CalibIn{icell},'SliceAngle')
     429            norm_plane=angle2normal(CalibIn{icell}.SliceAngle);
     430            Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3);
     431            end
     432        end
     433        [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,Z);%corresponding image indices for each point in the real space grid
     434    end
     435    Dx=(coord_x{icell}(end)-coord_x{icell}(1))/(npx(icell)-1);
     436    Dy=(coord_y{icell}(end)-coord_y{icell}(1))/(npy(icell)-1);
     437    indx_ima=1+round((XIMA-coord_x{icell}(1))/Dx);%indices of the initial matrix close to the points of the new grid
     438    indy_ima=1+round((YIMA-coord_y{icell}(1))/Dy);
     439    Delta_x=1+(XIMA-coord_x{icell}(1))/Dx-indx_ima;%
     440    Delta_y=1+(YIMA-coord_y{icell}(1))/Dy-indy_ima;
     441    XIMA=reshape(indx_ima,1,[]);%indices reorganized in 'line'
     442    YIMA=reshape(indy_ima,1,[]);%indices reorganized in 'line'
     443    flagin=XIMA>=1 & XIMA<=npx(icell) & YIMA >=1 & YIMA<=npy(icell);%flagin=1 inside the original image
    303444    siz=size(A{icell});
    304     [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid
    305     XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
    306     YIMA=reshape(round(YIMA),1,npx*npy);
    307     flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
     445    checkuint8=isa(A{icell},'uint8');%check for image input with 8 bits
     446    checkuint16=isa(A{icell},'uint8');%check for image input with 16 bits
     447    A{icell}=double(A{icell});
    308448    if numel(siz)==2 %(B/W images)
    309         vec_A=reshape(A{icell}(:,:,1),1,npx*npy);%put the original image in line
     449        vec_A=reshape(A{icell}(:,:,1),1,[]);%put the original image in line
    310450        ind_in=find(flagin);
    311451        ind_out=find(~flagin);
    312         ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
     452        ICOMB=((XIMA-1)*npy(icell)+(npy(icell)+1-YIMA));
    313453        ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    314454        vec_B(ind_in)=vec_A(ICOMB);
    315455        vec_B(ind_out)=zeros(size(ind_out));
    316         A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates
     456        A_out{icell}=reshape(vec_B,np_theta,np_r);%new image in real coordinates
     457        DA_y=circshift(A_out{icell},-1,1)-A_out{icell};
     458        DA_y(end,:)=0;
     459        DA_x=circshift(A_out{icell},-1,2)-A_out{icell};
     460        DA_x(:,end)=0;
     461        A_out{icell}=A_out{icell}+Delta_x.*DA_x+Delta_y.*DA_y;%linear interpolation
    317462    else
    318463        for icolor=1:siz(3)
    319                 vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
    320                 ind_in=find(flagin);
    321                 ind_out=find(~flagin);
    322                 ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
    323                 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    324                 vec_B(ind_in)=vec_A(ICOMB);
    325                 vec_B(ind_out)=zeros(size(ind_out));
    326                 A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
    327         end
    328     end
    329 end
    330 
     464            vec_A=reshape(A{icell}(:,:,icolor),1,[]);%put the original image in line
     465            ind_in=find(flagin);
     466            ind_out=find(~flagin);
     467            ICOMB=((XIMA-1)*npy(icell)+(npy(icell)+1-YIMA));
     468            ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
     469            vec_B(ind_in)=vec_A(ICOMB);
     470            vec_B(ind_out)=zeros(size(ind_out));
     471            A_out{icell}(:,:,icolor)=reshape(vec_B,np_theta,np_r);%new image in real coordinates
     472            DA_y=circshift(A_out{icell}(:,:,icolor),-1,1)-A_out{icell}(:,:,icolor);
     473            DA_y(end,:)=0;
     474            DA_x=circshift(A_out{icell}(:,:,icolor),-1,2)-A_out{icell}(:,:,icolor);
     475            DA_x(:,end)=0;
     476            A_out{icell}(:,:,icolor)=A_out{icell}(:,:,icolor)+Delta_x.*DA_x+Delta_y.*DA_y;%linear interpolation
     477        end
     478    end
     479    if checkuint8
     480        A_out{icell}=uint8(A_out{icell});
     481    elseif checkuint16
     482        A_out{icell}=uint16(A_out{icell});
     483    end
     484end
     485
  • trunk/src/uvmat.m

    r1077 r1078  
    640640
    641641%------------------------------------------------------------------------
     642% function called by the upper bar menu item Export/make movie
    642643% --------------------------------------------------------------------
    643644function MenuExportMovie_Callback(hObject, eventdata, handles)
     
    645646set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
    646647
    647 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    648 FileBase=fullfile(RootPath,RootFile);
     648[RootPath,SubDir,RootFile]=read_file_boxes(handles);%read input file path from the GUI uvmat
    649649
    650650%% create a fig and axis for movies
    651 figure_movie=findobj(allchild(0),'name','figure_movie');
    652 
     651figure_movie=findobj(allchild(0),'name','figure_movie');% find existing movie figure
    653652if ~isempty(figure_movie)
    654653    delete(figure_movie)%delete existing figure_movie
    655654end
    656 figure_movie=figure;
     655figure_movie=figure;% create a new movie figure
    657656nbpix=[640 480];% resolution VGA
    658657set(figure_movie,'name','figure_movie','Position',[1 1 nbpix])
     
    671670
    672671%% create the GUI set_movie
    673 %set(0,'Units','points')
    674 %ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    675672Position=get(figure_movie,'Position');
    676673Position(2)=Position(2)+1.2*Position(4);
     
    678675Position(4)=Position(4)/2;
    679676hfig=findobj(allchild(0),'Tag','set_movie');
    680 if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
     677if ~isempty(hfig),delete(hfig), end %delete existing version of the GUI
    681678hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',...
    682679    'Position',Position);
     
    787784    end
    788785end
    789 %create avi open
    790 %aviobj=avifile(MovieName,'Compression','None','fps',fps);
    791 
     786
     787%% create movie
     788% duration = 2*FrameNumber/60;
     789% [~,name,~] = fileparts(MovieName);
     790% ffmpegcmd = ['ffmpeg -i ' ' ' MovieName ' ' '-filter:v "setpts=(',...
     791%      num2str(fps/duration),')*PTS"' ' ' strcat(MovieDir,...
     792%      strcat('/',name,'.mkv'))];
     793% [ffmpeg_err,~] = system(ffmpegcmd);
     794% if ffmpeg_err
     795%     disp_uvmat('ERROR',['ERROR: Errors in conversion to mkv, close MATLAB and run "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab" in terminal'],1 )
     796%     return
     797% end
     798% msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']})
     799
     800
     801%
    792802aviobj = VideoWriter(MovieName,'Motion JPEG AVI');
    793803open(aviobj)
     
    11801190    'Callback',@(hObject,eventdata)set_slice_CheckRefraction_Callback(hObject,eventdata),...
    11811191    'String','refraction','Value',CheckRefraction,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckRefraction'':=1 to provide refraction correction');
    1182 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-1.75*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',...
     1192uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-1.7*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',...
    11831193    'String','index','Visible','off','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
    11841194uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-3*ii-2*hh ww hh],'tag','num_RefractionIndex','BackgroundColor',[1 1 1],...
    11851195    'String',num2str(RefractionIndex),'Visible','off','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_RefractionIndex'': refraction index of water');
    11861196%  raw 4 of the GUI
    1187 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3.25*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',...
     1197uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3.0*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',...
    11881198    'String','NbSlice','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
    1189 uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii-3*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],...
     1199uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii-2.8*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],...
    11901200    'String',num2str(NbSlice),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_NbSlice'':number of slices');%edit box
    1191 uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii-3*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,...
     1201uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii-2.7*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,...
    11921202    'String','volume scan','Value',CheckVolumeScan,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckVolumeScan'':=1 for volume scan (z varies with j index)');
    11931203%  raw 5 of the GUI
    1194 uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-3*ii-3.5*hh ww hh/2],'BackgroundColor',BackgroundColor,...
    1195     'String','first','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
    1196 uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-3*ii-3.5*hh ww hh/2],'BackgroundColor',BackgroundColor,...
    1197     'String','last','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
    1198 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',...
    1199     'String','tild angle x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
    1200 uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-6*ii-5*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',...
    1201     'String','tild angle y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     1204uicontrol('Style','text','Units','normalized', 'Position', [2*ii+1*ww 0.95-2*ii-3.9*hh ww hh],'BackgroundColor',BackgroundColor,...
     1205    'String','origin','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     1206uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-2*ii-3.5*hh ww hh],'BackgroundColor',BackgroundColor,...
     1207    'String',{'first';'angle'},'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     1208uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-2*ii-3.5*hh ww hh],'BackgroundColor',BackgroundColor,...
     1209    'String',{'last';'angle'},'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     1210
     1211uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+ww 0.95-5*ii-4.2*hh ww hh],'tag','num_SliceCoord_1','BackgroundColor',[1 1 1],...
     1212    'String',num2str(SliceCoord(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceCoord_1'':x position of the tild origin');%edit box
     1213uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+ww 0.95-6*ii-5.2*hh ww hh],'tag','num_SliceCoord_2','BackgroundColor',[1 1 1],...
     1214    'String',num2str(SliceCoord(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceCoord_2'':y position of the tild origin');%edit box
     1215
     1216uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4*hh 1.3*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',...
     1217    'String','tild x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     1218uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-6*ii-5*hh 1.3*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',...
     1219    'String','tild y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
    12021220%  raw 6 of the GUI
    12031221uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-5*ii-4.2*hh ww hh],'tag','num_SliceAngle_1_1','BackgroundColor',[1 1 1],...
     
    12701288end
    12711289GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
     1290GeometryCalib.SliceCoord(:,1)=SliceData.SliceCoord(1);
     1291GeometryCalib.SliceCoord(:,2)=SliceData.SliceCoord(2);
    12721292GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3);
    12731293Angle_1=linspace(SliceData.SliceAngle_1(1),SliceData.SliceAngle_1(2),SliceData.NbSlice);
     
    35543574end
    35553575switch UvData.FileInfo{1}.FieldType
    3556     case {'civdata','netcdf'};
     3576    case {'civdata','netcdf'}
    35573577        list_fields=get(handles.FieldName,'String');% list menu fields
    35583578        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
     
    36873707            end
    36883708    end
    3689     %     switch UvData.FileType{2}
    3690     %         case {'civx','civdata','netcdf'};
    3691     %             list_fields=get(handles.FieldName_1,'String');% list menu fields
    3692     %             if ischar(list_fields),list_fields={list_fields};end
    3693     %             FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
    3694     %             if ~strcmp(FieldName_1,'get_field...')
    3695     %                 if get(handles.FixVelType,'Value')
    3696     %                     VelTypeList=get(handles.VelType_1,'String');
    3697     %                     VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.
    3698     %                 end
    3699     %             end
    3700     %             if isempty(FieldName_1)
    3701     %                 FieldName_1=FieldName;% if blank reproduce the field name of the first field
    3702     %             end
    3703     %             if ~isempty(regexp(FieldName_1,'^vel', 'once'))&& strcmp(get(handles.ColorCode,'Visible'),'on')
    3704     %                 list_code=get(handles.ColorCode,'String');% list menu fields
    3705     %                 index_code=get(handles.ColorCode,'Value');% selected string index
    3706     %                 if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
    3707     %                     list_code=get(handles.ColorScalar,'String');% list menu fields
    3708     %                     index_code=get(handles.ColorScalar,'Value');% selected string index
    3709     %                     ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display
    3710     %                 end
    3711     %             end
    3712     %         case {'video','mmreader','cine_phantom'}
    3713     %             ParamIn_1=UvData.MovieObject{2};
    3714     %             if ~strcmp(NomType_1,'*')
    3715     %                 frame_index_1=j1_1;%frame index for movies or multimage
    3716     %             else
    3717     %                 frame_index_1=i1_1;
    3718     %             end
    3719     %          case 'multimage'
    3720     %             if strcmp(NomType_1,'*')%frame index for movies or multimage
    3721     %                 frame_index_1=i1_1;
    3722     %             else
    3723     %                 frame_index_1=j1_1;
    3724     %             end
    3725     %         case 'vol' %TODO: update
    3726     %             if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
    3727     %                 ParamIn_1.Npy=UvData.XmlData.Npy;
    3728     %                 ParamIn_1.Npx=UvData.XmlData.Npx;
    3729     %             else
    3730     %                 errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
    3731     %                 return
    3732     %             end
    3733     %     end
    37343709   
    37353710    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
     
    39513926    if numel(Field)==2
    39523927        UvData.Field=sub_field(Field{1},[],Field{2});
    3953        % UvData.Field.(FieldName)=Field{1}.(FieldName)-Field{2}.(FieldName_1);
    39543928    end     
    39553929else
     
    40243998    UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
    40253999
    4026 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
    4027 % if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
    4028 %     set(handles.num_MinA,'String','0')
    4029 %     set(handles.num_MaxA,'String','255')
    4030 % end
    4031     set(handles.Objects,'Visible','on')
    4032 
    4033     %% Plot the projections on the selected  projection objects
     4000   
     4001%% Plot the projections on the selected  projection objects
     4002     set(handles.Objects,'Visible','on')
    40344003    %if no projection object exists, create a default one
    40354004    if isempty(UvData.ProjObject{1})
     
    54615430%------------------------------------------------------------------------
    54625431set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    5463 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    54645432update_plot(handles);
    54655433
     
    54715439%------------------------------------------
    54725440set(handles.CheckFixScalar,'Value',1) %suppress auto mode
    5473 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    54745441MinA=str2double(get(handles.num_MinA,'String'));
    54755442MaxA=str2double(get(handles.num_MaxA,'String'));
Note: See TracChangeset for help on using the changeset viewer.