%-----------------------------------------------------------------------
%;  Copyright (C) 2001
%;  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
%-----------------------------------------------------------------------
%first draft, 7-9 February 2001
%revised 16 February 2001
%minor final revision 28 February 2001
%revised 17 April 2001 for Amy's procs
\documentclass[twoside]{article}
\usepackage{graphics}
\input LaCook.mac
\setlength\tabcolsep{0pt}%  was 6
\newcommand{\Mbtd}{\ps\par
    \begin{tabular*}{\textwidth}[t]{p{2.801in}p{3.7in}}}
\newcommand{\dispM}[2]{\Mbtd{\tt >\ }{\us #1}&#2\xetd}
\renewcommand{\doFIG}{T}
\title{\AIPS\ Procedures for Initial VLBA Data Reduction \\
Version 2.0 \\ \AIPS\ Memo No.~105}
\author{Jim Ulvestad, Eric W. Greisen, \&\ Amy Mioduszewski}
\date{April 26, 2001}
\renewcommand{\titlea}{\AIPS\ Memo No.~105: 17-Apr-2001}
\renewcommand{\Rheading}{\titlea\hfill}
\renewcommand{\Lheading}{\hfill \titlea}
\markboth{\Lheading}{\Rheading}
\maketitle

\begin{abstract}

This memo provides a guide to procedures currently available in
\AIPS\ (some in 31DEC00, all in 31DEC01) to do the initial processing
steps of VLBA data reduction.  These procedures are designed for
VLBA-only observations, and make a number of assumptions that may not
be appropriate for other types of VLBI experiments.  Therefore, they
should be used only with extreme caution for observations including
non-VLBA antennas.  The present memo discusses the key defaults that
are used in the VLBA procedures, as well as the times when these
procedures may not be appropriate.  For more details regarding the
procedures in the full context of VLBI data reduction, see Chapter~9
and Appendix~C of the \AIPS\ \cookbook.

\end{abstract}

\noindent{\Large{\bf 1. Summary of VLBA Procedures}}

The procedures needed to simplify many of the initial VLBI data
reduction steps in \AIPS\ are available to users after they
enter the command {\us RUN VLBAUTIL \CR}\@.  After this, the
following procedures will be available:

\begin{itemize}
\item {{\tt VLBALOAD}: loads VLBA data with simplified inputs}
\parskip 0pt
\item {{\tt VLBASUBS}: finds subarrays in VLBA data}
\item {{\tt VLBAMCAL}: removes redundant calibration data from tables}
\item {{\tt VLBAFQS}: copies different frequency IDs to separate
           files}
\item {{\tt VLBAFPOL}: fixes polarization labelling for common cases}
\item {{\tt VLBASUMM}: makes summary listings of your data set}
\item {{\tt VLBACALA}: determines {\it a-priori\/} amplitude
           calibrations}
\item {{\tt VLBAPANG}: determines phase corrections for parallactic
           angles}
\item {{\tt VLBACPOL}: calibrates cross polarization delays}
\item {{\tt VLBAPCOR}: determines instrumental phase corrections}
\item {{\tt VLBAFRNG}: does global fringe fit using {\tt FRING}}
\item {{\tt VLBAKRNG}: does global fringe fit using {\tt KRING}}
\item {{\tt VLBAFRGP}: does global fringe fit for phase referenced
         experiments using {\tt FRING}}
\item {{\tt VLBAKRGP}: does global fringe fit for phase referenced
         experiments using {\tt KRING}}
\item {{\tt VLBASNPL}: plots the {\tt SN} or {\tt CL} tables versus time}
\item {{\tt VLBACRPL}: plots the cross-correlation spectrum}
\end{itemize}

There are two additional procedures that can make life easier, called
{\tt ANTNUM} and {\tt SCANTIME}\@.  {\tt ANTNUM} will return the
antenna number of the antenna corresponding to a certain character
string, for a data set containing an {\tt AN} table.  For example, in
most data sets, typing {\us REFANT = ANTNUM ('BR') \CR} will be the
equivalent of typing {\us REFANT = 1 \CR}\@.  {\tt SCANTIME} will
return the time range of a given scan number, for use in various
programs.  Typing {\us TIMERANG = SCANTIME(4) \CR} will fill the
eight-element array {\tt TIMERANG} with the start and stop times of
the $4^{\uth}$ scan of a given data set.  (There must be an {\tt NX}
table for this to work.)

Note that all of the {\tt VLBAUTIL} procedures have {\tt HELP} files
with good discussions about when to use the simple procedures and when
to use the tasks directly.  Also, note that the procedures do not
include data editing, which should be performed at appropriate points
in the calibration process.  You only need to {\tt RUN VLBAUTIL} once
to access all of the procedures.  If you run it again for any reason,
it is a good idea to enter {\us COMPRESS \CR} immediately afterwards
to avoid overflowing {\tt AIPS}' symbol memory.
\vfil

\noindent{\Large{\bf 2. VLBALOAD}}

The procedure {\tt VLBALOAD} can be used in place of the task {\tt
FITLD} to load your VLBI data on disk.  Enter
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this need
           be done only once since they will be remembered.}
\dispM{INTAPE\qs {\it n\/}\CR}{to specify the input tape number.}
\dispM{NFILES\qs 0\CR}{to start loading from the current tape
           position.}
\dispM{NCOUNT\qs 20 \CR }{to load 20 tape files.}
\dispM{OUTNAME\qs 'TEST' ; OUTDI\qs 1 \CR}{to specify the name and
           disk of the output file.}
\dispM{DOUVCOMP\qs 1 \CR}{to save disk space by writing compressed
           data.}
\dispM{CLINT\qs $\triangle t$ \CR}{to set the {\tt CL} table interval
           to $\triangle t$ minutes (see discussion below).}
\dispM{INP\qs VLBALOAD \CR}{to review the inputs.}
\dispM{VLBALOAD \CR}{to run the procedure.}
\dispe{Typically, the user will set {\us DOUVCOMP=1 \CR} to write
compressed data.  {\tt CLINT} should be set so that there are several
{\tt CL} table entries for each self-calibration or fringe-fitting
interval anticipated; this will minimize interpolation error during
the calibration process.  However, setting {\tt CLINT} too short will
result in a needlessly large table.  (See further discussion in the
\AIPS\ \cookbook.)  For the VLBA correlator, {\tt VLBALOAD}
automatically does the appropriate digital and delay decorrelation
corrections.  The other key {\tt FITLD} parameter that is set
automatically is {\us WTTHRESH = 0.7}, which results in irrevocable
discarding of all data with playback weight less than 0.7.}

\vfil
\noindent{\Large{\bf 3. VLBASUBS}}

VLBA data may require some repair after {\tt VLBALOAD} has been run.
They may need to be sorted, have the subarray nomenclature corrected,
and/or have the index ({\tt NX}) table and calibration ({\tt CL})
version 1 table rebuilt.  If both of these tables are missing, then a
subarray condition is likely to exist.  Generally speaking, {\tt
VLBALOAD} or {\tt FITLD} will have given a message stating that a
subarray condition appears to exist.  In this case, there is a
simplified procedure to combine the three repair operations:
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{CLINT\qs $\triangle t$ \CR}{to set the {\tt CL} table interval
           to $\triangle t$ minutes.}
\dispM{INP\qs VLBASUBS \CR}{to review the inputs.}
\dispM{VLBASUBS \CR}{to run the procedure.}
\dispe{The only user-controllable input is the {\tt CL} table interval;
see discussion above.}

\vfil\eject
\noindent{\Large{\bf 4. VLBAMCAL}}

The information processed by the VLBA correlator is somewhat redundant
so that the calibration tables, the {\tt GC} table in particular, must
be merged using {\tt TAMRG}, a very general and hence complicated
task.  For the VLBA correlator, there is typically a new set of
entries made in the {\tt GC} table for each correlator job loaded with
{\tt VLBALOAD} or {\tt FITLD}, and calibration programs such as {\tt
APCAL} and {\tt VLBACALA} will fail if multiple {\tt GC} entries exist
for a single antenna.  To fix this,
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{INP\qs VLBAMCAL \CR}{to review the inputs.}
\dispM{VLBAMCAL \CR}{to run the procedure.}
\dispe{You should use {\tt VLBAMCAL} after you have finished loading
the data from tape, but before you either change the polarization
structure of the data with {\tt FXPOL} (or {\tt VLBAFPOL}), load any
calibration data for non-VLBA telescopes, or apply the calibration
data.  Another procedure called {\tt MERGECAL} will carry out
activities similar to {\tt VLBAMCAL}; see the \AIPS\ \cookbook\ for
further details.}

\noindent{\Large{\bf 5. VLBAFQS}}

If you have multiple frequency IDs in your data, it is strongly
recommended that you separate the data for different {\tt FREQID}s
at this point, before performing any calibration.  The procedure
{\tt VLBAFQS} will run {\tt UVCOP} to separate the different
{\tt FREQID}s, deleting the data flagged by the correlator with
{\tt FLAGVER=1}, and then re-index the data set to generate
new {\tt CL} and {\tt NX} tables.  Enter the following:
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{CLINT\qs $\triangle t$ \CR}{to set the {\tt CL} table interval
           to $\triangle t$ minutes.}
\dispM{INP\qs VLBAFQS \CR}{to review the inputs.}
\dispM{VLBAFQS \CR}{to run the procedure.}
\dispe{{\tt VLBAFQS} will normally be run after searching for
subarrays ({\tt VLBASUBS}) and before fixing polarization labels ({\tt
VLBAFPOL}).  Note that the subarray condition can be due to
overlapping frequency IDs rather than different sources.  In that
case, using {\tt VLBAFQS} before {\tt VLBASUBS} may be advantageous.}

\noindent{\Large{\bf 6. VLBAFPOL}}

The VLBA correlator does not preserve polarization information unless
it is operating in full polarization mode.  This results in
polarizations not being labelled correctly when both RR and LL
polarizations are observed without RL and LR\@, either within the same
band or in different bands.  Each VLBA correlator band is loaded into
\AIPS\ as a separate IF and is assigned the same polarization.  {\tt
FXPOL} takes a data set from the VLBA correlator and produces a new
data set that has the correct IF and polarization assignments.  {\it
Note that {\tt FXPOL} makes a new copy of the data set in order to
re-label the polarizations, so you must have plenty of disk space
available in order to run {\tt FXPOL}\@.}  For the simplest cases for
VLBA-only data, there is a procedure that attempts to determine which
polarization case applies and then runs {\tt FXPOL} for you:
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{INP\qs VLBAFPOL \CR}{to review the inputs.}
\dispM{VLBAFPOL \CR}{to run the procedure.}
\dispe{Use {\tt VLBAFPOL} to check whether you need to relabel the
polarizations in your data after loading the data, looking for
subarrays, and merging redundant calibration data, but before reading
any calibration data from non-VLBA stations.  {\tt VLBAFPOL} assumes
that all of your {\tt FREQID}s have similar polarization setups.  For
this reason, you should normally run {\tt VLBAFPOL} after copying each
frequency ID to a separate file using {\tt VLBAFQS}.  This strategy
also reduces the amount of disk space needed for {\tt VLBAFPOL}.}

\noindent{\Large{\bf 7. VLBASUMM}}

In order to keep track of your experiment it is a good idea to get
a listing of the antennas and scans in your experiment.  {\tt
VLBASUMM} does this, writing the information to a file, to the screen
or directly to the printer.  The last is likely to be the most useful.
This procedure runs {\tt PRTAN} and {\tt LISTR} ({\tt OPTYPE='SCAN'}).
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{DOCRT\qs -1 \CR}{to print to a file or printer; 1 to go the the
           CRT screen.}
\dispM{OUTPRI\qs  '{\it env\/}:{\it name\/}'}{to print to a file in
           area {\it env\/} called {\it name\/}.}
\dispM{VLBASUMM \CR}{to generate the listings.}
\dispe{This should be done after the data has been ``fixed'' ({\tt
VLBAMCAL}, {\tt VLBASUBS}, {\tt VLBAFPOL} and/or {\tt VLBAFQS}) and
before calibration is started ({\tt VLBACALA}).}

\noindent{\Large{\bf 8. VLBACALA}}

The procedure {\tt VLBACALA} will apply all {\it a-priori\/} amplitude
calibrations to your data, writing a {\tt CL} table with the
appropriate calibrations included.  This procedure runs {\tt ACCOR} to
use the autocorrelation results in order to correct cross-correlation
values; {\tt SNSMO} to clip discrepant values output by {\tt ACCOR}
and make a solution ({\tt SN}) table; {\tt APCAL} to merge {\tt GC}
(gain) and {\tt TY} (system temperature) tables into another {\tt SN}
table; and {\tt CLCAL} (twice) to apply these {\tt SN} tables and
create new {\tt CL} tables.  {\it {\tt VLBACALA} should be run only
for data from the VLBA correlator, since the {\tt ACCOR} correction is
not necessary for other correlators.}  To run this procedure, enter
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{FREQID\qs {\it ff\/} ; SUBAR\qs {\it ss\/} \CR}{to select the
           frequency ID and subarray numbers --- only one of each per
           execution.}
\dispM{REFANT 0 \CR}{to default the reference antenna appropriately.}
\dispM{INP\qs VLBACALA \CR}{to review the inputs.}
\dispM{VLBACALA \CR}{to run the procedure.}
\dispe{{\tt VLBACALA} will normally be run after correcting the
polarization labels with {\tt VLBAFPOL} (if needed) and loading any
gain curves or system temperature data for non-VLBA antennas using
{\tt ANTAB}\ (see \AIPS\ \cookbook).  Usually, {\tt VLBACALA} will be
run before doing any phase solutions, in which case the value of {\tt
REFANT} does not matter.  However setting {\tt REFANT=0 \CR} may be
the safest thing to do.  The {\tt VLBACALA} procedure defaults to
2-minute solution intervals for the computation of the autocorrelation
correction, then uses a 30-minute median-weight filter to clip all
autocorrelation solutions that are more than 0.02 (in gain) from the
running mean.  In applying the measured gain and system temperature
calibrations, the underlying task {\tt CLCAL} uses {\tt
INTERPOL='SELF'} in order to avoid interpolation between sources at
different elevations.  No atmospheric opacity corrections are applied
to the nominal amplitude calibration values for the antennas.}

\noindent{\Large{\bf 9. VLBAPANG}}

The RCP and LCP feeds on each antenna will rotate in position angle
with respect to the source during the course of the observation for
alt-az antennas (which probably constitute a majority of the antennas
in your observation).  Since this rotation is a simple geometric
effect, it can be corrected by adjusting the phases without looking at
the data.  This correction must be performed before executing any phase
calibration that actually examines the data.  It is important for
polarization observations, and also can be important for some phase
referencing observations, depending upon the distribution of
calibrators and targets on the sky.  The procedure {\tt VLBAPANG}
assists you in running {\tt CLCOR} together with doing the subsidiary
table copying ({\tt TACOP}) needed to correct phases for parallactic
angle:
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{SUBAR\qs {\it ss\/} \CR}{to select the subarray number --- only
             one per execution.}
\dispM{INP\qs VLBAPANG \CR}{to review the inputs.}
\dispM{VLBAPANG \CR}{to run the procedure.}
\dispe{{\tt VLBAPANG} will normally be run after applying {\it
a-priori\/} amplitude corrections with {\tt VLBACALA}, but before
applying any other phase corrections.}

\noindent{\Large{\bf 10.  VLBAPCOR}}

Each IF has its own phase offset and gradient with frequency.  These
offsets and ``instrumental single-band delays'' are caused by the
passage of the signal through the electronics of the VLBA baseband
converters or MkIII/MkIV video converter units.  If pulsed,
narrow-band signals (``phase-cals'') are sent through the electronics,
the IF channel phase offsets and instrumental single-band delays can
be determined.  If this pulse-cal information is not available, then
the offsets and single-band delays can be determined ``manually'' by
running {\tt FRING} (or {\tt KRING}) on a short scan on a calibrator
source.

The procedure {\tt VLBAPCOR} runs {\tt PCCOR} to take the information
out of the {\tt PC} table, create an {\tt SN} table, and run {\tt
CLCAL} to apply the corrections to a {\tt CL} table.   A {\tt
TIMERANGE} for a strong calibrator must be given.  This is to solve
$2\pi$ ambiguities after which the phase corrections are solved for
all times.  If there are antennas missing from the {\tt PC} table or
the data for some antennas in the {\tt PC} table are bad, {\tt
VLBAPCOR} will run {\tt FRING} and then {\tt CLCAL} to incorporate
them into the output {\tt CL} table.  To invoke this option, set {\tt
OPCODE='CALP'} and set {\tt ANTENNAS} to the missing (or bad)
antennas.  For this to work, the {\tt TIMERANGE} that is chosen {\it
must\/} have strong fringes for these antennas.  {\tt EXPLAIN
VLBAPCOR} lays out the steps to solve for the instrumental phase
solutions outside of {\tt VLBAPCOR}.\@

Note that {\tt VLBAPCOR} assumes that the highest {\tt PC} and {\tt
FG} tables are the correct ones to use.
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{TIMERANGE\qs {\it d1 h1 m1 s1 d2 h2 m2 s2\/} \CR}{to specify a
           short scan on a calibrator.  There is no default.}
\dispM{REFANT\qs {\it m}\CR}{to select a particular reference antenna.}
\dispM{SUBARRAY\qs 0}{to do all subarrays.}
\dispM{CALSOUR\qs '{\it cal1\/}', '\qs'}{to specify the calibrator
           source name.}
\dispM{GAINUSE\qs {\it CLin\/} \CR}{to indicate the {\tt CL} table
           with all calibration up to this point.}
\dispM{OPCODE\qs 'CALP' \CR}{to indicate that there are antennas
           with no usable pulse cals; use {\tt OPCODE\qs'\qs'} if all
           antennas have pulse cals.}
\dispM{ANTENNAS\qs {\it a1 a2 a3\/} \CR}{to solve for antennas {\it
           a1, a2, a3\/} ``manually'' (using {\tt FRING}).}
\dispM{VLBAPCOR \CR}{to run the procedure.}
\dispe{This should be done after the {\it a-priori\/} amplitude
calibration ({\tt VLBACALA}) and, for polarization experiments, the
paralactic angle correction ({\tt VLBAPANG}), but before any global
fringe fitting ({\tt VLBAFRNG}, {\tt VLBAKRNG}, {\tt VLBAFRGP}, or
{\tt VLBAKRGP})\@.  The corrections should be examined with {\tt
VLBACRPL}\@.}

\noindent{\Large{\bf 11. VLBACPOL}}

For polarization experiments, the instrumental delays must also be
removed from the cross-hand correlators.  This is done in a procedure
called {\tt VLBACPOL} (formerly known as {\tt CROSSPOL})\@.  Like the
other utility procedures, this procedure will produce new (highest
numbered) {\tt CL} and {\tt SN} tables.
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{OUTDI\qs 1 \CR}{to use disk 1 for temporary files.}
\dispM{FLAGVER\qs 0 \CR}{to use the highest numbered flag table.}
\dispM{GAINUSE\qs {\it CLin\/} \CR}{to use the {\tt CL} table with all
           calibration up to this point; {\it no default\/}.}
\dispM{SUBARRAY\qs 0 \CR}{to do all subarrays.}
\dispM{BASELINE\qs 0 \CR}{to use all antennas.}
\dispM{REFANT\qs 1 \CR}{to select the reference antenna; it must be the
           highest or lowest antenna number.}
\dispM{CALSOUR '{\it cal1\/}' , ' ' \CR}{to specify the calibrator
           source to use.}
\dispM{TIMERANGE\qs {\it d1 h1 m1 s1 d2 h2 m2 s2\/} \CR}{to specify a
           time range with high SNR for RL and LR\@.}
\dispM{SOLINT\qs 0 \CR}{to set the {\tt FRING} solution interval in
           minutes; 0 is taken as 10.}
\dispM{DPARM(4) = {\it x} \CR}{to tell {\tt FRING} the minimum
           integration time in the data set in seconds; other {\tt
           DPARM} parameters are also used by {\tt FRING}.}
\dispM{OPCODE\qs '\qs' \CR}{to solve for delays in each IF
           separately.}
\dispM{VLBACPOL \CR}{to run the procedure.}
\dispe{{\tt VLBACPOL} should be done after parallel-hand instrumental
delays are removed ({\tt VLBAPCOR}) but before fringe fitting
({\tt VLBAFRNG}, {\tt VLBAKRNG}, {\tt VLBAFRGP}, or {\tt VLBAKRGP})\@.
The corrections should be checked with {\tt VLBACRPL}, by setting {\tt
STOKES} to {\tt 'RL'} and/or {\tt 'LR'}\@.}

\noindent{\Large{\bf 12. VLBAFRNG, VLBAKRNG, VLBAFRGP, VLBAKRGP}}

Now one must remove global frequency- and time-dependent phase errors.
To do this, {\tt FRING} or {\tt KRING} is run along with {\tt CLCAL}
on the output {\tt SN} table.  The procedures {\tt VLBAFRNG}, {\tt
VLBAKRNG}, {\tt VLBAFRGP} and {\tt VLBAKRGP} do this.  These
procedures assume a simple experiment, \ie\ one frequency etc.  {\tt
VLBAFRNG} and {\tt VLBAFRGP} use {\tt FRING} and {\tt VLBAFRGP} is
specifically for phase referencing.  Similarly, {\tt VLBAKRNG} and
{\tt VLBAKRGP} use {\tt KRING}, with {\tt VLBAKRGP} specifically for
phase referencing.

For all these procedures, if the {\tt SOURCES} adverb is set, then
{\tt CLCAL} is run once for each source in {\tt SOURCES}\@.  For the
phase-referencing procedures ({\tt VLBAFRGP} and {\tt VLBAKRGP}), any
source that is in the {\tt SOURCES} list that is {\it not\/} in the
{\tt CALSOUR} list will be phase referenced to the {\it first} source
in the {\tt CALSOUR} list.  Note that, if every source in the {\tt
SOURCES} list occurs in the {\tt CALSOUR} list, {\tt VLBAFRNG} and
{\tt VLBAKRNG} will run identically to {\tt VLBAFRGP} and {\tt
VLBAKRGP}, respectively. If the {\tt SOURCES} list is empty, {\tt
VLBAFRNG} and {\tt VLBAKRNG} will run {\tt CLCAL} once over all
sources, while {\tt VLBAFRGP} and {\tt VLBAKRGP} will run {\tt CLCAL}
once referencing all the sources to the first source in {\tt CALSOUR}.
These procedures will produce new (highest numbered) {\tt SN} and {\tt
CL} tables.

Procedure {\tt VLBAKRNG}
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{TIMERANGE\qs 0}{to include all times.}
\dispM{BCHAN\qs 0 ; ECHAN\qs 0 \CR}{to use all frequency channels.}
\dispM{GAINUSE\qs {\it CLin\/} \CR}{to use the {\tt CL} table with all
           the calibration up to this point.}
\dispM{REFANT\qs {\it n} \CR}{to specify an antenna that is present
           most of the time as the reference antenna.}
\dispM{SUBARRAY\qs 0 \CR}{to use all subarrays.}
\dispM{SEARCH\qs 0 \CR}{to try all antennas as a reference antenna if
           fringes cannot be found using {\tt REFANT}\@.  {\it This is
           different from {\tt FRING}; in {\tt FRING} this must be set
           to try other reference antennas\/}.}
\dispM{OPCODE\qs '\qs' \CR}{to leave all solutions in the output {\tt
           SN} table.}
\dispM{CPARM\qs 0 \CR}{to use defaults for {\tt KRING} steering
           parameters; this is okay for strong sources.}
\dispM{CPARM(1)\qs {\it x\/} \CR}{to specify the minimum integration
           time in seconds.}
\dispM{CPARM(8)\qs 1 \CR}{to avoid re-referencing solutions; do this
           {\it only} for polarization experiments.}
\dispM{CALSOUR\qs '{\it src1\/}', '{\it src2\/}' \CR}{to specify the
           sources to fringe fit using {\tt KRING}.}
\dispM{SOURCES\qs '{\it src1\/}', '{\it src2\/}' \CR}{to have {\tt
           CLCAL} run for each source using the interpolation method
           given below.}
\dispM{INTERPOL\qs 'AMBG' \CR}{to use the ``{\tt AMBG}'' interpolation
           method (linear phase connection using rates to resolve
           phase ambiguities).}
\dispM{BADDISK\qs 0 \CR}{to use all disks for scratch files.}
\dispM{VLBAKRNG \CR}{to run the procedure.}
\pd

Procedure {\tt VLBAKRGP} sets the same adverbs as {\tt VLBAKRNG} {\it
except\/}
\dispM{SOURCES\qs '{\it src1\/}', '{\it src2\/}', '{\it src3\/}'
         \CR}{to have {\tt CLCAL} run for each source using the
         interpolation method given by {\tt INTERPOL}\@. Any source
         here that is not in the {\tt CALSOUR} list will be phase
         referenced to the first source in the {\tt CALSOUR} list.  In
         this example, {\it src3\/} is phase referenced to {\it
         src1\/}.}
\dispM{VLBAKRGP \CR}{to run the procedure.}
\pd

{\tt VLBAFRNG} and {\tt VLBAFRGP} are identical except there is no
{\tt OPCODE} (it is equivalent to {\tt DPARM(8)}) and {\tt DPARM(4)}
and {\tt DPARM(7)} in {\tt FRING} are the same as {\tt CPARM(1)} and
{\tt CPARM(8)} in {\tt KRING}, respectively.  Also note the different
use of {\tt SEARCH} in {\tt FRING} and {\tt KRING}\@.

These procedures should be run after the instrumental phase
calibration ({\tt VLBAPCOR}).  For polarization data, they should be
run after {\tt VLBACPOL}\@.  After the global fringe fit, the
solutions should be checked in {\tt VLBACRPL} setting {\tt GAINUSE} to
the CL table produced by the procedure chosen.

\noindent{\Large{\bf 13. VLBASNPL}}

{\tt VLBASNPL} is a utility procedure to check the calibrations by
plotting the {\tt SN} and/or {\tt CL} table versus time.  It runs {\tt
SNPLT} with simplified inputs.  The example below might be run after
{\tt VLBACALA}\@.
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{INEXT\qs 'CL' \CR}{to plot a {\tt CL} table.}
\dispM{INVERS\qs 0 \CR}{to plot the highest version.}
\dispM{SOURCES\qs '\qs' \CR}{to plot all sources.}
\dispM{TIMERANGE\qs 0 \CR}{to plot all times.}
\dispM{STOKES\qs  '\qs' \CR}{to plot both R and L solutions.}
\dispM{SUBARRAY\qs 0 \CR}{to plot all subarrays.}
\dispM{OPTYPE\qs 'AMP' \CR}{to look at amplitudes; {\tt 'PHAS'}, {\tt
            'DELA'}, and {\tt 'RATE'} are other useful choices.}
\dispM{DOTV\qs 1\CR}{to plot the data on the TV; -1 to make a plot
            file.}
\dispM{VLBASNPL \CR}{to plot the data.}
\pd

\noindent{\Large{\bf 14. VLBACRPL}}

This procedure plots the amplitude and phase of the cross-power
spectrum for a data set, applying the given {\tt CL} table.  This is
useful after {\tt VLBAPCOR}, {\tt VLBACPOL}, or {\tt VLBAFRNG} and
friends.  It is a simplified {\tt POSSM}\@.
\dispM{RUN VLBAUTIL \CR}{to acquire the procedures; this should
           be done only once since they will be remembered.}
\dispM{INDISK\qs{\it n\/} ; GETN\qs {\it ctn\/} \CR}{to specify the
           input file.}
\dispM{SOURCES\qs '\qs' \CR}{to plot all sources.}
\dispM{TIMERANGE\qs 0 \CR}{to plot all times.}
\dispM{SUBARRAY\qs 0 \CR}{to plot all subarrays.}
\dispM{REFANT\qs {\it n\/} \CR}{to plot the cross-power spectrum for
           baselines with antenna {\it n\/}.}
\dispM{STOKES\qs '\qs' \CR}{to plot Stokes I\@.}
\dispM{GAINUSE\qs {\it CLin\/} \CR}{to apply {\tt CL} table {\it CLin}
           to the data before plotting.}
\dispM{DOTV\qs 1\CR}{to plot the data on the TV; -1 to make a plot
            file.}
\dispM{VLBACRPL \CR}{to plot the data.}
\pd


\noindent{\Large{\bf 15. Concluding Remarks}}

At this stage, you are ready to apply the calibration to your data and
begin imaging.  Tasks {\tt SPLIT} and {\tt SPLAT} are used to apply
the calibration.  Both can do spectral averaging (after calibration
but before writing the output); {\tt SPLAT} can do time averaging and
can keep the data in the multi-source format.  Details of these
actions, and of later imaging and self-calibration processes can be
found in the \AIPS\ \cookbook.

Chris Flatters and Amy Mioduszewski developed these procedures.  The
original {\tt VLBACPOL} called {\tt CROSSPOL} was developed by Bill
Cotton.

\end{document}
