; CCRES
;---------------------------------------------------------------
;! Removes or restores a CC file to a map with a gaussian beam.
;# Task Imaging AP
;-----------------------------------------------------------------------
;;  Copyright (C) 2005, 2008-2009, 2017
;;  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
;-----------------------------------------------------------------------
CCRES     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCRES:  removes and/or restores a CC file to an image
                                   Input image
INNAME                                Image name (name)
INCLASS                               Image name (class)
INSEQ              0.0      9999.0    Image name (seq. #)
INDISK             0.0         9.0    Image disk drive #
BLC                                   Bottom left corner
TRC                                   Top right corner
                                   Image with CC file appended
IN2NAME                               Image name (name)
IN2CLASS                              Image name (class)
IN2SEQ             0.0      9999.0    Image name (seq. #)
IN2DISK            0.0         9.0    Image disk drive #
INVERS             0.0     46655.0    CC file ver. no.
                                   Output image
OUTNAME                               Image name (name)
OUTCLASS                              Image name (class)
OUTSEQ            -1.0      9999.0    Image name (seq. #)
OUTDISK            0.0         9.0    Image disk drive #
OPTYPE                             'SUB', 'ADD', 'S+A'
                                   'SGAU', 'AGAU'
BCOUNT             0.0             First component
ECOUNT             0.0             Last component
BMAJ            -999.9             FWHM(asec) maj. axis CLEAN
                                   restoring beam - used even
                                   on SUB - be careful
BMIN            -999.9             FWHM(asec) min. axis CLEAN
                                   restoring beam.
BPA             -360.0       360.0 CLEAN beam position angle
FACTOR                             > 0 => additional scaling of
                                   residual image above default
                                   < 0 do no residual scaling
----------------------------------------------------------------
CCRES
Type: Task
Use: CCRES does an in-core-based restoration of a CC file to an image.
     It is similar to RSTOR, but that task requires the CC components
     to fall on grid cells and the image to be an integer power of 2
     in size.  RSTOR also does its work with FFTs, meaning that the
     image may not contain blanked pixels.  CCRES can handle any size
     image, any set of Clean components, so long as your machine has
     enough memory, and will leave blanked pixels blank.  The CC
     file is copied from the second input map (which may be the
     same as the first input map) to the output.

     CCRES works only on single-plane images.

     The residual image is scaled to the units of the output image
     (Jy/ the new beam).
Adverbs:
  INNAME......The input map image name.   Standard defaults.
  INCLASS.....The input map image class.  Standard defaults.
  INSEQ.......The input map image sequence number. 0 => high
  INDISK......The input map image disk drive no. 0 => any
  BLC.........The bottom left corner of the input image in pixels to
              be copied to the output image.  0 -> 1
  TRC.........The top right corner of the input image to be copied to
              the output image in pixels.  Note TRC(3-7) are forced to
              BLC(3-7).
  IN2NAME.....The image name for the CC file.  blank => actual
              INNAME, otherwise standard defaults.
  IN2CLASS....The CC image class.  Blank => actual INCLASS.
  IN2SEQ......The CC image sequence number. 0 => actual INSEQ
  IN2DISK.....The CC image disk drive no. 0 => any
  INVERS......The CC file version number. 0=> highest
              current one.
  OUTNAME.....The restored map image name.  blank => actual
              INNAME.
  OUTCLASS....The output map image class.  Standard behavior:
              blank => task name
  OUTSEQ......The restored map image seq. no., 0=> highest unique
              If >0: image will be created if new, overwritten if
                image name exists and has the same number of pixels on
                the axes.  Use with great care or USE ZERO.
  OUTDISK.....Restored Map disk drive no., 0=> highest with space
  OPTYPE......'SUB '  subtract the Clean components of image 2 from
                      image 1.  Use BMAJ et al if set, else use the
                      Clean beam of image 2 - THE USUAL DESIRE ON
                      SUB REQUIRES YOU TO SET BMAJ AND BMIN TO ZERO.
              'ADD '  as SUB but add rather than subtract.
              'S+A '  subtract the Clean components of image 2 from
                      image 1 using the Clean beam of image 2 and then
                      add those same Clean components back using the
                      Clean beam specified in BMAJ, BMIN, BPA.
              'ADDP'  like ADD but put the point components in as
                      points
              'S+AP'  like S+A' but put the components in as points
              'SGAU'  Subtract the Gaussians in the CC table
              'AGAU'  Add the Gaussians in the CC table
              Else SUB if image 1 is a normal Clean image, else ADD if
              image 1 is a residual image, else quit.
  BCOUNT......Use Clean components from BCOMP through ECOMP.  0 -> 1
  ECOUNT......Use Clean components up to and including NCOMP.
              < BCOMP => all.
  BMAJ........The FWHM (asec) major axis of the restoring beam.
              If 0: value obtained from input image; CCRES will
                die if there is no beam in the input header.
  BMIN........The FWHM (asec) minor axis of the restoring beam.
  BPA.........The position angle in the unrotated image of BMAJ.
----------------------------------------------------------------
