Changeset 158 for trunk/src/proj_field.m


Ignore:
Timestamp:
Dec 22, 2010, 5:12:31 PM (13 years ago)
Author:
sommeria
Message:

CoordType? not used, replaced by CoordUnit?
bug repair in check_field_structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r156 r158  
    8787end
    8888%introduce default field properties (reading old standards)
    89 if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode')
     89if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'ProjMode')
    9090    ProjData=FieldData;
    9191    return
    9292end
    93 
     93if ~isfield(ObjectData,'Coord')
     94    if strcmp(ObjectData.Style,'plane')
     95        ObjectData.Coord=[0 0 0];%default
     96    else
     97        ProjData=FieldData;
     98        return
     99    end
     100end
     101       
    94102% OBSOLETE
    95103if isfield(ObjectData,'XMax') && ~isempty(ObjectData.XMax)
     
    112120end
    113121%%%%%%%%%%
    114 
    115 % FieldData=document_field(FieldData);%transform FieldData to the standard format
    116 % if ~isfield(FieldData,'VarAttribute')
    117 %     FieldData.VarAttribute={};
    118 % end
    119122switch ObjectData.Style
    120123    case 'points'
     
    138141        [ProjData,errormsg] = proj_volume(FieldData,ObjectData);
    139142end
    140 % if exist('IndexObj','var')
    141 %     ProjData.IndexObj=IndexObj;%transfer object index
    142 % end
     143
    143144
    144145%-----------------------------------------------------------------
     
    10041005
    10051006%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1006 %group the variables (fields of 'FieldData') in cells of variables with the same dimensions
     1007%% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
    10071008%-----------------------------------------------------------------
    10081009idimvar=0;
     
    10121013    return
    10131014end
    1014 %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
     1015
     1016% LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
    10151017% CellVarIndex=cells of variable index arrays
    10161018ivar_new=0; % index of the current variable in the projected field
     
    10361038    ivar_FF=VarType.errorflag;
    10371039    testX=~isempty(ivar_X) && ~isempty(ivar_Y);
    1038     %DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
    10391040    DimCell=FieldData.VarDimName{VarIndex(1)};
    10401041    if ischar(DimCell)
     
    10421043    end
    10431044
    1044 %case of input fields with unstructured coordinates
     1045%% case of input fields with unstructured coordinates
    10451046    if testX
    10461047        XName=FieldData.ListVarName{ivar_X};
     
    10661067            indcut=find(abs(fieldZ) <= width);
    10671068            for ivar=VarIndex
    1068                  VarName=FieldData.ListVarName{ivar};
    1069 %                 eval(['size(FieldData.' VarName ')'])
    1070                 eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);'])
    1071 %                 end     
     1069                VarName=FieldData.ListVarName{ivar};
     1070                eval(['FieldData.' VarName '=FieldData.' VarName '(indcut);']) 
    10721071                    % A VOIR : CAS DE VAR STRUCTUREE MAIS PAS GRILLE REGULIERE : INTERPOLER SUR GRILLE REGULIERE             
    10731072            end
     
    12171216            end
    12181217        end
    1219 %case of input fields defined on a structured  grid
     1218       
     1219%% case of input fields defined on a structured  grid
    12201220    else 
    12211221        AYName=FieldData.ListVarName{VarType.coord(1)};%name of input x coordinate (name preserved on projection)
     
    12561256                    DCoord_max=max(DCoord);
    12571257                %    test_direct(idim)=DCoord_max>0;% =1 for increasing values, 0 otherwise
    1258                     if ~isequal(DCoord_max,DCoord_min(idim)>0)
     1258                    if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)
    12591259                        msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'])
    12601260                                return
     
    13671367                ProjData.ListVarName=[ProjData.ListVarName VarName];
    13681368                ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
    1369                 if length(FieldData.VarAttribute)>=ivar
     1369                if isfield(FieldData,'VarAttribute') && length(FieldData.VarAttribute)>=ivar
    13701370                    ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar};
    13711371                end
    13721372                eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2) ;']);
    1373             end         
     1373            end 
     1374            eval(['ProjData.' AYName '=FieldData.' AYName ';']) %record the new (projected ) y coordinates
     1375            eval(['ProjData.' AXName '=FieldData.' AXName ';']) %record the new (projected ) x coordinates
    13741376        else       % case with rotation and/or interpolation
    13751377            if isempty(Coord_z) %2D case
     
    14521454        end
    14531455    end
    1454     %projection of  velocity components in the rotated coordinates
     1456   
     1457    %% projection of  velocity components in the rotated coordinates
    14551458    if ~isequal(Phi,0) && length(ivar_U)==1
    14561459        if isempty(ivar_V)
     
    20822085    end
    20832086end
    2084 if isfield(FieldData,'CoordType')
    2085     if isfield(ObjectData,'CoordType')&~isequal(FieldData.CoordType,ObjectData.CoordType)
    2086         errormsg=[ObjectData.Style ' in ' ObjectData.CoordType ' coordinates, while field in ' FieldData.CoordType ' coordinates'];
     2087if isfield(FieldData,'CoordUnit')
     2088    if isfield(ObjectData,'CoordUnit')&~isequal(FieldData.CoordUnit,ObjectData.CoordUnit)
     2089        errormsg=[ObjectData.Style ' in ' ObjectData.CoordUnit ' coordinates, while field in ' FieldData.CoordUnit ];
    20872090        return
    20882091    else
    2089          ProjData.CoordType=FieldData.CoordType;
     2092         ProjData.CoordUnit=FieldData.CoordUnit;
    20902093    end
    20912094end
Note: See TracChangeset for help on using the changeset viewer.