Changeset 684
- Timestamp:
- Sep 8, 2013, 10:24:51 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r675 r684 249 249 if numel(Coord{idim})==2 250 250 DCoord_min(idim)= (Coord{idim}(2)-Coord{idim}(1))/(npxy(idim)-1); 251 test_direct(idim)=DCoord_min(idim)>0;% =1 for increasing values, 0 otherwise 251 252 else 252 253 DCoord=diff(Coord{idim}); … … 924 925 XMin=min(ObjectData.RangeX); 925 926 XMax=max(ObjectData.RangeX); 926 testXMin=XMax>XMin; 927 testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has tow distinct elements) 927 928 testXMax=1;% range restriction along X 928 929 end … … 930 931 YMin=min(ObjectData.RangeY); 931 932 YMax=max(ObjectData.RangeY); 932 testYMin=YMax>YMin; 933 testYMin=YMax>YMin;%=1 if YMin defined (i.e. RangeY has tow distinct elements) 933 934 testYMax=1; 934 935 end … … 1041 1042 AYName='coord_y'; 1042 1043 AXName='coord_x'; 1043 if ~strcmp(ObjectData.ProjMode,'projection') 1044 if strcmp(ObjectData.ProjMode,'projection') 1045 ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1046 ProjData.coord_x=[FieldData.XMin FieldData.XMax]; 1047 coord_x_proj=FieldData.XMin:FieldData.CoordMesh:FieldData.XMax; 1048 coord_y_proj=FieldData.YMin:FieldData.CoordMesh:FieldData.YMax; 1049 else 1044 1050 ProjData.coord_y=[ObjectData.RangeY(1) ObjectData.RangeY(2)];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1045 ProjData.coord_x=[ObjectData.RangeX(1) ObjectData.RangeX(2)]; 1046 coord_x_proj=ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2); 1047 coord_y_proj=ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2); 1048 else 1049 ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1050 ProjData.coord_x=[FieldData.XMin FieldData.XMax]; 1051 coord_x_proj=FieldData.XMin:FieldData.CoordMesh:FieldData.XMax; 1052 coord_y_proj=FieldData.YMin:FieldData.CoordMesh:FieldData.YMax; 1053 end 1054 [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1055 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1056 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1051 ProjData.coord_x=[ObjectData.RangeX(1) ObjectData.RangeX(2)]; 1052 coord_x_proj=ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2); 1053 coord_y_proj=ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2); 1054 end 1055 [XI,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1056 % XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1057 % YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1057 1058 else% we use the existing grid from field cell #icell_grid 1058 1059 NbDim=NbDimArray(icell_grid); … … 1062 1063 ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates 1063 1064 end 1064 1065 1066 1065 ProjData.ListVarName={AYName,AXName}; 1066 ProjData.VarDimName={AYName,AXName}; 1067 ProjData.VarAttribute={[],[]}; 1067 1068 end 1068 1069 … … 1276 1277 ProjMode{icell}='interp_lin'; %request linear interpolation for projection on a tilted plane 1277 1278 end 1278 1279 1279 1280 if isequal(ProjMode{icell},'projection')% && (~testangle || test90y || test90x) 1280 1281 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction … … 1284 1285 VarAttribute=[VarAttribute FieldData.VarAttribute(VarIndex)]; 1285 1286 end 1286 1287 1287 ProjData.(AYName)=FieldData.(AYName); 1288 1288 ProjData.(AXName)=FieldData.(AXName); … … 1292 1292 end 1293 1293 else 1294 indY=NbDim-1; 1295 if test_direct(indY) 1296 min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1; 1297 max_indy=floor((YMax-Coord{indY}(1))/DYinit)+1; 1298 Ybound(1)=Coord{indY}(1)+DYinit*(min_indy-1); 1299 Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1); 1294 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1295 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}); 1296 if numel(Coord{NbDim-1})==2 1297 DY=(Coord{NbDim-1}(2)-Coord{NbDim-1}(1))/(DimValue(1)-1); 1298 end 1299 if numel(Coord{NbDim})==2 1300 DX=(Coord{NbDim}(2)-Coord{NbDim}(1))/(DimValue(2)-1); 1301 end 1302 if testYMin%test_direct(indY) 1303 YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min y value for the new field 1304 YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field 1300 1305 else 1301 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1;1302 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1;1303 Ybound(2)=Coord{ indY}(1)-DYinit*(max_indy-1);1304 Ybound(1)=Coord{ indY}(1)-DYinit*(min_indy-1);1305 end 1306 if test _direct(NbDim)==11307 min_indx=ceil((XMin-Coord{NbDim}(1))/DXinit)+1;1308 max_indx=floor((XMax-Coord{NbDim}(1))/DXinit)+1;1309 Xbound(1)=Coord{NbDim}(1)+DX init*(min_indx-1);1310 Xbound(2)=Coord{NbDim}(1)+DX init*(max_indx-1);1306 YIndexMin=(Coord{NbDim-1}(1)-YMax)/DY+1; 1307 YIndexMax=(Coord{NbDim-1}(1)-YMin)/DY+1; 1308 Ybound(2)=Coord{NbDim-1}(1)-DY*(YIndexMax-1); 1309 Ybound(1)=Coord{NbDim-1}(1)-DY*(YIndexMin-1); 1310 end 1311 if testXMin%test_direct(NbDim)==1 1312 XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field 1313 XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max x value for the new field 1314 Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);% x value corresponding to XIndexMin 1315 Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);% x value corresponding to XIndexMax 1311 1316 else 1312 min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1; 1313 max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1; 1314 Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1); 1315 Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1); 1316 end 1317 min_indy=max(min_indy,1);% deals with margin (bound lower than the first index) 1318 min_indx=max(min_indx,1); 1317 XIndexMin=(Coord{NbDim}(1)-XMax)/DX+1; 1318 XIndexMax=(Coord{NbDim}(1)-XMin)/DX+1; 1319 Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1); 1320 Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1); 1321 end 1322 YIndexRange(1)=ceil(min(YIndexMin,YIndexMax));%first y index to select from the previous field 1323 YIndexRange(1)=max(YIndexRange(1),1);% avoid bound lower than the first index 1324 YIndexRange(2)=floor(max(YIndexMin,YIndexMax));%last y index to select from the previous field 1325 YIndexRange(2)=min(YIndexRange(2),DimValue(NbDim-1));% limit to the last available index 1326 XIndexRange(1)=ceil(min(XIndexMin,XIndexMax));%first x index to select from the previous field 1327 XIndexRange(1)=max(XIndexRange(1),1);% avoid bound lower than the first index 1328 XIndexRange(2)=floor(max(XIndexMin,XIndexMax));%last x index to select from the previous field 1329 XIndexRange(2)=min(XIndexRange(2),DimValue(NbDim));% limit to the last available index 1319 1330 if test90y 1320 1331 ind_new=[3 2 1]; … … 1329 1340 eval(['ProjData.' VarName '=squeeze(ProjData.' VarName '(iz,:,:));'])% select the z index iz 1330 1341 end 1331 eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];'])%record the new (projected ) y coordinates1332 eval(['ProjData.' AXName '=[Coord{1}(end),Coord{1}(1)];'])%record the new (projected ) x coordinates1342 ProjData.(AYName)=[Ybound(1) Ybound(2)]; %record the new (projected ) y coordinates 1343 ProjData.(AXName)=[Coord{1}(end),Coord{1}(1)]; %record the new (projected ) x coordinates 1333 1344 else 1334 1345 if NbDim==3 … … 1341 1352 end 1342 1353 end 1343 max_indy=min(max_indy,DimValue(1));%introduce bounds in y and x indices1344 max_indx=min(max_indx,DimValue(2));1345 1354 for ivar=VarIndex% loop on non coordinate variables 1346 1355 VarName=FieldData.ListVarName{ivar}; … … 1351 1360 end 1352 1361 if NbDim==3 1353 eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,min_indy:max_indy,min_indx:max_indx));']);1362 ProjData.(VarName)=squeeze(FieldData.(VarName)(iz,YIndexRange(1):YIndexRange(end),XIndexRange(1):XIndexRange(end))); 1354 1363 else 1355 eval(['ProjData.' VarName '=FieldData.' VarName '(min_indy:max_indy,min_indx:max_indx,:);']);1364 ProjData.(VarName)=FieldData.(VarName)(YIndexRange(1):YIndexRange(end),XIndexRange(1):XIndexRange(end),:); 1356 1365 end 1357 1366 end 1358 eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];'])%record the new (projected ) y coordinates1359 eval(['ProjData.' AXName '=[Xbound(1) Xbound(2)];'])%record the new (projected ) x coordinates1367 ProjData.(AYName)=Coord{NbDim-1}(1)+DY*(YIndexRange-1); %record the new (projected ) y coordinates 1368 ProjData.(AXName)=Coord{NbDim}(1)+DX*(XIndexRange-1); %record the new (projected ) x coordinates 1360 1369 end 1361 1370 end … … 1370 1379 test_interp_tps=0; 1371 1380 end 1372 coord_x_proj=XMin:DX:XMax; 1373 coord_y_proj=YMin:DY:YMax; 1381 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1382 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}); 1383 xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin 1384 ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid 1385 xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame 1386 ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3)); 1387 if testXMin 1388 xcor_new=max(xcor_new,XMin); 1389 end 1390 if testXMax 1391 xcor_new=min(xcor_new,XMax); 1392 end 1393 if testYMin 1394 ycor_new=max(ycor_new,YMin); 1395 end 1396 if testYMax 1397 ycor_new=min(ycor_new,YMax); 1398 end 1399 coord_x_proj=min(xcor_new):DX:max(xcor_new); 1400 coord_y_proj=min(ycor_new):DY:max(ycor_new); 1401 ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates 1402 ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates 1374 1403 [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1375 1404 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1376 1405 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1377 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});1378 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});1379 1406 if numel(Coord{1})==2% x coordiante defiend by its bounds, get the whole set 1380 1407 Coord{1}=linspace(Coord{1}(1),Coord{1}(2),CellInfo{icell}.CoordSize(1)); … … 1392 1419 end 1393 1420 FFName=['FF_' num2str(ind)];% append an index to the name of error flag, FF_1,FF_2... 1394 end 1421 end 1395 1422 % project all variables in the cell 1396 1423 for ivar=VarIndex … … 1947 1974 if test_direct(indY) 1948 1975 min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1; 1949 max_indy=floor((YMax-Coord{indY}(1))/DYinit)+1;1976 YIndexFirst=floor((YMax-Coord{indY}(1))/DYinit)+1; 1950 1977 Ybound(1)=Coord{indY}(1)+DYinit*(min_indy-1); 1951 Ybound(2)=Coord{indY}(1)+DYinit*( max_indy-1);1978 Ybound(2)=Coord{indY}(1)+DYinit*(YIndexFirst-1); 1952 1979 else 1953 1980 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1; -
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' -
trunk/src/set_object.m
r681 r684 758 758 function KeyPressFcn(hObject, eventdata, handles) 759 759 set(handles.REFRESH,'BackgroundColor',[1 0 1])% se REFRESH to magenta color, indicates that refresh needs to be done 760 if strcmp(get(hObject,'Tag'),'num_Angle_3') 761 set(handles.num_RangeX_1,'String','') 762 set(handles.num_RangeX_2,'String','') 763 set(handles.num_RangeY_1,'String','') 764 set(handles.num_RangeY_2,'String','') 765 end 760 766 761 767 %------------------------------------------------------------------------ -
trunk/src/uvmat.m
r683 r684 1905 1905 1906 1906 %% display time interval for the image pair 1907 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time') 1907 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')... 1908 && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1 1908 1909 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); 1909 1910 if isfield(UvData,'TimeUnit')
Note: See TracChangeset
for help on using the changeset viewer.