Ignore:
Timestamp:
Feb 27, 2017, 9:28:27 AM (8 years ago)
Author:
sommeria
Message:

tubcorrelation added, compilation improved to accept tranform fct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_field.m

    r980 r1001  
    152152            [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,num,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVar]);
    153153            if numel(num)~=1
    154                 NbCoord=NbCoord+1;% adds time coordinate, except if q single time hqs been selected
     154                NbCoord=NbCoord+1;% adds time coordinate, except if a single time has been selected
    155155            end
    156156        else
     
    160160            return
    161161        end
    162         %scan all the variables beyond the two first ones, ParamIn.Coord_x and ParamIn.Coord_y.
     162        CheckStructured=1;
     163        %scan all the variables beyond the two first NbCoord ones describing the coordinates.
    163164        for ilist=NbCoord+1:numel(Field.VarDimName)
    164165            if isequal(Field.VarDimName{1},Field.VarDimName{ilist}) % if a variable has the same dimension as the coordinate, it denotes a field with unstructured coordinates
     
    168169                    Field.VarAttribute{3}.Role='coord_z';
    169170                end
     171                CheckUnstructured=0;
    170172                break
    171173            end
    172174        end
     175        if CheckStructured
     176            for ilist=NbCoord+1:numel(Field.VarDimName)
     177                rank(1)=find(strcmp(ParamIn.Coord_x,Field.VarDimName{ilist}));
     178                rank(2)=find(strcmp(ParamIn.Coord_y,Field.VarDimName{ilist}));
     179                if NbCoord==3
     180                rank(3)=find(strcmp(ParamIn.Coord_z,Field.VarDimName{ilist}));
     181                end
     182                rank=flip(rank);
     183                VarName=Field.ListVarName{ilist};
     184                Field.(VarName)=permute(Field.(VarName),rank);
     185                Field.VarDimName{ilist}=Field.VarDimName{ilist}(rank);% permute the order of dimensions
     186            end
     187        end             
    173188        NormName='';
    174189        UName='';
     
    225240                Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute];
    226241            end
     242           
    227243        end
    228244    case 'video'
Note: See TracChangeset for help on using the changeset viewer.