%-----------------------------------------------------------------------
%;  Copyright (C) 2014
%;  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,wrapfig}
\usepackage{pstricks}  % added by Greisen
\definecolor{hicol}{rgb}{0.7,0.1,0.1}
\definecolor{mecol}{rgb}{0.2,0.2,0.8}
\definecolor{excol}{rgb}{0.1,0.6,0.1}
\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{\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}{119}
\newcommand{\memtit}{TVSAD: interactive search and destroy}
\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}
{\tt TVSAD} is a new task in \AIPS, which first appeared in November
2014.  It is an interactive version of the automatic source finding
task, {\tt SAD} (or ``search-and-destroy'') which has been in \AIPS\
for a long time.  {\tt SAD} finds a list of Gaussian components and
writes a residual image with the components removed.  However, any
components for which the fit appears bad are left in the image.  {\tt
  TVSAD} is an attempt to allow the user to avoid these left-behind
components.
\end{abstract}

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

\section{Introduction}

Sources seen in interferometric images that are well resolved are
almost certainly complex and not described by any simple mathematical
form.  However, source components that are unresolved or slightly
resolved may be described as a Gaussian, for example, with a
particular peak brightness, spatial location, and spatial extent.
Since Gaussian ``Clean beams'' are used in typical deconvolution
algorithms, the use of Gaussian fitting to the final images in order
to make a list of the unresolved or weakly resolved components of the
image seems appropriate.

``Manual'' fitting of Gaussian source components is implemented in
\AIPS\ tasks {\tt IMFIT} and {\tt JMFIT}\@.  These two tasks are
nearly identical except for the mathematical algorithms used in the
least-squares minimization.  {\tt IMFIT} uses the Levenberg-Marquardt
algorithm while {\tt JMFIT} uses Davidon's optimally conditioned
variable metric (quasi-Newton) method for function minimization.  The
user is required to specify a window into the input image over which
the fit is conducted, plus initial guesses for the peak brightness,
pixel position in the image, major and minor axis dimensions, and
position angle for each component to be fit.  These tasks also allow
the fitting of a planar ``zero-level'' as well.  In November 2014, a
verb called {\tt MFITSET} was added to \AIPS\ to allow the user to set
these adverbs interactively.

The \AIPS\ task ``search-and-destroy'' or {\tt SAD} was initially
written and contributed by Walter Jaffe.  It has been used extensively
in the years since and has fared reasonably well in studies of the
completeness of the source lists produced.  {\tt SAD} functions by
finding connected groups of pixels, called ``islands,'' above a
user-selected brightness limit.  It then works through the list of
islands in order of peak brightness, finding one or two maxima within
the island, guessing component widths, and then attempting a Gaussian
fit using the mathematical algorithm of {\tt JMFIT}\@.  The resulting
Gaussian parameters are compared against a number of criteria and, if
all seems well, the fit components are subtracted from the input image
and added to the output component list and table.  The criteria
include peak brightness and total flux cutoffs, maximum rms in the
residual image of the island, excessive component widths, peaks found
outside the island or image, and total residual flux in the island.
{\tt SAD} can then loop to find more islands using a lower brightness
limit than the previous one.  Such looping allows the brightest
sources to be fit first, ignoring low-level emission surrounding them,
and then to fit weaker sources elsewhere in the field.  Note, {\tt
  SAD} deliberately leaves those components it did not fit well in the
residual image and out of the component lists and output {\tt MF}
(``model-fit'') table.  The user is then required to handle these
regions by hand with {\tt IMFIT}, {\tt JMFIT}, or other means.

The code for {\tt TVSAD} was based on the code for {\tt SAD}, but it
was converted into a more ``modern'' memory-based \AIPS\ style, rather
than the older, disk-based style of {\tt SAD}\@.  The converted code
was developed until it produced identical results to {\tt SAD} before
the interactive enhancements were added.

\section{Interactive search and destroy: {\tt TVSAD}}

\subsection{Inputs}

The adverbs for {\tt SAD} and {\tt TVSAD} are identical, so all
comments here apply more or less equally to both.  The {\tt INNAME}
{\it et al.}~adverbs select the image to be fit, while {\tt BLC} and
{\tt TRC} select the sub-image plane to be fit.  These tasks fit
two-dimensional Gaussians in celestial coordinates, recording to which
plane they apply, but not fitting anything in the third spectral or
other axis domain.  The tasks are restartable.  If {\tt INVERS}
specifies an existing {\tt MF} (``model fit'') table, the components
listed in that table will be subtracted from the input image before
any islands and Gaussians are found in the remainder.  Any new
Gaussians found will be added to this table.  Adverbs {\tt DORESID}
and {\tt OUTNAME} {\it et al.}~request the cataloging of the residual
image and specify its name parameters.  Since the tasks may be
restarted, saving the residual image is not necessary until the fit is
essentially complete.

The maximum number of Gaussians fit in any one island is eight.
Adverb {\tt NGAUSS} specifies the maximum number to be found over the
entire image in all islands.  At ``major cycle $i$'', the tasks look
over the entire residual image to find ``islands'' (connected regions
of pixels) above the brightness level set by {\tt CPARM($i$)}\@.  Then
they sort the islands into descending order of peak brightness, make
guesses for the component(s) in each island, and attempt fits.  You
should set {\tt DOWIDTH} greater than zero to fit widths as well as
positions and fluxes.  If the peak residual in the island is greater
than {\tt ICUT}, a second fit with two components is attempted (if
{\tt DOALL} $>0$) and the result with the lower peak residual is
taken.  The fit is then subjected to a variety of tests, controlled by
adverbs {\tt GAIN} and {\tt DPARM(1)} through {\tt DPARM(7)}\@.  The
defaults for these adverbs are useful, but you may wish to adjust
them.  If the fit meets all tests, then the component(s) are added to
the list of components and subtracted from the residual image.  You
may examine in detail the reasons for failures by setting the {\tt
  PRTLEV} adverb.  The tasks use the image rms to set a variety of
default values and cutoff levels.  You may read in an image of
position-dependent rms under control of adverbs {\tt DPARM(9)} and
{\tt IN2NAME} {\it et al.}~to make these defaults be position
dependent.  Task {\tt RMSD} can create such an image.

After all islands are fit for all non-zero {\tt CPARM($i$)}, the two
tasks apply position-dependent corrections for bandwidth smearing and
primary beam under control of adverbs {\tt BWSMEAR} and {\tt PBPARM}.
For Clean images, they also attempt to deconvolve the components.
Adverb {\tt EFACTOR} is used at this stage.  Then they write a variety
of outputs.  The most important of these is the {\tt MF} (model fit)
table containing all possible parameters of each component.  This
table will be discussed in some detail below.  The tasks write a
printer display under control of adverb {\tt DOCRT}, with the text
file being written to {\tt FITOUT} if desired.  The {\tt SORT} adverb
determines the order of the printing with flux and component
coordinate as the main choices.  The deconvolved fit components may
also be written to a {\tt CC} (``Clean components'') table, under
control of {\tt OUTVERS}, for use in modeling for calibration.  Note
that such {\tt CC} tables may only be used with {\tt CMETHOD = 'DFT'}
since they contain a variety of component widths.  Furthermore, the
components may also be written to a {\tt ST} (``stars'') table, under
control of {\tt STVERS}, for use in display tasks.

\subsection{Fitting}

\begin{figure}
\begin{center}
\resizebox{6.0in}{!}{\putfig{TVSAD.1}}
\caption{Island image with automatically generated initial guess.}
\label{fig:TVSAD.init}
\end{center}
\end{figure}

While {\tt TVSAD} may be run for a time in a non-interactive mode,
exactly like {\tt SAD}, {\tt TVSAD} always begins in an interactive
mode and will resume that mode whenever an attempted fit does not meet
the acceptance criteria.  In the interactive mode, before a fit is
attempted on the next island, the image of the island is displayed on
the TV\@.  The image will be linearly interpolated to make a
reasonable display on the screen.  Using data provided by Emmanuel
Momjian, the display is as shown in Figure~\ref{fig:TVSAD.init} with
an island containing two maxima and an initial guess of two Gaussians.
The first column of the menu offers the options:

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt OFF TRANS   } & Turn off black \&\ white and color TV
                      enhancements\\
 {\tt OFF TVZOOM  } & Turn off TV zoom\\
 {\tt TVFIDDLE    } & Interactive image enhancement and zoom \\
 {\tt CURVALUE    } & Display image value selected by TV cursor \\
 {\tt ZOOM IN     } & Reload image interpolated by one more step \\
 {\tt ZOOM OUT    } & Reload image interpolated by one less step \\
 {\tt REBOX       } & Change the island {\tt BLC} and {\tt TRC} \\
 {\tt ENTER GUESS } & Select number of Gaussians and their initial
                      guess \\
 {\tt REDO GAUSS 1} & Change the initial guess parameters for the
                      Gaussian labeled 1 \\
 {\tt REDO GAUSS 2} & Change the initial guess parameters for the
                      Gaussian labeled 2 \\ \hline
\end{tabular}
\end{center}

The first four options are familiar \AIPS\ functions to turn adjust
black and white image contrast or color enhancement with pixel
replication zoom, to display image values under the cursor, and to
reset the black and white and color enhancements and the pixel
replication zoom.  The {\tt ZOOM IN} and {\tt ZOOM OUT} functions
cause the image to be re-displayed with the degree of interpolation
increased or decreased by one.  {\tt REBOX} allows you to adjust the
rectangular island boundaries.  {\tt ENTER GUESS} allows you to set
the initial guess for up to eight Gaussians within this island.  You
are directed to position the cursor to the peak of component one and
press buttons {\tt A}, {\tt B}. or {\tt C}\@.  This sets the maximum
and the $x$ and $y$ positions of the guess.  Then you are directed to
position the cursor at the half-power point of the component along the
major axis and press buttons {\tt A}, {\tt B}. or {\tt C}\@.  Finally
you are directed to position at a half-power point on the minor axis
and press one of the 3 buttons.  While you are moving the cursor
around, a {\tt CURVALUE}-like display will be given at the upper left
corner to assist you.  When the minor axis point is selected, an
ellipse representing the component will appear on the screen in a
reddish color (graphics plane 5).  Then you are directed to point at
the peak of component 2, and so on.  To stop at any time, press button
{\tt D}\@.  The number of Gaussians to be fit will then be set to the
number fully specified.

A suitable number of {\tt REDO GAUSS $n$} menu items will appear,
reflecting the current number to be attempted in this island.  These
options follow the same pattern described above but change only the
component number selected.  The second menu column contains the
operations that cause this island to be processed in some way.  They
are

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt DO FIT      } & Try to fit the island with the current initial
                      guess \\
 {\tt TVOFF       } & Fit this island with the current initial guess
                      and \\
 {\tt             } & then fit other islands until a failure
                      occurs \\
 {\tt NEXT ISLAND } & Skip this island, leaving it unchanged in the
                      residual image\\
 {\tt             } & and omitting any components from the lists \\
 {\tt QUIT        } & Exit the fitting process at this point \\ \hline
\end{tabular}
\end{center}

\begin{figure}
\begin{center}
\resizebox{6.0in}{!}{\putfig{TVSAD.2}}
\caption{Island image with fit from automatically generated initial
  guess.}
\label{fig:TVSAD.badfit}
\end{center}
\end{figure}

{\tt NEXT ISLAND} tells {\tt TVSAD} to skip this island and simply go
on to the next with a new display like that in
Figure~\ref{fig:TVSAD.init}.  No components for the current island are
kept in the lists or subtracted from the image.  {\tt QUIT} is even
more drastic, telling the task to stop building the component list and
computing further residuals at this point and simply to go on to the
output routines to write out whatever components were found
previously.

{\tt DO FIT} tells {\tt TVSAD} to leave the current display and
attempt to fit the current initial guess in this island.  {\tt TVOFF}
is the same, except that it also turns off the interactive mode.  That
mode will be turned back on only after some failure in fitting is
found.  If the fit is found to be defective by the various component
value tests, then the initial screen will be re-displayed with the fit
values shown as the new initial guess.  If {\tt TVSAD} does not think
the fit is defective, and the interactive mode remains on, the screen
shown in Figure~\ref{fig:TVSAD.badfit} will appear.  This figure
contains the result of fitting with the 2 Gaussians initially guessed
and has rather high rms and residuals.

This second display of the residual image after the fit offers a menu
of two columns.  The first column contains some of the functions of
the previous display, without the option to change any of the initial
guess.

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt OFF TRANS   } & Turn off black \&\ white and color TV
                      enhancements\\
 {\tt OFF TVZOOM  } & Turn off TV zoom\\
 {\tt TVFIDDLE    } & Interactive image enhancement and zoom \\
 {\tt CURVALUE    } & Display image value selected by TV cursor \\
 {\tt ZOOM IN     } & Reload image interpolated by one more step \\
 {\tt ZOOM OUT    } & Reload image interpolated by one less step \\ \hline
\end{tabular}
\end{center}

\begin{figure}
\begin{center}
\resizebox{6.0in}{!}{\putfig{TVSAD.3}}
\caption{Island image with near 4-component initial guess entered with
  the TV cursor.}
\label{fig:TVSAD.newguess}
\end{center}
\end{figure}

The second menu column in the residual display contains functions

\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt GOOD        } & Accept the current fit, adding components to the
                      list \\
 {\tt             } & and subtracting from the image \\
 {\tt RE-TRY      } & Go back to the previous display and enter a new
                      initial guess \\
 {\tt NEXT ISLAND } & Skip this island, leaving it unchanged in the
                      residual image\\
 {\tt             } &  and omitting any components from the lists \\
 {\tt QUIT        } & Exit the fitting process at this point \\ \hline
\end{tabular}
\end{center}

{\tt NEXT ISLAND} and {\tt EXIT} function as they did for the first
display screen.  {\tt GOOD} tells the task to accept this solution, to
save the components to the lists, to remove them from the image, and
then to go on to the next island, if any.  {\tt RE-TRY}, selected
here, tells {\tt TVSAD} to return to the first display to allow the
user to alter the initial guess.  That alteration, to 4 Gaussians, is
shown in Figure~\ref{fig:TVSAD.newguess}.  The result of a {\tt DO
  FIT} with much improved residual rms and extrema is shown in
Figure~\ref{fig:TVSAD.goodfit}.  The user accepts this solution and
goes on to the next island or, in this case, the output routines.

\begin{figure}
\begin{center}
\resizebox{6.0in}{!}{\putfig{TVSAD.4}}
\caption{Island image with fit from user-generated initial
  guess.}
\label{fig:TVSAD.goodfit}
\end{center}
\end{figure}

\vfill\eject
\subsection{Outputs}

All of the details of each component fit are written in the model fit
({\tt MF}) table specified by {\tt INVERS}\@.  The contents and use of
this table will be discussed below.  If {\tt OUTVERS} $\ge 0$, a Clean
components ({\tt CC}) table will be written containing the components
found.  The deconvolved widths are written to the table unless {\tt
  DOWIDTH} was false.  In that case, widths of zero are written.  This
non-point {\tt CC} table could be used as a model in, for example,
{\tt CALIB} to do a self-calibration.  Note that {\tt CMETHOD =
  'DFT'} will be required since there will be a variety of fit widths
in the table.  If {\tt STVERS} $\ge 0$, a stars ({\tt ST}) table will
also be written (or appended).  Tasks like {\tt KNTR} can over-plot
``star'' positions and sizes on top of their contour and grey-scale
displays.  Verb {\tt TVSTAR} allows such over-plots on the TV screen.

{\tt DOCRT} controls a printer-like display of the results.  Two
groups of numbers are shown.  In the first, the component peak
brightness, flux, position, and width parameters are shown along with
their uncertainties.  In the second, the attempts at deconvolution
(for Clean images only) are shown.  The first three columns are the
deconvolution at the formal solution.  The second and third groups of 3
columns show the extrema in the possible deconvolved widths and
position angles after trying all possible variations of $\pm $ {\tt
  EFACTOR} times the various width uncertainties.  A single character
expresses the opinion that the components are probably resolved ({\tt
  R}), probably unresolved ({\tt U}), or its anybody's guess ({\tt
  ?}).  The output from the run illustrated in the figures is shown
below.
\par\vspace{-10pt}\begin{verbatim}
Test TVSAD  .SUBIM .      1     Disk  2     Plane    1     User     208

Window BLC  102   63   1   1  1  1  1 TRC  157  157   1   1  1  1  1
Sources found down to  0.000305 in JY/BEAM
Retry level  0.100000 (JY/BEAM ) plus gain 0.100
Reject components peak <  0.00000 in JY/BEAM
Reject components flux <  0.00000
Reject components outside window >   0.0 cells
Reject components outside image >    0.0 cells
Reject residual flux >   0.00000 with gain 0.100
Fluxes expressed in units of milliJY/BEAM
NOTE: Fluxes marked by * have been divided by 1000.
Errors determined by theory from RMS 101.58 microJy
Reference Center: 09 42 21.9911  06 23 34.960
All source widths and coordinates and their errors are in arc seconds
NO corrections for bandwidth smearing have been made
Source peaks and fluxes NOT corrected for primary beam

    #      Peak      Flux     RA---SIN   DEC--SIN    Maj     Min     PA
    1 L    3.582     7.417    -0.12100    0.16825   0.01605 0.00692 157
        (  0.096) (  0.279) (  0.00010    0.00017) (0.00043 0.00019   1)
    2      4.857    10.804    -0.11595    0.12998   0.01305 0.00914 173
        (  0.096) (  0.293) (  0.00008    0.00011) (0.00026 0.00018   2)
    3     31.107    62.556    -0.11573    0.17477   0.01461 0.00738 178
        (  0.096) (  0.274) (  0.00001    0.00002) (0.00005 0.00002   0)
    4     10.340    21.091    -0.11178    0.13672   0.01753 0.00624 179
        (  0.096) (  0.276) (  0.00002    0.00007) (0.00016 0.00006   0)

Component widths & PA: deconvolved at fit &  1.30 sigma low & high from fit
   #  MAJ-dec MIN-dec   PA   MAJ-low MIN-low   PA  MAJ-hi  MIN-hi   PA

    1 0.01145 0.00201  139 R 0.01057 0.00000  134 0.01230 0.00346  144
    2 0.00805 0.00433   89 R 0.00777 0.00298   79 0.00842 0.00528   95
    3 0.00799 0.00581   10 R 0.00787 0.00574    8 0.00811 0.00588   12
    4 0.01255 0.00430    3 R 0.01225 0.00415    2 0.01286 0.00444    4
\end{verbatim}\par\vspace{-8pt}

\subsection{The {\tt MF} table}

The model fit ({\tt MF}) table is written by {\tt SAD}, {\tt TVSAD},
{\tt IMFIT}, and {\tt JMFIT} Gaussian-fitting tasks.  It specifies all
fit parameters, all uncertainties, the deconvolved widths and their
extrema, bandwidth and primary beam correction factors, and certain
of the parameters in pixel units to aid in restarting {\tt TVSAD} and
{\tt SAD}\@.   One row of the table is devoted to each fit component
and the table may be sorted in a wide variety of ways.

The {\tt MF} table has 41 columns and is supported for software by the
parameter include file {\tt \$INC/PMFC.INC} which specifies the number
of columns and a symbolic name for each column.  There is also an
initialization routine {\tt \$APLSUB/MFINI.FOR} to define and open
such tables.  However, due to the extreme number of columns, no table
I/O routine has been defined.  Instead, every task that accesses the
table either reads or writes full table rows with the fundamental {\tt
  TABIO} routine or gets selected column values with the {\tt GETCOL}
routine.  Two tasks access {\tt MF} tables.  {\tt MF2ST} simply
translates flux-selected portions of the {\tt MF} table to write a
stars table of selected type.  {\tt MFPRT} is more complicated.  Its
basic mode is to print a selected set of the table columns onto the
terminal or into a text file.  It also has special formats for \AIPS\
tasks {\tt STARS}, {\tt BOXES}, {\tt SETFC}, and {\tt FACES}\@.

\section{Image data models}

There are three tasks designed to modify an image adding a specified
model and noise.  Of these, {\tt IMMOD} is the one of most interest
here since it is intended for continuum images.  The existing image
may be scaled (or eliminated) and noise added.  It adds {\tt NGAUSS}
components up to four using adverbs {\tt OPCODE} to specify type, and
{\tt FMAX}, {\tt FPOS}, and {\tt FWIDTH} to specify peak brightness
and pixel position and size.  Alternatively, adverb {\tt INLIST} may
be used to specify up to 9999 components, one per line in the text
file. Each non-comment line specifies
\begin{center}
\begin{tabular}{|r|l|}\hline
 1. & Peak brightness (Jy/beam)\\
 2. & Component $X$ center (pixels)\\
 3. & Component $Y$ center (pixels)\\
 4. & Major axis (pixels)\\
 5. & Minor axis (pixels)\\
 6. & Position angle (degrees CCW from North)\\ \hline
\end{tabular}
\end{center}

To make realistic test images, it might be best to eliminate the input
values ({\tt FACTOR = 0}). set a sensible noise level ({\tt FLUX}),
and then put in components of very small (but $> 0$) diameters.  Then
use {\tt CONVL} to convolve the image, both noise and components, with
a Gaussian ``Clean beam.''  \AIPS\ has a random number generator ({\tt
  RANDOM}) which could be used to generate a collection of more or
less random source components, but there are probably better ways to
generate proper component lists to test {\tt SAD} and {\tt TVSAD}\@.

\end{document}
