; ACCOR
;---------------------------------------------------------------
;! Corrects cross amplitudes using auto correlation measurements
;# Task UV VLBI CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1996, 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
;-----------------------------------------------------------------------
;---------------------------------------------------------------
ACCOR     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ACCOR     Correct cross using auto correlation
INNAME                             Input UV file name (name)
INCLASS                            Input UV file name (class)
INSEQ             0.0     9999.0   Input UV file name (seq. #)
INDISK            0.0        9.0   Input UV file disk unit #
TIMERANG                           Timerange:
                                    1-4 = start day,hr,min,sec
                                    5-8 = end   day,hr,min,sec
SOLINT                             Solution interval (min)
                                   .GT.0 => no pay attention
                                            on scans
                                   .LT.0 => SOLINT=ABS(SOLINT)
                                   and average is terminated
                                   at the end of scans
                                   0 => -2 min;
                                   see help
----------------------------------------------------------------
ACCOR
Type: Task
Use:  ACCOR corrects amplitudes in cross correlation spectrum
      due to errors in samplers thresholds using  measurements
      of auto correlation spectrum.
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.
  TIMERANG...Time range of the data to be used. In order:
             Start day, hour, min. sec,
             End day, hour, min. sec. Days relative to
             reference date.
             TIMERANGE = 0  => All available data are used
  SOLINT.....The solution interval (minutes). The mean values of
             spectra are averaged through the SOLUTION intervals
             following concurrently starting of TIMERANGE start.
             If SOLINT is more than TIMERANG, the time of
             averaging is equal the TIMERANG.

             If SOLINT.GE.0 then the averaging does not pay
             attention on the scans and several scans inside
             SOLINT may be averaged together.
             The averaging  at this case may include more than
             one source ID or/and frequency ID.
             So the source ID and frequency ID appeared at
             the output SN table is the same for the all rows of
             the SN table, and equal 0.
             Use CALSOUR = '' at CLCAL to convert such a SN table
             to the relevant CL table.

             If SOLINT.LT.0  then the ABS(SOLINT) is used as the
             average interval and averaging is terminating at the
             end of the scan.
             The right source IDs and frequency IDs appear at
             the output SN table for the each averaged interval.
             CALSOUR can be used at CLCAL to select calibrators
             at this case.

             Because of the gaps between scan small intervals can
             appear at the scan ends. The interval less than
             0.2*MIN(SOLINT, SVAN) are not recorded to the output
             SN table.

             0 => -2 min
----------------------------------------------------------------
ACCOR: Task to correct amplitudes distorted by errors of samplers.
Documentor:  L.R. Kogan
RELATED PROGRAMS: FITLD

                          PURPOSE

Calibration of a cross correlation spectrum supposes knowing parameters
of samplers (digitizers in particular). Unfortunately these parameters
are not identical to optimal ones and their real values are not known
with enough accuracy. As a result the cross correlation spectrum
amplitudes are measured with errors. These errors can be estimated
having measured the mean value of auto correlation spectrum of a given
interferometer's antennas. The theory of this correction is given by
L. Kogan in VLBA SCIENTIFIC MEMO #9, 1995.
  The task estimates the mean values of the auto correlation spectra of
all antennas of a given VLBI network and records them in a new SN table.
The following application of the correction is provided by standard
procedure of applying the SN table to an CL table (CLCAL) and following
application this table with DOCALIB = 1 in relevant tasks.

                          COMMENTS

This method of correction is especially effective in the case of TWO
bits (FOUR levels) digitizers. Uncorrected amplitudes of cross
correlation spectra can differ from real ones in this case up to 25%.
The correction can minimize the errors to a bit of percent.
The behavior of the samplers' errors is unknown. In many cases it is
stable for hours for a given sampler. But cases of minute changing can
not be excluded. The default value of SOLINT is 60 minutes. But smaller
value 5-10 minutes can be recommended as well.
The correction quality can be checked by POSSM (for example) with
DOCALIB=1 and GAINUSE equaled to the CL table number gotten from
ACCOR's SN table.
The mean values of all auto correlation spectra would be close to unit.
  The task corrects other small errors of spectrum amplitudes caused by
other errors besides samplers errors.
  The task requires TB order of data. If it is not the task UVSRT has
to be applied to the data early.



