Changeset 684 for trunk/src/read_field.m
 Timestamp:
 Sep 8, 2013, 10:24:51 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/read_field.m
r681 r684 50 50 end 51 51 check_colorvar=zeros(size(InputField)); 52 if isfield(ParamIn,'ColorVar') 52 if isfield(ParamIn,'ColorVar')&&~isempty(ParamIn.ColorVar) 53 53 InputField=[ParamIn.FieldName {ParamIn.ColorVar}]; 54 54 check_colorvar(numel(InputField))=1; … … 71 71 Role={}; 72 72 ProjModeRequest={}; 73 ListInputField={}; 74 ListOperator={}; 73 75 checkU=0; 74 76 checkV=0; 75 77 for ilist=1:numel(InputField) 76 78 r=regexp(InputField{ilist},'(?<Operator>(^vec^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); 77 Operator='';78 79 if isempty(r)% no operator used 79 80 if isempty(find(strcmp(InputField{ilist},ListVar))) 80 ListVar=[ListVar InputField(ilist)];%append the variable name if not already in the list 81 ListVar=[ListVar InputField(ilist)];%append the variable name if not already in the list 82 ListInputField=[ListInputField InputField(ilist)]; 83 ListOperator=[ListOperator {''}]; 81 84 end 82 85 if check_colorvar(ilist) … … 88 91 end 89 92 else % an operator 'vec' or 'norm' is used 90 Operator=r.Operator;93 %Operator=r.Operator; 91 94 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm') 92 95 ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot) … … 97 100 ind_var_V=find(strcmp(r.VName,ListVar));%check previous listing of variable r.VName 98 101 if isempty(ind_var_U) 99 ListVar=[ListVar r.UName]; % append the variable in the list if not previously listed102 ListVar=[ListVar {r.UName}]; % append the variable in the list if not previously listed 100 103 Role=[Role {'vector_x'}]; 101 104 ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}]; 105 ListInputField=[ListInputField InputField(ilist)]; 106 %ListOperator=[ListOperator {[r.Operator '_U']}]; 102 107 else 103 108 checkU=1; 104 109 end 105 110 if isempty(ind_var_V) 106 ListVar=[ListVar r.VName];% append the variable in the list if not previously listed111 ListVar=[ListVar {r.VName}];% append the variable in the list if not previously listed 107 112 Role=[Role {'vector_y'}]; 108 113 ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}]; 114 ListInputField=[ListInputField {''}]; 115 %ListOperator=[ListOperator {[r.Operator '_V']}]; 109 116 else 110 117 checkV=1; … … 128 135 end 129 136 end 130 for ivar=1:numel(ListVar) 131 Field.VarAttribute{ivar+2}.Role=Role{ivar}; 137 NormName=''; 138 UName=''; 139 VName=''; 140 for ilist=1:numel(ListVar) 141 Field.VarAttribute{ilist+2}.Role=Role{ilist}; 142 Field.VarAttribute{ilist+2}.ProjModeRequest=ProjModeRequest{ilist}; 132 143 if isfield(ParamIn,'FieldName') 133 Field.VarAttribute{ivar+2}.FieldName=ParamIn.FieldName; 134 end 135 Field.VarAttribute{ivar+2}.ProjModeRequest=ProjModeRequest{ivar}; 136 end 137 if strcmp(Operator,'norm') 138 NormName='norm'; 139 if ~isempty(strcmp(ListVar,'norm')) 140 NormName='norm_1'; 141 end 142 Field.ListVarName=[Field.ListVarName {NormName}]; 143 ilist=numel(Field.ListVarName); 144 Field.VarDimName{ilist}=Field.VarDimName{ind_var_U}; 145 Field.VarDimName{ilist}.Role='scalar'; 146 Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName); 147 Field.(NormName)=sqrt(Field.(NormName)); 148 if ~checkU && ~checkV 149 Field.ListVarName([ind_var_U ind_var_V])=[]; 150 Field.VarDimName([ind_var_U ind_var_V])=[]; 151 Field.VarAttribute([ind_var_U ind_var_V])=[]; 152 elseif ~checkU 153 Field.ListVarName(ind_var_U)=[]; 154 Field.VarDimName(ind_var_U)=[]; 155 Field.VarAttribute(ind_var_U )=[]; 156 elseif ~checkV 157 Field.ListVarName(ind_var_V)=[]; 158 Field.VarDimName(ind_var_V)=[]; 159 Field.VarAttribute(ind_var_V )=[]; 160 end 144 Field.VarAttribute{ilist+2}.FieldName=ListInputField{ilist}; 145 end 146 r=regexp(ListInputField{ilist},'(?<Operator>(^vec^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); 147 if ~isempty(r)&& strcmp(r.Operator,'norm') 148 NormName='norm'; 149 if ~isempty(find(strcmp(ListVar,'norm'))) 150 NormName='norm_1'; 151 end 152 Field.ListVarName=[Field.ListVarName {NormName}]; 153 ilistmax=numel(Field.ListVarName); 154 Field.VarDimName{ilistmax}=Field.VarDimName{ilist+2}; 155 Field.VarAttribute{ilistmax}.Role='scalar'; 156 Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName); 157 Field.(NormName)=sqrt(Field.(NormName)); 158 UName=r.UName; 159 VName=r.VName; 160 end 161 end 162 if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables 163 ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName 164 ind_var_V=find(strcmp(VName,ListVar));%check previous listing of variable r.VName 165 if ~checkU && ~checkV 166 Field.ListVarName([ind_var_U+2 ind_var_V+2])=[]; 167 Field.VarDimName([ind_var_U+2 ind_var_V+2])=[]; 168 Field.VarAttribute([ind_var_U+2 ind_var_V+2])=[]; 169 elseif ~checkU 170 Field.ListVarName(ind_var_U+2)=[]; 171 Field.VarDimName(ind_var_U+2)=[]; 172 Field.VarAttribute(ind_var_U+2 )=[]; 173 elseif ~checkV 174 Field.ListVarName(ind_var_V+2)=[]; 175 Field.VarDimName(ind_var_V+2)=[]; 176 Field.VarAttribute(ind_var_V+2 )=[]; 177 end 161 178 end 162 179 case 'video'
Note: See TracChangeset
for help on using the changeset viewer.