; CLINV
;---------------------------------------------------------------
;! copy CL/SN file inverting the calibration
;# TASK TABLE CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 1999
;;  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
;-----------------------------------------------------------------------
CLINV     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CLINV     task to invert SN/CL tables
INNAME                             Input image name (name)
INCLASS                            Input image name (class)
INSEQ             0.0     9999.0   Input image name (seq. #)
INDISK            0.0        9.0   Input image disk unit #
INEXT                              Input table extension type
INVERS                             Input table file version no.
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
OUTSEQ           -1.0     9999.0   Output image name (seq. #)
OUTDISK           0.0        9.0   Output image disk unit #.
OUTVERS                            Output table file version.
OPTYPE                             'PHAS' => invert phase only
                                   (output amplitude gain = 1)
                                   'AMPL' => invert amp. only
                                   (output phase = 0)
                                   otherwise completely invert
                                   the calibration
----------------------------------------------------------------
CLINV
Task:  CLINV inverts the calibration in an AIPS CL or SN extention
       table.  The specified output table should not exist before the
       execution of CLINV.
Adverbs:
  INNAME.....Input image name (name).       Standard defaults.
  INCLASS....Input image name (class).      Standard defaults.
  INSEQ......Input image name (seq. #).     0 => 1.
  INDISK.....Disk drive # of input image.   0 => any.
  INEXT......Extention table type (e.g. 'CL') ' ' => 'SN'
  INVERS.....Version number of table to copy, 0=>highest no.
  OUTNAME....Output image name (name).      Standard defaults.
  OUTCLASS...Output image name (class).     Standard defaults.
  OUTSEQ.....Output image name (seq. #).    0 => highest unique.
  OUTDISK....Disk drive # of output image.  0 => highest disk
             number with sufficient space.
  OUTVERS....Output version number, 0=> next higher.
  OPTYPE.....'PHAS' => invert phase only (output amplitude gain = 1)
             'AMPL' => invert amplitude only (output phase = 0)
             otherwise completely invert the calibration
----------------------------------------------------------------
CLINV
Task:  Calibration inversion

IF an AIPS CL or SN table has been applied to a data set and one wants
to undo the calibration (or the phase or amplitude part of the
calibration), one may use CLINV to produce an inverse table which may
then be applied to the data with SPLIT.  The example that caused this
task to be written is a field with a strong source at the half-power
point of the beam.  Pointing errors make calibration found with this
strong source inaccurate for sources near the center of the field, but
one has to self-cal on the strong source in order to remove it.
Therefore:

      1. Calibrate in the normal way and SPLIT
      2. Self-calibrate with a strong source in/near the field
      3. Run UVSUB to subtract that strong source
      4. Run CLINV on the self-calibration SN table attaching the
         inverse table to the output of UVSUB
      5. Undo the strong-source self-cal from the residual data by
         running SPLIT on the UVSUB/CLINV output file.
