Changeset 672 for trunk/src/proj_field.m
 Timestamp:
 Aug 6, 2013, 3:47:07 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/proj_field.m
r655 r672 1012 1012 else 1013 1013 %% case of a grid requested by the input field 1014 1015 1014 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates 1016 1015 if isfield(CellInfo{icell},'ProjModeRequest') … … 1545 1544 test_interp_tps=0; 1546 1545 end 1547 % ProjData.coord_y=[YMin YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined1548 % ProjData.coord_x=[XMin XMax];1549 1546 coord_x_proj=XMin:DX:XMax; 1550 1547 coord_y_proj=YMin:DY:YMax; … … 1552 1549 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1553 1550 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1554 [X,Y]=meshgrid(Coord{2},Coord{1});%initial coordiantes 1551 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1552 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}); 1553 if numel(Coord{1})==2% x coordiante defiend by its bounds, get the whole set 1554 Coord{1}=linspace(Coord{1}(1),Coord{1}(2),CellInfo{icell}.CoordSize(1)); 1555 end 1556 if numel(Coord{2})==2% y coordiante defiend by its bounds, get the whole set 1557 Coord{2}=linspace(Coord{2}(1),Coord{2}(2),CellInfo{icell}.CoordSize(2)); 1558 end 1559 [X,Y]=meshgrid(Coord{2},Coord{1});%initial coordinates 1560 %name of error flag variable 1561 FFName='FF';%default name (if not already used) 1562 if isfield(ProjData,'FF') 1563 ind=1; 1564 while isfield(ProjData,['FF_' num2str(ind)]) 1565 ind=ind+1; 1566 end 1567 FFName=['FF_' num2str(ind)];% append an index to the name of error flag, FF_1,FF_2... 1568 end 1569 % project all variables in the cell 1555 1570 for ivar=VarIndex 1556 1571 VarName=FieldData.ListVarName{ivar}; 1557 % if test_interp(1)  test_interp(2)%interpolate on a regular grid1558 1572 if size(FieldData.(VarName),3)==1 1559 1573 ProjData.(VarName)=interp2(X,Y,double(FieldData.(VarName)),XI,YI,'*linear'); 1560 1574 else 1561 1575 ProjData.(VarName)=interp2(X,Y,double(FieldData.(VarName)(:,:,1)),XI,YI,'*linear'); 1562 for icolor=2:size(FieldData.(VarName),3) 1576 for icolor=2:size(FieldData.(VarName),3)% project 'color' components 1563 1577 ProjData.(VarName)=cat(3,ProjData.(VarName),interp2(X,Y,double(FieldData.(VarName)(:,:,icolor)),XI,YI,'*linear')); %TO TEST 1564 1578 end … … 1570 1584 VarAttribute{length(ListVarName)+nbcoord}=FieldData.VarAttribute{ivar}; 1571 1585 end; 1572 end 1586 ProjData.(FFName)=isnan(ProjData.(VarName));%detact NaN (points outside the interpolation range) 1587 ProjData.(VarName)(ProjData.(FFName))=0; %set to 0 the NaN data 1588 end 1589 %update list of variables with error flag 1590 ListVarName=[ListVarName FFName]; 1591 VarDimName=[VarDimName {DimCell}]; 1592 VarAttribute{numel(ListVarName)}.Role='errorflag'; 1573 1593 elseif ~testangle 1574 1594 % unstructured z coordinate
Note: See TracChangeset
for help on using the changeset viewer.