Changeset 231 for trunk/src/proj_field.m
- Timestamp:
- Apr 5, 2011, 12:46:34 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r227 r231 1256 1256 %% case of input fields defined on a structured grid 1257 1257 else 1258 'TESTproj' 1259 VarName=FieldData.ListVarName{VarIndex(1)}%get the first variable of the cell to get the input matrix dimensions 1258 VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions 1260 1259 eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions 1261 1260 DimValue(DimValue==1)=[];%remove singleton dimensions … … 1267 1266 return 1268 1267 else 1269 VarType.coord1270 1268 if numel(find(VarType.coord))==2% the third matrix dimension does not correspond to a space coordinate 1271 1269 nbcolor=DimValue(3); … … 1275 1273 end 1276 1274 end 1277 testangle 1275 AYName=FieldData.ListVarName{VarType.coord(NbDim-1)};%name of input x coordinate (name preserved on projection) 1276 AXName=FieldData.ListVarName{VarType.coord(NbDim)};%name of input y coordinate (name preserved on projection) 1278 1277 if testangle% TODO modify name also in case of origin shift in x or y 1279 AY Name='Y';1280 AX Name='X';1278 AYProjName='Y'; 1279 AXProjName='X'; 1281 1280 count=0; 1282 1281 %modify coordinate names if they are already used 1283 1282 while ~(isempty(find(strcmp('AXName',ProjData.ListVarName),1)) && isempty(find(strcmp('AYName',ProjData.ListVarName),1))) 1284 1283 count=count+1; 1285 AY Name=[AYName '_' num2str(count)];1286 AX Name=[AXName '_' num2str(count)];1284 AYProjName=[AYProjName '_' num2str(count)]; 1285 AXProjName=[AXProjName '_' num2str(count)]; 1287 1286 end 1288 1287 else 1289 AYName=FieldData.ListVarName{VarType.coord(NbDim-1)}%name of input x coordinate (name preserved on projection) 1290 AXName=FieldData.ListVarName{VarType.coord(NbDim)}%name of input y coordinate (name preserved on projection) 1291 end 1292 eval(['AX=FieldData.' AXName ';']) 1293 eval(['AY=FieldData.' AYName ';']) 1288 AYProjName=AYName;% (name preserved on projection) 1289 AXProjName=AXName;%name of input y coordinate (name preserved on projection) 1290 end 1294 1291 ListDimName=FieldData.VarDimName{VarIndex(1)}; 1295 ProjData.ListVarName=[ProjData.ListVarName {AYName} {AXName}]; %TODO: check if it already exists in Projdata (several cells)1296 ProjData.VarDimName=[ProjData.VarDimName {AYName} {AXName}];1292 ProjData.ListVarName=[ProjData.ListVarName {AYProjName} {AXProjName}]; %TODO: check if it already exists in Projdata (several cells) 1293 ProjData.VarDimName=[ProjData.VarDimName {AYProjName} {AXProjName}]; 1297 1294 Coord_z=[]; 1298 1295 Coord_y=[]; … … 1392 1389 coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line 1393 1390 end 1394 % case with no rotation andinterpolation1395 if isequal(ProjMode,'projection') && ~testangle1396 if ~testXMin && ~testXMax && ~testYMin && ~testYMax && NbDim==21397 ProjData=FieldData; 1391 % case with no interpolation 1392 if isequal(ProjMode,'projection') && (~testangle || test90y || test90x) 1393 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax 1394 ProjData=FieldData;% no change by projection 1398 1395 else 1399 indY=NbDim-1; 1396 test_direct 1397 indY=NbDim-1 1400 1398 if test_direct(indY) 1401 1399 min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1; … … 1404 1402 Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1); 1405 1403 else 1406 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1 ;1407 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1 ;1408 Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1) ;1409 Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1) ;1404 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1 1405 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1 1406 Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1) 1407 Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1) 1410 1408 end 1411 1409 if test_direct(NbDim)==1 … … 1417 1415 min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1; 1418 1416 max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1; 1419 Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1); 1420 1421 1417 Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1); 1422 1418 Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1); 1423 1419 end … … 1426 1422 1427 1423 if test90y 1428 'TEST3D'1429 1424 ind_new=[3 2 1]; 1430 DimCell=DimCell(ind_new); 1431 DimValue=DimValue(ind_new); 1432 DimCell(1)=[]; %suppress x variable 1433 DimValue(1)=[]; 1425 DimCell={AYProjName,AXProjName} 1426 % DimValue=DimValue(ind_new); 1434 1427 iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1; 1435 1428 for ivar=VarIndex … … 1438 1431 ProjData.VarDimName=[ProjData.VarDimName {DimCell}]; 1439 1432 ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes 1440 eval(['size(FieldData.' VarName ')']) 1441 eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new)'])% permute x and z indices for 90 degree rotation 1442 eval(['size(ProjData.' VarName ')']) 1443 eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz 1444 end 1445 eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates 1446 eval(['ProjData.' AXName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates 1433 eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new);'])% permute x and z indices for 90 degree rotation 1434 eval(['ProjData.' VarName '=squeeze(ProjData.' VarName '(iz,:,:));'])% select the z index iz 1435 end 1436 eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates 1437 eval(['ProjData.' AXProjName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates 1447 1438 else 1448 1439 if NbDim==3 … … 1470 1461 end 1471 1462 end 1472 eval(['ProjData.' AY Name '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates1473 eval(['ProjData.' AX Name '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates1463 eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates 1464 eval(['ProjData.' AXProjName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates 1474 1465 end 1475 1466 end … … 1575 1566 end 1576 1567 end 1577 1568 ProjData 1569 ProjData.VarDimName{3} 1578 1570 %----------------------------------------------------------------- 1579 1571 %projection in a volume
Note: See TracChangeset
for help on using the changeset viewer.