Ignore:
Timestamp:
Jan 26, 2022, 7:37:21 PM (3 years ago)
Author:
sommeria
Message:

set_slice separated from geometrey_calib

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/transform_field/phys_polar.m

    r1107 r1112  
    7878Data=DataIn; %default output
    7979if isfield(Data,'CoordUnit')
    80 Data=rmfield(Data,'CoordUnit');
     80    Data=rmfield(Data,'CoordUnit');
    8181end
    8282Data.ListVarName = {};
     
    8585DataCell{1}=DataIn;
    8686Calib{1}=[];
     87Slice{1}=[];
    8788DataCell{2}=[];%default
    8889checkpixel(1)=0;
    89 if isfield(DataCell{1},'CoordUnit')&& strcmp(DataCell{1}.CoordUnit,'pixel') 
     90if isfield(DataCell{1},'CoordUnit')&& strcmp(DataCell{1}.CoordUnit,'pixel')
    9091    checkpixel(1)=1;
    9192end
     
    9495        Calib{1}=XmlData.GeometryCalib;
    9596    end
     97    Slice{1}=Calib{1};
     98    if isfield(XmlData,'Slice')
     99        Slice{1}=XmlData.Slice;
     100    end
    96101    Calib{2}=Calib{1};
     102    Slice{2}=Slice{1};
    97103else
    98104    Data.Txt='wrong input: need two or four structures';
     
    101107if nargin==4% case of two input fields
    102108    checkpixel(2)=0;
    103 if isfield(DataCell{2},'CoordUnit')&& strcmp(DataCell{2}.CoordUnit,'pixel')
    104     checkpixel(2)=1;
    105 end
     109    if isfield(DataCell{2},'CoordUnit')&& strcmp(DataCell{2}.CoordUnit,'pixel')
     110        checkpixel(2)=1;
     111    end
    106112    DataCell{2}=DataIn_1;%default
    107113    if isfield(XmlData_1,'GeometryCalib')&& ~isempty(XmlData_1.GeometryCalib) && checkpixel(2)
    108114        Calib{2}=XmlData_1.GeometryCalib;
     115    end
     116    if isfield(XmlData_1,'Slice')
     117        Slice{2}=XmlData_1.Slice;
    109118    end
    110119    nbinput=2;
     
    218227                    if ~isempty(Calib{ifield})
    219228                        [X,Y,Z,DataCell{ifield}.(UName),DataCell{ifield}.(VName)]=...
    220                             phys_XYUV(DataCell{ifield},Calib{ifield},ZIndex);
     229                            phys_XYUV(DataCell{ifield},Calib{ifield},Slice{ifield},ZIndex);
    221230                    end
    222231                end
     
    304313                    ZInd(nbgrid)=ZIndex;
    305314                    Calib_new{nbgrid}=Calib{ifield};
     315                    Slice_new{nbgrid}=Slice{ifield};
    306316                end
    307317                if isfield(CellInfo{icell},'VarIndex_vector_x')&& isfield(CellInfo{icell},'VarIndex_vector_y')
     
    325335                    Calib_new{nbgrid+1}=Calib{ifield};
    326336                    Calib_new{nbgrid+2}=Calib{ifield};
     337                    Slice_new{nbgrid+1}=Calib{ifield};
     338                    Slice_new{nbgrid+2}=Calib{ifield};
    327339                    nbgrid=nbgrid+2;
    328340                    nbvar=nbvar+2;
     
    335347%% tranform cartesian to polar coordinates for gridded data
    336348if nbgrid~=0
    337     [A,Data.radius,Data.theta]=phys_Ima_polar(A,coord_x,coord_y,Calib_new,ZInd,origin_xy,radius_offset,angle_offset,angle_scale);
     349    [A,Data.radius,Data.theta]=phys_Ima_polar(A,coord_x,coord_y,Calib_new,Slice_new,ZInd,origin_xy,radius_offset,angle_offset,angle_scale);
    338350    for icell=1:numel(A)
    339351        if icell<=numel(A)-1 && check_vector(icell)==1 && check_vector(icell+1)==1   %transform u,v into polar coordinates
     
    373385%------------------------------------------------
    374386%--- transform a single field into phys coordiantes
    375 function [X,Y,Z,U,V]=phys_XYUV(Data,Calib,ZIndex)
     387function [X,Y,Z,U,V]=phys_XYUV(Data,Calib,Slice,ZIndex)
    376388%------------------------------------------------
    377389%% set default output
     
    385397%% transform  X,Y coordinates for velocity fields (transform of an image or scalar done in phys_ima)
    386398if isfield(Data,'X') &&isfield(Data,'Y')&&~isempty(Data.X) && ~isempty(Data.Y)
    387     [X,Y,Z]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex);
     399    [X,Y,Z]=phys_XYZ(Calib,Slice,Data.X,Data.Y,ZIndex);
    388400    Dt=1; %default
    389401    if isfield(Data,'dt')&&~isempty(Data.dt)
     
    394406    end
    395407    if isfield(Data,'U')&&isfield(Data,'V')&&~isempty(Data.U) && ~isempty(Data.V)
    396         [XOut_1,YOut_1]=phys_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,ZIndex);
    397         [XOut_2,YOut_2]=phys_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,ZIndex);
     408        [XOut_1,YOut_1]=phys_XYZ(Calib,Slice,Data.X-Data.U/2,Data.Y-Data.V/2,ZIndex);
     409        [XOut_2,YOut_2]=phys_XYZ(Calib,Slice,Data.X+Data.U/2,Data.Y+Data.V/2,ZIndex);
    398410        U=(XOut_2-XOut_1)/Dt;
    399411        V=(YOut_2-YOut_1)/Dt;
     
    404416% tranform gridded field into polar coordiantes on a regular polar grid,
    405417% transform to phys coordiantes if requested by calibration input
    406 function [A_out,radius,theta]=phys_Ima_polar(A,coord_x,coord_y,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
     418function [A_out,radius,theta]=phys_Ima_polar(A,coord_x,coord_y,CalibIn,SliceIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)
    407419rcorner=[];
    408420thetacorner=[];
     
    420432    % transform edges into phys coordinates if requested
    421433    if ~isempty(CalibIn{icell})
    422         [x_edge,y_edge]=phys_XYZ(CalibIn{icell},x_edge,y_edge,ZIndex(icell));% physical coordinates of the image edge
     434        [x_edge,y_edge]=phys_XYZ(CalibIn{icell},SliceIn{icell},x_edge,y_edge,ZIndex(icell));% physical coordinates of the image edge
    423435    end
    424436   
Note: See TracChangeset for help on using the changeset viewer.