%-----------------------------------------------------------------------
%;  Copyright (C) 2018, 2021-2022, 2024-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
%-----------------------------------------------------------------------
\setcounter{chapter}{14}
\APPEN{Handling Data from Older Telescopes in \AIPS}{Special Considerations for
       Data from Older Telescopes in \AIPS}{Olderdata}
\renewcommand{\Chapt}{28}

\renewcommand{\titlea}{31-December-2025 (revised 16-July-2025)}
\renewcommand{\Rheading}{\AIPS\ \cookbook:~\titlea\hfill}
\renewcommand{\Lheading}{\hfill \AIPS\ \cookbook:~\titlea}
\markboth{\Lheading}{\Rheading}

Chapter 4 on data calibration has been revised to describe the modern
\indx{VLA} data format and calibration in \AIPS\@.  Similarly, old
VLBI formats have been excised from Chapter 9 to avoid confusion with
more modern practices.  Nonetheless, the VLA archive for the
pre-expansion VLA is widely and productively used and we suspect that
there are VLBI users with older data files which may still need
reduction and analysis.  This appendix is used to address first the
older VLA data format and initial reduction steps and then the older
Mk III and Mk IV VLBI formats.

\Sects{The Historical VLA}{oldVLA}

The NRAO archive contains all of the data from the historical (or
pre-EVLA) Very Large Array.  These data are frequently mined for uses
above and beyond those of the original observers.  There is a new
archive at {\tt https://data.nrao.edu}; the old archive is no longer
available.  Log in at the above web address using your {\tt
my.nrao.edu} account and then select Show Search Inputs.  This has all
sorts of ways to find what you may desire.  You may specify one or more
of telescope, project code, date range, target name, target coordinates
and search radius, observing band, or telescope configuration.  You may
submit your query and the tool will show you all data sets that match
your specification.  You may then request the data sets that you
actually want and they will be downloaded to a publicly accessible disk
area.  All historical VLA data have been in the public domain for a long
time, so no special permission should be needed.  You will be notified
when your data are available and told how to access them.

The old archive contained less well known content which is not available
in the new archive.  Instead the web site {\tt
https://www.vla.nrao.edu/astro/nvas/} describes an archive of
\AIPS-processed legacy VLA data sets containing calibrated data and
images.  There is a description of this service and, at the left,
buttons to connect to various web pages of informations and also a
search tool.

For VLA data from the archive, use {\tt FILLM} to read one or more
disk files; see \Sec{fillmold}.   The VLA format was changed on
January 1, 1988, but all older data were translated and archived in
the modern format.  On July 1, 2007, the ModComps were replaced with
modern computers and the format had an essential change made to it.
Use {\tt FILLM} to read data from both the ModComp and post-ModComp
eras.

For VLA calibration, there are several useful procedures described in
this chapter and \Rchap{cal}.  They are contained in the {\tt RUN}
file called \hbox{{\tt \tndx{VLAPROCS}}}.  Each of these procedures
has an associated {\tt HELP} file and inputs.  Before any of these
procedures can be used, this {\tt RUN} file must be invoked with:
\dispt{RUN VLAPROCS \CR}{to compile the procedures.}
\dispe{There is a ``pipeline'' procedure designed to do a preliminary
calibration and imaging of ordinary VLA data sets.  This provides a
good first look at the data.  Nonetheless, the results are still not
likely to be of publishable quality.  To run the pipeline, enter}
\dispt{RUN \Tndx{VLARUN} \CR}{to compile the procedures.}
\dispt{INP VLARUN \CR}{to review the input adverbs and, when ready,}
\dispt{VLARUN \CR}{to execute the pipeline.}

See \Rappen{cont} for a simplified summary of data reduction suitable
to data from the historic VLA\@.  Much of the calibration of historic
VLA data is similar to that of the modern EVLA, although the latter is
fundamentally multi-channel and wide band.  See \Rchap{cal} for a
discussion of the steps used in calibrating all VLA data.

\Subsections{Reading from VLA archive files using {\tt FILLM}}{fillmold}

     The NRAO Archive makes available, among other things, data from
the EVLA, which began observing in January 2010, and from the old
\indx{VLA} which ceased observing a few days into 2010.  To load data
from the EVLA into \AIPS\ consult \Rchap{cal} for information about
{\tt BDF2AIPS} and other options.  The following describes how to read
old VLA data into \AIPS\@.

     The Archive now serves VLA data in the form of one or more
``MOdComp'' format disk files.  To load these into \AIPS, enter
\dispt{TASK\qs '\Tndx{FILLM}' ; INP \CR}{to review the inputs needed.}
\dispt{DATAIN\qs 'MYDATA:AC238\_' \CR}{to read from the disk area
        pointed at by the logical {\tt MYDATA} and the data from
        program ID {\tt AC238}\@.}
\dispt{NFILES\qs 0 \CR}{to start with file AC238\_1.  If your first
        file is \eg\ {\tt AC238\_4}, set {\tt NFILES = 3}.}
\dispt{NCOUNT\qs 3 \CR}{to read three data files {\tt AC238\_1} through
        {\tt AC238\_3}\@.}
\dispt{OUTNA\qs ' ' \CR}{to take the default output file name.}
\dispt{OUTDI\qs 3 \CR}{to write the data to disk 3 (one with enough
         space).}
\dispt{DOUVCOMP\qs -1 \CR}{to write visibilities in uncompressed
         format.  VLA files are small by modern standards, so saving
         space is not worth the costs.}
\dispt{DOWEIGHT\qs 1 \CR}{Data weights will depend on the ``nominal
        sensitivity'' and should be calibrated along with the
        visibility amplitudes ({\tt DOCALIB = 1})\@.}
\dispt{CPARM\qs 0 \CR}{to do no averaging of the data in {\tt FILLM}\@.}
\dispt{CPARM(6)\qs 1 \CR}{to select VLA sub-array 1.}
\dispt{CPARM(7)\qs 2000 \CR}{to have observations within 2 MHz be
         regarded as being at the same frequency.}
\dispt{CPARM(8)\qs 1 \CR}{to use a 1-minute interval for the {\tt CL}
         table; default is 5 min.}
\dispt{CPARM(9)\qs 0.25 \CR}{to use a 15-second interval for the {\tt
         TY} table; default is the input data interval.}
\dispt{DPARM\qs 0 \CR}{to have no selection by specific frequency.}
\dispt{REFDATE\qs '{\it yyyymmdd\/}' \CR}{to specify the year, month,
         and day of the reference date.  This should be the first date
         in the data set (or earlier).  All times in \AIPS\ will be
         measured with respect to that date and must be positive.  The
         default is the first date included by the data selection
         adverbs, which may not be the desired one. Note that {\tt
         REFDATE} is only a reference point; it does not affect which
         data are loaded from the the files.}
\dispf{TIMERANG\qs {\it db} , {\it hb} , {\it mb} , {\it sb} , {\it
         de},  {\it he} , {\it me} , {\it se} \CR}{to specify the
         beginning day, hour, minute, and second and ending day, hour,
         minute, and second (wrt {\tt REFDATE}) of the data to be
         included.  The default is to include all times.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when you're satisfied with inputs.}
\dispe{In {\tt 31DEC21}, {\tt FILLM} first tries to open the file under
the name in {\tt DATAIN}\@.  If that fails, it then tries the name in
{\tt DATAIN} with the file number appended as described above.}

     There are numerous adverbs including {\tt BAND}, {\tt QUAL},
{\tt CALCODE}, {\tt VLAOBS}. and {\tt VLAMODE} to limit what data were
loaded from magnetic tapes which could hold data from multiple
projects.  These adverbs still function, but are of little use today.
Note that the values given above are illustrative and should not be
copied verbatim in most cases.

      Be careful when choosing the averaging time with {\tt CPARM(1)}.
If you have a large data set, setting this time too {\it low\/} will
make an unnecessarily large output file; this may waste disk space
and slow the execution of subsequent programs.  Setting it too {\it
high\/} can, however, (1) smear bad data into good, limiting the
ability to recognize and precisely remove bad data, (2) smear features
of the image that are far from the phase center, and (3) limit the
dynamic range that can be obtained using self-calibration.  If you
need a different (usually shorter) averaging time for the calibrator
sources than for your program sources, use {\tt CPARM(10)} to specify
the averaging time for calibrators.  See Lectures~12  and 13 in
{\it \jndx{Synthesis Imaging in Radio Astronomy}\/}\footnote{{\it
Synthesis Imaging in Radio Astronomy\/}, Astronomical Society of the
Pacific Conference Series, Volume~6 ``A Collection of Lectures from
the Third NRAO Synthesis Imaging Summer School'' eds.\/ R.\ A.\
Perley, F.\ R.\ Schwab and A.\ H.\ Bridle (1989)} for general guidance
about the choice of averaging time given the size of the required
field of view and the observing bandwidth.

     {\tt CPARM(2)} controls a number of mostly esoteric options.  If
your data include the Sun (see \Sec{oldsuncal}) or planets, you must
set {\tt CPARM(2) = 16} to avoid having each scan on the moving source
assigned a different name.  The adverb {\tt DOWEIGHT = 1} has the same
affect as {\tt CPARM(2) = 8} and both select the use of the nominal
sensitivity to scale the data weights.  When this is done, the weights
will be $1/\sigma^2$ as they should for imaging, with $\sigma$ in
``Jy'' in the same uncalibrated scale as the fringe visibilities.
Having selected this option, you should apply any amplitude
calibration to the weights as well as the visibilities.  If you store
the data in compressed form, only one weight may be retained with each
sample. Any differences between polarizations and/or IFs in that
sample will be lost.  Uncompressed data require less CPU, but more
real, to read but 2 to 3 times as much disk space to store.

      {\tt CPARM(2)=2048} allows you to load data as correlation
coefficients, which can be scaled to visibilities later with {\tt
TYAPL} (\Sec{oldVLATY}).  {\tt CPARM(3)} controls which on-line flags
are applied by {\tt \Tndx{FILLM}}, which now always writes an {\tt OF}
table containing information about these flags.  That information can
be viewed with {\tt \Tndx{PRTOF}} and applied selectively to the data
at a later time with {\tt \Tndx{OFLAG}}\@.

      {\tt FILLM} writes a weather ({\tt WX}) table to the output
file.  At the same time, it uses ``canned'' \indx{VLA} antenna gain
curves and a balance of the current with a seasonal model weather data
to estimate opacity and gain corrections to be written into the first
calibration ({\tt CL}) table.  These functions are controlled by
adverbs {\tt CALIN} and {\tt BPARM} and may be turned off, although
the default is to make the corrections. In subsequent tasks, set {\tt
DOCALIB = 1} to use these initial calibration data.  If, for some
reason, the data weights do not depend on the nominal sensitivity, use
{\tt DOCALIB=100} to apply calibration.

     Where possible, {\tt FILLM} will try to place all data in one
file.  However, in many cases this is not possible.  For instance
so-called ``channel 0'' data from a spectral-line observation will be
placed in a separate file from its associated line data.  Similarly,
scans which have differing numbers of frequency channels will also be
placed into separate files.  Another case is observations made in mode
LP, \ie\ one IF-pair is set to L band, the other to P band. In this
case the two bands will be split into separate files.  Yet another
case arises when there are observations of different bandwidths. All
of this should be relatively transparent to the user.

     {\tt FILLM} and many \AIPS\ tasks are able to handle multiple,
logically different, frequencies within a multi-source data set.  {\tt
FILLM} does this by assigning an {\tt FQ} number to each observation
\todx{FQ number} and associating a line of information about that
frequency in the {\tt FQ} file associated with the data set.  Users
should note that this concept can become quite complicated and that
not all tasks can handle it in full generality.  In fact, most tasks
can only process one {\tt FQ} number at a time.  Polarization
calibration works only on one {\tt FQ} at a time since the antenna
file format allows for only one set of instrumental polarization
parameters.  Therefore, it is {\it strongly\/} advised that you fill
continuum experiments which involve multiple frequencies into separate
data sets.  {\tt FILLM} will separate bands automatically, but you
will have to force any remaining separation.  To do this, (a) use the
{\tt QUAL} adverb in {\tt FILLM}, assuming that you have used separate
qualifiers in {\tt OBSERVE} for each frequency pair; (b) use the {\tt
DPARM} adverb array in {\tt FILLM} to specify the desired frequencies
precisely; or (c) use the {\tt UVCOP} task to separate a multiple {\tt
FQ} data set into its constituent parts.  Note that the first two
options require multiple executions of {\tt FILLM}, while the third
option requires more disk space.

      Spectral-line users and continuum observers using different
frequencies in the same band should be aware of the {\tt FQ} entry
tolerance.  Each frequency in a \uv\ file will be assigned an {\tt FQ}
number as it is read from disk by \hbox{{\tt \Tndx{FILLM}}}.  For
spectral-line users, the observing frequency will normally change as a
function of time due to Doppler tracking of the Earth's rotation, or
switching between sources or between spectral lines; in general, this
will cause different scans to have different {\tt FQ} numbers.  {\tt
FILLM} assigns an {\tt FQ} number to a scan based on the {\tt FQ}
tolerance adverb {\tt CPARM(7)} which defines the maximum change of
frequency allowed before a new {\tt FQ} number is allocated.  If
{\tt CPARM(7) < 0}, the the same FQ number is assigned to all data in
spectral-line data sets.  If {\tt CPARM(7)} is positive, a scan's
\todx{FQ number} will be assigned to an existing {\tt FQ} number if
$$ \| \nu_{current} - \nu_{firstFQ} \| < {\tt CPARM(7)} $$
where $\nu_{firstFQ}$ is the frequency of the first sample to which
the particular {\tt FQ} number was assigned.  If no match is found,
then a new {\tt FQ} number is created and assigned and another line
added to the {\tt FQ} table file.  Alternatively, if {\tt CPARM(7)} is
zero, then the {\tt FQ} tolerance is assumed to be half of the
maximum frequency difference caused by observing in directions 180
degrees apart (\ie\ $\Delta\nu = 10^{-4}\times \nu$).

     An example: if an observer observes the 1612, 1665 and 1667 MHz
OH masers in VY CMa and NML Cygnus, then presumably he would like his
data to have 3 {\tt FQ} numbers, one associated with each OH
transition.  However, running {\tt \tndx{FILLM}} with {\tt CPARM(7)}
set to $0$ would produce 6 {\tt FQ} numbers because the frequency
difference between the masers in VY CMa and NML Cygnus is greater than
the calculated tolerance of 160 kHz.  Therefore, in order to ensure
that only 3 {\tt FQ} numbers are assigned, he should set {\tt
CPARM(7)} to 1000 kHz.  Setting {\tt CPARM(7) < 0} would result in all
data having the same {\tt FQ} number, which is clearly undesirable.

     For most continuum experiments the {\tt FQ} number will be
constant throughout the database.  Normally any change in frequency
should be given a new {\tt FQ} number.  To achieve this, {\tt FILLM}
treats {\tt CPARM(7)} differently for continuum.  If {\tt CPARM(7)}
$\leq$ 0.0, then {\tt FILLM} assumes a value of 100 kHz.  A positive
value of {\tt CPARM(7)} is treated as a tolerance in kHz as in the
spectral line case.

      {\bf Note:} {\it If your \uv\ database contains several
frequency identifiers, you should go through the calibration steps for
each {\tt FQ} code separately.}

     {\tt FILLM} can still read from magnetic tape.  Set {\tt DATAIN}
to blanks, mount your tape (adverb {\tt INTAPE}), index the tape with
{\tt PRTTP}, and use the adverbs to limit the data loaded to that
portion of your project in which you are interested.

      If {\tt FILLM} is executing correctly, your message terminal
will report the number of your observing program, the \indx{VLA}
archive format revision number, and then the names of the sources as
they are found in the data files.  Once {\tt FILLM} has completed, you
can find the database on disk using:
\dispt{INDI\qs 0 ; \tndx{UCAT} \CR}{ }
\dispe{This should produce a listing such as:}
\bve
Catalog on disk  3
Cat Usid Mapname      Class  Seq  Pt     Last access      Stat
  1  103 25/11/88    .X BAND.   1 UV 26-JAN-2018 12:34:16
\end{verbatim}\eve

     You might then examine the header information for the disk data set by:
\dispt{INDI\qs 3 ; GETN\qs 1 ; \tndx{IMHEAD} \CR}{}
\dispe{This should produce a listing like:}
\bve
AIPS 1: Image=MULTI     (UV)         Filename=25/11/88    .X BAND.   1
AIPS 1: Telescope=VLA                Receiver=VLA
AIPS 1: Observer=AC238               User #=   36
AIPS 1: Observ. date=25-NOV-1988     Map date=26-JAN-2018
AIPS 1: # visibilities   2613887     Sort order  TB
AIPS 1: Rand axes: UU-L-SIN  VV-L-SIN  WW-L-SIN  BASELINE  TIME1
AIPS 1:            SOURCE  FREQSEL
AIPS 1: ----------------------------------------------------------------
AIPS 1: Type    Pixels   Coord value     at Pixel     Coord incr   Rotat
AIPS 1: COMPLEX      1   1.0000000E+00       1.00  1.0000000E+00    0.00
AIPS 1: STOKES       4  -1.0000000E+00       1.00 -1.0000000E+00    0.00
AIPS 1: FREQ         1   8.4110000E+09       1.00  1.2500000E+07    0.00
AIPS 1: IF           2   1.0000000E+00       1.00  1.0000000E+00    0.00
AIPS 1: RA           1    00 00 00.000       1.00       3600.000    0.00
AIPS 1: DEC          1    00 00 00.000       1.00       3600.000    0.00
AIPS 1: ----------------------------------------------------------------
AIPS 1: Coordinate equinox 1950.00
AIPS 1: Maximum version number of extension files of type HI is   1
AIPS 1: Maximum version number of extension files of type AN is   1
AIPS 1: Maximum version number of extension files of type NX is   1
AIPS 1: Maximum version number of extension files of type SU is   1
AIPS 1: Maximum version number of extension files of type FQ is   1
AIPS 1: Maximum version number of extension files of type CL is   1
AIPS 1: Maximum version number of extension files of type TY is   1
AIPS 1: Maximum version number of extension files of type WX is   1
AIPS 1: Maximum version number of extension files of type OF is   1
AIPS 1: Keyword = 'CORRMODE'  value = '        '
AIPS 1: Keyword = 'VLAIFS  '  value = 'ABCD    '
AIPS 1: Keyword = 'CORRCOEF'  value =           -1
\end{verbatim}\eve
\dispe{This header identifies the file as a multi-source file ({\tt
Image=MULTI}) with 2613887 floating-point visibilities in time-baseline
({\tt TB}) order.  There are two entries on the {\tt IF} axis.  These
correspond to the old VLA's ``AC'' and ``BD'' IF-pairs respectively.
The description of the frequency ({\tt FREQ}) axis shows that the
first IF (``AC'') is at 8411 MHz and has 12.5 MHz bandwidth.  The
parameters of the second IF-pair (``BD'') are determined from the data
in the {\tt FQ} table file and cannot be read directly from this
header; these values are shown in the {\tt 'SCAN'} listing from
\hbox{{\tt LISTR}}.  The header shown above indicates that the data
are in compressed format since the number of pixels on the {\tt
COMPLEX} axis is 1 and the {\tt WEIGHT} and {\tt SCALE} random
parameters are not present.  Uncompressed data does not use these
random parameters and has 3 pixels on the {\tt COMPLEX}
axis.\todx{IMHEAD}}

     The term ``IF'' can be confusing.  At the \indx{VLA}, IFs ``A''
and ``C'' correspond to right-hand and left-hand circularly polarized
(RHC and LHC) signals, respectively, and are normally for the same
frequency in an observing band.  Such pairs, if at the same frequency,
are considered to be one ``IF'' in \hbox{\AIPS}.   An observation
which was made in spectral line mode ``{\tt 2AC}'' is considered at
the VLA to have two ``IFs'' whereas within \AIPS\ this would be filled
as one ``IF'' with two polarizations if they were both observed with
the same frequency, the same number of channels, and the same channel
separation.  If these conditions do not hold, then they are filled
into separate \uv\ files, each with a single IF and a single
polarization.  The term ``sub-array'' is also confusing.  At the VLA
--- and in task {\tt \tndx{FILLM}} --- sub-array means the subset of
the 27 antennas actually used to observe your sources.  (The historic
VLA allowed up to 5 simultaneous sub-arrays in this sense.)  In the
rest of \AIPS, sub-array refers to sets of antennas used together at
the same time.  If observations from separate times (\eg\ separate
array configurations) are concatenated into the same file, then \AIPS\
will regard the separate sets of antennas as different ``sub-arrays''
whether or not the same physical antennas occur within more than one
of these sub-arrays.

     Besides the main $uv$ data file, this header listing shows that
there are numerous ``extension'' files attached to the data.  These
are, in order, the history, antenna, index, source, frequency,
calibration, system temperature, weather, and on-line flags tables.
{\tt \tndx{LISTR}} with {\us OPTYPE='SCAN'} provides a useful summary
of the index, source, and frequency tables.\iodx{extension files}

     If your experiment contains data from several bands {\tt
\Tndx{FILLM}} will place the data from each band in separate data
sets.  Also, if you observed with several sets of frequencies or
bandwidths in a given observing run these will be assigned different
{\tt FQ} numbers by \hbox{{\tt FILLM}}.  You can determine which
frequencies correspond to which {\tt FQ} numbers from the {\tt 'SCAN'}
listing provided by \hbox{{\tt LISTR}}.  Line data are divided into
the ``channel 0'' (central $3/4$ of the of the observing band
averaged) and the spectra. Data observed in the ``LP'' mode (or any
other two-band mode) will be broken into separate data sets, one for
each band.

\Subsections{Reading old spectral-line data}{oldlineread}

     If your spectral-line data are in a \indx{VLA} archive disk file,
they should be read into \AIPS\ using {\tt \tndx{FILLM}}, as described
in \Sec{fillmold}.  {\tt FILLM} will fill a typical line observation
into two files, a large one containing the line data only, and a
smaller file containing the ``channel-0'' data.  (Note that {\tt
  FILLM} computes channel-0 from the line data rather than using the
channel-0 provided by the on-line system.)  The standard
\Indx{calibration} and editing steps are performed on channel 0 and
the results copied over to the line data set.  {\it You must be
  careful with the tolerance you   allow {\tt FILLM} to use in
  determining the {\tt FQ} numbers.  If   you desire all of your data
  to have the same {\tt FQ} number, so   that you can calibrate it all
  in one pass, then set {\tt CPARM(7)}   in {\tt FILLM} to an
  appropriately large value.}  If you wish to retain spectral-line
autocorrelation data, you must set {\tt DOACOR} to true.

     By default for the VLA, the channel-0 data are generated by the
vector average of the central {\it 3/4\/} of the observing band.  If
this algorithm is not appropriate for your data, you may generate your
own channel-0 data set by averaging only selected channels.  You may
now select different spectral channels in different IFs.  To do this,
use the task {\tt \tndx{AVSPC}}:
\dispt{TASK\qs 'AVSPC' \CR}{}
\dispt{INDI\qs {\it n\/} ; GETN {\it m\/} \CR}{to specify line data
           set.}
\dispt{OUTDI\qs {\it i\/} ; OUTCL\qs 'CH 0' \CR}{to specify output
           ``channel-0'' data set disk and class.}
\dispt{ICHANSEL\qs 10, 30, 1, 0, 31, 55, 2, 1 \CR}{for example, to
           average every channel between 10 and 30 in all IFs and
           also every other channel between 31 and 55, but only in IF
           1.}
\dispt{GO \CR}{to create a new channel-0 data set.}
\dispe{You might find this necessary when observing neutral hydrogen
at galactic velocities.  Most calibrator sources have some absorption
features at these frequencies.}

\Subsections{Applying nominal sensitivities to historic VLA
    data}{oldVLATY}

{\tt FILLM} scales the correlation coefficients by the instantaneous
measured ``nominal sensitivities,'' producing data approximately in
deci-Jy.   The VLA nominal sensitivities are stored in the {\tt TY}
table as ``system temperatures'' ($T_{sys}$)\@.  For calibration
purposes, it is best to have the nominal sensitivities applied, but it
may be better to use a clipped and/or time-smoothed version of those
sensitivities.  If you want to do this, load the $T_{sys}$ data into
the {\tt TY} table with the highest time resolution possible by
setting {\tt CPARM(9)=0} in {\tt FILLM}\@.  {\tt FILLM} can also be
told not to apply the nominal sensitivities and therefor produce
correlation coefficients by setting {\tt CPARM(2)=2048}, but this is
not strictly necessary.  In order to smooth and clip the {\tt TY}
table use the task {\tt \tndx{TYSMO}}\@.  If you have done editing
such as {\tt QUACK}, it may help to copy the data with {\tt UVCOP},
applying your flag table not only to the visibilities but also to the
{\tt TY} table ({\tt UVCOPPRM(6)=3}) before running {\tt TYSMO} to
remove questionable values at the start of scans.  Alternatively,
{\tt \tndx{SNEDT}} will apply the data flags to the table allowing you
to write a new, cleaned-up version of the table.  Then a {\tt TY}
table may be applied (and/or removed) from a data set with {\tt
\tndx{TYAPL}}\@:
\dispt{TASK\qs '\tndx{TYAPL}' ; INP \CR}{to review the inputs needed.}
\dispt{INDI\qs {\it n\/} ; GETN\qs {\it m\/} \CR}{to select the
        correct data  set.}
\dispt{FREQID\qs 1 \CR}{to select {\tt FQ} number 1.}
\dispt{INVERS\qs 1 \CR}{{\tt TY} table to remove from data, will only
        work if data are not already correlation coefficients.}
\dispt{IN2VERS\qs 2 \CR}{smoothed {\tt TY} table to apply to data,
        will only work if data is in correlation coefficient form ---
        either initially or after removal of {\tt INVERS}\@.}
\dispt{INP \CR}{to re-check {\it all\/} the inputs parameters.}
\dispt{GO \CR}{to start the task.}

\Subsections{Calibrating historic VLA data}{oldVLAcal}

There are many similarities to the \indx{calibration} of historic and
modern \indx{VLA} data.  After reading in the data, you should with
both run {\tt LISTR} for the scan listing, {\tt PRTAN} for the antenna
layout information, and {\tt VLANT} to correct antenna positions; see
\Sec{calrecord} and \Sec{blcorr} for details.  The general discussion
on flagging (\Sec{getjy}) applies to both types of data.  However,
with historic VLA data one does a purely continuum calibration and
editing initially.  If the observation is of spectral lines, the flag
and calibration tables are copied to the line $uv$ data file following
the calibration of ``channel 0.''  Thus, the spectral editing tasks
such as {\tt SPFLG}, {\tt FTFLG}, and {\tt RFLAG} become useful only
in the second half of spectral-line reductions.  {\tt TVFLG}
(\Sec{tvflg} below) is the preferred interactive editing task and
editing with {\tt LISTR} plus {\tt UVFLG} (\Sec{uvflg} below) is
actually a reasonable option.

\Subsections{Editing with {\tt LISTR} and {\tt UVFLG}}{uvflg}

      Data may be flagged using task {\tt UVFLG} based on
listings from \hbox{{\tt \tndx{LISTR}}}.  To print out the
scalar-averaged raw amplitude data for the calibrators, and their {\it
rms\/} values, once per scan in a matrix format, the following inputs
are suggested:
\dispt{TASK\qs 'LISTR' ; INP \CR}{to review the inputs needed.}
\dispt{INDI\qs {\it n\/}; GETN\qs {\it m\/} \CR}{to select the data
           set, $n=3$ and $m=1$ above.}
\dispt{SOURCES ' ' ; CALCODE\qs '*' \CR} {to select calibrators.}
\dispt{TIMER\qs 0 \CR}{to select all times.}
\dispt{ANTENNAS\qs 0 \CR}{to list data for all antennas.}
\dispt{OPTYPE\qs 'MATX' \CR}{to select matrix listing format.}
\dispt{DOCRT\qs FALSE \CR}{to route the output to printer, not
           terminal.}
\dispt{DPARM\qs  3 , 1 , 0 \CR}{amplitude and {\it rms\/}, scalar scan
           averaging.}
\dispt{BIF\qs 1; EIF\qs 0 \CR}{to select all IFs, {\tt LISTR} will list
           IFs separately.}
\dispt{FREQID\qs 1 \CR}{to select {\tt FQ} number 1 (note that {\tt FQ}
           numbers must also be done separately).}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when inputs set correctly.}

      For unresolved calibrators, the VLA on-line gain settings
normally produce roughly the same values in all rows and columns
within each matrix.  At L, C, X, and U bands, these values should be
approximately $0.1$ of the expected source flux densities.  At P band,
the factor is about $0.01$.  The factors for other bands are
unspecified.  Any rows or columns with consistently high or low values
in either the amplitude or the {\it rms\/}  matrices should be noted,
as they probably indicate flaky antennas.  In particular, you should
look for
\xbit
\Item In the amp-scalar averages, look for {\it dead\/} antennas,
     which are easily visible as rows or columns with small numbers.
     Rows or columns that differ by factors of two or so from the
     others are generally fine.  Such deviations mean only that the
     on-line gains were not set entirely correctly.
\Item In the {\it rms\/} listings, look for discrepant high values.
     Almost all problems are antenna based and will be seen as a row
     or column.  Factors of 2 too high are normally okay, while
     factors of 5 high are almost certainly indicative of serious
     trouble.
\xeit
\Iodx{editing}\Iodx{flagging}\iodx{VLA}

     The next step is to locate the bad data more precisely.  Suppose
that you have found a bad row for antenna 3 in right circular
polarization in IF 2 between times ({\it d1\/}, {\it h1\/}, {\it
m1\/}, {\it s1\/}) and ({\it d2\/}, {\it h2\/}, {\it m2\/}, {\it
s2\/}).  You might then rerun {\tt \tndx{LISTR}} with the following
new inputs:
\dispt{SOURCES\qs ' ' \CR} {to select all sources.}
\dispt{TIMER\qs {\it d1 h1 m1 s1 d2 h2 m2 s2} \CR}{to select by time
           range.}
\dispt{ANTENNAS\qs 1 , 2 , 3 \CR}{to list data for antenna 3 with two
           ``control'' antennas.}
\dispt{BASEL\qs 1 , 2 , 3 \CR}{to list all baselines with these three
           antennas.}
\dispt{OPTYPE\qs 'LIST' \CR}{to select column listing format.}
\dispt{DOCRT\qs 1 \CR}{to route the output to terminal at its width.}
\dispt{DPARM\qs = 0 \CR}{amplitude only, no averaging.}
\dispt{STOKES\qs 'RR' \CR}{to select right circular.}
\dispt{BIF\qs 2 \CR}{to specify the ``BD'' IFs.}
\dispt{FLAGVER\qs 1 \CR}{to choose flag table 1.}
\dispt{GO \CR}{to run the program.}
\dispe{This produces a column listing on your terminal of the
amplitude for baselines 1--2, 1--3 and 2--3 at every time stamp
between the specified start and stop times.  The `1--2'' column
provides a control for comparison with the two columns containing the
suspicious antenna.}

     Note that ``amp-scalar'' averaging ignores phase entirely and is
therefore not useful on weak sources, nor can it find jumps or other
problems with the phases.  To examine the data in a phase-sensitive
way, repeat the above process, but set {\us DPARM(2) = 0} rather than
1.  Bad phases will show up as reduced amplitudes and increased {\it
rms\/}'s.

     Once bad data have been identified, they can be expunged using
\hbox{{\tt \tndx{UVFLG}}}.  For example, if antenna 3 RR was bad for
the full interval shown above, it could be deleted with
\dispt{TASK\qs 'UVFLG' ; INP \CR}{to select the editor and check its
          inputs.}
\dispt{TIMER\qs {\it d1 h1 m1 s1 d2 h2 m2 s2} \CR}{to select by time
           range.}
\dispt{BIF\qs 2 ; EIF = BIF \CR}{to specify the ``BD'' IFs.}
\dispt{BCHAN\qs 0 ; ECHAN\qs 0 \CR}{to flag all channels.}
\dispt{FREQID\qs 1 \CR}{to flag only the present {\tt FQ} number.}
\dispt{ANTEN\qs 3 , 0 \CR}{to select antenna 3.}
\dispt{BASEL\qs 0 \CR}{to select all baselines to antenna 3.}
\dispt{STOKES\qs 'RR' \CR}{to select only the RR Stokes (LL was found
           to be okay in this example).}
\dispt{REASON = 'BAD RMS WHOLE SCAN' \CR}{to set a reason.}
\dispt{OUTFGVER\qs 1 \CR}{to select the first (only) flag table.}
\dispt{INP \CR}{be careful with the inputs here!}
\dispt{GO \CR}{to run the task when ready.}

     Continue the process until you have looked at all parts of the
data set that seemed anomalous in the first matrix listing, then rerun
that listing to be sure that the flagging has cleaned up the data set
sufficiently.  If there are lots of bad data, you may find that you
have missed a few on the first pass.  If you change your mind about a
flagging entry, you can use {\tt \tndx{UVFLG}} with {\us OPCODE =
'UFLG'} to remove entries from the flag table.  All adverbs of {\tt
UVFLG} are used when removing entries, so you may use {\tt REASON}
along with the channel, IF, source, et al.~adverbs to select the
entries to be removed.  {\tt OPCODE}s {\tt 'REAS'} and {\tt 'WILD'}
may be used to undo an entry solely based on the {\tt REASON}\@.  If
the table becomes hopelessly messed up, use {\tt \tndx{EXTDEST}} to
delete the flag table and start over or use a higher numbered flag
table. The contents of the flag table may be examined at any time with
the general task {\tt \tndx{PRTAB}} and entries in it may also be
removed with {\tt \tndx{TABED}} and/or \hbox{{\tt TAFLG}}.  Two flag
tables can be merged using {\tt TAPPE}\@.
\Iodx{editing}\Iodx{flagging}

\Subsections{Editing with {\tt TVFLG}}{tvflg}

       If your data are seriously corrupted, contain numerous
baselines, and you like video games, {\tt \Tndx{TVFLG}} is the
visibility editor of choice.  The following discussion assumes that
you have read \Sec{xas} and are familiar with using the \AIPS\ TV
display.  The latest versions of {\tt TVFLG} and {\tt SPFLG} are
described in detail in an \AIPS\ Memo\footnote{Greisen, E. W. 2025,
``Interactive flagging in \AIPS'', \AIPS\ Memo 127, {\tt
https://www.aips.nrao.edu/aipsdoc.html}} which should be consulted for
current details.  The following inputs are suggested:\iodx{VLA}
\dispt{TASK\qs 'TVFLG' ; INP \CR}{to review the inputs needed.}
\dispt{INDI\qs {\it n\/} ; GETN\qs {\it m\/} \CR}{to select the data
         set, $n=3$ and $m=1$ above.}
\dispt{SOURCES\qs ' ' \CR} {to select all sources.}
\dispt{TIMER\qs 0 \CR}{to select all times.}
\dispt{STOKES\qs 'FULL' \CR}{to select all four or {\tt 'HALF'} to
         select the two parallel-hand polarizations; you can then
         toggle between them interactively.}
\dispt{FREQID\qs 3 \CR}{Select {\tt FQ} entry 3.}
\dispt{BIF\qs 1 ; EIF\qs 2 \CR}{to specify both VLA IFs; you can then
         toggle between the two interactively.}
\dispt{ANTENNAS\qs 0 \CR}{to display data for all antennas.}
\dispt{BASELINE\qs 0 \CR}{to display data for all baselines.}
\dispt{DOCALIB\qs 1 \CR}{to apply initial calibration to the data.}
\dispt{FLAGVER\qs 1 \CR}{to use flag ({\tt FG}) table 1.}
\dispt{OUTFGVER\qs 0 \CR}{to create a new flag table with the flags
      from {\tt FG} table 1 plus the new flags.}
\dispt{DPARM\qs = 0 \CR}{to use default initial displays and normal
         baseline ordering.}
\dispt{DPARM(6)\qs = 30 \CR}{to declare that the input data are
         30-second averages, or to have the data averaged to 30
         seconds.  Note that one can interactively increase the time
         averaging, in integer units of {\tt DPARM(6)}, after the
         master grid is created.}
\dispt{DPARM(5)\qs = 10 \CR}{to expand the flagging time ranges
         by 10 seconds in each direction.  The times in the master
         grid are average times and may not encompass the times of the
         samples entering the average without this expansion.}
\dispt{DOCAT\qs 1 \CR}{to save the master grid file.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when inputs set correctly.}
\dispe{If you make multiple runs of {\tt TVFLG}, it is important to
make sure that the flagging table entries are all in one version
of the {\tt FG} table.  The easiest way to ensure this is to set
{\tt FLAGVER} and {\tt OUTFGVER} to 0 and keep it that way for all
runs of {\tt TVFLG}\@.  If you make a mistake, two flag tables may be
merged with the task {\tt TAPPE}\@.}

     {\tt TVFLG} begins by constructing a ``master grid'' file of all
included data.  This can be a long process if you include lots of data
at once, even though a faster, large-memory method of gridding is now
usually used.  It is probably better to use the channel selection
(including averaging channels with {\tt NCHAV}), IF selection, source
selection, and time range selection adverbs to build rather smaller
master grid files and then to run {\tt TVFLG} multiple times.  It will
work with all data included, allowing you to select interactively which
data to edit at any one moment and allowing you to resume the editing as
often as you like.  But certain operations (such as undoing flags) have
to read and process the entire grid, and will be slow if that grid is
large.  The master grid file is always cataloged (on {\tt IN2DISK} with
class {\tt TVFLGR}), but is saved at the end of your session only if you
set {\us DOCAT = 1} (actually $ > 0$) before starting the task.  To
resume {\tt TVFLG} with a pre-existing master grid file, set the adverb
{\tt IN2SEQ} (and {\tt IN2DISK}) to point at it.  When resuming in this
way, {\tt \Tndx{TVFLG}} ignores all of its data selection adverbs since
they might result in a different master grid than the one it is going to
use.  If you wish to change any of the data selection parameters, \eg\
channels, IFs, sources, times, or time averaging, then you must use a
new master grid.\Iodx{editing}\Iodx{flagging}

     Kept with the master grid file is a special file of {\tt TVFLG}
flagging commands.  This file is updated as soon as you enter a new
flagging command, making the master grid and your long editing time
virtually proof from power failures and other abrupt program
terminations.  These flagging commands are not entered into your
actual {\it uv\/} data set's flagging ({\tt FG}) table until you exit
from {\tt TVFLG} and tell it to do so.  During editing, {\tt TVFLG}
does not delete data from its master grid; it just marks the flagged
data so that they will not be displayed.  This allows you to undo
editing as needed during your {\tt TVFLG} session(s).  When the flags
are transferred to the main {\it uv\/} data set, however, the flagged
data in the master grid are fully deleted since undoing the flags at
that point has no further meaning.  When you are done with a master
grid file, be sure to delete it (with {\tt ZAP}) since it is likely to
occupy a significant amount of disk.\iodx{VLA}

     {\tt TVFLG} keeps track of the source name associated with each
row of data.  When averaging to build the master grid and to build the
displayed grids, {\tt TVFLG} will not average data from different
sources and will inform you that it has omitted data if it has had to
do so for this reason.  For multi-source files, the source name is
displayed during the {\tt CURVALUE}-like sections.  However, the
flagging table is prepared to flag {\it all\/} sources for the
specified antennas, times, {\it etc.}~or just the displayed source.
If you are flagging two calibrator scans, you may wish to do all
sources in between as well.  Use the {\tt SWITCH SOURCE FLAG}
interactive option to make your selection before you create flagging
commands.  Similarly, you will need to decide whether flagging
commands that you are about to prepare apply only to the displayed
channel and/or IF, or to all possible channels and/or IFs.  In
particular, spectral-line observers often use {\tt TVFLG} on the
pseudo-continuum ``channel-0'' data set, but want the resulting flags
to apply to all spectral channels when copied to the spectral-line
data set.  They should be careful to select all channels before
generating any flagging commands.  Each flagging command generated is
applied to a list of Stokes parameters, which {\it does not have to
include\/} the Stokes currently being displayed.  When you begin {\tt
TVFLG} and whenever you switch displayed Stokes, you should use the
{\tt ENTER STOKES FLAG} option to select which Stokes are to be
flagged by subsequent flagging commands.

     If you get some of this wrong, you can use the {\tt UNDO FLAGS}
option in {\tt TVFLG} if the flags have not yet been applied to the
\uv\ data set.  Or you can use tasks {\tt UVFLG}, {\tt TABED} or {\tt
TAFLG} to correct errors written into the {\tt FG} table of your
multi-source \uv\ data set.  Flag tables are now used with both
single- and multi-source data sets.

     {\tt TVFLG} displays the data, for a single IF, channel
(average), and Stokes, as a grey-scale display with time increasing up
the screen and baseline number increasing to the right.  Thus
baselines for the VLA run from left to right as 1--1, 1--2, 1--3,
$\ldots$, 2--2, 2--3, $\ldots$, 27--27, 27--28, and 28--28.  An input
parameter ({\tt DPARM(3) = 1} allows you to create a master grid and
display baselines both as, say 1--2 and 2--1.  An interactive
(switchable) option allows you to order the baselines from shortest to
longest (ignoring projection effects) along the horizontal axis.

     The interactive session is driven by a menu which is displayed on
a graphics overlay of the TV display.  An example of this full display
is shown on the next page.  Move the cursor to the desired operation
(noting that the currently selected one is highlighted in a different
color on many TVs) and press button A, B, or C to select the desired
operation; pressing button D produces on-line help for the selected
operation.  The first (left-most column) of choices is:
\dispx{OFFZOOM  }{turn off any zoom magnification}
\dispx{OFFTRANS }{turn off any black \&\ white enhancement}
\dispx{OFFCOLOR }{turn off any pseudo-coloring}
\dispx{TVZOOM   }{interactive zoom as in {\tt AIPS}}
\dispx{TVTRANSF }{black \&\ white enhancement as in {\tt AIPS}}
\dispx{TVPSEUDO }{many pseudo-colorings as in {\tt AIPS}}
\dispx{TVPHLAME }{many flame-like pseudo-colorings as in {\tt AIPS}}
\dispx{OFMCOLOR }{30 pseudo-colorings as in {\tt AIPS}}
\dispx{DO WEDGE ? }{switches choice of displaying a step wedge}
\dispx{LOAD xxxx  }{switch TV load transfer function to xxxx}
\dispx{LIST FLAGS }{list selected range of flag commands}
\dispx{UNDO FLAGS }{remove flags by number from the {\tt FC} table
         master grid}
\dispx{REDO FLAGS }{re-apply all remaining flags to master grid}
\dispx{SET REASON }{set reason to be attached to flagging commands}
\dispx{DO LABEL ? }{turn axis labeling on and off}
\dispx{CHAR MULT  }{to control TV character size as in {\tt AIPS}}
\dispe{Note: when a flag is undone, all cells in the master grid which
were first flagged by that command are restored to use.  Flag commands
done after the one that was undone may also, however, have applied to
some of those cells.  To check this and correct any improperly
un-flagged pixels, use the {\tt REDO FLAGS} option.  This option even
re-does {\tt CLIP} operations!  After an {\tt UNDO} or {\tt REDO FLAGS}
operation, the TV is automatically re-loaded if needed.  Note that the
{\tt UNDO} operation is one that reads and writes the full master
grid. \Iodx{editing}\Iodx{flagging}\Todx{TVFLG}}

The load to the TV for all non-phase displays may be done with all
standard transfer functions: LINear, LOG, SQRT, LOG2 (more extreme
log).  The menu shows the next one in the list (xxxx above) through
which you may cycle.  The TV is reloaded immediately when a new
transfer function is selected.\iodx{VLA}

\begin{figure}
\centering
%\resizebox{!}{6.35in}{\gname{tvflgnew}}
\resizebox{!}{6.35in}{\gbb{530,730}{tvflg14}}
\caption[{\tt TVFLG} display]{A display of a sample TV screen from
\hbox{{\tt TVFLG}}, made using the \AIPS\ task {\tt TVCPS} to produce
a negative black-and-white display.  The {\tt TVFLG} menu (in the
boxes) is displayed in a graphics plane which is normally colored
light green.  The status line(s) at the bottom and optional axis
labels are displayed in a graphics plane that is normally cyan in
color.  The data are grey scales in a TV memory and may be enhanced in
black-and-white or pseudo-colored. The particular display chosen is
the amplitude of the vector difference between the sample and a
running vector average of samples surrounding it.  This particular
parameter is sensitive to both phase and amplitude problems and may
save you the extra time of looking at phase and amplitude separately.
It requires that there be data to average, but does not blur the
flagging by the averaging interval (as the RMS method does).  The
visibility data are from the JVLA\@.  All baselines are shown once
only in baseline number order.  Antenna 8 and 27 are missing for all
times, while antennas 11 and 22 are missing for some times in the
piece displayed here.  The displayed data are the RR Stokes samples
and have been windowed to exclude some times.  Flag commands generated
at the moment illustrated will flag all source names, one spectral
channel (actually channels 9-24 averaged here), one IF, and Stokes RR
only (from a 2-Stokes data set).  The step wedge and labeling options
have been selected.  This figure was produced with an older version of
{\tt TVFLG}; consult \AIPS\ Memo 127 for the latest details.
\Iodx{editing} \Iodx{flagging}\Todx{TVFLG}\iodx{VLA}}
\label{fig:tvflg}
\end{figure}

     Column 2 offers type-in controls of the TV display and controls
of which data are to be flagged.  In general, the master grid will be
too large to display on the TV screen in its entirety.  The program
begins by loading every $n^{\uth}$ baseline and time smoothing by {\it
m\/} time intervals in order to fit the full image on the screen.
However, you may select a sub-window in order to see the data in more
detail. You may also control the range of intensities displayed (like
the adverb {\tt PIXRANGE} in {\tt TVLOD} inside \hbox{{\tt AIPS}}).
The averaging time to smooth the data for the TV display may be
chosen, as may the averaging time for the ``scan average'' used in
some of the displays.  Which correlators are to be flagged by the next
flagging command may be typed in.  All of the standard Stokes values,
plus any 4-bit mask may be entered.  The spectral channel and IF may
be typed in.  Flagging may be done only for the current channel and IF
and source, or it may be done for all channels and/or IFs and/or
sources.  Note that these controls affect the next {\tt LOAD}s to the
TV or the flagging commands prepared after the parameter is changed.
When the menu of options is displayed at the top of the TV, the
current selections are shown along the bottom.  If some will change on
the next load, they are shown with a trailing asterisk.  Column 2
contains
\dispx{ENTER BLC          }{Type in a bottom left corner pixel number
          on the terminal}
\dispx{ENTER TRC          }{Type in a top right corner pixel number on
          the terminal}
\dispx{ENTER AMP PIXRANGE }{Type in the intensity range to be used
         for loading amplitude images to the TV}
\dispx{ENTER PHS PIXRANGE }{Type in the phase range to be used for
        loading phase images to the TV}
\dispx{ENTER RMS PIXRANGE }{Type in the intensity range to be used
        for loading images of the rms to the TV}
\dispx{ENTER R/M PIXRANGE }{Type in the value range to be used for
        loading rms/mean images to the TV}
\dispx{ENTER SMOOTH TIME  }{Type in the time smoothing (averaging)
        length in units of the master grid cell size}
\dispx{ENTER SCAN TIME    }{Type in the time averaging length for
        the ``scan average'' in units of the master grid cell size}
\dispx{ENTER CHANNEL     }{Type in the desired spectral channel
        number using the terminal}
\dispx{ENTER IF          }{Type in, on the terminal, the desired IF
        number}
\dispx{ENTER STOKES FLAG  }{To type in the 4-character string which
        will control which correlators (polarizations) are flagged.
        Note: this will apply only to subsequent flagging commands. It
        should be changed whenever a different Stokes is displayed.}
\dispx{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. The
        former is desirable when a time range encompasses all of 2
        calibrator scans.}
\dispx{SWITCH ALL-CH FLAG }{To reverse the flag all channel status;
        applies to subsequent flag commands}
\dispx{SWITCH ALL-IF FLAG }{To cycle the flag all IFs status;
        applies to subsequent flag commands}
\dispx{AUTO Y ZOOM ?}{To allow interpolative zoom in the time axis}
\dispe{The all-channel flag remains true if the input data set has
only one channel and the all-IF flag remains true if the input data
set has no more than one \hbox{IF}.  If there are more than 2 IFs, the
{\tt SWITCH ALL-IF FLAG} cycles between flagging one IF, flagging a
range of IFs, and flagging all IFs.  When going to the range of IFs,
it will ask you to enter the desired range.
\Iodx{editing}\Iodx{flagging}\Todx{TVFLG}\iodx{VLA}}

     An extra word should be said about the ``scan average'' to which
reference was made above.  This is used solely for displaying the
difference of the data at time {\it T\/} and the average of the data
at times near {\it T\/}.  This average is computed with a ``rolling
buffer.''  Thus, for a scan average time of 30 seconds and data at
10-second intervals, the average for a set of 7 points is as follows:
\bve
      time        average of times
       00           00   10   20
       10           00   10   20
       20           10   20   30
       30           20   30   40
       40           30   40   50
       50           40   50   60
       60           40   50   60
\end{verbatim}\eve

     The third column of options is used to control which data are
displayed and to cause the TV display to be updated.  The master grid
must be converted from complex to amplitude, phase, the rms of the
amplitude, or the rms divided by the mean of the amplitude for
display.  It may also be converted to the amplitude of the vector
difference between the current observation and the ``scan average'' as
defined above or the absolute value of the difference in amplitude
with the scalar-average amplitude or the absolute value of the
difference in phase with the vector scan average.  Furthermore, the
baselines may be reordered in the TV display by their length rather
than their numerical position. This column has the options:
\dispx{DISPLAY AMPLITUDE  }{To display amplitudes on the TV}
\dispx{DISPLAY PHASE      }{To display phases on the TV}
\dispx{DISPLAY RMS        }{To display amplitude rms on the TV}
\dispx{DISPLAY RMS/MEAN   }{To display amplitude rms/mean on the TV}
\dispx{DISPLAY VECT RMS   }{To display vector amplitude rms on the TV}
\dispx{DISPLAY VRMS/VAVG  }{To display vector amplitude rms/mean on
            the TV}
\dispx{DISPLAY AMP V DIFF }{To display the amplitude of the difference
            between the data and a running (vector) ``scan average''}
\dispx{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''}
\dispx{DISPLAY PHASE DIFF }{To display the abs(difference) of the
            phase of the data and the phase of a running (vector)
            ``scan average''}
\dispx{DISPLAY STOKES {\it xx\/}}{To switch to Stokes type {\it xx\/}
            (where {\it xx\/} can be RR, LL, RL, LR, etc.~as chosen by
            the {\tt STOKES} adverb).}
\dispx{SORT BY {\it xxxxxxxx\/}}{To switch to a display with the {\it
            x\/} axis (baseline) sorted by ordered by {\tt LENGTH} or
            by {\tt BASELINE} number}
\dispx{OFF WINDOW + LOAD  }{Reset the window to the full image and
            reload the TV}
\dispx{SET WINDOW + LOAD  }{Interactive window setting (like {\tt
            TVWINDOW}) followed by reloading the TV}
\dispx{LOAD LAST PIECE    }{Reload the TV with the previous piece of
            the total time range.}
\dispx{LOAD NEXT PIECE    }{Reload the TV with the next piece of the
            total time range.}
\dispx{LOAD               }{Reload TV with the current parameters}
\dispe{{\tt SET WINDOW + LOAD} is ``smarter'' than {\tt TVWINDOW} and
will not let you set a window larger than the basic image.  Therefore,
if you wish to include all pixels on some axis, move the TV cursor
outside the image in that direction.  The selected window will be
shown.  When there are more times than will fit on the TV screen at
the current smoothing (averaging) time, the task divides the data up
into overlapping time-range ``pieces.''  When it has done so, the
{\tt LOAD LAST PIECE} and {\tt LOAD NEXT PIECE} menu items will
appear.  This lets you view one piece after the next, rotating through
all pieces, to edit each time interval at full resolution.  Note that
a {\tt FLAG BASELINE} will flag that baseline through all pieces.
\Iodx{editing}\Iodx{flagging}\Todx{TVFLG}\iodx{VLA}}

     The fourth column is used to select the type of flagging to be
done.  During flagging, a TV graphics plane is used to display the
current pixel much like {\tt CURVALUE} in {\tt AIPS}\@.  Buttons
A and B  do the flagging (except A switches corners for the area and
time-range modes).  Button C also does the flagging, but the program
then returns to the main menu rather than prompting for more flagging
selections.  Button D exits back to the menu without doing any
additional flagging.  Another graphics plane is used to show the
current area/time/baseline being flagged.  All flagging commands can
create zero, one, two, or more entries in the flagging list; hit
button D at any time.  There are also two clipping modes, an
interactive one and one in which the user enters the clip limits from
the terminal.  In both, the current image computed for the TV (with
user-set windows and data type, but not any other windows or alternate
pixels etc.~required to fit the image on the TV) is examined for
pixels which fall outside the allowed intensity range.  Flagging
commands are prepared and the master file blanked for all such pixels.
In the interactive mode, buttons A and B switch between setting the
lower and upper clip limits, button C causes the clipping to occur
followed by a return to the main menu, and button D exits to the menu
with no flagging.  The options are
\dispx{FLAG PIXEL      }{To flag single pixels}
\dispx{FLAG/CONFIRM    }{To flag single pixels, but request a yes
          or no on the terminal before proceeding}
\dispx{FLAG AREA       }{To flag a rectangular area in baseline-time}
\dispx{FLAG TIME RANGE }{To flag all baselines for a range of times}
\dispx{FLAG ANTENNA-DT }{To flag all baselines to a specific antenna
          for a range of times}
\dispx{FLAG A TIME     }{To flag all baselines for a specific time}
\dispx{FLAG BASELINE   }{To flag all times for a specific baseline}
\dispx{FLAG BASELINE-DT}{To flag a time range for a specific baseline}
\dispx{CLIP BY SET \#S  }{To enter from the terminal a clipping range
          for the current mode and then clip high and low samples}
\dispx{CLIP INTERACTIV }{To enter with the cursor and LUTs a clipping
          range for the current mode and then clip data outside the
          range.}
\dispx{CLIP BY FORM    }{To clip selected channels/IFs using the
         ``method'' and clipping range of some previous clip
         operation}
\dispx{LOAD NEXT IF/ST }{Load TV with the next IF or polarization.}
\dispx{LOAD NEXT CHAN  }{To load the next spectral channel to the TV
         with current parameters}
\dispx{LOAD PREV CHAN  }{To load the previous spectral channel to the
         TV with current parameters}
\dispe{The {\tt CLIP BY FORM} operation allows you to apply a clipping
method already used on one channel/IF to other channels and/or IFs.
It asks for a command number (use {\tt LIST FLAGS} to find it) and
applies its display type (amp, phase, rms, rms/mean, differences),
averaging and scan intervals and clip levels to a range of channels,
IFs and Stokes (as entered from the terminal).  To terminate the
operation, doing nothing, enter a letter instead of one of the
requested channel or IF 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.}

     The right-most column has only the option:
\dispx{EXIT }{Resume {\tt AIPS} and, optionally, enter the flags
          in the data}
\dispe{Before the flags are entered in the data, {\tt TVFLG} asks you
whether or not you actually wish to do this.  You must respond yes or
no.  Note that, if the master grid is to remain cataloged, there is no
need to enter the flagging commands every time you decide to exit the
program for a while.  In fact, if you do not enter the commands, you
can still undo them later, giving you a reason not to enter them in
the main \uv\ data set too hastily.\Iodx{editing}\Iodx{flagging}
\Todx{TVFLG}\iodx{VLA}}

     The two most useful data modes for editing are probably amplitude
and amplitude of the vector difference.  The former is useful for
spotting bad data over longer time intervals, such as whole scans.
The latter is excellent for detecting short excursions from the norm.
For editing uncalibrated data, rms of two time intervals is useful,
but the rms modes require data to be averaged (inside {\tt TVFLG}) and
therefore reduce the time resolution accuracy of the flagging.
If you edit by phase, consider using the pseudo-coloration scheme that
is circular in color (option {\tt TVPSEUDO} followed by button B)
since your phases are also circular.

     Using {\tt TVFLG} on a workstation requires you to plan the real
estate of your screen.  We suggest that you place your message server
window and your input window side-by-side at the bottom of the screen.
Then put the TV window above them, occupying the upper 70--90\%\ of
the screen area.  (Use your window manager's tools to move and stretch
the TV window to fill this area.)  Instructions and informative,
warning and error messages will appear in the message server window.
Prompts for data entry (and your data entry) appear in the input
window.  Remember to move the workstation cursor into the input window
to enter data (such as IF, channel, antenna numbers, and the like) and
then to move the cursor back into the TV area to select options, mark
regions to be flagged, adjust enhancements, and so on.

\Subsections{Spectral-line calibration}{linecal}

     The \Indx{calibration} of \indx{spectral-line} data is very
similar to that of continuum data with the exception that the antenna
gains have to be determined and corrected as a function of frequency
as well as time. The model used by \AIPS\ is to determine the antenna
gains as a function of time using a pseudo-continuum (``channel-0'')
form of the data.  Then the complex spectral response function
(``bandpass'') is determined from observations of one or more strong
continuum sources at or near the same frequency as the line
observation.  In general, the channel-0 data are calibrated using the
recipes in the previous sections of this chapter.  The sub-sections
below are designed to bring out the few areas in which spectral-line
calibration differs from continuum.

\subsubsections{Spectral-line aspects of {\tt SETJY}}

     The {\tt LISTR} output with {\tt OPTYPE = 'SCAN'} will show
information from the source table including spectral-line parameters.
VLA data from {\tt FILLM} are normally supplied with adequate
information regarding the source velocity, line rest frequency, and
velocity reference (radio versus optical, LSR versus barycentric).
However, data from the EVLA and other telescopes may be missing these
parameters.  {\tt \Tndx{SETJY}} must then be used to fill in the
needed values.  An {\tt OPTYPE='VCAL'} option computes the velocity of
the reference channel from first principles.  It is recommended over
inaccurate guesses of adverb values in other {\tt SETJY OPTYPE}s.  It
may be run over all sources after the rest frequencies and velocity
reference information has been filled in.

\subsubsections{Editing the spectral data}

     You should follow the steps outlined in \Sec{caledit} to edit the
calibrator data using the channel-0 data set.  Even though channel-0
data is continuum, be careful to have {\tt TVFLG} and {\tt UVFLG}
generate the flagging commands for all channels, not just channel 1.
Then, copy the resulting {\tt FG} table to the line file. Use {\tt
\tndx{TACOP}}\iodx{flagging}\iodx{editing}:
\dispt{TASK\qs 'TACOP' \CR}{}
\dispt{INDI\qs {\it n\/} ; GETN\qs {\it m\/} \CR}{to specify channel-0
           data set.}
\dispt{OUTDI\qs {\it i\/} ; GETO\qs {\it j\/} \CR}{to specify the line
           data set.}
\dispt{INEXT\qs 'FG' \CR}{to copy the {\tt FG} table.}
\dispt{INVER\qs 1 \CR}{to copy table 1.}
\dispt{NCOUNT\qs 1 \CR}{to copy only one table.}
\dispt{OUTVER\qs 1 \CR}{to copy it to output table 1}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO\qs \CR}{to run the program when inputs set correctly.}
\dispe{Specifying the ``{\tt ALL-CH}'' setting in {\tt TVFLG} and
specifying {\us BCHAN 1 ; ECHAN 0 \CR} in {\tt UVFLG} cause all
channels to be flagged when the {\tt FG} table is copied to the line
data set.\iodx{VLA}}

     Spectral-line observers should also use {\tt \tndx{SPFLG}}
(\Sec{spflg}) to examine and, perhaps, to edit their data.  This task
is very similar to {\tt TVFLG} described in \Sec{tvflg}, but {\tt
SPFLG} displays spectral channels for all IFs on the horizontal axis,
one baseline at a time.  If you have a large number of baselines, as
with the VLA, then you should examine a few of the baselines to check
for interference, absorption (or emission) in your calibrator sources,
and other frequency-dependent effects.  Use the {\tt ANTENNAS} and
{\tt BASELINE} adverbs to limit the displays to a few short spacings
and one or two longer ones as well.  If there are serious
frequency-dependent effects in your calibrators, use {\tt SPFLG} and
{\tt UVFLG} to delete them.  (You might wish to delete the {\tt FG}
table with {\tt EXTDEST} to begin all over again.)  Then use {\tt
\tndx{AVSPC}} to build a new channel-0 data set and repeat the
continuum editing.  Note that you should not copy the {\tt FG} table
from the spectral-line data set to the new continuum one.  The reason
for this is the confusion over the term ``channel.''  If you have
flagged channel 1, but not all channels, in the spectral-line data set
--- a very common occurrence --- then a copied {\tt FG} table would
flag all of the continuum data since it has only one ``channel.''
When you have flagged the channel-0 data set, you can merge the new
flags back into the spectral-line {\tt FG} table with task \hbox{{\tt
\tndx{TABED}}}\iodx{flagging}\iodx{editing}\iodx{spectral-line}.
\dispt{TASK\qs 'TABED' \CR}{}
\dispt{INDI\qs {\it n\/} ; GETN\qs {\it m\/} \CR}{to specify channel-0
              data set.}
\dispt{OUTDI\qs {\it i\/} ; GETO\qs {\it j\/} \CR}{to specify the line
              data set.}
\dispt{INEXT\qs 'FG' \CR}{to copy the {\tt FG} table.}
\dispt{INVER\qs 1 \CR}{to copy table 1.}
\dispt{OUTVER\qs 1 \CR}{to copy it to output table 1.}
\dispt{BCOUNT\qs 1 ; ECOUNT\qs 0 \CR}{to copy from the beginning to
            the end.}
\dispt{OPTYPE\qs 'COPY' \CR}{to do a simple copy appending the input
            table to the output table.}
\dispt{TIMER\qs 0 \CR}{to copy all times.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO\qs \CR}{to run the program when inputs set correctly.}

     If the channel-0 data set is meaningful for your program sources,
you might consider doing a first-pass editing of them along with your
calibrators before copying the {\tt FG} table back to the line data
set.  If your program sources contain significant continuum emission,
then this is a reasonable operation to perform.  If they do not, then
the standard channel-0 data set is not useful for editing program
sources.  You can use {\tt SPFLG} to edit all channels, or if the
signal is strong in a few channels, you could run {\tt TVFLG} on those
channels from the \indx{spectral-line} data set or average those
with the {\tt BCHAN}, {\tt ECHAN}, and {\tt NCHAV} adverbs.

\subsubsections{Calibrating the spectral data}

The channel-0 data set should be calibrated as described above for
continuum data (\Sec{caledit} and \Sec{getjy}).  When you are
satisfied with your results, you should copy the relevant {\tt CL}
table over to the line data set with {\tt \tndx{TACOP}}:
\iodx{spectral-line}\iodx{VLA}
\dispt{TASK\qs 'TACOP' \CR}{}
\dispt{INDI\qs {\it n\/} ; GETN\qs {\it m\/} \CR}{to specify the
              channel-0 data set.}
\dispt{OUTDI\qs {\it i\/} ; GETO\qs {\it j\/} \CR}{to specify the line
              data set.}
\dispt{INEXT\qs 'CL' \CR}{to copy a {\tt CL} table.}
\dispt{INVER\qs 0 \CR}{to copy highest numbered table from {\tt CLCAL} step.}
\dispt{NCOUNT\qs 1 \CR}{to copy only one table.}
\dispt{OUTVER\qs 0 \CR}{to create new output table.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO\qs \CR}{to run the program when inputs set correctly.}
\dispe{If you copy {\tt SN}, {\tt TY}, or {\tt SY} tables, you may
apply a flagging table to the table values.}

Then one runs {\tt BPASS} on the bandpass calibration source(s).  This
is the same process as for the modern VLA; see \Sec{BPASSit} for
details.

     At this point it is often useful to examine your fully calibrated
data using {\tt \tndx{POSSM}}:
\dispt{TASK\qs 'POSSM' \CR}{}
\dispt{INDI\qs {\it i\/} ; GETN\qs {\it j\/} \CR}{specify line data.}
\dispt{SOURCES\qs '{\it source1\/}' , '\ ' \CR}{to specify the source
            of interest.}
\dispt{ANTENNAS\qs 0 \CR}{to plot all antennas.}
\dispt{BCHAN\qs 10 ; ECHAN\qs 55 \CR}{to plot spectrum for this
            channel range only.}
\dispt{DOCALIB\qs 1 \CR}{to apply the antenna gain to both
            visibilities and weights (if appropriate).
            \Indx{calibration}.}
\dispt{GAINUSE\qs 0 \CR}{to use most recent {\tt CL} table.}
\dispt{DOBAND\qs 3 \CR}{to apply the bandpass calibration time smoothed.}
\dispt{BPVER\qs 1 \CR}{to use {\tt BP} table 1.}
\dispt{FREQID\qs 1 \CR}{to use only one {\tt FQ} value.}
\dispt{APARM\qs 0 \CR}{to do vector averaging of amplitudes and
             self-scale the plots.}
\dispt{SMOOTH\qs 5 , 0 \CR}{to apply Hanning smoothing in the spectral
             domain after bandpass calibration is applied.  Use 13,0
             to smooth after the data are averaged, which is faster
             and less prone to oddities due to channel-dependent
             flagging.  Use 1,0 only if the data were Hanning smoothed
             when {\tt BPASS} was run.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO\qs \CR}{to run the program when inputs set correctly.}
\dispt{GO \tndx{LWPLA} \CR}{to send the plot to the (PostScript)
             printer/plotter.}

     If you have multiple {\tt FQ} entries in your data set, you
should repeat the calibration for each additional {\tt FQ} entry.
Bookkeeping is simplified if you eliminate all extant {\tt SN} tables
before calibrating the data associated with each frequency identifier.
However, it is not essential to do this.\iodx{spectral-line}

\Subsections{Solar data calibration for the historic VLA}{oldsuncal}

     The calibration of solar \uv\ data differs from normal continuum
and spectral-line calibration in one critical respect: the system
temperature correction to the visibility data is applied by the
observer in \hbox{\AIPS}.  See Lecture 21 in {\it \jndx{Synthesis
Imaging in Radio Astronomy}\/} for a discussion of the system
temperature correction as it applies to VLA solar visibility data.
The system temperature correction is embodied in a quantity referred
to as the ``nominal sensitivity,'' an antenna-based numerical factor
normally applied in real time to the scaled correlation coefficients
before they are written to the VLA archive.  With the exception
of X and L band, only a handful of VLA antennas are equipped with
so-called ``solar CALs.''  The nominal sensitivity is only computed
for those antennas so-equipped, namely (for the old VLA) antennas 5,
11, 12, and 18 (at K, U,and C bands) and antennas 7, 12, 21, and 27
(at P band).  The system-temperature correction for those antennas
without solar CALs must, therefore, be bootstrapped from those
antennas which do have solar CALS\@.  This is accomplished through two
tasks for the old VLA and two other tasks for the new VLA\@..  For the
old VLA, {\tt FILLM} fills the uncalibrated visibility data to disk
and places the nominal sensitivities in a {\tt TY} extension table.
Then, {\tt \tndx{SOLCL}} applies the nominal sensitivities to
calibration parameters in the {\tt CL} table.  For the new VLA, {\tt
\tndx{BDF2AIPS}} reads the data in, writing a SysPower ({\tt SY}) and
CalDevice ({\tt CD}) table.  Then {\tt SYSOL} applies the gain and
weight corrections.  See \Sec{BDF2aips} and \Sec{tyapl}.
\Iodx{Solar data}\Iodx{calibration}\iodx{VLA}

\Subsubsections{Reading solar data from the VLA archive}{oldsunread}

To load a solar \uv-data file to disk from an old VLA archive data set
follow the general instructions given above (\Sec{fillmold} and
\Sec{oldlineread}) with the following additions:
\dispt{VLAMODE\qs 'S ' \CR}{to indicate solar mode observing.}
\dispt{CPARM(2)\qs 16 \CR}{to indicate that moving sources are allowed
   without renaming.}

If your experiment involved observing active solar phenomena,
(\eg\ flares), you may wish to update the system-temperature
correction every integration time.  For example, if you observed a
flare with an integration time $\tau = 1.67$ seconds, choose
\dispt{CPARM(8)\qs 1.67 / 60 \CR}{for 1.67 sec {\tt CL} and {\tt TY}
   table intervals.}

     Loading an entire solar \uv-data set to disk with the minimum
integration time results in large disk files which make all subsequent
programs take a longer time to run.  By modern standards, historic VLA
data sets are relatively small, so the following may no longer be
necessary.  A useful strategy is to load the data with relatively low
time resolution (20--30 seconds for observations of active solar
phenomena) and to proceed with the usual continuum data calibration,
deferring the system temperature correction.  When a satisfactory
calibration is obtained, the relevant {\tt SN} table may be saved
using \hbox{{\tt \tndx{TASAV}}}.  (Note that you must save the {\tt
  SN} table, before running {\tt \tndx{CLCAL}} rather than the final
{\tt CL} table.)  Then run {\tt CLCAL} and inspect the data for
interesting periods of activity --- try {\tt \tndx{UVPLT}} with {\us
  BPARM = 11, 1} for plots of amplitude versus time or {\tt
  \tndx{TVFLG}}, displaying amplitudes as a function of baseline
length and time.  Use {\tt \tndx{FILLM}} to load the relevant time
ranges of solar \uv\ data to disk with no averaging. The saved {\tt
  SN} table is then copied to each high-time resolution data set.
Assess, and possibly edit, the nominal sensitivities
(\Sec{oldsunsens}) and then apply the system-temperature corrections
(\Sec{oldsuntsys}).  Finally, apply the saved/copied {\tt SN} table to
the {\tt CL} table of each using \hbox{{\tt CLCAL}}.

\Subsubsections{Using {\tt SNPLT} and {\tt LISTR} to assess the nominal
sensitivities}{oldsunsens}

     When solar \uv\ data are written to disk, {\tt FILLM} writes the
nominal sensitivities of those antennas equipped with solar CALs into
the {\tt TY} table.  Before bootstrapping the system temperature
correction for antennas without solar CALs from those which do, it is
always wise to examine the nominal sensitivity for each of the solar
CAL antennas for each of the IFs.  The tools available for this
purpose include: {\tt \tndx{SNPLT}}, which plots the nominal
sensitivities in graphical form, {\tt \tndx{LISTR}} or {\tt PRTAB},
which allow one to inspect the values directly, and {\tt EDITA}, which
provides an interactive display of the {\tt TY} data and allows you to
edit the data.  To make plots:\iodx{VLA}
\dispt{TASK\qs 'SNPLT' ; INP \CR}{to review the inputs needed.}
\dispt{IND\qs {\it m\/} ; GETN {\it n\/} \CR}{to specify the input
             \uv\ file.}
\dispt{INEXT\qs 'TY' \CR}{to plot data from {\tt TY} extension table.}
\dispt{INVERS\qs 0 \CR}{to use the highest version number.}
\dispt{SOURCES\qs 'SUN' , ' ' \CR}{to plot solar source only.}
\dispt{TIMERANG\qs 0 \CR}{to select all times.}
\dispt{ANTENNAS\qs 5 11 12 18 \CR}{to select only CAL-equipped
              antennas; this sample list for K, U, or C band.}
\dispt{PIXRANGE\qs 0 \CR}{to self-scale each plot.}
\dispt{NPLOTS\qs 4 \CR}{to do 4 plots on a page.}
\dispt{FACTOR\qs 2 ; SYMBOL\qs 5 \CR}{to use triangles to mark the
              data and enlarge them by a factor of 2.  The symbols may
              even be connected by lines.}
\dispt{XINC\qs 1 \CR}{to plot every {\tt XINC}$^{\uth}$ point.}
\dispt{OPTYPE\qs 'TSYS' \CR}{to plot nominal sensitivities.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when you're satisfied with inputs.}
\dispe{{\tt \tndx{SNPLT}} produces a {\tt PL} extension file which may
be plotted using {\tt LWPLA}, {\tt TKPL}, or \hbox{{\tt TVPL}} --- or
you could set {\us DOTV TRUE} in {\tt SNPLT} and get the display
directly (and temporarily) on the \hbox{TV}.  Then to inspect the
values over some limited time range in detail, run {\tt \tndx{LISTR}}
(assuming the adverbs set above and):\Iodx{Solar data}\Iodx{calibration}}
\dispt{TASK\qs 'LISTR' ; INP \CR}{to review the inputs needed.}
\dispt{OPTYPE\qs 'GAIN' \CR}{to list quantities in a calibration
              file.}
\dispt{INEXT\qs 'TY' \CR}{to select the sensitivities.}
\dispt{TIMER\qs {\it d1 h1 m1 s1 d2 h2 m2 s2} \CR}{to select by
              suspect time range.}
\dispt{DOCRT\qs -1 \CR}{to route output to the printer.}
\dispt{DPARM\qs 10 0 \CR}{to list nominal sensitivities.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when you're satisfied with inputs.}
\dispe{Task {\tt SNIFS} is similar to {\tt SNPLT} except that it
plots IF on the $x$ axis to compare solutions across them.  It has
numerous binning options to control the otherwise excessive plotting.}

     The use of {\tt \tndx{EDITA}} with {\tt TY} tables is described
extensively in \Sec{edita} and need not be described further here.

\Subsubsections{Using {\tt SOLCL} to apply the system-temperature
  correction}{oldsuntsys}
\Iodx{Solar data}\Iodx{calibration}

     For the old VLA, once you have identified the appropriate subset
of reference solar CAL antennas for each source and IF, you are ready
to bootstrap the system-temperature correction of the remaining
antennas.  It is recommended that you run {\tt \tndx{SOLCL}} before
applying any other calibration to the {\tt CL} table.  In this way,
you can easily verify that the appropriate corrections have been made
to each antenna.  Then you apply the system-temperature correction to
version 2 and correct mistakes by deleting and recreating version 2.
To run {\tt SOLCL}:
\dispt{TASK\qs 'SOLCL' ; INP \CR}{to review the inputs needed.}
\dispt{SOURCES\qs '*' \CR}{to correct all sources.}
\dispt{STOKES\qs '\ ' \CR}{to correct both polarizations.}
\dispt{TIMERANG\qs 0 \CR}{to correct all times.}
\dispt{ANTENNAS\qs 5 11 12 18 \CR}{to use the listed antennas as
             references.}
\dispt{SUBARRAY\qs 1 \CR}{to modify sub-array 1.}
\dispt{GAINVER\qs 2 \CR}{to write corrected entries to {\tt CL} table
             version 2.}
\dispt{INP \CR}{to review the inputs.}
\dispt{GO \CR}{to run the program when you're satisfied with inputs.}

     After applying the system temperature correction, you may proceed
with the usual \AIPS\ data calibration procedures outlined in previous
sections, including the special solar tactics described in
\Sec{oldsunread}.\iodx{VLA}

\Sects{Old VLBI format data}{oldvlb}

For data from a MkIII correlator, run {\tt MK3TX}, {\tt \tndx{MK3IN}},
{\tt MSORT}, {\tt DBCON}, {\tt UVAVG}, {\tt TAMRG}, {\tt SBCOR}, and
{\tt INDXR} as needed (\Sec{mk3in}--\Sec{Mk3INDXR}).   However,
observations which require multiple passes through the correlator
(including \indx{MkIII} Modes A, B, and C observations) will have one
file per observing mode {\it per correlation pass\/}.  Data from
separate correlator passes can be concatenated using task {\tt VBGLU}
and/or merged with task {\tt VBMRG}\@.


\Subsections{Loading data from a MkIII/MkIV correlator}{MkIII}

\Subsubsections{Running {\tt MK3IN}}{mk3in}

Data from a \Indx{MkIII} correlator, such as that in Bonn, Germany or
Haystack, Massachusetts, can also be read into \AIPS\@.  To do this
you need to be supplied with the so called ``A'' tape output, also
known as ``type 52's.''  These data tapes can be read and translated
by the task {\tt \Tndx{MK3IN}}\@.  The process of reading MkIII
correlator data into \AIPS\ and preparing it for further processing is
more cumbersome than the equivalent process for VLBA correlator data.
This simply reflects the manner in which data are generated on a
baseline-based correlator with a limited number of playback
drives.  MkIII data may also appear in the form of a Unix
{\tt tar} file.  For such data, use {\tt \tndx{M3TAR}} and {\tt
\tndx{TFILE}} rather than {\tt MK3IN} and {\tt AFILE}, respectively.

Before running {\tt MK3IN}, run the task {\tt MK3TX} to extract
the text files from the MkIII archive tape.  These text files contain
information about the correlated scans in the data set. {\tt
\Tndx{MK3TX}} will first provide an index of all the text files and
then ask you to select files for loading onto disk.  It then asks you
interactively for the desired destination of the text files.  It is
important to load and concatenate all the ``A'' files, \ie\ those
files having names like {\tt A}{\it tttt\/}.  The meaning of the other
text files is described in the {\tt MK3TX} Explain file.  Sometimes
the text files are not on the tapes, which means that you cannot
select sub-sets of the data using the A-files, but is not otherwise
catastrophic.

If the A-files are present and have been loaded onto the disk, use
{\tt AFILE} to sort and edit these files to produce a list of scans to
be loaded by {\tt MK3IN}\@.  Use {\tt APARM} settings in {\tt AFILE}
to establish criteria for selecting between any duplicate scans which
may appear on the archive.  If the data set contains data at multiple
frequencies, you should edit the resulting output text file so that
there is a version for each frequency, containing only those scans at
that frequency.

The final step before running {\tt MK3IN} is to create another text
file which provides the commands for the task.  This step is necessary
since some information that is needed by \AIPS\ is not present on the
tape.  Ideally, in this text file (as shown below), the parameter {\tt
STATIONS} should be a list of all the stations correlated, with the
exact name used at correlation. If you do not have such a list, you
can instead specify a list containing {\tt STATIONS\qs `ANY', `ANY'
$\ldots$} Note that there must be at least as many {\tt `ANY'} entries
as there are stations in the data set or some of the stations will not
be loaded.  The parameters in this text file are:
\dispx{STOKES='RR','LL'}{the Stokes range of the output file.  The
          standard abbreviations are used to select the polarization
          range.  The largest consistent range is used. For example:
          {\tt STOKES='RR','LL'} will cause only RR and LL to be
          written.  {\tt STOKES='LL'} will cause just LL to be
          written. {\tt STOKES='RR','LR'} will cause all four circular
          polarization combinations to be in the output file, since RR
          and LR span the range of allowed \AIPS\ Stokes values.}
\dispx{FREQCODE='R','L','r',l'}{the polarization codes used by MkIII
          correlators are anything but standard and they need to be
          supplied to {\tt MK3IN} using the parameter {\tt
          FREQCODE}\@.  The one character polarization identifiers are
          expected in the order RR, LL, RL, and LR\@.  The usual
          correlator convention is 'R'=RR, 'L'=LL, 'r'=RL, 'l'=LR and
          this is the default assumed by {\tt MK3IN}\@. However, other
          codes are possible.  For example {\tt FREQCODE = 'A', 'B',
          'C', 'D'} will interpret 'A' as RR, 'B' as LL and so forth,
          while {\tt FREQCODE = 'R', 'C', 'r', 'l'} will use the default
          abbreviations except that 'C'=LL\@.  If {\tt MK3IN}
          encounters an unidentified \indx{polarization} code the task
          will report: {\tt AT20XX: Unidentified Stokes parameter:
          '{\it X\/}'}. In this case, modify the {\tt FREQCODE}
          parameter to include this polarization identifier.  This
          will ensure that polarizations are not misidentified
          inadvertently.\Iodx{VLBI}}
\dispx{NO\_POL=2}{the number of polarization correlations (\eg\ RR,
          LL, RL and LR), the default is 1.}
\displx{STATIONS='NRAO','VLA','OVRO','FDVS','MPI'}{station names.}
\dispx{/}{{\tt keyin} style delimiter.}
\pd
\Iodx{MkIII}

Then, from inside {\tt AIPS}, mount the tape (\Sec{magtape}) and run
{\tt \Tndx{MK3IN}}:
\dispt{TASK\qs 'MK3IN' ; INP \CR}{to review the inputs.}
\dispt{INFILE\qs 'MYVLB:PARAM.LIS' \CR}{to define the text control
         file.}
\dispt{IN2FILE\qs 'MYVLB:AFILE.LIS \CR}{to point to a file containing
         a list of scans to be loaded as produced by {\tt AFILE} }
\dispt{INTAPE\qs 4 \CR}{to specify the tape drive number.}
\dispt{NFILES\qs 0\CR}{to skip no files on tape.}
\dispt{OUTNA\qs 'EXP 86-34' \CR}{to select the output file name.}
\dispt{OUTCL\qs 'MK3IN' \CR}{to select the default output class name.}
\dispt{REFDATE\qs '12/11/89' \CR}{to tell {\tt MK3IN} the start date
         of the observations --- get this right or you may get
         negative times.}
\dispt{SOURCES\qs ''\CR}{to accept all sources found.}
\dispt{TIMERANG\qs 0\CR}{to accept data from all times found.}
\dispt{DOUVCOMP\qs 1 \CR}{to write data on disk in compressed format.}
\dispt{APARM\qs 1, 0 \CR}{to set the time increment in the {\tt CL}
         table entries in minutes.}
\dispt{APARM(7)\qs 1 \CR}{to separate sidebands into separate \AIPS\
         IFs; the default is to store both USB and LSB in the same
         IF\@.}
\dispt{GO \CR}{to run the program.}
\dispe{If the data are contained on more than one Exabyte or DAT tape,
load the second tape and re-run {\tt MK3IN}, setting {\us DOCONCAT = 1
\CR} so that the data are appended to the previous output file.
Before running {\tt MK3IN} a second time, it is important to set the
list of {\tt STATIONS} in the control file to exactly those found when
loading the first tape; use {\tt PRTAN} on the output file to obtain
this list.  Also leave additional {\tt `ANY'} entries after the list
for any stations that are on the second tape but which were not on the
first tape. The use of {\tt DOUVCOMP = 1} is recommended for most data
sets, see \Rappen{size}.}

\subsubsections{Sorting MkIII/IV data}

The \AIPS\ data files created by {\tt MK3IN} will be in an arbitrary
sort order.  Use {\tt \tndx{UVSRT}} or {\tt \tndx{MSORT}} to sort them
into time-baseline order:\Iodx{VLBI}
\dispt{TASK 'UVSRT' ; INP \CR}{to review the inputs.}
\dispt{INDISK\qs {\it n\/} ; GETN\qs {\it ctn\/} \CR}{to select the
             input file.}
\dispt{OUTNA\qs INNA ; OUTCL\qs 'TBSRT' \CR}{to specify the output
             file.}
\dispt{SORT\qs 'TB' \CR}{to sort to time-baseline order.}
\dispt{GO \CR}{to make the sorted \uv\ file.}
\pd

\subsubsections{Concatenating MkIII/IV data}

If you did not set {\tt DOCONCAT=1} when running {\tt MK3IN} and as a
result several files were loaded from tape for one observation, use
{\tt DBCON} to concatenate them together.  In order to have the
concatenated data all appear in a single subarray, both input files
for {\tt DBCON} must have the same reference day number and identical
antenna numbers.  That is, the antennas extension ({\tt AN}) files
with each input \uv\ data file must be the same.  {\tt MATCH} may be
used to repair discrepancies.

You may list the contents of {\tt AN} files using {\tt
\tndx{PRTAN}}\@.  To run {\tt \tndx{DBCON}}:
\dispt{TASK\qs 'DBCON' ; INP \CR}{to review the inputs.}
\dispt{INDISK\qs {\it n1\/} ; GETN {\it ctn1\/} \CR}{to select the
             $1^{\ust}$ input file.}
\dispt{IN2DISK\qs {\it n2\/} ; GET2N\qs {\it ctn2\/} \CR}{to select
             the $2^{\und}$ input file.}
\dispt{OUTNA\qs INNA ; OUTCL\qs 'DBCON' \CR}{to specify the output
             file.}
\dispt{DOARRAY\qs 1 \CR}{to force {\tt DBCON} to mark the output data
             records as being in the same sub-array.  For this to work
             properly, both of the input files must have the same
             reference day and have identical antennas files.}
\dispt{GO \CR}{to concatenate the two files.}
\dispe{Task {\tt \tndx{DBAPP}} may be used to avoid the $2^n$
             proliferation of files, but only if the files are fairly
             similar in antennas, subarrays, and frequency IDs.}

\Subsubsections{Labeling correlator polarization data}{oldfxpol}

Most MkIII and MkIV VLBI setups reverse the polarizations and assign
odd-numbered bands to LCP and even-numbered bands to RCP\@.  In this
case {\tt BANDPOL} should be set to {\tt '*(LR) '} and the output data
set will again be of equal size to the input data with two
polarizations and half the number of IFs.  This case normally applies
if {\tt LISTR} shows pairs of IFs with the same frequency and {\tt
QHEADER} shows one pixel on the {\tt STOKES} axis with coordinate
value {\tt LL}, but there may be exceptions to this rule when non-VLBA
antennas are used.

To use {\tt FXPOL} directly, typical inputs are:
\dispt{TASK\qs 'FXPOL' ; INP \CR}{to review the inputs.}
\dispt{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
              input file.}
\dispt{BANDPOL\qs '*(LR)' \CR}{to specify the normal MkIII and MkIV
              polarization  structure.}
\dispt{GO \CR}{to run the program.}
\dispe{Consult {\tt HELP \Tndx{FXPOL}} for further information
about more complicated cases.  Note that {\tt FXPOL} has to write a
new output file since the structure of the data is being changed.  All
standard extension files are also converted, but it is still a good
idea to run {\tt FXPOL} before running the calibration tasks.}

\subsubsections{Merging MkIII/IV data}

\Indx{MkIII} \Indx{VLBI} correlators usually produce redundantly
correlated data. You must merge the data using {\tt \tndx{UVAVG}}:
\dispt{TASK\qs 'UVAVG' ; INP \CR}{to review the inputs.}
\dispt{INDISK {\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
              input file.}
\dispt{OUTNA\qs INNA ; OUTCL\qs 'UVMRG' \CR}{to specify the output
              file.}
\dispt{YINC\qs 4.0 \CR}{to set the averaging interval of the input
              data records (in seconds).}
\dispt{OPCODE 'MERG' \CR}{to direct the task to perform the merge
              operation.}
\dispt{GO \CR}{to run the program.}
\pd

The {\tt CL} table should only contain one entry for each antenna at
each time stamp. But, due to the merging process described above and
the fact that redundant correlations may have been performed, there is
one step to follow before you have consolidated your database fully.
You must run {\tt \tndx{TAMRG}} to remove the redundant {\tt CL}
entries:
\dispt{TASK\qs 'TAMRG' ; INP \CR}{to review the inputs.}
\dispt{INDISK {\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
                input file.}
\dispt{INEXT\qs 'CL' \CR}{to specify the table type to merge.}
\dispt{INVER\qs 1; OUTVER\qs INVER \CR}{to process the input table in place.}
\dispt{APARM\qs 4, 1, 4, 0, 1, 1, 1, 0 \CR}{to control the merging:
              don't ask why, just do it!}
\dispt{BPARM\qs 1, 4 \CR}{to set compared columns --- again, don't
              ask.}
\dispt{CPARM\qs 1.157e-5, 0.2 \CR}{to set degree of equality --- ditto.}
\dispt{GO \CR}{to run the program.}
\pd

\subsubsections{Correcting MkIII/IV sideband phase offsets}

If your observation contains a mixture of VLBA and non-VLBA antennas
and you have not stored the sidebands as separate IFs, there will be a
phase offset of about $130^{\circ}$ between the upper and lower
sidebands on baselines from VLBA to non-VLBA antennas.  A correction
for this offset is achieved using the task {\tt \Tndx{SBCOR}}:
\dispt{TASK\qs 'SBCOR' ; INP \CR}{to review the inputs.}
\dispt{INDISK {\it n1\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
               input file.}
\dispt{OUTNA\qs INNA ; OUTCL\qs 'SBCOR' \CR}{to specify the output
               file.}
\dispt{BCHAN\qs  1 \CR}{to specify the lowest channel of lower
               sideband.}
\dispt{ECHAN\qs  4 \CR}{to specify the highest channel of
               lower sideband.}
\dispt{APARM(1)\qs 0 \CR}{to apply the default phase offset
               (\ie\ $-130^{\deg}$.)}
\dispt{ANTENNAS\qs = \qs VLBA ; INP \CR}{to specify the VLBA antenna
               numbers; the {\tt =} sign is required here.  The verb
               {\tt \tndx{VLBA}} reads the antenna file to find
               VLBA antennas.}
\dispt{GO \CR}{to run the program.}
\dispe{If you have loaded the {\tt \tndx{VLBAUTIL}} procedures, then
you may use a procedure called {\tt \tndx{ANTNUM}} to translate a
station name into a station number.  Thus {\tt ANTENNAS =
ANTNUM('BR'), ANTNUM('FD'), $\ldots$}\@.  The verb {\tt VLBA} in is
easier.\Iodx{VLBI}}

\Subsubsections{Indexing MkIII/IV data}{Mk3INDXR}

Next, you must index your data.  The {\tt NX} table is useful as a
summary of the file for you, and is also used by the calibration
programs to provide quick access for reading data.  Create this file
with {\tt \tndx{INDXR}}:
\dispt{TASK\qs 'INDXR' ; INP \CR}{to review the inputs.}
\dispt{INDISK {\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
            input file.}
\dispt{CPARM\qs 0, 30, -1 \CR}{to allow $\leq 10$-minute time gaps
            within scans, to limit scans to $\leq 30$ minutes, and to
            not create a new {\tt CL} table.}
\dispt{GO \CR}{to run the program.}
\pd

Files with suffixes {\tt .SCAN} and {\tt .MKIII} contain scan
summaries and MkIII information and are for information purposes only.

Other than these initial loading and merging steps, the reduction of
\Indx{MkIII} and MkIV correlator data is identical to that of VLBA
correlator data.

For MkIII data from the Bonn correlator, phase-cal measurements are
incorporated directly into the first {\tt CL} table produced by {\tt
MK3IN} --- this is another strong reason to protect the first {\tt CL}
table.
