; VLABP
;---------------------------------------------------------------
;! VLA antenna beam polarization correction for snapshot images
;# TASK CALIBRATION POLARIZATION  Image VLA OOP
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1999, 2019
;;  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
;-----------------------------------------------------------------------
VLABP     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
VLABP     VLA snapshot beam polarization correction
                                   Input image
INNAME                                Image name (name),
INCLASS                               Image class; must have
                                      'I*', 'Q*' and 'U*'.
                                      or polarization cube
INSEQ              0.0      9999.0    Image name (seq. #)
INDISK             0.0         9.0    Image disk drive #
ROTATE                                Parallactic angle (deg)
                                   Antenna fract. poln. image
IN2NAME                               Name
IN2CLASS                              Class, must have
                                      'Q*' and 'U*'.
IN2SEQ             0.0      9999.0    Ant. poln seq. #
IN2DISK            0.0         9.0    Ant. poln drive #
                                   Corrected image
OUTNAME                               Image name
OUTCLASS                              Class: 'Q*' and 'U*'.
OUTSEQ            -1.0      9999.0    Image name (seq. #)
OUTDISK            0.0         9.0    Image disk drive #
BADDISK           -1.0      1000.0 Disks to avoid for scratch.
----------------------------------------------------------------
VLABP
Task:  Corrects an VLA snapshot polarization image for the
antenna residual polarization.  Note this will ONLY work for
snapshots as the antenna residual polarization function rotates
with parallactic angle.
Adverbs:
  INNAME......The input image name.   Standard defaults.
  INCLASS.....The root of the input classes.  The polarization images
              are assumed to have the same class except for the first
              character which is 'I', 'Q', or 'U' (e.g. 'ICL001',
              'QCL001' and 'UCL001').   Default 'ICL001'.
              An alternative is if the input image is a polarization
              cube, e.g. three planes with I, Q, and U on the third
              axis.
  INSEQ.......The input map image sequence number. 0 => high
  INDISK......The input map image disk drive no. 0 => any
  ROTATE......The parallactic angle of the observations.  This is used
              iff the Q input image does NOT have a header keyword
              'PARANGLE'.  If this keyword exists its associated value
              is used.
  IN2NAME.....The antenna fractional polarization image name.
  IN2CLASS....The root of the class name; the real and imaginary parts
              must be 'Q*' and 'U*' respectively (e.g. 'QFRACT',
              'UFRACT').  Default 'QFRACT'
  IN2SEQ......The antenna polarization image sequence number.
              0 => actual INSEQ
  IN2DISK.....The antenna polarization image disk drive no.  0 => any
  OUTNAME.....The output polarized image name.
              blank => Standard defaults based on INNAME.
  OUTCLASS....The root of the output image class. The real and
              imaginary parts will be 'Q*' and 'U*'
              respectively. (e.g. 'QCORR', 'UCORR')
              The output image may be the same as the input
              image. Default 'QCORR'
              If the input image was a polarization cube then
              the output will be a polarization cube in which
              the total intensity plane is copied from the
              input.
  OUTSEQ......The output image seq. no., 0=> highest unique
              If >0; image will be created if new,
                overwritten if image name exists.
  OUTDISK.....Output image disk drive no., 0=> highest with space
  BADDISK.....This array contains the numbers of disks on which
              it is desired that scratch files not be located.
              BADDISK has no effect on input and output maps.
----------------------------------------------------------------
VLABP: Task to correct VLA polarized snapshot images for antenna
       residual polarization.
Documentor: W. D. Cotton NRAO
Related Programs: IMAGR

     This task is intended to correct VLA widefield polarization
snapshot images for the effects of the residual polarization
pattern of the antenna/feed.  As this pattern rotates with
parallactic angle this correction can only be made in the image
plane for snapshots for which there is a well defined
parallactic angle.
   The parallactic angle of the observations can either be
attached to the input 'Q' image as a header keyword 'PARANGLE'.
This keyword can be written ising verb PUTHEAD.  An alternative
is using avderb ROTATE.

IN2NAME:
   An image of the antenna fractional polarization must be
provided.  This has a real ('Q') and imaginary ('U') parts which
should be the ratio of the Q or U polarization to the total
insensity for a source at the corresponding location.  The image
should correspond to parallactic angle 0 deg.
   This image need not be at the same cell spacing as the input
image but should cover the entire region of the input images.
Regions outside of this image will be blanked.

Polarization cubes.
   The input and output image may be polarization cubes with
Stokes I, Q and U on the third axis. In this case the total
intensity image is copied from the input to output.
