Changeset 906 for trunk/src/sub_field.m


Ignore:
Timestamp:
May 31, 2015, 7:49:31 PM (8 years ago)
Author:
sommeria
Message:

various bgu repairs and ima_remove_partices and ima_remove_background updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sub_field.m

    r876 r906  
    9898%% field request
    9999ProjModeRequest=cell(size(Field.ListVarName));
     100if isfield(Field,'VarAttribute')
    100101for ilist=1:numel(Field.VarAttribute)
    101102    if isfield(Field.VarAttribute{ilist},'ProjModeRequest')
     
    103104    end
    104105end
     106end
    105107ProjModeRequest_1=cell(size(Field_1.ListVarName));
     108if isfield(Field_1,'VarAttribute')
    106109for ilist=1:numel(Field_1.VarAttribute)
    107110    if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest')
     
    109112    end
    110113end
    111 
     114end
    112115
    113116%% rename the dimensions of the second field if identical to those of the first
     
    162165check_rename=zeros(size(ListVarNameSub));
    163166check_remove=zeros(size(ListVarNameSub));
    164 for ilist=1:numel(ListVarNameSub)
    165     ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
    166     if ~isempty(ind_prev)% variable name exists in Field
    167         if isfield(Field_1.VarAttribute{ilist},'Role')&&...
    168             ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
    169             ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
    170             check_rename(ilist)=1;
    171         else
    172             check_remove(ilist)=1;% variable will be removed
    173         end
    174     end
    175 end
    176 ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
    177 ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
    178 VarDimNameSub=Field_1.VarDimName(~check_remove);
    179 if numel(Field_1.VarAttribute)<max(find(~check_remove))
    180     for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove))
    181         Field_1.VarAttribute{ilist}={};
    182     end
    183 end
    184 VarAttributeSub=Field_1.VarAttribute(~check_remove);
    185 check_rename=check_rename(~check_remove);
    186 
     167VarDimNameSub={};
     168VarAttributeSub={};
     169if isfield(Field_1,'VarAttribute')&&~isempty(Field_1.VarAttribute)
     170    for ilist=1:numel(ListVarNameSub)
     171        ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
     172        if ~isempty(ind_prev)% variable name exists in Field
     173            if isfield(Field_1.VarAttribute{ilist},'Role')&&...
     174                    ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
     175                ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
     176                check_rename(ilist)=1;
     177            else
     178                check_remove(ilist)=1;% variable will be removed
     179            end
     180        end
     181    end
     182    ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
     183    ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
     184    VarDimNameSub=Field_1.VarDimName(~check_remove);
     185    if numel(Field_1.VarAttribute)<max(find(~check_remove))
     186        for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove))
     187            Field_1.VarAttribute{ilist}={};
     188        end
     189    end
     190    VarAttributeSub=Field_1.VarAttribute(~check_remove);
     191    check_rename=check_rename(~check_remove);
     192end
    187193% apply the variable renaming and mark the second field variables with the attribute .CheckSub
    188194for ilist=1:numel(ListVarNameSub)
Note: See TracChangeset for help on using the changeset viewer.