; FXAVG
;---------------------------------------------------------------
;# PROCEDURE VLBI
;! Procedure to enable VLBA delay de-correlation corrections
;-----------------------------------------------------------------------
;;  Copyright (C) 1995
;;  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
;-----------------------------------------------------------------------
;---------------------------------------------------------------
FXAVG     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
FXAVG:    Procedure to enable VLBA de-correlation corrections
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 #
SUBARRAY                           Subarray number (0 => 1)
APARM                              (1) = FFT_size
                                      <=0 => disable the
                                             correction
                                   (2) = Spectral avg. factor
                                      <=0 => calculate using
                                             FFT_size and no.
                                             of freq. chan.
----------------------------------------------------------------
FXAVG
Procedure:  This procedure is used to set the keyword
            SPEC_AVG in the antenna (AN) table, so enabling
            or disabling the delay de-correlation corrections
            for the VLBA. To use the procedure, set the
            input adverbs using TGET FXAVG and INP FXAVG,
            then run the procedure as:
            > RUN FXAVG
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.
  SUBARRAY...Subarray to use (0 => 1). Run this procedure
             separately for each subarray.
  APARM......(1) = FFT_size; check the keyword FFT_SIZE in
                   the MC table or ask VLBA correlator
                   operations staff. If < 1 then the delay
                   decorrelation correction will be
                   disabled.
             (2) = Spectral averaging factor. If < 1 on input
                   this will be calculated using the FFT size
                   and the present number of frequency channels.
----------------------------------------------------------------
FXAVG:  Set the SPEC_AVG parameter in the AN table
Documentor: A. J. Kemball
Related Programs: SPLIT, FRING, general calibration

The amplitudes of data from the VLBA FX correlator may need to be
corrected for small de-correlation losses caused by spectral averaging
in the correlator and segmentation losses, both of which are
exacerbated by large residual delay errors. The spectral averaging
loss is caused by frequency averaging of cross-power spectra in the
correlator in the presence of residual delays.  It is more marked for
the larger bandwidths. The segmentation loss is an inherent feature of
FX correlation and is caused by misalignment of the data segments used
in the FFT, again due to residual delay errors.

These amplitude losses can be corrected in AIPS after the residual
delays have been determined in fringe-fitting. If the keyword
SPEC_AVG is set in the AN table and the array name in the AN table
is 'VLBA' then the amplitude correction will be made when the
delay correction is applied at any point in the calibration. In
more recent VLBA datasets FITLD may have written the correct SPEC_AVG
keyword in the AN table. This can be determined using task PRTAB.
If not then FXAVG can be used to set this keyword. If SPEC_AVG is
set to a value less than or equal to zero the correction is
disabled.

This procedure should be run immediately after loading the data,
and before any averaging in frequency. The factor SPEC_AVG
indicates how many FFT frequency channels were pre-averaged in
the correlator to produce each of the present frequency channels.
For example, an FFT size of 512 and a present number of frequency
channels of 16, implies a spectral averaging factor of:

SPEC_AVG = 512 / (2 * 16)
         = 16

The 15JAN95 and 15JUL95 releases of AIPS correct for the spectral
averaging loss if SPEC_AVG is present. The correction for
segmentation losses, which is a second-order effect, will be
introduced shortly.


