Changeset 650 for trunk/src/proj_field.m
- Timestamp:
- Jun 17, 2013, 6:46:06 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r648 r650 622 622 %% identify vector components 623 623 testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors 624 if testU625 UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};626 VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};627 vector_x=FieldData.(UName);628 vector_y=FieldData.(VName);629 end624 % if testU 625 % UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 626 % VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 627 % vector_x=FieldData.(UName); 628 % vector_y=FieldData.(VName); 629 % end 630 630 %identify error flag 631 631 errorflag=0; %default, no error flag … … 635 635 end 636 636 VarName=FieldData.ListVarName(VarIndex);% cell array of the names of variables to pje 637 ivar_U=[]; 638 ivar_V=[]; 637 639 %% check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 638 640 … … 647 649 coord_x=FieldData.(XName); 648 650 coord_y=FieldData.(YName); 651 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 652 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 653 nbvar=numel(ProjData.ListVarName); 654 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; 649 655 if isequal(ProjMode,'projection') 650 656 if width==0 … … 663 669 Xproj=(coord_x-ObjectData.Coord(1,1))*costheta + (coord_y-ObjectData.Coord(1,2))*sintheta; %projection on the line 664 670 [Xproj,indsort]=sort(Xproj);% sort points by increasing absissa along the projection line 671 ProjData.(XName)=Xproj; 665 672 for ivar=1:numel(VarIndex) 666 673 ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict vrtibles to the projection band 667 674 ProjData.(VarName{ivar})=ProjData.(VarName{ivar})(indsort);% sort by absissa 668 end 669 % project the velocity components if vectors are projected 670 if testU 671 vector_x=ProjData.(UName); 672 ProjData.(UName)=costheta*vector_x+sintheta*ProjData.(VName);% longitudinal component 673 ProjData.(VName)=-sintheta*vector_x+costheta*ProjData.(VName);%transverse component 675 ProjData.ListVarName=[ProjData.ListVarName VarName{ivar}]; 676 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 677 ProjData.VarAttribute{nbvar+ivar}=FieldData.VarAttribute{VarIndex(ivar)};%reproduce var attribute 678 if isfield(ProjData.VarAttribute{nbvar+ivar},'Role') 679 if strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_x'); 680 ivar_U=ivar; 681 elseif strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_y'); 682 ivar_V=ivar; 683 end 684 end 685 ProjData.VarAttribute{ivar+nbvar}.Role='discrete';% will promote plots of the profiles with continuous lines 674 686 end 675 687 elseif isequal(ProjMode,'interp_lin') %filtering %linear interpolation: 676 688 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_x coord_y],FieldData,CellInfo{icell}.FieldName,XI,YI); 677 689 ProjData.X=Xproj; 678 ProjData.ListVarName=[ProjData.ListVarName {XName}];679 ProjData.VarDimName=[ProjData.VarDimName {XName}];680 nbvar=numel(ProjData.ListVarName);681 ProjData.VarAttribute{nbvar}.long_name='abscissa along line';682 690 ProjData.ListVarName=[ProjData.ListVarName ListFieldProj]; 683 691 ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute]; 684 692 for ivar=1:numel(VarAttribute) 685 693 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 694 if isfield(VarAttribute{ivar},'Role') 695 if strcmp(VarAttribute{ivar}.Role,'vector_x'); 696 ivar_U=ivar; 697 elseif strcmp(VarAttribute{ivar}.Role,'vector_y'); 698 ivar_V=ivar; 699 end 700 end 686 701 ProjData.VarAttribute{ivar+nbvar}.Role='continuous';% will promote plots of the profiles with continuous lines 687 702 ProjData.(ListFieldProj{ivar})=ProjVar{ivar}; … … 696 711 FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x_tps}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y_tps})); 697 712 end 698 % coord_x_proj=XMin:DX:XMax;699 % coord_y_proj=YMin:DY:YMax;700 % np_x=numel(coord_x_proj);701 % np_y=numel(coord_y_proj);702 713 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI)); 703 714 ProjData.X=Xproj; 704 ProjData.ListVarName=[ProjData.ListVarName {XName}];705 ProjData.VarDimName=[ProjData.VarDimName {XName}];715 % ProjData.ListVarName=[ProjData.ListVarName {XName}]; 716 % ProjData.VarDimName=[ProjData.VarDimName {XName}]; 706 717 nbvar=numel(ProjData.ListVarName); 707 718 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; … … 711 722 for ivar=1:numel(VarAttribute) 712 723 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 724 if isfield(VarAttribute{ivar},'Role') 725 if strcmp(VarAttribute{ivar}.Role,'vector_x'); 726 ivar_U=ivar; 727 elseif strcmp(VarAttribute{ivar}.Role,'vector_y'); 728 ivar_V=ivar; 729 end 730 end 713 731 ProjData.VarAttribute{ivar+nbvar}.Role='continuous';% will promote plots of the profiles with continuous lines 714 732 ProjData.(ProjVarName{ivar})=DataOut.(ProjVarName{ivar}); … … 822 840 ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line 823 841 end 824 if testU825 vector_x =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x});826 vector_y =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y});827 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y;828 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y;829 end830 ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line';831 842 if nbcolor==3 832 843 ProjData.VarDimName{end}={AXName,'rgb'}; 833 844 end 834 845 end 835 end 846 end 847 if ~isempty(ivar_U) && ~isempty(ivar_V) 848 vector_x =ProjData.(ProjData.ListVarName{nbvar+ivar_U}); 849 ProjData.(ProjData.ListVarName{nbvar+ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V}); 850 ProjData.(ProjData.ListVarName{nbvar+ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V}); 851 end 852 836 853 end 837 854 … … 1152 1169 coord_X=coord_X(indsel); 1153 1170 coord_Y=coord_Y(indsel); 1171 for ivar=1:numel(CellInfo{icell}.VarIndex) 1172 VarName=FieldData.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 1173 FieldData.(VarName)=FieldData.(VarName)(indsel); 1174 end 1154 1175 end 1155 1176 % testFF=0; 1156 % nbvar=numel(ProjData.ListVarName); 1157 if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')1158 VarName_x=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};1159 VarName_y=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};1160 if isfield(CellInfo{icell},'VarIndex_errorflag')1161 FieldData.(VarName_x)=FieldData.(VarName_x)(indsel);1162 FieldData.(VarName_y)=FieldData.(VarName_y)(indsel);1163 end1164 %FieldVar=cat(2,FieldData.(VarName_x),FieldData.(VarName_y));1165 if ~isfield(CellInfo{icell},'CheckSub') || ~CellInfo{icell}.CheckSub1166 vector_x_proj=numel(ProjData.ListVarName)+1;1167 vector_y_proj=numel(ProjData.ListVarName)+2;1168 end1169 end1170 if isfield(CellInfo{icell},'VarIndex_scalar')1171 VarName_scalar=FieldData.ListVarName{CellInfo{icell}.VarIndex_scalar};1172 if isfield(CellInfo{icell},'errorflag') && ~isempty(CellInfo{icell}.errorflag)1173 FieldData.(VarName_scalar)=FieldData.(VarName_scalar)(indsel);1174 end1175 end1176 if isfield(CellInfo{icell},'VarIndex_ancillary')% do not project ancillary data with interp1177 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_ancillary});1178 end1179 if isfield(CellInfo{icell},'VarIndex_warnflag')% do not project ancillary data with interp1180 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag});1181 end1177 % nbvar=numel(ProjData.ListVarName); 1178 % if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') 1179 % VarName_x=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 1180 % VarName_y=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 1181 % if isfield(CellInfo{icell},'VarIndex_errorflag') 1182 % FieldData.(VarName_x)=FieldData.(VarName_x)(indsel); 1183 % FieldData.(VarName_y)=FieldData.(VarName_y)(indsel); 1184 % end 1185 % %FieldVar=cat(2,FieldData.(VarName_x),FieldData.(VarName_y)); 1186 % if ~isfield(CellInfo{icell},'CheckSub') || ~CellInfo{icell}.CheckSub 1187 % vector_x_proj=numel(ProjData.ListVarName)+1; 1188 % vector_y_proj=numel(ProjData.ListVarName)+2; 1189 % end 1190 % end 1191 % if isfield(CellInfo{icell},'VarIndex_scalar') 1192 % VarName_scalar=FieldData.ListVarName{CellInfo{icell}.VarIndex_scalar}; 1193 % if isfield(CellInfo{icell},'errorflag') && ~isempty(CellInfo{icell}.errorflag) 1194 % FieldData.(VarName_scalar)=FieldData.(VarName_scalar)(indsel); 1195 % end 1196 % end 1197 % if isfield(CellInfo{icell},'VarIndex_ancillary')% do not project ancillary data with interp 1198 % FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_ancillary}); 1199 % end 1200 % if isfield(CellInfo{icell},'VarIndex_warnflag')% do not project ancillary data with interp 1201 % FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag}); 1202 % end 1182 1203 % interpolate and calculate field on the grid 1183 1204 [VarVal,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.FieldName,XI,YI);
Note: See TracChangeset
for help on using the changeset viewer.