Page MenuHomec4science

dspComm.sty
No OneTemporary

File Metadata

Created
Thu, Mar 13, 09:42

dspComm.sty

\typeout{dspComm, by Paolo Prandoni, 2013 }
\typeout{contact: paolo.prandoni@epfl.ch}
\typeout{ }
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% Set up constellation plot
%
% \begin{psQAMplot}[OPTIONS]{SIZE}
%
% SIZE number of points on the positive axis
%
% Specialized options:
% decreg=[true|FALSE] draw decision regions
% labels=[TRUE|false] draw axis labels
%
%
\newif\ifPAM
\define@key{psDSP@QAM}{decreg}{\def\qamDecReg{#1}}
\define@choicekey*{psDSP@QAM}{ticks}[\ll\ln]{true,false}[true]{%
\ifcase\ln\relax
\DoXTickstrue
\or
\DoXTicksfalse
\fi}
\define@choicekey*{psDSP@QAM}{pam}[\ll\ln]{true,false}[false]{%
\ifcase\ln\relax
\PAMtrue
\or
\PAMfalse
\fi}
%
\newenvironment{dspConstellation}[2][]{%
\setlength{\dspW}{\dspHeight}\setlength{\dspH}{\dspHeight}
\def\qamNoiseScale{0.2 }
\presetkeys{psDSP@QAM}{decreg=false,ticks=true,pam=false}{}%
\setkeys{dspPZ,psDSP@QAM}{#1}%
\ifPAM\setlength{\dspH}{2em}\def\qamDecReg{false}\fi
%
%% Axes range, increment and labels %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\FPupn\qamSpan{#2 2 * clip}
\FPupn\qamMax{#2 2 * -1 + 0 trunc clip}%
\FPupn\rangeX{\qamMax{} 1 + clip}%
\FPupn\extRange{\rangeX{} 1.1 * 2 trunc clip}%
\ifPAM%
\dspSetDims{-\extRange},{\extRange},{-1},{1},0\relax%
\else%
\dspSetDims{-\extRange},{\extRange},{-\extRange},{\extRange},0\relax%
\fi
%% Ticks
\def\incX{-1}\def\incY{-1}\dspSetupAxes\def\sp{ }
\gdef\dspTickX##1{\psline[linewidth=\dspTickLineWidth,linecolor=\dspAxisColor](##1,-\tickEndX)(##1,\tickEndX)}%
\ifPAM%
\gdef\dspTickLabelX##1##2{\rput[b]{{0}}(##1,\tickTxtX){{##2}}}%
\else%
\gdef\dspTickY##1{\psline[linewidth=\dspTickLineWidth,linecolor=\dspAxisColor](-\tickEndY,##1)(\tickEndY,##1)}%
\gdef\dspTickLabelY##1##2{\uput{{2\dspYTickGap}}[180]{{0}}(! -\tickEndY\sp 0.5 mul ##1 ){{##2}}}%
\gdef\dspTickLabelX##1##2{\rput[b]{{0}}(! ##1 0.2 add \tickTxtX\sp 0.7 mul ){{##2}}}%
\fi
%
\begin{pspicture}(\LX,\BY)(\RX,\TY)
%%% Font %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\def\pshlabel##1{\psframe{##1}}%
%\def\psvlabel##1{\selectPlotFont ##1}%
%%%% Box %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\psaxes[ticks=none,labels=none,linewidth=\dspFrameLineWidth]{->}(0,0)(-\extRange,-\extRange)(\extRange,\extRange)
\psline[linewidth=\dspFrameLineWidth]{->}(-\extRange,0)(\extRange,0)%
\ifPAM\relax\else\psline[linewidth=\dspFrameLineWidth]{->}(0,-\extRange)(0,\extRange,0)%
\uput[-90](\extRange,0){Re}\uput[0](0,\extRange){Im}\fi
\ifthenelse{\equal{\qamDecReg}{true}}{%
\FPsub\numRep#2{1}%
\FPclip\numRep\numRep%
\multips(2,-\rangeX)(2,0){\numRep}{%
\psline[linewidth=0.4pt](0,0)(! 0 2 \rangeX.0 mul)}%
\multips(-2,-\rangeX)(-2,0){\numRep}{%
\psline[linewidth=0.4pt](0,0)(! 0 2 \rangeX.0 mul)}%
\multips(-\rangeX,2)(0,2){\numRep}{%
\psline[linewidth=0.4pt](0,0)(! 2 \rangeX.0 mul 0)}%
\multips(-\rangeX,-2)(0,-2){\numRep}{%
\psline[linewidth=0.4pt](0,0)(! 2 \rangeX.0 mul 0)}%
}{}
}
{
\ifDoXTicks%
\multido{\n=-\qamMax+2}{\qamSpan}{\dspTickX{\n}}%
\multido{\n=-\qamMax+2}{\qamSpan}{\dspTickLabelX{\n}{$\n$}}%
\ifPAM\dspTickX{0}\dspTickLabelX{0}{$0$}\else%
\multido{\n=-\qamMax+2}{\qamSpan}{\dspTickY{\n}}%
\multido{\n=-\qamMax+2}{\qamSpan}{\dspTickLabelY{\n}{$\n$}}\fi
\fi
\end{pspicture}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% Plot QAM point at given coordinates (Specify the type of point)
%
\newcommand{\dspDataPoint}[2][*]{%
\psdot[dotstyle=#1,dotsize=\dspDotSize]#2
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% Plot NOISY QAM dot at given coordinates
%
% Specify point type. To change amount of noise deviation change the
% value of \qamNoiseScale
%
\newcommand{\dspNoisyPoint}[3][diamond*]{%
\psdot[dotstyle=#1,dotsize=\dspDotSize](! #2 rand 100 mod 50 div 1 sub \qamNoiseScale mul add #3 rand 100 mod 50 div 1 sub \qamNoiseScale mul add)
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% Plot entire QAM constellation
%
% Specify point drawing function and point type.
%
\newcommand{\dspFullConstellation}[2][*]{%
\ifPAM \def\iy{0}\def\ya{0}\def\ys{1}\else\def\ya{-\qamMax}\def\ys{\qamSpan}\fi
\multido{\ix=-\qamMax+2}{\qamSpan}{%
\multido{\iy=\ya+2}{\ys}{#2[#1](\ix,\iy)}}}
\makeatother

Event Timeline