%-----------------------------------------------------------------------
%;  Copyright (C) 2025
%;  Associated Universities, Inc. Washington DC, USA.
%;
%;  This program is free software; you can redistribute it and/or
%;  modify it under the terms of the GNU General Public License as
%;  published by the Free Software Foundation; either version 2 of
%;  the License, or (at your option) any later version.
%;
%;  This program is distributed in the hope that it will be useful,
%;  but WITHOUT ANY WARRANTY; without even the implied warranty of
%;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%;  GNU General Public License for more details.
%;
%;  You should have received a copy of the GNU General Public
%;  License along with this program; if not, write to the Free
%;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
%;  MA 02139, USA.
%;
%;  Correspondence concerning AIPS should be addressed as follows:
%;          Internet email: aipsmail@nrao.edu.
%;          Postal address: AIPS Project Office
%;                          National Radio Astronomy Observatory
%;                          520 Edgemont Road
%;                          Charlottesville, VA 22903-2475 USA
%-----------------------------------------------------------------------
\documentclass[twoside]{article}
\usepackage{palatino}
\renewcommand{\ttdefault}{cmtt}
% Highlight new text.
\usepackage{color}
\usepackage{alltt}
\usepackage{graphicx,xspace}
\usepackage{pstricks}  % added by Greisen
\definecolor{hicol}{rgb}{0.6,0.05,0.05}
\definecolor{mecol}{rgb}{0.1,0.1,0.6}
\definecolor{excol}{rgb}{0.05,0.5,0.05}
\newcommand{\Hi}[1]{\textcolor{hicol}{#1}}
%\newcommand{\Hi}[1]{\textcolor{black}{#1}}
\newcommand{\Me}[1]{\textcolor{mecol}{#1}}
%\newcommand{\Me}[1]{\textcolor{black}{#1}}
\newcommand{\Ex}[1]{\textcolor{excol}{#1}}
%\newcommand{\Ex}[1]{\textcolor{black}{#1}}
\newcommand{\No}[1]{\textcolor{black}{#1}}
\newcommand{\hicol}{\color{hicol}}
%\newcommand{\hicol}{\color{black}}
\newcommand{\mecol}{\color{mecol}}
%\newcommand{\mecol}{\color{black}}
\newcommand{\excol}{\color{excol}}
%\newcommand{\excol}{\color{black}}
\newcommand{\hblack}{\color{black}}
%
\newcommand{\AIPS}{{$\cal AIPS\/$}}
\newcommand{\eg}{{\it e.g.},}
\newcommand{\ie}{{\it i.e.},}
\newcommand{\etal}{{\it et al.}}
\newcommand{\tablerowgapbefore}{-1ex}
\newcommand{\tablerowgapafter}{1ex}
\newcommand{\keyw}[1]{\hbox{{\tt #1}}}
\newcommand{\sub}[1]{_\mathrm{#1}}
\newcommand{\degr}{^{\circ}}
\newcommand{\vv}{v}
%\newcommand{\vv}{\varv}
\newcommand{\eq}{\hbox{\hspace{0.6em}=\hspace{0.6em}}}
\newcommand{\newfig}[2]{\includegraphics[width=#1]{data.fig#2}}
%\newcommand{\putfig}[1]{\includegraphics{data.fig#1.eps}}
%\newcommand{\putfig}[1]{\includegraphics{#1.eps}}
\newcommand{\putfig}[1]{\includegraphics{#1}}
\newcommand{\whatmem}{\AIPS\ Memo \memnum}
\newcommand{\boxit}[3]{\vbox{\hrule height#1\hbox{\vrule width#1\kern#2%
\vbox{\kern#2{#3}\kern#2}\kern#2\vrule width#1}\hrule height#1}}
%
\newcommand{\memnum}{126 \Hi{Revised}}
\newcommand{\memtit}{Spectral index fitting in \AIPS}
\title{
   \vskip -35pt
   \fbox{{\large\whatmem}} \\
   \vskip 28pt
%   \vskip 10pt
%   \fbox{{\Huge \Me{D R A F T}}}
%   \vskip 10pt
   \memtit \\}
\author{Eric W. Greisen}
%
\parskip 4mm
\linewidth 6.5in                     % was 6.5
\textwidth 6.5in                     % text width excluding margin 6.5
\textheight 9.0 in                  % was 8.81
\marginparsep 0in
\oddsidemargin .25in                 % EWG from -.25
\evensidemargin -.25in
\topmargin -0.4in
%\topmargin 0.2in
\headsep 0.25in
\headheight 0.25in
\parindent 0in
\newcommand{\normalstyle}{\baselineskip 4mm \parskip 2mm \normalsize}
\newcommand{\tablestyle}{\baselineskip 2mm \parskip 1mm \small }
%
%
\begin{document}

\pagestyle{myheadings}
\thispagestyle{empty}

\newcommand{\Rheading}{\whatmem \hfill \memtit \hfill Page~~}
\newcommand{\Lheading}{~~Page \hfill \memtit \hfill \whatmem}
\markboth{\Lheading}{\Rheading}
%
\vskip -.5cm
\pretolerance 10000
\listparindent 0cm
\labelsep 0cm
%
%

\vskip -30pt
\maketitle

\normalstyle
\begin{abstract}
  \AIPS\ has had the task {\tt SPIXR} to fit the spectral index of image
  cubes since 2005.  Beginning in the {\tt 31DEC24} release, a new
  interactive task called {\tt TVSPX} became available.  It does the
  same fitting as {\tt SPIXR} but then allows the user to examine the
  results and to try to improve upon them.  This Memo will describe the
  usage of this new task.
\end{abstract}

\renewcommand{\floatpagefraction}{0.75}
\typeout{bottomnumber = \arabic{bottomnumber} \bottomfraction}
\typeout{topnumber = \arabic{topnumber} \topfraction}
\typeout{totalnumber = \arabic{totalnumber} \textfraction\ \floatpagefraction}

\section{Introduction}

Spectral index has the definition in \AIPS\
$$
   \log(T(x,y,f)) = \log(T(x,y,f_0)) + S(x,y) \log(f/f_0) +
    C(x,y) (\log(f/f_0))^2
$$
where the logarithms are base 10, $T(x,y,f)$ is the brightness or
flux density at a particular spatial coordinate and frequency, $x$ and
$y$ are the spatial coordinates, $f$ is frequency, $f_0$ is a reference
frequency, $S(x,y)$ is the ``spectral index'' and $C(x,y)$ is the
``spectral curvature''.

\AIPS\ has had the ability to fit images for spectral index for a very
long time.  In the early days of the VLA, this took the form of an
operation in task {\tt COMB} to compute the spectral index from two
continuum images.  In 2005, the task {\tt SPIXR} was written.  It takes
a spectral-line cube that has been transposed to make the first axis be
the spectral axis.  That axis has units of frequency in Hz and can
either be a regularly gridded function or an irregularly spaced axis
whose values are described in an {\tt FQ} table.  As will be described
below, the task has a number of adverbs which allow the user to reject
anomalous solutions.  These solutions are simply blanked in the output
images of $T$, $S$, and $C$\@.  In many cases, this is a quite
reasonable result due to low signal levels and the like.  However, some
cubes contain many good spectral channels with some channels adversely
affected by RFI or poor calibration and imaging.  The new task {\tt
  TVSPX} was written to allow the user to locate pixels for which good
solutions are possible if some of the spectral channels are omitted.

\section{Spectral index fitting: {\tt SPIXR}}

The usual {\tt INNAME} {\it et al.} adverbs define the three-dimensional
image cube to be fit.  The cube is required to be transposed so that the
frequency axis is first.  That axis may be called {\tt FREQ}, {\tt
  FQID}, or {\tt SEQ.NUM.}\@.  The usual {\tt OUTNAME}, {\it et al.}
adverbs specify the name, sequence number, and disk of the output
images.  The {\tt OUTCLASS} is controlled by the task as described below.
Adverbs {\tt BLC} and {\tt TRC} may be used to limit the extent of the
cube that is fit and the size of the output images.  {\tt FLUX}
specifies the lowest brightness (usually in Jy/beam) used in the fit.
{\tt REFREQ} specifies $f_0$ in GHz where 0 says to use 1 GHz and less
than 0 says to use the header frequency.  {\tt OPTYPE = 'CURV'} tells
the task to solve for curvature ($C$) as well as spectral index.
Otherwise only spectral index ($S$) is computed.  {\tt PBPARM} is used
to adjust the {\tt FLUX} cutoff for primary beam with {\tt PBPARM(1) =
  0} turning the correction off.  Output pixels are flagged if

\begin{center}
  \begin{eqnarray*}
    N(x,y)              & < & {\tt DPARM(1)} \\
    S(x,y)              & < & {\tt DPARM(2)} \\
    S(x,y)              & > & {\tt DPARM(3)} \\
    T(x,y,f_0) / T_{min} & < & {\tt DPARM(4)} \\
    T(x,y,f_0) / T_{max} & > & {\tt DPARM(5)} \\
    T(x,y,f_0)          & < & {\tt DPARM(6)} \\
    T(x,y,f_0)          & > & {\tt DPARM(7)} \\
    C(x,y)              & < & {\tt DPARM(8)} \\
    C(x,y)              & > & {\tt DPARM(9)} \\
    \sigma(T(x,y,f_0))  & > & {\tt CPARM(1)} \\
    \sigma(S(x,y))      & > & {\tt CPARM(2)} \\
    \sigma(C(x,y))      & > & {\tt CPARM(3)}
  \end{eqnarray*}
\end{center}

$T_{min}$ is the minimum brightness included in the fit at the present
$(x,y)$ and $T_{max}$ is the maximum brightness in that fit.  $N(x,y)$
is the number of data samples included in the fit, \ie\ the number with
brightness $>$ beam corrected {\tt FLUX}\@.  The $\sigma()$ are the
uncertainties in the fit.  Default values for the {\tt DPARM} and {\tt
  CPARM} are set so that no pixels are flagged if there are enough
spectral channels above {\tt FLUX} to do a fit.

The 7 output images have class name {\tt 'B TEMP'} for $T(x,y,f_0)$,
{\tt 'D BT'} for $\sigma(T(x,y,f_0))$, {\tt 'SP CNT'} for $N(x,y)$, {\tt
  'SPIX'} for $S(x,y)$, {\tt 'D SPIX'} for $\sigma(S(x,y))$, and,
optionally, {\tt 'SPCU'} for $C(x,y)$ and {\tt 'D SPCU'} for
$\sigma(C(x,y))$.

\section{Interactive task {\tt TVSPX}}

Beginning in \AIPS\ version {\tt 31DEC24}, the task {\tt TVSPX} allows
the user to attempt to improve the results of {\tt SPIXR} before the
final images are written to disk.  It has exactly the same adverbs as
{\tt SPIXR} used in the same way.  The flagging caused by {\tt DPARM}
and {\tt CPARM} is applied to any fit done in {\tt TVSPX} including in
the interactive phase.  {\tt TVSPX} begins by computing the output
images exactly like {\tt SPIXR}\@.

At that point, the \AIPS\ TV screen shows a two-column menu as
illustrated in Figure~\ref{fig:spxmain}.  The right-hand side is

\begin{figure}
\begin{center}
\resizebox{5.6in}{!}{\putfig{TVSPXa.eps}}
\caption{Main interactive window after a {\tt SHOW IMAGE BR}, a {\tt
    LABEL WEDGE}, a {\tt SET SPIX RANGE}, and two {\tt SET MAX ER}
  operations.  The image is a trivial example produced by new task
  {\tt SPXMD}\@.}
\label{fig:spxmain}
\end{center}
\end{figure}

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt SHOW IMAGE NP  } & Enter image interaction with image of number of
                        channels used in fit\\
 {\tt SHOW IMAGE BR  } & Enter image interaction with brightness image\\
 {\tt SHOW IMAGE EBR } & Enter image interaction with uncertainty in
                         brightness image\\
 {\tt SHOW IMAGE SP  } & Enter image interaction with spectral index image\\
 {\tt SHOW IMAGE ESP } & Enter image interaction with uncertainty in
                         spectral index image\\
 {\tt SHOW IMAGE CU  } & Enter image interaction with spectral curvature
                         image\\
 {\tt SHOW IMAGE ECU } & Enter image interaction with uncertainty in
                         spectral curvature image\\ \hline
\end{tabular}
\end{center}

To select one of these options in all menus, move the TV cursor to the
option which will cause it to change color.  Pressing button D causes
helpful information to appear in the window in which you are running
{\tt AIPS}\@.  Press keyboard letters A, B, or C to select an image to
display.  This causes an image display window to appear with its own
menu and a display of the selected image in whole or in a previously
selected sub-window.  That screen will be illustrated and described
below.  But first, let us describe the left-hand menu in the main
screen.

\begin{center}
\begin{tabular}{|l|l|}\hline
  {\tt EXIT             } & Exit {\tt TVSPX}, writing output images\\
  {\tt ABORT            } & Exit {\tt TVSPX}, deleting output images\\
  {\tt                  } & \\
  {\tt SET BRIGHT RANGE } & Set range of valid brightness values\\
  {\tt SET SPIX RANGE   } & Set range of valid spectral index values\\
  {\tt SET CURV RANGE   } & Set range of valid spectral curvature values\\
  {\tt SET MAX ER BR    } & Set maximum uncertainty in brightness\\
  {\tt SET MAX ER SPIX  } & Set maximum uncertainty in spectral index\\
  {\tt SET MAX ER CURV  } & Set maximum uncertainty in spectral curvature\\
  {\tt REDO ALL         } & Re-do all solutions which are not okay
                            following the above criteria\\
  {\tt FLAG ALL         } & Mark bad all solutions which are not okay\\
  {\tt                  } & \\
  {\tt ADD TO LIST      } & Type in output pixel coordinates to add to
                            list\\
  {\tt CLEAR LIST       } & To reset the list to empty\\
  {\tt SHOW LIST        } & Display pixel coordinates in list\\
  {\tt REDO LIST        } & Re-do solutions for all pixels in list\\
  {\tt FLAG LIST        } & Flag solutions for all pixels in list\\
  {\tt                  } & \\
  {\tt OFF ZOOM         } & Turn of TV zoom\\
  {\tt OFF TRANSFER     } & Turn off black \&\ white and color TV
                            enhancements\\
  {\tt RESET WINDOW     } & Display full view of current image \\
  {\tt LABEL WEDGE?     } & Turn on/off labeling of step wedge \\
  {\tt CHAR MULT        } & Set the character size multiplier\\\hline
\end{tabular}
\end{center}

This menu enables two forms of editing.  The first form edits all pixels
which have values outside user-specified ranges.  The {\tt SET BRIGHT
  RANGE} option prompts the user for 2 numbers to be entered in the
window in which {\tt AIPS} is being run.  If the first is less than the
second, values of $T(x,y,f_0)$ less than the first or greater than the
second are viewed as suspect.  If the first is greater than the second,
values of $T(x,y,f_0)$ between the two are viewed as suspect.  The
{\tt SET SPIX RANGE} and {\tt SET CURV RANGE} are similar and apply to
$S(x,y)$ and $C(x,y)$, respectively.  The {\tt SET MAX ER} options
prompt for a single number which is viewed as the maximum uncertainty
that is not viewed as suspect in the specified parameter.  These limits
are displayed at the top of the screen after they are set.  Then the
{\tt FLAG ALL} option will flag all ``suspect'' pixels, while the {\tt
  REDO ALL} will enter an interactive window for each ``suspect'' pixel
in turn.  The range and error limits are reset after {\tt FLAG ALL} and,
if not terminated prematurely, after {\tt REDO ALL}\@.

The second form of editing begins with a list of $(x,y)$ pixels to be
edited.  {\tt ADD TO LIST} allows the user to type in an $x$, $y$ pair
to be added to the list while {\tt CLEAR LIST} empties the list, and
{\tt SHOW LIST} shows the current list in the message window.  The
image display window allows the list to be increased by selecting
pixels with a button push while running {\tt CURVALUE}\@.  Then
{\tt FLAG LIST} will mark all pixels in the list as bad and {\tt REDO
  LIST} will enter the interactive editing window for each entry in the
list.  The list is cleared after the former and reduced to any pixels
not processed in the latter.

The other options turn off any zoom setting, reset any black and white
or color enhancements, reset the sub-image selection to the full image,
turn on or off the labeling of the step wedge, and, for large TV windows
only, change the size of the displayed characters.

When a {\tt SHOW IMAGE} option is selected, a new window appears.  At
the top a text line in yellow identifies the type of image and the
range of pixel values displayed.  The image itself is displayed and
labeled in red with the robust and full mean and rms of the full image.
The displayed image is either the full image or a selected sub-image.
The image is accompanied with a step wedge which may or may not be
labeled.  This screen is illustrated in Figure~\ref{fig:spximage}.  This
screen is accompanied by a menu containing

\begin{figure}
\begin{center}
\resizebox{4.65in}{!}{\putfig{TVSPXb.eps}}
\centerline{\hphantom{MM}}
\resizebox{4.65in}{!}{\putfig{TVSPXc.eps}}
\caption{Top: Image display window showing the spectral index image
  before any interactive flagging.  Pixels with spectral index $< -3$ or
  $> 3$ were flagged by {\tt DPARM}, but many bad pixels remain.
  Bottom: image after a {\tt FLAG ALL} was applied using the limits
  shown in Figure~\ref{fig:spxmain}.}
\label{fig:spximage}
\end{center}
\end{figure}

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt RETURN      } & Return to the main menus, image stays displayed\\
 {\tt             } & \\
 {\tt LOAD AS SQ  } & Re-load image with square root transfer function\\
 {\tt LOAD AS LG  } & Re-load image with log transfer function\\
 {\tt LOAD AS L2  } & Re-load image with extreme log transfer function\\
 {\tt LOAD AS LN  } & Re-load image with linear transfer function\\
 {\tt SET WINDOW  } & Set a sub-image to view\\
 {\tt RESET WINDOW} & Return too viewing the full image\\
 {\tt OFF TRANSF  } & Turn off enhancement done with {\tt TVTRANSF}\\
 {\tt OFF COLOR   } & Turn off color enhancements\\
 {\tt TVTRANSF    } & Black \&\ white image enhancement\\
 {\tt TVPSEUDO    } & Color enhancement of numerous sorts\\
 {\tt TVPHLAME    } & Color enhancement of flame type, multiple colors\\
\Hi{{\tt OFMCOLOR}} & \Hi{Many standard color tables (OFMs) available} \\
 {\tt TVZOOM      } & Interactive zooming and centering of image\\
 {\tt IMSTAT      } & Compute statistics of current sub-window\\
 {\tt CURVALUE    } & Display value under cursor, mark pixels for list\\
 {\tt NEXT WINDOW } & Move to next window in large images\\ \hline
\end{tabular}
\end{center}

The image is initially loaded with a linear transfer function.  Only one
{\tt LOAD AS} option is displayed which is the next one in sequence.
Selecting, for example, {\tt LOAD AS SQ} will reload the image with a
square-root transfer function and will change the menu to {\tt LOAD AS
  LG}\@.  The remaining options are mostly familiar as {\tt AIPS} verbs.
{\tt SET WINDOW} allows the user to select a sub-window over which the
display scaling and the {\tt FLAG ALL} and {\tt REDO ALL} operations
function.  {\tt OFF TRANSF} and {\tt OFF COLOR} turn off black and white
and color enhancements, respectively.  {\tt TVTRANSF} enhances the image
in black and white, while {\tt TVPSEUDO}, {\tt TVPHLAME}\Hi{, {\tt
OFMCOLOR} add color with numerous options selected by the buttons and
  cursor position}.  {\tt TVZOOM} allows the display to be zoomed during
window setting and {\tt CURVALUE}\@  This last displays the pixel
coordinates and the image value under the cursor.  If one hits buttons
A, B, or C while running {\tt CURVALUE}, the selected pixel is added to
the edit list.  {\tt IMSTAT} computes the full (using all pixels) and
robust mean and rms over the selected sub-image.  If that is the full
image, the statistics displayed with the image are updated.  In either
case, the statistics are displayed in the message window.  Note that the
statistics of all 5 or 7 images are computed when the interactive
portion of the code is begun and whenever a {\tt REDO} or {\tt FLAG}
operation is done.  But you must select {\tt IMSTAT} to report the
statistics in a sub-image.

Very large images may not be able to fit on your TV\@.  When the image
exceeds the size of the TV, the top line will show the sub-image number
followed by the parameter type and the {\tt NEXT WINDOW} option will
appear.  The first sub-image displayed is called number 0 and shows the
full image every n'th pixel in X and Y (see message window for n).
Sub-image 1 begins at the lower left.  Later sub-images move right, then
back to the left and up, and so forth until the top right is reached.
Every pixel is displayed in these sub-images.  Use the {\tt NEXT WINDOW}
option to step through the sub-images in a circular fashion.

There is one more screen which appears when doing the {\tt REDO ALL} and
{\tt REDO LIST} functions.  This screen is illustrated in
Figure~\ref{fig:spxredo}.  The spectrum at the selected $(x,y)$ is
displayed with image value on the vertical axis and frequency on the
horizontal axis.  The celestial coordinates of the pixel and the current
fit parameters are displayed below the spectrum.  A solid line shows the
current fit and plus signs show the data.  The menu contains

\begin{figure}
\begin{center}
\resizebox{4.8in}{!}{\putfig{LISPXa.eps}}
\centerline{\hphantom{MM}}
\resizebox{4.8in}{!}{\putfig{LISPXb.eps}}
\caption{Top: Spectrum at image center after a {\tt CHAN RANGE} to make
  the data samples more distinct and showing bad samples already
  flagged by (and still in) {\tt FLAG POINTS} with the initial fit to
  all samples.  Bottom: spectrum after {\tt RESET CHANS} and {\tt NEW
    FIT}\@.  {\tt SPXMD} can offset specified channel ranges, simulating
  bad gains in some spectral windows, an option that was used here.}
\label{fig:spxredo}
\end{center}
\end{figure}

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt CHAN RANGE  } & To display only a portion of the spectrum\\
 {\tt RESET CHANS } & To display all of the spectrum\\
 {\tt FLAG POINTS } & Select data points to omit from fit\\
 {\tt UNDO FLAGS  } & Reset all current flagging\\
 {\tt NEW FIT     } & Try a new fit\\
 {\tt             } & \\
 {\tt GOOD        } & Stop this screen return current fit values\\
 {\tt BAD         } & Stop this screen, flag this pixel\\
 {\tt             } & \\
 {\tt QUIT        } & Stop the {\tt REDO} option now\\ \hline
\end{tabular}
\end{center}

The {\tt CHAN RANGE} operation allow you to display only a portion of
the spectrum to make flagging of that portion easier.  The cursor
controls the window selection.  Hit buttons A or B to switch to the
other end of the window and buttons C or D to select the window and
display only that portion.  {\tt RESET CHANS} reverts to displaying the
full spectrum.  The {\tt FLAG POINTS} operation shows at the top left of
the screen the data value and frequency under the cursor.  Hit buttons A
or B to mark the nearest data sample ``flagged''.  After marking all
desired samples, hit buttons C or D to return to the present menu.  {\tt
  UNDO FLAGS} simply restores the initial data points.  {\tt NEW FIT}
takes the data samples minus the flagged samples and repeats the basic
spectral index fit.  Note that the results are compared to the limits
set in adverbs {\tt DPARM} and {\tt CPARM} which may flag the solution.
A good solution is plotted on the screen, a flagged solution leaves the
plot alone but unflags all flagged data samples.  When tired of this
pixel, select {\tt GOOD} to return the current fit parameters for this
pixel or {\tt BAD} to flag this pixel.  {\tt QUIT} tells both {\tt REDO}
operations to stop abruptly.  On {\tt QUIT}, any pixels not yet
processed remain in the list and any limits remain set.

\section{Interactive task {\tt LISPX}}

{\tt TVSPX} is designed to fit spectral indices to full image cubes.  At
times, users find themselves with a few spectra taken at one or more
celestial coordinates rather than full images.  {\tt LISPX} is a new
task to assist in this situation.  It reads a text file giving one or
more spectra with the first column of data being the channel frequencies
and the second column being the data values.  An optional third column,
frequently used for uncertainty, is read and written but not otherwise
used.  The units of these data columns are arbitrary but must be
consistent with the adverb values.

The input adverbs to this task are similar to those of {\tt TVSPX} and
{\tt SPIXR}\@.  {\tt INFILE} is required to specify the data file to be
read.  Each spectrum in the file begins with a line\\
\centerline{{\tt SPECTRUM   'identifying string'}}\\
where {\tt SPEC} must appear in the first four characters and the
identifying string is any character string beginning with a single quote
({\tt '}) to annotate the particular spectrum.  The ending quote mark is
optional.  {\tt OUTFILE} is an optional file to which the solutions are
written along with the spectra including the optional third column and
additional columns giving the computed value fit for that channel and
the difference between the data and the fit.  The remaining adverbs are
used in the same ways as those described above for {\tt SPIXR} and {\tt
  TVSPX}\@.  {\tt FLUX} is the minimum spectral value to be used in the
fit and {\tt REFREQ} is the reference frequency.  These two numbers must
be given in the same units as the data in {\tt INFILE}\@.  {\tt OPTYPE}
may be used to request a fit for curvature and {\tt DPARM} and {\tt
  CPARM} are used to flag bad solutions.

After {\tt LISPX} reads in the data and does a fit for each spectrum,
the TV displays the minimal menu:

\begin{center}
\begin{tabular}{|l|l|}\hline
  {\tt EXIT             } & Exit {\tt LISPX}, writing output file\\
  {\tt ABORT            } & Exit {\tt LISPX}, with no output file\\
  {\tt                  } & \\
  {\tt REDO ALL         } & Re-do all solutions\\\hline
\end{tabular}
\end{center}

{\tt EXIT} is the normal closing of the task, allowing the answers to
appear in the message window and the output file, if any, to be written.
{\tt ABORT} exits the task without these outputs.  {\tt REDO ALL}
loops through all spectra showing the options described above in the
section on {\tt TVSPX} and illustrated in Figure~\ref{fig:spxredo}.

\section{Spectral index image simulation with {\tt SPXMD}}

The collection of data simulation tasks was found to be incomplete when
{\tt TVSPX} was created.  Therefore, a new task named {\tt SPXMD} was
created to make model image cubes with spectral index and spectral
curvature.  The task can start with an image cube specified by the
{\tt INNAME}, {\it et al.} adverbs along with {\tt BLC} and {\tt TRC}
and scaled by {\tt FACTOR}\@.  Alternatively, the output image
parameters may be set with adverbs {\tt COORDINA}, {\tt IMSIZE}, and
{\tt CELLSIZE}\@.  In both cases the reference frequency is set by {\tt
REFREQ} (with sensible defaults).  The image noise level is set by
{\tt FLUX}\@.  The frequency of spectral channel one is set by {\tt
APARM(1)}, the frequency increment by {\tt APARM(2)}, and the number
of frequencies by {\tt APARM(3)}\@.  Adverbs {\tt FPARM}, {\tt RPARM},
{\tt VPARM}, and {\tt DOFIT} may be used to set up to 30 channel
ranges in which the amplitude is scaled by a specified factor and the
noise level is scaled by a second specified factor.  Up to 9999
``sources'' may be described in a text file pointed to by {\tt
INLIST}\@.  In that file, each source is given a peak brightness,
$(x,y)$ pixel position, 3 width parameters, a type, a spectral index,
and a spectral curvature.  Types allowed are point, Gaussian, uniform
disk, uniform rectangle, optically thin sphere, and exponential.

\end{document}
