Ignore:
Timestamp:
Apr 30, 2018, 8:01:35 PM (3 years ago)
Author:
sommeria
Message:

miscellaneous updates

File:
1 edited

Legend:

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

    r1027 r1033  
    7979%% transform first field
    8080iscalar=0;% counter of scalar fields
     81checktransform=0;
    8182if  ~isempty(Calib{1})
    82     if ~isfield(Calib{1},'CalibrationType')||~isfield(Calib{1},'CoordUnit')
    83         return %bad calib parameter input
    84     end
    85     if ~(isfield(DataIn,'CoordUnit')&& strcmp(DataIn.CoordUnit,'pixel'))
    86         return % transform only fields in pixel coordinates
    87     end
    88     DataOut=phys_1(DataIn,Calib{1},ZIndex);% transform coordinates and velocity components
    89     %case of images or scalar: in case of two input fields, we need to project the transform  on the same regular grid
    90     if isfield(DataIn,'A') && isfield(DataIn,'Coord_x') && ~isempty(DataIn.Coord_x) && isfield(DataIn,'Coord_y')&&...
    91                                            ~isempty(DataIn.Coord_y) && length(DataIn.A)>1
    92         iscalar=1;
    93         A{1}=DataIn.A;
     83    if isfield(Calib{1},'CalibrationType')&& isfield(Calib{1},'CoordUnit') && isfield(DataIn,'CoordUnit')&& strcmp(DataIn.CoordUnit,'pixel')   
     84        DataOut=phys_1(DataIn,Calib{1},ZIndex);% transform coordinates and velocity components
     85        %case of images or scalar: in case of two input fields, we need to project the transform  on the same regular grid
     86        if isfield(DataIn,'A') && isfield(DataIn,'Coord_x') && ~isempty(DataIn.Coord_x) && isfield(DataIn,'Coord_y')&&...
     87                ~isempty(DataIn.Coord_y) && length(DataIn.A)>1
     88            iscalar=1;
     89            A{1}=DataIn.A;
     90        end
     91        checktransform=1;
    9492    end
    9593end
    9694
    9795%% document the selected  plane position and angle if relevant
    98 if isfield(Calib{1},'SliceCoord')&&size(Calib{1}.SliceCoord,1)>=ZIndex
     96if  checktransform && isfield(Calib{1},'SliceCoord')&&size(Calib{1}.SliceCoord,1)>=ZIndex
    9997    DataOut.PlaneCoord=Calib{1}.SliceCoord(ZIndex,:);% transfer the slice position corresponding to index ZIndex
    10098    if isfield(Calib{1},'SliceAngle') % transfer the slice rotation angles
     
    108106
    109107%% transform second field if relevant
     108checktransform_1=0;
    110109if ~isempty(DataOut_1)
    111110    if isfield(DataIn_1,'ZIndex') && ~isequal(DataIn_1.ZIndex,ZIndex)
     
    113112        return
    114113    end
    115     if ~isfield(Calib{2},'CalibrationType')||~isfield(Calib{2},'CoordUnit')
    116         return %bad calib parameter input
    117     end
    118     if (isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
     114    if isfield(Calib{2},'CalibrationType')&&isfield(Calib{2},'CoordUnit') && isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel')
    119115        DataOut_1=phys_1(DataOut_1,Calib{2},ZIndex);
    120     end
    121     if isfield(Calib{1},'SliceCoord')
    122         if ~(isfield(Calib{2},'SliceCoord') && isequal(Calib{2}.SliceCoord,Calib{1}.SliceCoord))
    123             DataOut_1.Txt='different plane positions for the two input fields';
    124             return
    125         end
    126         DataOut_1.PlaneCoord=DataOut.PlaneCoord;% same plane position for the two input fields
    127         if isfield(Calib{1},'SliceAngle')
    128             if ~(isfield(Calib{2},'SliceAngle') && isequal(Calib{2}.SliceAngle,Calib{1}.SliceAngle))
    129                 DataOut_1.Txt='different plane angles for the two input fields';
     116        if isfield(Calib{1},'SliceCoord')
     117            if ~(isfield(Calib{2},'SliceCoord') && isequal(Calib{2}.SliceCoord,Calib{1}.SliceCoord))
     118                DataOut_1.Txt='different plane positions for the two input fields';
    130119                return
    131120            end
    132             DataOut_1.PlaneAngle=DataOut.PlaneAngle; % same plane angle for the two input fields
    133         end
    134     end
    135     if isfield(DataIn_1,'A')&&isfield(DataIn_1,'Coord_x')&&~isempty(DataIn_1.Coord_x) && isfield(DataIn_1,'Coord_y')&&...
    136             ~isempty(DataIn_1.Coord_y)&&length(DataIn_1.A)>1
    137         iscalar=iscalar+1;
    138         Calib{iscalar}=Calib{2};
    139         A{iscalar}=DataIn_1.A;
     121            DataOut_1.PlaneCoord=DataOut.PlaneCoord;% same plane position for the two input fields
     122            if isfield(Calib{1},'SliceAngle')
     123                if ~(isfield(Calib{2},'SliceAngle') && isequal(Calib{2}.SliceAngle,Calib{1}.SliceAngle))
     124                    DataOut_1.Txt='different plane angles for the two input fields';
     125                    return
     126                end
     127                DataOut_1.PlaneAngle=DataOut.PlaneAngle; % same plane angle for the two input fields
     128            end
     129        end
     130        if isfield(DataIn_1,'A')&&isfield(DataIn_1,'Coord_x')&&~isempty(DataIn_1.Coord_x) && isfield(DataIn_1,'Coord_y')&&...
     131                ~isempty(DataIn_1.Coord_y)&&length(DataIn_1.A)>1
     132            iscalar=iscalar+1;
     133            Calib{iscalar}=Calib{2};
     134            A{iscalar}=DataIn_1.A;
     135        end
     136        checktransform_1=1;
    140137    end
    141138end
    142139
    143140%% transform the scalar(s) or image(s)
    144 if iscalar~=0
     141if checktransform && iscalar~=0
    145142    [A,Coord_x,Coord_y]=phys_ima(A,XmlData,ZIndex);%TODO : introduire interp2_uvmat ds phys_ima
    146143    if iscalar==1 && ~isempty(DataOut_1) % case for which only the second field is a scalar
Note: See TracChangeset for help on using the changeset viewer.