%-----------------------------------------------------------------------
%;  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}{127}
\newcommand{\memtit}{Interactive flagging 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}
  The first truly interactive task in \AIPS\ was {\tt TVFLG},
  introduced in the late 1980s.  It enabled interactive editing
  primarily of continuum data.  A similar task suited to spectral line
  data sets appeared in January 1990.  This task, {\tt SPFLG}, has
  recently undergone some useful changes suggesting that this family of
  editing tasks should be described in a memo.
\end{abstract}

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

\section{Introduction}

It was this author's dream to write a truly interactive task to edit
continuum data from interferometers.  \AIPS, my seventh system, was the
first system on which I worked that became sufficiently mature that I
could take the time to develop such a task.  The result in the late
1980s was {\tt TVFLG}, the first truly interactive task in \AIPS\@.  It
displayed an image of visibility data with baseline on the $x$ axis and
time on the $y$ axis.  It allowed the data to be calibrated, the
baselines to appear in length or numerical order, and to display
multiple representations of the visibilities.  At this time, the VLA
produced primarily continuum data with one, or at most 7, spectral
channels, making this a very useful task.

In January 1990, a similar task to edit spectral-line data was released.
{\tt SPFLG} shows images with spectral channel on the $x$ axis and time
on the $y$ axis.  Modern interferometers such as the Jansky VLA now
produce a large number of spectral channels even for continuum
observations.  This makes {\tt SPFLG} the more useful interactive
editor, allowing examination for interference from terrestrial and
celestial (mostly the Sun) sources.  While computers are now very much
faster than they were in the 1980s, the large volume of JVLA data sets
still makes the initial stages of {\tt SPFLG} time consuming.  A task
to reduce the start-up time was written in 2013.  {\tt FTFLG} is very
similar to {\tt SPFLG} except that all baselines are summed into a
single image (per polarization).  The hope is that this task will
provide a quick examination of the data to find persistent RFI affecting
all antennas.  It is less useful for actually editing data.

All three of these tasks begin by reading the visibility data applying
user-specified data selection and calibration.  The resulting
visibilities are written to a ``master'' grid disk file with times
averaged over a user-specified interval.  This master grid file is an
\AIPS\ cataloged image (type {\tt 'MA'}) which may be retained when the
task finishes or discarded.  The production of this master file was so
expensive in the early days that the tasks have an option to compute and
save the master grid and then exit with no interaction ({\tt
  DOCAT=2})\@.  Users used to start these tasks in this mode and return
the next day to start the interactive portions.

The next sections of this memo will describe the options in some detail
but it may be helpful to describe the general structure here.  When an
image is loaded to the display ({\tt XAS} TV window), the master grid
is read, the visibilities are converted to whatever form has been
requested and then are written to a scratch disk file.  The {\tt TVLOAD}
subroutine then reads this file and displays it on the TV\@.  Then a
menu of options is displayed in 5 columns.  This loading operation may
involve time averaging, rms computation, data differencing, and more.
In the old days, this was expensive enough that the tasks require an
explicit {\tt LOAD} request.  The user may select a variety of options
changing windows, polarization, display type, display range, and
integration times and only then apply the new parameters when finally
doing the load operation.  Some of the other operations, such as
clipping, undoing or redoing flags, and changing the display loading
transfer function will reload the display automatically.

One more general concept should be explained here.  The basic
integration time of the master grid is set by the value of {\tt
  DPARM(6)} which should be set to the integration time in the data.
In {\tt 31DEC24}, the verb {\tt GETITIME} may be useful in determining
this value.  When the image is loaded to the display, an additional time
averaging is applied.  The {\tt ENTER SMOOTH TIME} option lets you set
this using the terminal entering an integer in units of the initial
{\tt DPARM(6)}\@.  The default smooth time when the task begins is that
needed to allow all times to appear in the display.  It is displayed at
the bottom of the screen with keyword {\tt AVG}\@.  A smooth time
greater than one is required by display types called {\tt RMS} since
that parameter can be computed at load time only if data are time
averaged at that point.  There is another time interval called the
``scan time'' in units of {\tt DPARM(6)}\@.  The visibilities are
averaged over this time and then compared to the visibility at the
central time in a sliding window fashion.  The displays that use this
are called {\tt DIFF}\@.  The current value of the scan time is
displayed at the bottom of the screen labeled {\tt SCAN}\@.

\section{Spectral-line editing: {\tt SPFLG}}

\subsection{Input parameters}

Most of the adverbs in this task are the usual widely-used ones.
{\tt INNAME} \etal\ select the data set to be edited.  Numerous adverbs
then select the portion of the data set to be processed including {\tt
  SOURCES}, {\tt CALCODE}, {\tt TIMERANG}, {\tt FREQID}, {\tt BIF}, {\tt
  EIF}, {\tt BCHAN}, {\tt ECHAN}, {\tt UVRANGE}, {\tt SUBARRAY}, and
most importantly {\tt ANTENNAS} and {\tt BASELINE}\@.  All the usual
calibration adverbs are applied to the data including {\tt DOCALIB},
{\tt GAINUSE}, {\tt DOPOL}, {\tt DOBAND}, {\tt BPVER}, {\tt FLAGVER},
and {\tt SMOOTH}\@.

There are a few adverbs that are used in particular ways by {\tt
  SPFLG}\@.  {\tt DOCAT} specifies that the master grid file should be
kept when {\tt SPFLG} finishes ({\tt DOCAT} $> 0$) or should be
discarded.  If {\tt DOCAT}$= 2$, {\tt SPFLG} will exit after creating
and filling the master grid file, leaving it to be used at a later
time.  {\tt IN2SEQ} specifies the sequence number of the master grid and
must be specified to access a pre-existing master grid.  If {\tt
  IN2SEQ}$ = 0$, {\tt SPFLG} will create a new master grid file.
{\tt IN2DISK} specifies the \AIPS\ disk number to be used for the grid
file.  {\tt OUTFGVER} specifies the output flag table version.  If it is
less than or equal 0, a new flag table will be created and will be
populated with the flags in flag table version {\tt FLAGVER} if it is
$\geq\ 0$.

Of the {\tt DPARM}s, only {\tt DPARM(6)} is really important.  It sets
the time interval on the $y$ axis in seconds.  This can be used to time
average the data while building the master grid, but further time
averaging may be done later.  It may be best to set this to the
integration time of the input data.  The {\tt AIPS} verb {\tt GETITIME}
may be helpful in determining this.  {\tt DPARM(2)} selects what data
are included, with 0 including only cross-correlations, 1 including also
auto-correlations, and 2 including only auto-correlations.  For the
VLBA, a value of 2 may be useful, but for the JVLA this is less likely.
{\tt DPARM(4)} controls whether the visibilities after calibration are
divided by the source flux with or without spectral index.  This may be
useful when editing calibration sources.  In {\tt 31DEC25}, {\tt
  DPARM(7)} controls the maximum $x$ axis zoom and {\tt DPARM(8)} limits
the maximum $y$ zoom factor.  {\tt DPARM(1)} controls the data type
displayed initially, {\tt DPARM(3)} selects the baseline to be displayed
initially, and {\tt DPARM(9)} and {\tt DPARM(10)} control the initial
range of intensity displayed.  All of these can be changed while running
the task making it best just to leave them at zero initially.

\subsection{The master grid file}

The master grid file has \AIPS\ class {\tt SPFLGR} and is an image (type
{\tt MA}) whose rows are 3 times the number of spectral channels plus 3
in length.  The first 3 words contain the source number, the current
time (in days), and the time of the next row.  Three words are used for
each spectral channel to hold the real part, the imaginary part, and the
flag number when the data are flagged by {\tt SPFLG}\@.  If the
particular channel was flagged on input, the values are represented by
the ``magic blank'' value used by \AIPS\ ({\tt 'INDE'} as a floating
point number).  The number of rows in the master grid is the number of
times represented.  To limit the size of the array long gaps in time are
represented by no more than 5 blank rows.  The third axis in the master
grid image is used for Stokes and will be  1, 2, or 4 in  length.  The
fourth axis in this grid is for baseline and includes only those
baselines present in the data after application of the task adverbs.
Attached to the master grid are two tables.  The {\tt BL} table has
three columns labeled {\tt ANTENNA1}, {\tt ANTENNA2}, and {\tt
  BASELINE}\@.  It is primarily used to acquire the relationship between
baseline number and antenna numbers when restarting {\tt SPFLG} with a
pre-existing master grid.  The {\tt FC} (``flag command'') table
contains 17 columns:
\begin{center}
\begin{tabular}{|l|r|l|}\hline
  {\tt FLAGNUMB } & 1 I &Number assigned to current logical flag\\
  {\tt FLAGOPER } & 8 C &Type of flagging operation\\
  {\tt FLAGTIME } & 2 R &Time range of flag (days)\\
  {\tt FLAGBL   } & 2 I &Baseline number of flag (0 means all)\\
  {\tt FLAGCHAN } & 2 I &Channel range of flag \\
  {\tt FLAGIF   } & 2 I &IF range of flag \\
  {\tt FLAGSTOK } & 4 C &Stokes flagged by this command\\
  {\tt FLAGSOUR } & 1 I &Source number of flag (0 means all)\\
  {\tt CLIPRANG } & 2 R &Brightness range of non-flagged pixels\\
  {\tt TVTYPE   } & 1 I &Type of visibility displayed\\
  {\tt TVCHAN   } & 1 I &Row number on {\tt BL} table \\
  {\tt TVIF     } & 1 I &IF number when clip was done \\
  {\tt TVSTOKES } & 1 I &Stokes value currently displayed\\
  {\tt TVWINDOW } & 4 I &Current image window\\
  {\tt TVTIMAVG } & 1 R &Smoothing time in seconds\\
  {\tt TVSCAN   } & 1 R &``Scan'' time in seconds\\
  {\tt REASON   } & 24 C & Reason for flag\\\hline
\end{tabular}
\end{center}

The central column above gives the number of values and the data type (I
integer, R real, C character).  Some of these parameters translate
directly into flag table ({\tt FG}) entries attached to the input data
set.  Specifically, these are the time, baseline, channel, IF, Stokes,
source, and reason columns.  The {\tt FLAGNUMB} is the flag number used
to identify the flag command for listing flags and for marking samples
in the master grid flagged by the flag command.  {\tt FLAGOPER} is
mostly used when listing the flags.  The {\tt CLIPRANG} and parameters
labeled {\tt TV} are used by the {\tt CLIP BY FORM} operation to
control the ``form'' of a previous clip now being applied to other parts
of the master grid.

\subsection{Running {\tt SPFLG}}

\begin{figure}
\begin{center}
  \resizebox{5.8in}{!}{\putfig{SPFLG.init.eps}}
\centerline{\hphantom{MM}}
  \resizebox{5.8in}{!}{\putfig{SPFLG.piece.eps}}
\caption{{\bf Top:} Initial display of data after {\tt DO LABEL?}, {\tt
    DO WEDGE ?}, {\tt LOAD LOG}, and {\tt TVTRANSF} were used to make
  these data more visible.  Note the {\tt SMOOTH 6} in the bottom text
  line which was required to fit the display on the screen.  The master
  grid was made on a 2 second time interval, matching the data
  integration time.
  {\bf Bottom:} Same display after changing the smooth time to two of
  the master's 2-second intervals.  Note in the bottom text line the
  asterisk next to the baseline, the {\tt SCAN} length, and {\tt SHOW
  RR} entries.  This means that the next {\tt LOAD} will display an
  image for which these parameters will change.}
\label{fig:SPFLG.init}
\end{center}
\end{figure}

After {\tt SPFLG} builds the master grid, it loads the first baseline's
data in the requested form to the TV in grey-scale and draws a five
column menu in graphics overlay 2 (usually green in color).  The loaded
data are smoothed in time from the master grid's integration time enough
so that the resulting image fits on the TV display.  This initial screen
is illustrated in the top of Figure~\ref{fig:SPFLG.init} where the data
have been smoothed by a factor of 6 to fit on the screen.

When the smoothing parameter is reduced, making the image too large
for the display vertically, the menu is changed to refer to the
``pieces'' of the image.  These are overlapping time intervals that will
cover the full time range one piece at a time.  This is illustrated in
the bottom of Figure~\ref{fig:SPFLG.init}.

At the bottom of the screen is a very important line of text describing
the current data display and marking with asterisks any parameters that
will change with the next load operation.  If your screen is narrow,
this text will appear in multiple lines.  Parameters 1, 3, 4, 5, 6, 10,
11, and 12 can show asterisks if appropriate.  Parameter 2 changes on
loads, the others change as soon as they are invoked.  For {\tt SPFLG}
this text contains
\begin{center}
\begin{tabular}{|r|l|}\hline
 1. & Data type, \eg\ {\tt AMPLITUDE}, {\tt VEC DIFF}, et al.\\
 2. & Intensity range \eg\ {\tt (-0.42-77.66)} mJy in this case\\
 3. & Baseline number, antennas, subarray \eg\ {\tt BL 4(01-05/01)}\\
 4. & Time averaging in units of {\tt DPARM(6)}, \eg\ {\tt AVG 2}\\
 5. & Window bottom left corner \eg\ {\tt BLC 1 1}\\
 6. & Window top right corner \eg\ {\tt TRC 1024 1470}\\
 7. & Which sources get flagged \eg\ {\tt ALL-SOURCE}, {\tt
    ONE-SOURCE}\\
 8. & Which baselines get flagged \eg\ {\tt BL=01-05}, {\tt BL=01-**},
    {\tt BL=**-05}, {\tt BL=**-**}\\
 9. & Which IFs get flagged \eg\ {\tt ONE-IF}, {\tt IF02-03}, {\tt
    ALL-IF}\\
 10. & Scan time in units of {\tt DPARM(6)} \eg\ {\tt SCAN 12}\\
 11. & Spectral smoothing width in channels \eg\ {\tt CSMOOTH 3.0}\\
 12. & Current polarization \eg\ {\tt SHOW RR}\\
 13. & Which polarizations get flagged \eg\ {\tt FLAG NOLL}\\\hline
\end{tabular}
\end{center}

Operations are selected from the menu by moving the cursor to the desired
operation, pressing the left mouse button to signal {\tt SPFLG} which
will change the color of the menu item from green to red, and then
pressing the A, B, or C keys on the keyboard.  Pressing the D key will
cause helpful information about the operation to appear in the main
terminal window.

  The left-most column of the menu contains the options
\begin{center}
\begin{tabular}{|l|l|}\hline
{\tt OFFZOOM   } & turn off any zoom magnification\\
{\tt OFFTRANS  } & turn off any black \&\ white enhancement\\
{\tt OFFCOLOR  } & turn off any pseudo-coloring\\
{\tt TVZOOM    } & interactive image zooming as in {\tt AIPS}\\
{\tt TVTRANSF  } & black and white enhancement as in {\tt AIPS}\\
{\tt TVPSEUDO  } & many pseudo-colorings as in {\tt AIPS}\\
{\tt TVPHLAME  } & many flame-like pseudo-colorings as in {\tt AIPS}\\
{\tt OFMCOLOR  } & very many OFM pseudo-colorings as in {\tt AIPS}\\
{\tt DO WEDGE ?} & switches choice of displaying a step wedge\\
{\tt LOAD xxxx } & switch TV load transfer function to xxxx= {\tt LOG},
                   {\tt SQRT}, {\tt LOG2}, and {\tt LIN}\\
{\tt LIST FLAGS} & list selected range of flag commands\\
{\tt UNDO FLAGS} & remove flags by number from {\tt FC} table and from
                    the master grid\\
{\tt REDO FLAGS} & reapply all flags to master grid\\
{\tt LIST BASLS} & list antenna pairs by baseline ``number''\\
{\tt SET REASON} & enter reason to be attached to flagging commands\\
{\tt DO LABEL ?} & turns on/off axis labeling\\
{\tt CHAR MULT } & set the character size multiplier\\\hline
\end{tabular}
\end{center}

The first operation turns off any zoom magnification produced by {\tt
  TVZOOM}, the second operation turns off any black-and-white
ehancement produced by {\tt TVTRANSF}, and the third operation turns
off any coloring produced by {\tt TVPSEUDO}, {\tt TVPHLAME}, or {\tt
  OFMCOLOR} operations.  The following five operations are interactive
and issue instructions on the message terminal.  {\tt TVZOOM} allows you
to select the center of a pixel-replication zoom, hitting terminal
buttons A or B to increment the zoom factor, button C to decrement it,
and button D to exit.  The zoom is turned off to allow the menu to be
accessible, but will be turned back on for the enhancement operations
above and for the flagging operations of column 4.  {\tt TVTRANSF}
adjusts the black-and-white enhancement function with buttons A and B
turning on and off a graphics display of the function, button C
reversing the sign of the slope, and button D exiting.  {\tt TVPSEUDO}
offers a rainbow-like coloring on button A, a circular coloring
especially good for phase on button B, a set of step functions on button
C, and exiting on button D\@.  Repeated hitting of the buttons steps
through the color order (A) or the various step functions (C)\@.
{\tt TVPHLAME} implements a flame-like coloring with buttons A and B
switching the sequence of colors and buttons C and D exiting.  {\tt
  OFMCOLOR} offers 10 different color schemes on each of buttons A, B,
and C with button D exiting.  The cursor horizontal position adjusts the
central point of the color functions.

{\tt DO WEDGE ?} reverses a logical switch controlling whether a step
wedge is displayed along with the data.  Similarly, {\tt DO LABEL ?}
reverses a logical switch controlling whether axis labels appear on the
image and step wedge.  {\tt CHAR MULT} will appear in the menu only if
the task starts with a character multiplier bigger than one or has the
default multiplier bigger than one.  Unless the display has a very large
number of pixels, the large menu of {\tt SPFLG} probably will require
you to set the character multiplier to one.  {\tt SET REASON} will
prompt the user on the terminal to enter a ``reason'' for the flags to
follow.  This is not required but can be helpful when reviewing the flag
tables produced by {\tt SPFLG}\@.

When the image is first loaded to the display a linear relationship is
used to scale the data minimum to maximum into the display minimum to
maximum.  {\tt LOAD LOG} will then appear in the menu.  To reload the
display with a logarithmic relationship, select this option.  Then the
menu will display {\tt LOAD SQRT} and so forth.  The menu will always
display the relationship you get if you select it.  This option
immediately reloads the display when selected.  The {\tt LIST BASLS}
operation will prompt you for the range of entries in the baseline
list to be displayed.  The relationship between ``baseline'' number and
antenna numbers is often less than obvious.

The {\tt FC} table is updated every time you create a new flag command
so that any interruption (power, software bug, user error) will not cause
the work up to that point to be lost.  Each flag command is assigned a
number which is not necessarily the row number since some commands will
require multiple rows in the {\tt FC} table each with the same flag
command number.  That number is written in the master grid with each
voxel flagged by the command.  To examine the current contents of the
{\tt FC} table select {\tt LIST FLAGS}\@.  If there is more than one,
you will be prompted to enter a range of flag command numbers to
display.  This display only shows the first of each flag number plus a
line saying how many {\tt FC} table rows are needed for that flag
number.  To undo one or more flag commands, select {\tt UNDO FLAGS}
which will prompt you for the flag command numbers to be undone, one per
prompt with 0 ending the list.  Sometimes a later flag command will flag
a voxel that was already flagged by an earlier command.  Undoing that
later command will resurrect the voxel.  Select {\tt REDO FLAGS} to undo
all remaining flag commands and then redo them in sequence.  If you do
not do this, voxels will appear unflagged in the master grid but will be
flagged when you exit {\tt SPFLG} translating the {\tt FC} table into
the flag table attached to the $uv$ data set.

The second column of the menu contains the options
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt ENTER BLC          } & Type in a {\tt BLC} in pixels on the
                             terminal\\
 {\tt ENTER TRC          } & Type in a {\tt TRC} in pixels on the
                             terminal\\
 {\tt ENTER AMP PIXRANGE } & Type in the intensity range to be used for
                             loading amplitude images to the TV\\
 {\tt ENTER PHS PIXRANGE } & Type in the phase range to be used for loading
                             phase images to the TV\\
 {\tt ENTER RMS PIXRANGE } & Type in the intensity range to be used for
                             loading images of the rms to the TV\\
 {\tt ENTER R/M PIXRANGE } & Type in the value range to be used for loading
                             rms/mean images to the TV\\
 {\tt ENTER SMOOTH TIME  } & To enter the time smoothing length in units of
                             the master grid $y$ cell size\\
 {\tt ENTER SCAN TIME    } & To enter the time averaging length for the
                             ``scan average'' in units of the\\
                           & master grid $y$ cell size\\
 {\tt ENTER BASELINE     } & To enter a desired antenna pair using the
                             terminal or\\
                           & the baseline number and a zero\\
 {\tt ENTER STOKES FLAG  } & To type in the 4-character string which will
                             control which correlators\\
                           & (polarizations) are flagged.\\
 {\tt ENTER CH SMOOTH    } & To type in the FWHM of a Gaussian smoothing
                             in spectral channels\\
                           & in the data type being loaded.\\
 {\tt SWITCH SOURCE FLAG } & To switch between having all sources flagged by
                             the current flag commands\\
                           & and having only those sources included in
                             this execution of {\tt SPFLG} flagged.\\
 {\tt SWITCH BASLIN FLAG } & To rotate the pointer that selects which
                             baselines are flagged.\\
 {\tt SWITCH ALL-IF FLAG } & To rotate the flag all IFs status from one IF
                         to a range of IFs, to all IFs.\\
 {\tt AUTO X Y ZOOM ?    } & To switch between no zooming of the master
                             grid and automatic zooming\\
                           & where possible limited by {\tt DPARM(7)} and
                             {\tt DPARM(8)}\\\hline
\end{tabular}
\end{center}

The {\tt ENTER BLC} and {\tt ENTER TRC} operations will prompt you in
the terminal for two numbers specifying the bottom left corner and top
right corner of the master grid where the $x$ values are in spectral
channels.  Selecting these operations will cause an asterisk to appear
in the bottom text line.  The new corners will be applied on the next
load operation.  The default ``pixrange'' for each type of visibility
parameter (amplitude, phase, rms, rms/mean) is 0 0, meaning to use the
full range of the current (sub)image.  To set a fixed value range for
each type select the appropriate {\tt ENTER xxx PIXRANGE} option and
then type two values into the terminal.  If the first of these is less
than the second, the specified intensity range will be used henceforth
until changed.  Enter two zeros to return to self scaling.

{\tt ENTER SMOOTH TIME} will prompt you to enter on the terminal the
number of master grid time intervals to be averaged before the resulting
image is loaded to the display.  {\tt ENTER SCAN TIME} will prompt you
to enter on the terminal the number of master grid intervals surrounding
the current data interval to be averaged when differencing the current
visibility with this ``scan'' average.  {\tt ENTER BASELINE} will
prompt you on the terminal for two numbers, either the two antennas of
the baseline you wish to see next or the baseline number itself plus a
zero.  ({\tt LIST BASLS} will help you with this correspondence.)
{\tt ENTER CH SMOOTH} will prompt you for the full width at half maximum
in channels of a Gaussian spectral smoothing to be applied to the image
as it is being loaded to the display.  All four of these options will
place an asterisk in the bottom text line indicating that the parameter
will change on the next load.

The {\tt ENTER STOKES FLAG} will prompt you to enter a four-character
string on the terminal specifying which correlators will be flagged by
subsequent flagging operations.  By default, this is changed when a new
Stokes component is loaded but it is wise to check this since it is
possible to display one Stokes component but apply the flags only to
other components.  The simplest form of this string is a bit mask of
zeros and ones, where the first bit applies to I, RR, or VV, the second
bit applies to Q, LL, HH, the third bit applies to U, RL, VH, and the
fourth bit applies to V, LR, HV\@.  Many other strings will be
translated correctly.  If the string you enter is not understood, {\tt
  SPFLG} will complain and in any case the string that will now be
applied will be displayed at the end of the string at the bottom of the
display.

The next 3 operations control what is flagged by subsequent flagging
functions.  The {\tt SWITCH SOURCE FLAG} toggles the flag that
determines whether subsequent flag commands apply to all sources or just
to the source generating the flag.  It starts at all sources.  {\tt
  SWITCH BASELINE FLAG} starts at $n-m$ where $n$ and $m$ are the 2
antennas of the baseline currently displayed.  If the operation is
selected, it then changes to $n${\tt -*}, then $m${\tt -*}, then {\tt
  *-*}, and then back to $n-m$, etc., where {\tt *} means all.  The {\tt
  SWITCH ALL-IF FLAG} has three states, the one-IF state, the range of
IFs state (entered from the terminal), and the all-IF state.  Flag
commands are limited by this so interactive flagging will allow the
flagging in the first state to occur in any one IF only.  In the second
state, the interactive flagging will be confined to the specified IFs.
In the third state, interactive flagging will show all IFs.  A flag
generated on one IF will apply to the listed IFs or all when in the
second and third states, but clip operations will only apply to the
specific channel and IF being clipped.

\begin{figure}
\begin{center}
  \resizebox{6.0in}{!}{\putfig{SPFLG.zoom1.eps}}
\centerline{\hphantom{MM}}
  \resizebox{6.0in}{!}{\putfig{SPFLG.zoom2.eps}}
  \caption{{\bf Top:} Display of data where only one source was selected
    and the $x-y$ zoom is not allowed.  One time has been flagged in IF
    2.  {\bf Bottom:} Same display after allowing the interplative zoom.
    The $y$ axis has been zoomed by a factor of 2.  For illustrative
    purpose only, another time in IF 3 has been flagged.}
\label{fig:SPFLG.xyzoom}
\end{center}
\end{figure}

The last operation in column two, {\tt AUTO X Y ZOOM ?}, is new in {\tt
  31DEC25}\@.  It toggles a switch which tells all operations loading an
image on the display to have each grid pixel (after any time averaging)
correspond to one TV pixel or to blow up the image as much as possible
while still fitting on the display.  This is illustrated in
Figure~\ref{fig:SPFLG.xyzoom} where the top portion shows the display
when the zoom is not allowed and the bottom shows the display when zoom
is allowed.  Adverbs {\tt DPARM(8)} and {\tt DPARM(9)} limit the maximum
magnification factor in $x$ and $y$, respectively.  Like many of the
operations, this switch controls what happens for the next image loaded
to the display.

The third column of the menu contains the options to choose which aspect
of the visibilities is displayed and to load the image to the display.
It contains
\vfill\eject
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt DISPLAY AMPLITUDE } & To display amplitudes on the TV\\
 {\tt DISPLAY PHASE     } & To display phases on the TV\\
 {\tt DISPLAY RMS       } & To display scalar amplitude rms on the TV\\
 {\tt DISPLAY RMS/MEAN  } & To display scalar amplitude rms/mean on the TV\\
 {\tt DISPLAY VECT RMS  } & To display vector amplitude rms on the TV\\
 {\tt DISPLAY VRMS/VAVG } & To display vector amplitude rms/mean on the TV\\
 {\tt DISPLAY AMP V DIFF} & To display the amplitude of the difference
                             between the data and a running\\
                          & (vector) ``scan average''\\
 {\tt DISPLAY AMPL DIFF } & To display the abs(difference) of the amplitude
                            of the data and a running\\
                          & scalar average of the amplitudes in the
                            ``scan''\\
 {\tt DISPLAY PHASE DIFF} & To display the abs(difference) of the phase of
                            the data and the phase of a\\
                          & running (vector)``scan average''\\
 {\tt DISPLAY STOKES xx } & To switch to Stokes type xx (where xx can be
                            RR, LL, RL, LR, etc.~as chosen\\
                          &  by the data plus the {\tt STOKES} adverb)\\
 {\tt OFF WINDOW + LOAD } & Reset the window to the full image and reload
                         the TV\\
 {\tt SET WINDOW + LOAD } & Interactive window setting (like {\tt TVWINDOW})
                         followed by reloading the TV\\
 {\tt LOAD LAST BASELINE} & Reload TV with the current parameters and the
                          previous baseline in sequence\\
 {\tt LOAD NEXT BASELINE} & Reload TV with the current parameters and the
                         next baseline in sequence\\
 {\tt LOAD LAST PIECE   } & Load the previous overlapping piece of the
                         data\\
 {\tt LOAD NEXT PIECE   } & Load the next overlapping piece of the data\\
 {\tt LOAD              } & Reload TV with the current parameters\\\hline
\end{tabular}
\end{center}

The {\tt DISPLAY} options select the type of visibility data to be
displayed by the next load operation.  The first two simply select the
amplitude and phase of the data from the master grid vector averaged
over any smoothing time (default and set by the {\tt ENTER SMOOTH TIME}
operation).  The next four options compute rms over the smoothing
time and hence require that the smoothing time be greater than one.
The first two of these compute the rms from amplitudes and hence are
scalar rms and scalar rms weighted by scalar mean amplitude.  The second
two are rms amplitude evaluated by vector averaging over the smoothing
time and rms scaled by the vector averaged amplitude.  The {\tt DISPLAY
  AMP V DIFF} is a very useful display option that shows the vector
amplitude difference between the smoothed sample and the vector average
of a ``scan'' interval surrounding the sample.  This display is very
sensitive to both short-term differences in phase and amplitude and is
the basis of one of the two flagging operations in {\tt RFLAG}, the
popular automatic flagging task.  The remaining two display difference
operations show in absolute value the difference between the amplitude
and the scalar average amplitude in the surrounding ``scan'' interval
and the difference between the phase and the vector average phase in the
surrounding interval.

The operation {\tt DISPLAY STOKES xx} selects the Stokes value of the
data to be displayed in the next load operation.  This option always
appears and shows the next Stokes type from {\tt RR},{\tt LL}, {\tt RL},
{\tt LR}, {\tt VV}, {\tt HH}, {\tt VH}, and {\tt HV} depending on the
Stokes values present in the master grid.  If there is only one Stokes
in the master grid, then this option does nothing.

The remaining operations in this column all load a new image to the
display updating all parameters shown with asterisks in the bottom text
line(s).  {\tt OFF WINDOW + LOAD} resets the {\tt BLC} to 1, 1 and the
{\tt TRC} to the size of the master grid.  It then reloads the display
even if the current smoothing parameter causes the image to be larger in
the $y$ direction than the display.  {\tt SET WINDOW + LOAD} lets you
use the TV cursor to set the lower left corner and upper right corner of
a subimage which is then loaded to the display.  This operation is
identical to the {\tt AIPS} verb {\tt TVWINDOW} except that {\tt SPFLG}
does not let the cursor go outside the available image.  The {\tt BLC}
and {\tt TRC} of this new subimage will be displayed in the text line(s)
at the bottom.  The {\tt LOAD LAST BASELINE} loads the previous baseline
and the {\tt LOAD NEXT BASELINE} loads the next baseline from the
baseline list.  The two antennas in the new baseline are shown in the
bottom text line(s).  The {\tt LOAD LAST PIECE} loads the previous
vertical subimage and the {\tt LOAD NEXT PIECE} loads the next (later
times) subimage.  These operations rotate through the baselines and
times and so, for example, if the highest time piece is currently
displayed, {\tt LOAD NEXT PIECE} will load the lowest time subimage.
{\tt LOAD} simply loads the image using any changed parameters but
keeping the current baseline and piece number.

\vfill\eject
The fourth column lets you generate flag commands using
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt FLAG PIXEL        } & To flag single pixels\\
 {\tt FLAG/CONFIRM      } & To flag single pixels, but request a yes or no
                         on the terminal before proceeding\\
 {\tt FLAG AREA         } & To flag a rectangular area in Channel-T\\
 {\tt FLAG TIME RANGE   } & To flag all channels for a range of times\\
 {\tt FLAG CHANNEL-DT   } & To flag a channel for a range of times\\
 {\tt FLAG TIME         } & To flag all channels for a specific time\\
 {\tt FLAG A CHANNEL    } & To flag all times for a specific channel\\
 {\tt FLAG CHANNEL RANGE} & To flag all times for a range of channels\\
 {\tt CLIP BY SET \#S   } & To enter from the terminal a clipping range
                         for the current mode and then clip\\
 {\tt CLIP INTERACTIV   } & To enter with the cursor and LUTs a clipping
                            range for the current mode and\\
                          & then clip the data\\
 {\tt CLIP BY FORM      } & To clip selected baselines using the "method"
                            and clipping range of some\\
                          &  previous clip operation\\\hline
\end{tabular}
\end{center}

The {\tt FLAG} commands let you select data to be flagged with the TV
cursor.  The source name, time, channel and IF, and data value under the
cursor are displayed in the upper left corner.  Instructions will appear
in the message window.  Button D exits from all flagging operations
without making an additional flag.  Flagging a point, a time, or a
channel is done on buttons A, B, or C with C exiting afterwards.  The
confirm point version will require you to answer y or n in the terminal
window for each point selected.  Flagging area, time range, channel
range, and a channel-time range start with the lower level or corner and
button A lets you switch between the levels or corners.  Button B after
both levels/corners have been set at least once creates a flag and goes
on to the next area or range.  Button C creates the flag and exits.
Note that these flagging operations honor the specified range of IFs.
A flag generated in one IF will be applied to all specified IFs.  An
exception is made when an area or channel range covers more than one
IF\@.  In that case, a separate flag is created for each IF and they are
not extended to the other IFs.

The {\tt CLIP BY SET \#S} operation prompts you for a lower limit and
upper limit for the visibility parameter currently displayed.  A flag is
  then generated for each pixel outside this range.  The {\tt CLIP
    INTERACTIVE} operation displays the lower limit and upper limit
  intensities in the upper left corner and the cursor position is used
  to change the value.  Buttons A and B switch which limit is set and
  the black and white lookup table is used the make ```clipped'' values
  invisible.  Button C exits causing a flag to be generated for each
  visibility parameter value outside this range.  Button D exits without
  generating any flags.  The display is automatically updated.

  The {\tt CLIP BY FORM} operation is particularly complex (or perhaps
  amusing).  It prompts you for a previous clip operation flag number
  which you can get using {\tt LIST FLAGS}.  It then applies its display
  type (amplitude, phase, rms, rms/mean, etc.), averaging interval and
  clip levels to a range of baselines and Stokes (as entered from the
  terminal).  To terminate the operation, doing nothing, enter a letter
  instead of one of the requested baseline numbers.  To omit a Stokes,
  reply, if requested for a flag pattern, with a blank line.  You may
  watch the operation being carried out on the TV as it proceeds because
  it carries out parts of its operation using the TV display.

  The fifth column contains only
\begin{center}
\begin{tabular}{|l|l|}\hline
  {\tt EXIT} & Go resume {\tt AIPS} and enter the flags in the
               data\\\hline
\end{tabular}
\end{center}

When exiting, {\tt SPFLG} will ask if any {\tt FC} table flag commands
should be applied to the data.  If the answer is yes, the existing {\tt
  FG} flag table is copied to a new one and the flag commands are
translated into {\tt FG} table entries following the pre-existing ones.
The master grid is then updated, applying the flag commands in an
immutable fashion.  If the answer is no, {\tt SPFLG} will ask a second
time if the master grid is going to be deleted ({\tt DOCAT}$\leq 0$)
reminding the user that the flag commands will be lost.  If the master
grid is being retained, the {\tt FC} table is simply kept for later use.
\vfill\eject

\section{Average baselines spectral editing {\tt FTFLG}}

{\tt FTFLG} first appeared in 2013.  It is essentially the same as {\tt
  SPFLG} except that the data from all included baselines are
accumulated in one plane of the master grid per polarization.  This
accumulation is done by averaging real parts and imaginary parts
separately in each spectral channel and IF, \ie\ by vector averaging.
The {\tt BL} table and the {\tt FC} table are created in a manner
identical to that in {\tt SPFLG}\@.  The menus are also identical except
that {\tt LIST BASLS} is omitted from the first column, {\tt ENTER
  BASLINE} and {\tt SWITCH BASLIN FLAG} are omitted from the second
column, and {\tt LOAD LAST BASELINE} and {\tt LOAD NEXT BASELINE} are
omitted from the third column.  Flag table entries from {\tt FTFLG}
apply to all antennas except when the adverbs {\tt ANTENNAS} and/or {\tt
  BASELINE} have one and only one non-zero entry.  The bottom line is
the sames as for {\tt SPFLG} except that the current baseline, antenna
numbers, and IF (parameter 3) is omitted.  Parameter 8 shows which
baselines will get flagged and cannot be changed from the menu.

{\tt FTFLG} was written in the hope that it could create the master grid
file more quickly than {\tt SPFLG} and that it would reveal instrumental
issues and RFI that affect all of the data.  One really bad antenna can
make a voxel in {\tt FTFLG} appear bad, but flagging all antennas for it
is excessive.  This is especially true in VLBI where the antennas are
not all likely to see the same RFI signals.  Thus, it cannot replace
{\tt SPFLG}, but {\tt SPFLG} is rather demanding when processing a large
number of baselines such as are present in the JVLA\@.

\section{Continuum interactive editing: {\tt TVFLG}}

{\tt TVFLG} was the first task in this family, having been developed in
the 1980s.  There are enough differences between {\tt TVFLG} and the
other two to require a more detailed exposition here.

\subsection{Input parameters}

{\tt TVFLG} is designed to show visibility data on a plane with baseline
number on the $x$ axis and time on the $y$ axis.  The task has all the
usual adverbs to specify which data are included in the master grid and
how they are to be calibrated.  {\tt TVFLG} has two significant adverbs
not in {\tt SPFLG}\@.  These are {\tt NCHAV} to specify pre-averaging of
spectral channels within each IF and {\tt CHINC} to specify the
increment in spectral channels between planes written to the master
grid.

{\tt DPARM} is also somewhat different in {\tt TVFLG}\@.  {\tt DPARM(6)}
is still the most significant time integration parameter and is best set
to the integration time in the data or a small integer times that.  {\tt
  DPARM(3)}$ > 0$ specifies that both baseline $n-m$ and $m-n$ be
present along the $x$ axis.  This has the advantage that an issue with a
particular antenna will be more visible even when the antenna is one of
the higher numbered ones.  See following Figures which illustrate that
point.  {\tt DPARM(4)}$> 0$ causes the visibilities to be divided by the
flux density in the source table before being added to the master grid
file.  This does help mask the otherwise large differences in amplitude
due to source strength.  {\tt DPARM(5)} controls how much each flag
command is extended in time when converted to the flag table.  {\tt
  DPARM(7)} through {\tt DPARM(10)} control the initial display type and
scaling.  These matters may easily be changed while running {\tt TVFLG}
and so are best left zero at the start.

\subsection{The master grid file}

The master grid file has \AIPS\ class {\tt TVFLGR} and is an image (type
{\tt MA}) whose rows are 3 times the number of baselines plus 3 in
length.    The first 3 words contain the source number, the current time
(in days), and the time of the next row.  Three words are used for each
baseline to hold the real part, the imaginary part, and the flag number
when the data are flagged by {\tt TVFLG}\@.  If the particular
correlator was flagged on input, the values are represented by the
``magic blank'' value used by \AIPS\ ({\tt 'INDE'} as a floating point
number).  The number of rows in the master grid is the number of times
represented.  To limit the size of the array long gaps in time are
represented by no more than 5 blank rows.  The third axis in the master
grid is the Stokes included which can be 1, 2, or 4 in number.  The
fourth axis is frequency (the spectral channels left after {\tt BCHAN},
{\tt ECHAN}, {\tt NCHAV}, and {\tt CHINC}).  The fifth axis is the IF or
spectral window range set by {\tt BIF} and {\tt EIF}\@.

Only one table, the {\tt FC} table, is attached to this file.
Its contents are the same as those already described for {\tt SPFLG}.

\subsection{Running {\tt TVFLG}}

\begin{figure}
\begin{center}
  \resizebox{5.6in}{!}{\putfig{TVFLG.init.eps}}
%  \resizebox{4.25in}{!}{\putfig{TVFLG.length.eps}}
\caption{Initial display of data after {\tt DO LABEL?} and {\tt DO WEDGE
    ?} were used.  Each baseline appears twice ({\tt DPARM(3)}$ > 0$)
  which makes the high and low amplitudes easier to assign to an
  antenna.  This is an old VLA data set which included the Pie Town
  antenna called VLA antenna 29 and only 111 times including the scan
  gaps.}
\label{fig:TVFLG.init}
\end{center}
\end{figure}

After {\tt TVFLG} finishes building the master grid, it loads the
requested plane from the grid to the display screen.  By default this is
the first Stokes value, first spectral channel, and first IF\@.  The
loaded data are smoothed in time from the master grid's integration time
enough so that the resulting image fits on the TV display.  This initial
screen is illustrated in Figure~\ref{fig:TVFLG.init} where the data have
not been smoothed because all of the rows in this modest data set fit
easily.

Like {\tt SPFLG}, {\tt TVFLG} displays an important text line at the
bottom of the screen.  Parameters 1, 3, 4, 5, 6, 7, 10, 12, and 13
can show asterisks if appropriate.  Parameter 2 changes on loads, the
others change as soon as they are invoked.  It contains
\begin{center}
\begin{tabular}{|r|l|}\hline
 1. & Data type, \eg\ {\tt AMPLITUDE}, {\tt VEC DIFF}, et al.\\
 2. & Intensity range \eg\ {\tt (-0.42-77.66)} mJy in this case\\
 3. & Spectral channel number \eg\ {\tt CH 1)}\\
 4. & IF number \eg\ {\tt IF 1}\\
 5. & Time averaging in units of {\tt DPARM(6)}, \eg\ {\tt AVG 2}\\
 6. & Window bottom left corner \eg\ {\tt BLC 1 1}\\
 7. & Window top right corner \eg\ {\tt TRC 870 111}\\
 8. & Which spectral channels get flagged \eg\ {\tt ALL-CH}, {\tt ONE-CH}\\\hline
\end{tabular}
\end{center}
\begin{center}
\begin{tabular}{|r|l|}\hline
 9. & Which IFs get flagged \eg\ {\tt ONE-IF}, {\tt IF02-03}, {\tt
    ALL-IF}\\
 10. & Baseline sort order \eg\ {\tt BLNUMB}, {\tt LENGTH}, {\tt ANT.PR}
      (both $n-m$ and $m-n$)\\
 11. & Which sources get flagged \eg\ {\tt ALL-SOURCE}, {\tt
    ONE-SOURCE}\\
 12. & Scan time in units of {\tt DPARM(6)} \eg\ {\tt SCAN 12}\\
 13. & Current polarization \eg\ {\tt SHOW RR STOKES,}\\
 14. & Which polarizations get flagged \eg\ {\tt FLAG NOLL}\\\hline
\end{tabular}
\end{center}

The displayed menu is very similar to that of {\tt SPFLG}\@.  The menu
columns will be listed here but the discussion of them will be truncated
when it would not be different from that already done for {\tt SPFLG}\@.

The left-most column of the menu contains the same options as {\tt
  SPFLG} other than the {\tt LIST BASLS} operation is omitted.
\begin{center}
\begin{tabular}{|l|l|}\hline
{\tt OFFZOOM   } & turn off any zoom magnification\\
{\tt OFFTRANS  } & turn off any black \&\ white enhancement\\
{\tt OFFCOLOR  } & turn off any pseudo-coloring\\
{\tt TVZOOM    } & interactive image zooming as in {\tt AIPS}\\
{\tt TVTRANSF  } & black and white enhancement as in {\tt AIPS}\\
{\tt TVPSEUDO  } & many pseudo-colorings as in {\tt AIPS}\\
{\tt TVPHLAME  } & many flame-like pseudo-colorings as in {\tt AIPS}\\
{\tt OFMCOLOR  } & very many OFM pseudo-colorings as in {\tt AIPS}\\
{\tt DO WEDGE ?} & switches choice of displaying a step wedge\\
{\tt LOAD xxxx } & switch TV load transfer function to xxxx= {\tt LOG},
                   {\tt SQRT}, {\tt LOG2}, and {\tt LIN}\\
{\tt LIST FLAGS} & list selected range of flag commands\\
{\tt UNDO FLAGS} & remove flags by number from {\tt FC} table and from
                    the master grid\\
{\tt REDO FLAGS} & reapply all flags to master grid\\
{\tt SET REASON} & enter reason to be attached to flagging commands\\
{\tt DO LABEL ?} & turns on/off axis labeling\\
{\tt CHAR MULT } & set the character size multiplier\\\hline
\end{tabular}
\end{center}

\begin{figure}
\begin{center}
  \resizebox{4.25in}{!}{\putfig{TVFLG.baseline.eps}}
\centerline{\hphantom{MM}}
  \resizebox{4.25in}{!}{\putfig{TVFLG.length.eps}}
\caption{{\bf Top:} Initial display of data after {\tt DO LABEL?}, {\tt
    DO WEDGE ?}, and {\tt OFMCOLOR} were used to make these data more
  visible.  Each baseline appears only once ({\tt DPARM(3)}$ = 0$) which
  makes the high and low amplitudes more difficult to assign to an
  antenna.  This is an old VLA data set which included the Pie Town
  antenna called VLA antenna 29.
  {\bf Bottom:} Same display after selecting {\tt SORT BY LENGTH}\@.
  Note that the $x$ axis is highly non-linear with baselines ordered by
  distance between antennas ignoring projection effects.  The lower
  amplitudes at long baselines are now clear.}
\label{fig:TVFLG.baseline}
\end{center}
\end{figure}

The second column of the menu contains the options
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt ENTER BLC          } & Type in a {\tt BLC} in pixels on the
                             terminal\\
 {\tt ENTER TRC          } & Type in a {\tt TRC} in pixels on the
                             terminal\\
 {\tt ENTER AMP PIXRANGE } & Type in the intensity range to be used for
                             loading amplitude images to the TV\\
 {\tt ENTER PHS PIXRANGE } & Type in the phase range to be used for loading
                             phase images to the TV\\
 {\tt ENTER RMS PIXRANGE } & Type in the intensity range to be used for
                             loading images of the rms to the TV\\
 {\tt ENTER R/M PIXRANGE } & Type in the value range to be used for loading
                             rms/mean images to the TV\\
 {\tt ENTER SMOOTH TIME  } & To enter the time smoothing length in units of
                             the master grid $y$ cell size\\
 {\tt ENTER SCAN TIME    } & To enter the time averaging length for the
                             ``scan average'' in units of the\\
                           & master grid $y$ cell size\\
 {\tt ENTER CHANNEL      } & To enter the desired spectral channel
                             number using the terminal\\
 {\tt ENTER IF           } & To enter the desired spectral window (IF)
                             number using the terminal\\
 {\tt ENTER STOKES FLAG  } & To type in the 4-character string which will
                             control which correlators\\
                           & (polarizations) are flagged.\\
 {\tt SWITCH SOURCE FLAG } & To switch between having all sources flagged by
                             the current flag commands\\
                           & and having only those sources included in
                             this execution of {\tt TVFLG} flagged.\\
 {\tt SWITCH ALL-CH FLAG } & To reverse the flag all channel status\\
 {\tt SWITCH ALL-IF FLAG } & To rotate the flag all IFs status from one IF
                         to a range of IFs, to all IFs.\\
 {\tt AUTO Y ZOOM ?      } & To switch between no zooming of the master
                             grid and automatic zooming\\\hline
\end{tabular}
\end{center}

This column is mostly the same as that used by {\tt SPFLG}\@.  The
options to {\tt ENTER BASELINE}, {\tt ENTER CH SMOOTH} and {\tt SWITCH
  BASLIN FLAG} are not appropriate in {\tt TVFLG}\@.  They are replaced
by {\tt ENTER CHANNEL} and {\tt ENTER IF} which let you specify in the
terminal window the spectral channel and spectral window (aka IF) to be
displayed next.  These are the coordinates in the fourth and fifth axes,
respectively, of the master grid.  The {\tt SWITCH ALL-CH FLAG} switches
between having subsequent flag commands apply to the current spectral
channel or to all spectral channels.  The auto zoom option is changed to
{\tt AUTO Y ZOOM ?} since smoothing in the $x$ axis between baselines is
a bad idea.

 Figure~\ref{fig:TVFLG.baseline} illustrates the use of the auto zoom
 option which blows up the compact display of times to something much
 more manageable.  The {\tt OFMCOLOR} option with multiple hits of button
 B was used to select the ``turbo'' OFM color scheme which works well
 here.  Note that both of these options are new in {\tt TVFLG} in the
 {\tt 31DEC25} version of \AIPS\@.

The third column of the menu contains the options to choose which aspect
of the visibilities is displayed and to load the image to the display.
It contains
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt DISPLAY AMPLITUDE } & To display amplitudes on the TV\\
 {\tt DISPLAY PHASE     } & To display phases on the TV\\
 {\tt DISPLAY RMS       } & To display scalar amplitude rms on the TV\\
 {\tt DISPLAY RMS/MEAN  } & To display scalar amplitude rms/mean on the TV\\
 {\tt DISPLAY VECT RMS  } & To display vector amplitude rms on the TV\\
 {\tt DISPLAY VRMS/VAVG } & To display vector amplitude rms/mean on the TV\\
 {\tt DISPLAY AMP V DIFF} & To display the amplitude of the difference
                             between the data and a running\\
                          & (vector) ``scan average''\\
 {\tt DISPLAY AMPL DIFF } & To display the abs(difference) of the amplitude
                            of the data and a running\\
                          & scalar average of the amplitudes in the
                            ``scan''\\
 {\tt DISPLAY PHASE DIFF} & To display the abs(difference) of the phase of
                            the data and the phase of a\\
                          & running (vector)``scan average''\\
 {\tt DISPLAY STOKES xx } & To switch to Stokes type xx (where xx can be
                            RR, LL, RL, LR, etc.~as chosen\\
                          &  by the {\tt STOKES} adverb)\\
 {\tt SORT BY xxxxxxxx  } & Reload TV with the $x$ axis data (baseline)
                            ordered by {\tt LENGTH}\\
                          & or by {\tt BASELINE} number\\
 {\tt OFF WINDOW + LOAD } & Reset the window to the full image and reload
                         the TV\\
 {\tt SET WINDOW + LOAD } & Interactive window setting (like {\tt TVWINDOW})
                         followed by reloading the TV\\
 {\tt LOAD LAST PIECE   } & Load the previous overlapping piece of the
                         data\\
 {\tt LOAD NEXT PIECE   } & Load the next overlapping piece of the data\\
 {\tt LOAD              } & Reload TV with the current parameters\\\hline
\end{tabular}
\end{center}

This column does not contain the {\tt LOAD NEXT BASELINE} and {\tt LOAD
  LAST BASELINE} options of {\tt SPFLG} but does contain either the
{\tt SORT BY LENGTH} or the {\tt SORT BY BASELINE} options.  The former
option appears in the menu when the $x$ is ordered by baseline number,
\ie\ $1-2, 1-3, 1-4, \ldots\ 1-29, 2-3, 2-4, 2-5, \ldots\ 2-29, 3-4,
3-5, \ldots\ 28-29$ as shown in Figure~\ref{fig:TVFLG.baseline} which
was created with {\tt DPARM(3)}$\leq\ 0$.  If the length option is
selected, the baselines are ordered by the distance between the antennas
as listed in the antenna file.  This ignores the actual projected
baseline lengths which vary with time and do not retain their order as
time changes.  Note the preponderance of short baselines in the VLA as
shown in the bottom half of Figure~\ref{fig:TVFLG.baseline}.

\vfill\eject
The fourth column lets you generate flag commands and to change rapidly
the spectral channel, IF, or Stokes displayed.
\begin{center}
\begin{tabular}{|l|l|}\hline
 {\tt FLAG PIXEL        } & To flag single pixels\\
 {\tt FLAG/CONFIRM      } & To flag single pixels, but request a yes or no
                         on the terminal before proceeding\\
 {\tt FLAG AREA         } & To flag a rectangular area in Channel-T\\
 {\tt FLAG TIME RANGE   } & To flag all baselines for a range of times\\
 {\tt FLAG ANTENNA-DT   } & To flag all baselines to an antenna for a range of times\\
 {\tt FLAG TIME         } & To flag all baselines for a specific time\\
 {\tt FLAG BASELINE     } & To flag all times for a specific baseline\\
 {\tt FLAG BASELINE-DT  } & To flag a specific baseline for a range of times\\
 {\tt CLIP BY SET \#S   } & To enter from the terminal a clipping range
                         for the current mode and then clip\\
 {\tt CLIP INTERACTIV   } & To enter with the cursor and LUTs a clipping
                            range for the current mode and\\
                          & then clip the data\\
 {\tt CLIP BY FORM      } & To clip selected baselines using the "method"
                            and clipping range of some\\
                          &  previous clip operation\\
 {\tt LOAD NEXT IF/ST   } & Load TV with next spectral IF or
                            polarization \\
 {\tt LOAD NEXT CHAN    } & Reload the TV with current parameters except
                            the next higher spectral channel\\
 {\tt LOAD PREV CHAN    } & Reload the TV with current parameters except
                            the next lower spectral channel\\\hline
\end{tabular}
\end{center}

\begin{figure}
\begin{center}
%  \resizebox{4.25in}{!}{\putfig{TVFLG.turbo1.eps}}
%\centerline{\hphantom{MM}}
\resizebox{5.25in}{!}{\putfig{TVFLG.turbo.eps}}
\caption{Display of data after {\tt DO LABEL?}, {\tt DO WEDGE ?}, {\tt
    OFMCOLOR} and {\tt AUTO Y ZOOM ?} were used to make these data more
  visible.  Each baseline appears twice ({\tt DPARM(3)}$ > 0$) which
  makes the high and low amplitudes easier to assign to an antenna.}
\label{fig:TVFLG.turbo}
\end{center}
\end{figure}

The 3 flag channel operations of {\tt SPFLG} are replaced by 3 flag
baseline or antenna operations in {\tt TVFLG}\@.  The {\tt FLAG
  ANTENNA-DT} operation starts by requesting an antenna number using the
terminal window.  Then the vertical cursor position selects the begin
and end times of the interval.  Use buttons A and B to switch which is
being set, button C to exit flagging the data, and button D to exit with
no flagging.  {\tt FLAG BASELINE} uses the horizontal cursor position to
select the baseline to be flagged.  Buttons A and B cause a flag to be
generated, button C also generates a flag but then exits, and button D
exits without generating any more flags.  {\tt FLAG BASELINE-DT} uses
the cursor horizontal position to select a baseline and vertical
position to select the begin and end times of the time range.  Button A
selects which of the 2 limits is being set, button B creates a flag and
continues the operation, button C creates a flag and exits, and button D
exits creating no more flags.  As with all flag operations, instructions
will appear on the message terminal.

Three more operations are offered to allow faster movement through the
master grid.  {\tt LOAD NEXT IF/ST} loads the display with the next IF
keeping the current Stokes and spectral channel unchanged.  When the IF
exceeds {\tt EIF}, it is changed to {\tt BIF} and the Stokes number is
increased if possible.  {\tt LOAD NEXT CHAN} and {\tt LOAD LAST CHAN}
increment or decrement the spectral channel number by one and reload the
display.  These three options immediately reload the display with the
changed channel, IF, or Stokes.  Note that the last 2 of these options
do not appear in the figures because the data set had only one spectral
channel.  ({\tt ENTER CHANNEL} does appear in the menu, but with this
data set is a no-op.)


Figure~\ref{fig:TVFLG.turbo} illustrates the effect of creating the
master grid with {\tt DPARM(3)}$ > 0$.  In this case, the baseline order
is $1-2, 1-3, 1-4, \ldots\ 1-29, 2-1, 2-3, 2-4, \ldots\ 2-29, 3-1, 3-2,
3-4, \ldots\ 29-29$.  The lower amplitudes of antennas 9 and 15 are now
obvious as well as the reduction in the visibility amplitudes in the
longest baselines (those to the Pie Town antenna 29).

  The fifth column contains only
\begin{center}
\begin{tabular}{|l|l|}\hline
  {\tt EXIT} & Go resume {\tt AIPS} and enter the flags in the
               data\\\hline
\end{tabular}
\end{center}




\end{document}
