; CRSFRING
;---------------------------------------------------------------
;# PROCEDURE VLBI
;! Procedure to calibrate cross pol. delay and phase offsets
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1996, 2002
;;  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
;-----------------------------------------------------------------------
;---------------------------------------------------------------
CRSFRING  LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CRSFRING: Procedure to calibrate cross pol. delays
                                   Use RUN CRSFRING first
INNAME                             UV file name (name)
INCLASS                            UV file name (class)
INSEQ              0.0      9999.0 UV file name (seq. #)
INDISK             0.0         9.0 UV file disk drive #
OUTDISK                            Disk for temporary files
FLAGVER                            Flag table to use
GAINUSE                            Calibration table to use
                                   NO DEFAULT
SUBARRAY          0.0       99.0   Selected subarray
ANTENNAS                           List of antennas, 0->use all
REFANT                             Reference antenna
CALSOUR                            Calibrator sources to use.
                                   See note in HELP file!
TIMERANG                           Time range
SOLINT                             Pre-averaging interval (min)
BADDISK                            Disk drive #'s to avoid
----------------------------------------------------------------
CRSFRING
Procedure:  This procedure use a selected subset of a uv data
       set and determine cross polarized multi and single band
       delays.  The average single band and multiband delays
       will be written into an SN table which can be applied to
       the GAINUSE CL table.  See EXPLAIN CRSFRING for details.
          Before attempting to use CRSFRING the RUN file
       CRSFRING must be run to define the procedure.  This is
       done by:
       >RUN CRSFRING
       and only needs be done once.
          CRSFRING creates one temporary file which it will
       destroy if able.  The name of this files is fixed and
       it must be destroyed if a previous attempt at CRSFRING
       failed. To execute the procedure simple type:
       >CRSFRING

Adverbs:
  INNAME.....Input UV file name (name).    Standard defaults.
  INCLASS....Input UV file name (class).   Standard defaults.
  INSEQ......Input UV file name (seq. #).  0 -> highest.
  INDISK.....Disk drive # of input UV file.  0 -> any.
  OUTDISK....Disk for temporary files 0->INDISK.
  FLAGVER....Flag table version to apply
  GAINUSE....CL table from prior calibration to apply before
             determining solutions.  There is no default.
  SUBARRAY...Subarray to use.
  ANTENNAS...List of antennas, 0->use all.
  REFANT.....Reference antenna. Use the one you used for
             parallel hand fringe fitting.
  CALSOUR....Calibrator sources to use.
             NOTE! Selection of only ONE source is
             not implemented correctly -> use TIMERANG instead.
  TIMERANG...Timerange of the data subset.
  SOLINT.....The BLAVG pre-averaging interval (min)
  BADDISK...Disk drive #'s to avoid for scratch files
----------------------------------------------------------------
CRSFRING:  Make an SN for the calibration of cross polarized
          delays.
Documentor: K. J. Leppanen
Related Programs: BLAVG, FRING, POLSN, CLCAL

      Calibration of cross polarized delays

   This procedure will take a selected subset of a uv data set
and determine the corrections needed to remove differences in
single and multiband delays for the right and left handed
systems.  The output is an SN table which can be applied to a CL
table to affect these corrections.  The output SN table will be
written to the input data set and on successful completion of
CRSFRING will be the highest version SN table.  Cross polarized
rate errors are assumed to be zero. It is assumed that parallel
hand fringe fitting has been completed, and the resulting
calibration is in the CL table version GAINUSE.


  The basic steps of this procedure are the following:

1) Average cross-polarized data from the selected timerange and
antennas over baselines using the task BLAVG. This will improve the
signal-to-noise ratio of the usually weak cross-polarized signal
significantly. In most cases a single scan using all antennas is
adequate, and can be selected by using the TIMERANGE adverb; the delay
offsets should remain constant over the experiment.

2) Run FRING on this segment of data to obtain the delay and phase
offsets, one solution per scan.  Use APARM=2,0; DPARM=1,0,0,60*SOLINT,
0,0,1. Other FRING parameters are as passed to the procedure either
explicitly in the inputs file or implicitly by the appropriate adverb
values.

3) Run POLSN on the SN table produced by FRING.

4) Use TACOP to copy the SN table produced by POLSN to the
original data set.

   When applying the SN table to the prior CL table with CLCAL use
TIMER=0, ANTENNA=0, SOURC '', CALSOU '', and typically INTERPOL=''.
