; PHASE
;---------------------------------------------------------------
;! Baseline Phase coherence measurement
;# TASK UV IMAGING
;-----------------------------------------------------------------------
;;  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
;-----------------------------------------------------------------------
;---------------------------------------------------------------
PHASE     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
PHASE:  Baseline dependent time averaging of "BT" order uv data
INNAME                             Input UV data (name)
INCLASS                            Input UV data (class)
INSEQ                              Input UV data (seq. #)
INDISK                             Input UV data disk #
OUTNAME                            Output uvdata name (name)
OUTCLASS                           Output uv data class
OUTDISK                            Output uvdata disk #
OUTSEQ          -1.0    32000.0    Output seq. no.
APARM                              (1) Max Coherent ave time
                                   (2) Max SNR deviation to pass
                                   (4) Min Vector/Scalar ratio
                                   (5)>0 = Coherent Average `
                                   (6) Interval to write out
                                   data (minutes)
                                   (10) Prtlev, (# baselines) 
BADDISK                            Disk #'s to avoid
----------------------------------------------------------------
PHASE
Type:  WARNING, WARNING, Verrry Experimental Task WARNING.
Use:   Baseline dependent estimation of coherence time, 
       automatic flagging of data and coherenct time averaging
       of UV-data.
       NB: data must be sorted to 'BT' order before running.
Adverbs:
  INNAME.....Input UV data file (name).     Standard defaults.
  INCLASS....Input UV data file (class).    Standard defaults.
  INSEQ......Input UV data file (seq. #).   0 => highest.
  INDISK.....Input UV data file disk #.  0 => any.
  OUTNAME....Output UV data name (name). Standard defaults.
  OUTCLASS...Output UV data file (class).
  OUTDISK....The disk # of output data.  0 => highest
             with space.
  OUTSEQ.....Output sequence number. 0 => new file.
  APARM.....Task enrichment parameters.
            (1)  This gives the maximum averaging time in
            seconds, 0=> infinite.
               This parameter may be necessary if subsequent
            editing or self calibration is required.

            (2)  Max SNR deviation to pass.  While calculating
            the coherence time, the mean and rms of each
            baseline is calculated.  If the value of a
            visibility exceed A(2) times the RMS, the correlator
            is flagged.

            (3) No longer used.
    
            (4) Min Vector/Scalar amplitude ratio.  The ratio of
            the vector to scalar amplitude of the real and
            imaginary parts of the correlator output is calculated
            for the average of a few visibilities.  When the
            ratio becomes less than A(4) the coherence time is
            said to be exceeded.  A(4) = 0.9 is good for many 
            applications.

            (5) if A(5) > 0 then the output data are averaged
            (smoothed) over the coherence time for the baseline

            (6) Interval to write out data.  The data should
            be written out at an interval of 1/2 the coherence
            time.
  BADDISK...Disk #'s to avoid for scratch files
----------------------------------------------------------------

Documentor: Glen Langston

An output of PHASE is the minimum coherence time for all 
baselines.  This result is placed in the output uvdata header.
