Changeset 907 for trunk/src/read_field.m
 Timestamp:
 Jun 1, 2015, 10:10:05 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/read_field.m
r896 r907 80 80 case 'civdata'% new format for civ results 81 81 [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType); 82 if ~isempty(errormsg),errormsg=['read_civdata / ' errormsg];return,end 82 if ~isempty(errormsg),errormsg=['read_civdata / ' errormsg];return,end 83 83 ParamOut.CivStage=Field.CivStage; 84 84 case 'civx'% old (obsolete) format for civ results … … 105 105 end 106 106 if check_colorvar(ilist) 107 if isempty(find(strcmp(InputField{ilist},ListVar))) 107 108 Role{numel(ListVar)}='ancillary';% not projected with interpolation 108 109 ProjModeRequest{numel(ListVar)}=''; 110 end 109 111 else 110 112 Role{numel(ListVar)}='scalar'; … … 146 148 elseif isfield(ParamIn,'TimeVarName')% case of reading of a single time in a multidimensional array 147 149 [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,num,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVar]); 148 NbCoord=NbCoord+1;% adds time coordinate 150 if numel(num)~=1 151 NbCoord=NbCoord+1;% adds time coordinate, except if q single time hqs been selected 152 end 149 153 else 150 154 [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,[ParamIn.Coord_x ParamIn.Coord_y ParamIn.Coord_z ListVar]); … … 168 172 VName=''; 169 173 if numel(Field.ListVarName)>NbCoord % if there are variables beyond coord (1 D plots) 170 for ilist=1:numel(ListVar)171 Field.VarAttribute{ilist+NbCoord}.Role=Role{ilist};172 Field.VarAttribute{ilist+NbCoord}.ProjModeRequest=ProjModeRequest{ilist};173 if isfield(ParamIn,'FieldName')174 Field.VarAttribute{ilist+NbCoord}.FieldName=ListInputField{ilist};175 end176 r=regexp(ListInputField{ilist},'(?<Operator>(^vec^norm))\((?<UName>.+),(?<VName>.+)\)$','names');177 if ~isempty(r)&& strcmp(r.Operator,'norm')178 NormName='norm';179 if ~isempty(find(strcmp(ListVar,'norm')))180 NormName='norm_1';181 end182 Field.ListVarName=[Field.ListVarName {NormName}];183 ilistmax=numel(Field.ListVarName);184 Field.VarDimName{ilistmax}=Field.VarDimName{ilist+2};185 Field.VarAttribute{ilistmax}.Role='scalar';186 Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName);187 Field.(NormName)=sqrt(Field.(NormName));188 UName=r.UName;189 VName=r.VName;190 end191 end192 193 if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables194 ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName195 ind_var_V=find(strcmp(VName,ListVar));%check previous listing of variable r.VName196 if ~checkU && ~checkV197 Field.ListVarName([ind_var_U+2 ind_var_V+2])=[];198 Field.VarDimName([ind_var_U+2 ind_var_V+2])=[];199 Field.VarAttribute([ind_var_U+2 ind_var_V+2])=[];200 elseif ~checkU201 Field.ListVarName(ind_var_U+2)=[];202 Field.VarDimName(ind_var_U+2)=[];203 Field.VarAttribute(ind_var_U+2 )=[];204 elseif ~checkV205 Field.ListVarName(ind_var_V+2)=[];206 Field.VarDimName(ind_var_V+2)=[];207 Field.VarAttribute(ind_var_V+2 )=[];208 end209 end210 % insert coordinates as indices in case of plots vs matrix index211 if isfield(ParamIn,'CheckCoordIndex') && ParamIn.CheckCoordIndex212 Field.ListVarName=[Field.ListDimName Field.ListVarName];213 Field.VarDimName=[Field.ListDimName Field.VarDimName];214 for idim=1:numel(Field.ListDimName)215 CoordName=Field.ListDimName{idim};216 Field.(CoordName)=1:Field.DimValue(idim);217 end218 Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute]219 end220 174 for ilist=1:numel(ListVar) 175 Field.VarAttribute{ilist+NbCoord}.Role=Role{ilist}; 176 Field.VarAttribute{ilist+NbCoord}.ProjModeRequest=ProjModeRequest{ilist}; 177 if isfield(ParamIn,'FieldName') 178 Field.VarAttribute{ilist+NbCoord}.FieldName=ListInputField{ilist}; 179 end 180 r=regexp(ListInputField{ilist},'(?<Operator>(^vec^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); 181 if ~isempty(r)&& strcmp(r.Operator,'norm') 182 NormName='norm'; 183 if ~isempty(find(strcmp(ListVar,'norm'))) 184 NormName='norm_1'; 185 end 186 Field.ListVarName=[Field.ListVarName {NormName}]; 187 ilistmax=numel(Field.ListVarName); 188 Field.VarDimName{ilistmax}=Field.VarDimName{ilist+2}; 189 Field.VarAttribute{ilistmax}.Role='scalar'; 190 Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName); 191 Field.(NormName)=sqrt(Field.(NormName)); 192 UName=r.UName; 193 VName=r.VName; 194 end 195 end 196 197 if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables 198 ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName 199 ind_var_V=find(strcmp(VName,ListVar));%check previous listing of variable r.VName 200 if ~checkU && ~checkV 201 Field.ListVarName([ind_var_U+2 ind_var_V+2])=[]; 202 Field.VarDimName([ind_var_U+2 ind_var_V+2])=[]; 203 Field.VarAttribute([ind_var_U+2 ind_var_V+2])=[]; 204 elseif ~checkU 205 Field.ListVarName(ind_var_U+2)=[]; 206 Field.VarDimName(ind_var_U+2)=[]; 207 Field.VarAttribute(ind_var_U+2 )=[]; 208 elseif ~checkV 209 Field.ListVarName(ind_var_V+2)=[]; 210 Field.VarDimName(ind_var_V+2)=[]; 211 Field.VarAttribute(ind_var_V+2 )=[]; 212 end 213 end 214 % insert coordinates as indices in case of plots vs matrix index 215 if isfield(ParamIn,'CheckCoordIndex') && ParamIn.CheckCoordIndex 216 Field.ListVarName=[Field.ListDimName Field.ListVarName]; 217 Field.VarDimName=[Field.ListDimName Field.VarDimName]; 218 for idim=1:numel(Field.ListDimName) 219 CoordName=Field.ListDimName{idim}; 220 Field.(CoordName)=1:Field.DimValue(idim); 221 end 222 Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute]; 223 end 224 end 221 225 case 'video' 222 226 if strcmp(class(ParamIn),'VideoReader') … … 239 243 A=permute(A,[3 2 1]); 240 244 case 'multimage' 241 % warning 'off'245 % warning 'off' 242 246 A=imread(FileName,num); 243 247 case 'image'
Note: See TracChangeset
for help on using the changeset viewer.