Changeset 580 for trunk/src/sub_field.m


Ignore:
Timestamp:
Mar 7, 2013, 1:47:51 PM (11 years ago)
Author:
sommeria
Message:

bugs corrected for combining fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sub_field.m

    r548 r580  
    105105end
    106106
    107 %look for coordinates common to Field in Field_1
     107%% look for coordinates common to Field in Field_1
    108108ind_remove=zeros(size(Field_1.ListVarName));
    109109for ilist=1:numel(Field_1.ListVarName)
     
    121121                   NewDim={NewDim};
    122122               end
    123                Field_1.VarDimName=regexprep_r(Field_1.VarDimName,OldDim{1},NewDim{1});
     123               Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDim{1} '$'],NewDim{1});
    124124            end
    125125        end
     
    130130Field_1.VarAttribute(find(ind_remove))=[];
    131131
    132 %append the other variables of the second field, modifying their name if needed
     132%% append the other variables of the second field, modifying their name if needed
    133133for ilist=1:numel(Field_1.ListVarName)
    134134    VarName=Field_1.ListVarName{ilist};
     
    138138    else  % variable name exists in Field     
    139139            VarNameNew=[VarName '_1'];   
     140            if isfield(Field_1.VarAttribute{ilist},'FieldName')
     141                Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,VarName,VarNameNew);
     142            end
    140143    end
    141144        SubData.ListVarName=[SubData.ListVarName {VarNameNew}];
     
    146149end
    147150
    148 %append the other variables of the second field, modifying their name if needed
    149 
    150151%% substrat fields when possible
    151152%[CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(SubData);
    152 [CellInfo,NbDim,errormsg]=find_field_cells(SubData)
     153[CellInfo,NbDim,errormsg]=find_field_cells(SubData);
    153154ind_remove=zeros(size(SubData.ListVarName));
    154155ivar=[];
     
    179180SubData.VarDimName(find(ind_remove))=[];
    180181SubData.VarAttribute(find(ind_remove))=[];
     182%end
    181183
    182 function OutputCell=regexprep_r(InputCell,dimname,dimname_new)
     184function OutputCell=regexprep_r(InputCell,search_string,new_string)
    183185for icell=1:numel(InputCell)
    184     OutputCell{icell}=regexprep(InputCell{icell},['^' dimname '$'],dimname_new);
     186    OutputCell{icell}=regexprep(InputCell{icell},search_string,new_string);
    185187end
    186188       
Note: See TracChangeset for help on using the changeset viewer.