Ignore:
Timestamp:
Mar 12, 2013, 12:52:13 PM (11 years ago)
Author:
sommeria
Message:

clean the transform field functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r580 r581  
    1 %'find_field_cells': test field structure for input in proj_field and plot_field
    2 %    group the variables  into 'fields' with common dimensions
     1%'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables  into 'fields' with common coordinates
    32%------------------------------------------------------------------------
    43% function  [CellInfo,NbDim,errormsg]=find_field_cells(Data)
     
    98%     .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x)
    109%     .CoordSize: array of the nbre of values for each  coordinate in a grid, nbre of points in the unstructured case
    11 %     .NbSite_tps:
     10%     .NbCentres_tps:
    1211%     .SubRange_tps
    1312%     .VarIndex: arrays of the variable indices in the field cell
     
    1918%              _vector_x,_y,_z: indices of variables giving the vector components x, y, z
    2019%              _warnflag: index of warnflag   
    21 %      .FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
     20%      .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
    2221%      .FieldName = operation to be performed to finalise the field cell after projection
    2322%      .SubCheck=0 /1 indicate that the field must be substracted (second  entry in uvmat)
     
    6160
    6261function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
    63 
     62CellInfo={};
    6463NbDim=0;
    6564errormsg='';
    6665if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end
    6766if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end
    68 nbvar=numel(Data.ListVarName);%number of field variables
     67nbvar=numel(Data.ListVarName);%number of variables in the field structure
    6968if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
    7069% check the existence of variable data
     
    8685%   'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y
    8786Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
    88 FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
     87ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
    8988FieldName=cell(size(Role)); % fieldRequest set to {} by default
    9089CheckSub=zeros(size(Role));% =1 for fields to substract
     
    9594            Role{ivar}=Data.VarAttribute{ivar}.Role;
    9695        end
    97         if isfield(Data.VarAttribute{ivar},'FieldRequest')
    98             FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;
     96        if isfield(Data.VarAttribute{ivar},'ProjModeRequest')
     97            ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest;
    9998        end
    10099        if isfield(Data.VarAttribute{ivar},'FieldName')
     
    162161check_coord_tps= strcmp('coord_tps',Role(~check_select));
    163162ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates
     163
     164% loop on the tps coordinate sets
    164165for icell_tps=1:numel(ivar_tps)
     166    check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell
     167    check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected
    165168    DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable
    166169    icell=numel(CellInfo)+icell_tps; % new field cell index
    167170    CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the  tps coordinate variable
    168     %CellInfo{icell}.VarIndex_subrange_tps=[];
    169     %CellInfo{icell}.VarIndex_nbsites_tps=[];
    170171    if numel(DimCell)==3
    171172        VarDimName=Data.VarDimName(~check_select);
    172173        for ivardim=1:numel(VarDimName)
    173174            if strcmp(VarDimName{ivardim},DimCell{3})
    174                 CellInfo{icell}.NbSite_tps= ivar_remain(ivardim);
    175                 check_cell(ivar_remain(ivardim))=1;% nbre of sites for each tps subdomain
     175                CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain
     176                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
    176177            elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3})
    177                 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);
    178                 check_cell(ivar_remain(ivardim))=1;% subrange definiton for tps
    179             elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})
    180                 check_cell(ivar_remain(ivardim))=1;% variable
     178                CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps
     179                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
     180            elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})% variable
     181                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
    181182            end
    182183        end
     
    222223    end
    223224end
    224 ListCoordIndex=ListCoordIndex(check_coord_select);% list of coordinate variable indices
     225ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices
    225226ListCoordName=ListCoordName(check_keep);% list of coordinate variable names
    226227ListDimName=ListDimName(check_keep);% list of coordinate dimension names
     
    315316            CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar;
    316317        end
    317         if ~isempty(FieldRequest{ivar})
    318             CellInfo{icell}.FieldRequest=FieldRequest{ivar};
     318        if ~isempty(ProjModeRequest{ivar})
     319            CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar};
    319320        end
    320321        if ~isempty(FieldName{ivar})
Note: See TracChangeset for help on using the changeset viewer.