Changeset 690 for trunk/src/proj_field.m


Ignore:
Timestamp:
Sep 29, 2013, 1:19:30 PM (10 years ago)
Author:
sommeria
Message:

representation of ancillary data as table improved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r684 r690  
    306306[ProjData,errormsg]=proj_heading(FieldData,ObjectData);
    307307
    308 objectfield=fieldnames(ObjectData);
     308%objectfield=fieldnames(ObjectData);
    309309widthx=0;
    310310widthy=0;
    311 if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
     311if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX)
    312312    widthx=max(ObjectData.RangeX);
    313313end
    314 if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
     314if isfield(ObjectData,'RangeY') && ~isempty(ObjectData.RangeY)
    315315    widthy=max(ObjectData.RangeY);
    316316end
     
    324324CoordMesh=zeros(1,numel(FieldData.ListVarName));
    325325if isfield (FieldData,'VarAttribute')
    326     %ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names
    327326    for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values
    328 %         ProjData.VarAttribute{iattr}={};
    329327        if isfield(FieldData.VarAttribute{iattr},'Unit')
    330328            unit{iattr}=FieldData.VarAttribute{iattr}.Unit;
     
    374372        ivar_Z=CellInfo{icell}.CoordIndex(1);
    375373    end
    376     if strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured coordinates
    377         %nbpoint=numel(FieldData.(FieldData.ListVarName{VarIndex(1)}));
    378         for ivar=[VarIndex ivar_X ivar_Y ivar_FF]
    379             VarName=FieldData.ListVarName{ivar};
    380             FieldData.(VarName)=reshape(FieldData.(VarName),[],1);
    381         end
    382         XName=FieldData.ListVarName{ivar_X};
    383         YName=FieldData.ListVarName{ivar_Y};
    384         coord_x=FieldData.(XName);
    385         coord_y=FieldData.(YName);
    386     end
    387     % image or 2D matrix
    388     if  strcmp(CellInfo{icell}.CoordType,'grid')%case of structured coordinates
    389         test_Amat=1;% test for image or 2D matrix
    390         AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    391         AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
    392         eval(['AX=FieldData.' AXName ';'])% x coordinate
    393         eval(['AY=FieldData.' AYName ';'])% y coordinate
    394         VarName=FieldData.ListVarName{VarIndex(1)};
    395         DimValue=size(FieldData.(VarName));
    396         if length(AX)==2
    397             AX=linspace(AX(1),AX(end),DimValue(2));
    398         end
    399         if length(AY)==2
    400             AY=linspace(AY(1),AY(end),DimValue(1));
    401         end
    402         if length(DimValue)==3
    403             testcolor=1;
    404             npxy(3)=3;
    405         else
    406             testcolor=0;
    407             npxy(3)=1;
    408         end
    409         [Xi,Yi]=meshgrid(AX,AY);
    410         npxy(1)=length(AY);
    411         npxy(2)=length(AX);
    412         Xi=reshape(Xi,npxy(1)*npxy(2),1);
    413         Yi=reshape(Yi,npxy(1)*npxy(2),1);
    414         for ivar=1:length(VarIndex)
    415             VarName=FieldData.ListVarName{VarIndex(ivar)};
    416             FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors
    417         end
     374    switch CellInfo{icell}.CoordType
     375        case 'scattered' %case of unstructured coordinates
     376            for ivar=[VarIndex ivar_X ivar_Y ivar_FF]
     377                VarName=FieldData.ListVarName{ivar};
     378                FieldData.(VarName)=reshape(FieldData.(VarName),[],1);
     379            end
     380            XName=FieldData.ListVarName{ivar_X};
     381            YName=FieldData.ListVarName{ivar_Y};
     382            coord_x=FieldData.(XName);
     383            coord_y=FieldData.(YName);
     384            % image or 2D matrix
     385        case 'grid' %case of structured coordinates
     386            test_Amat=1;% test for image or 2D matrix
     387            AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
     388            AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
     389            AX=FieldData.(AXName);% x coordinate
     390            AY=FieldData.(AYName);% y coordinate
     391            VarName=FieldData.ListVarName{VarIndex(1)};
     392            DimValue=size(FieldData.(VarName));
     393            if length(AX)==2
     394                AX=linspace(AX(1),AX(end),DimValue(2));
     395            end
     396            if length(AY)==2
     397                AY=linspace(AY(1),AY(end),DimValue(1));
     398            end
     399            if length(DimValue)==3
     400                testcolor=1;
     401                npxy(3)=3;
     402            else
     403                testcolor=0;
     404                npxy(3)=1;
     405            end
     406            [Xi,Yi]=meshgrid(AX,AY);
     407            npxy(1)=length(AY);
     408            npxy(2)=length(AX);
     409            Xi=reshape(Xi,npxy(1)*npxy(2),1);
     410            Yi=reshape(Yi,npxy(1)*npxy(2),1);
     411            for ivar=1:length(VarIndex)
     412                VarName=FieldData.ListVarName{VarIndex(ivar)};
     413                FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors
     414            end
    418415    end
    419416    %select the indices in the range of action
     
    476473        end
    477474        if isfield(FieldData,'VarAttribute')&& numel(FieldData.VarAttribute)>=ivar
    478         ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
     475            ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
    479476        end
    480477    end
Note: See TracChangeset for help on using the changeset viewer.