Changeset 782 for trunk/src/plot_field.m
- Timestamp:
- Jun 3, 2014, 8:10:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r781 r782 694 694 XName=Data.ListVarName{ivar_X}; 695 695 YName=Data.ListVarName{ivar_Y}; 696 eval([' AX=reshape(Data.' XName ',1,[]);'])697 eval([' AY=reshape(Data.' YName ',1,[]);'])698 [A, AX,AY]=proj_grid(AX',AY',A',[],[],'np>256'); % interpolate on a grid696 eval(['Coord_x=reshape(Data.' XName ',1,[]);']) 697 eval(['Coord_y=reshape(Data.' YName ',1,[]);']) 698 [A,Coord_x,Coord_y]=proj_grid(Coord_x',Coord_y',A',[],[],'np>256'); % interpolate on a grid 699 699 if isfield(Data,'VarAttribute') 700 700 if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units') … … 707 707 elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 708 708 YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 709 AY=Data.(YName);710 AX=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});709 Coord_y=Data.(YName); 710 Coord_x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)}); 711 711 test_interp_X=0; %default, regularly meshed X coordinate 712 712 test_interp_Y=0; %default, regularly meshed Y coordinate … … 719 719 end 720 720 end 721 if numel( AY)>2722 D AY=diff(AY);723 D AY_min=min(DAY);724 D AY_max=max(DAY);725 if sign(D AY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise721 if numel(Coord_y)>2 722 DCoord_y=diff(Coord_y); 723 DCoord_y_min=min(DCoord_y); 724 DCoord_y_max=max(DCoord_y); 725 if sign(DCoord_y_min)~=sign(DCoord_y_max);% =1 for increasing values, 0 otherwise 726 726 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ]; 727 727 return 728 728 end 729 test_interp_Y=(D AY_max-DAY_min)> 0.0001*abs(DAY_max);730 end 731 if numel( AX)>2732 D AX=diff(AX);733 D AX_min=min(DAX);734 D AX_max=max(DAX);735 if sign(D AX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise729 test_interp_Y=(DCoord_y_max-DCoord_y_min)> 0.0001*abs(DCoord_y_max); 730 end 731 if numel(Coord_x)>2 732 DCoord_x=diff(Coord_x); 733 DCoord_x_min=min(DCoord_x); 734 DCoord_x_max=max(DCoord_x); 735 if sign(DCoord_x_min)~=sign(DCoord_x_max);% =1 for increasing values, 0 otherwise 736 736 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ]; 737 737 return 738 738 end 739 test_interp_X=(D AX_max-DAX_min)> 0.0001*abs(DAX_max);739 test_interp_X=(DCoord_x_max-DCoord_x_min)> 0.0001*abs(DCoord_x_max); 740 740 end 741 741 if test_interp_Y 742 npxy(1)=max([256 floor(( AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);743 yI=linspace( AY(1),AY(end),npxy(1));742 npxy(1)=max([256 floor((Coord_y(end)-Coord_y(1))/DCoord_y_min) floor((Coord_y(end)-Coord_y(1))/DCoord_y_max)]); 743 yI=linspace(Coord_y(1),Coord_y(end),npxy(1)); 744 744 if ~test_interp_X 745 xI=linspace( AX(1),AX(end),size(A,2));%default746 AX=xI;745 xI=linspace(Coord_x(1),Coord_x(end),size(A,2));%default 746 Coord_x=xI; 747 747 end 748 748 end 749 749 if test_interp_X 750 npxy(2)=max([256 floor(( AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);751 xI=linspace( AX(1),AX(end),npxy(2));750 npxy(2)=max([256 floor((Coord_x(end)-Coord_x(1))/DCoord_x_min) floor((Coord_x(end)-Coord_x(1))/DCoord_x_max)]); 751 xI=linspace(Coord_x(1),Coord_x(end),npxy(2)); 752 752 if ~test_interp_Y 753 yI=linspace( AY(1),AY(end),size(A,1));754 AY=yI;753 yI=linspace(Coord_y(1),Coord_y(end),size(A,1)); 754 Coord_y=yI; 755 755 end 756 756 end 757 757 if test_interp_X || test_interp_Y 758 [ AX2D,AY2D]=meshgrid(AX,AY);759 A=interp2( AX2D,AY2D,double(A),xI,yI');760 end 761 AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation762 AY=[AY(1) AY(end)];758 [Coord_x2D,Coord_y2D]=meshgrid(Coord_x,Coord_y); 759 A=interp2(Coord_x2D,Coord_y2D,double(A),xI,yI'); 760 end 761 Coord_x=[Coord_x(1) Coord_x(end)];% keep only the lower and upper bounds for image represnetation 762 Coord_y=[Coord_y(1) Coord_y(end)]; 763 763 end 764 764 end … … 874 874 cont_pos=[cont_pos_min cont_pos_plus];% set of all contour values 875 875 876 sizpx=( AX(end)-AX(1))/(np(2)-1);877 sizpy=( AY(1)-AY(end))/(np(1)-1);878 x_cont= AX(1):sizpx:AX(end); % pixel x coordinates for image display879 y_cont= AY(1):-sizpy:AY(end); % pixel x coordinates for image display876 sizpx=(Coord_x(end)-Coord_x(1))/(np(2)-1); 877 sizpy=(Coord_y(1)-Coord_y(end))/(np(1)-1); 878 x_cont=Coord_x(1):sizpx:Coord_x(end); % pixel x coordinates for image display 879 y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display 880 880 881 881 %axes(haxes)% set the input axes handle as current axis … … 963 963 end 964 964 if test_interp%if we interpolate 965 x=linspace( AX(1),AX(2),np(2));966 y=linspace( AY(1),AY(2),np(1));965 x=linspace(Coord_x(1),Coord_x(2),np(2)); 966 y=linspace(Coord_y(1),Coord_y(2),np(1)); 967 967 [X,Y]=meshgrid(x,y); 968 xi=linspace( AX(1),AX(2),npxy(2));969 yi=linspace( AY(1),AY(2),npxy(1));968 xi=linspace(Coord_x(1),Coord_x(2),npxy(2)); 969 yi=linspace(Coord_y(1),Coord_y(2),npxy(1)); 970 970 A = interp2(X,Y,double(A),xi,yi'); 971 971 end … … 974 974 tag=get(haxes,'Tag'); 975 975 if MinA<MaxA 976 hima=imagesc( AX,AY,A,[MinA MaxA]);976 hima=imagesc(Coord_x,Coord_y,A,[MinA MaxA]); 977 977 else % to deal with uniform field 978 hima=imagesc( AX,AY,A,[MaxA-1 MaxA]);978 hima=imagesc(Coord_x,Coord_y,A,[MaxA-1 MaxA]); 979 979 end 980 980 % the function imagesc reset the axes 'DataAspectRatioMode'='auto', change if .CheckFixAspectRatio is … … 992 992 set(haxes,'CLim',[MinA MaxA+1]) 993 993 end 994 set(hima,'XData', AX);995 set(hima,'YData', AY);994 set(hima,'XData',Coord_x); 995 set(hima,'YData',Coord_y); 996 996 end 997 997 … … 1193 1193 else 1194 1194 if test_ima %both background image and vectors coexist, take the wider bound 1195 MinX=min( AX);1196 MaxX=max( AX);1197 MinY=min( AY);1198 MaxY=max( AY);1195 MinX=min(Coord_x); 1196 MaxX=max(Coord_x); 1197 MinY=min(Coord_y); 1198 MaxY=max(Coord_y); 1199 1199 if test_vec 1200 1200 MinX=min(MinX,min(vec_X));
Note: See TracChangeset
for help on using the changeset viewer.