; WTSUM
;---------------------------------------------------------------
;! Task to do a a sum of images weighted by other images
;# TASK IMAGING SINGLEDISH SPECTRAL
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1996
;;  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
;-----------------------------------------------------------------------
WTSUM     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
WTSUM: Task to do a weighted sum of two or more images
INNAME                             1st input image name (name)
INCLASS                            1st input image name (class)
INSEQ           0.0      9999.0    1st input image name (seq #)
INDISK          0.0         9.0    1st input image disk drive #
IN2NAME                            2nd input image name (name)
                                   ' ' => loop INSEQ to IN2SEQ
IN2CLASS                           2nd input image name (class)
IN2SEQ          0.0      9999.0    2nd input image name (seq #)
IN2DISK         0.0         9.0    2nd input image disk drive #
IN3NAME                            1st weight image name (name)
IN3CLASS                           1st weight image name (class)
IN3SEQ          0.0      9999.0    1st weight image name (seq #)
IN3DISK         0.0         9.0    1st weight image disk drive #
IN4NAME                            2nd weight image name (name)
                                   IN2NAME = ' ' => loop IN3SEQ
                                   to IN3SEQ + IN2SEQ-INSEQ
IN4CLASS                           2nd weight image name (class)
IN4SEQ          0.0      9999.0    2nd weight image name (seq #)
IN4DISK         0.0         9.0    2nd weight image disk drive #
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
OUTSEQ          0.0      9999.0    Output image name (seq #)
OUTDISK         0.0         9.0    Output image disk drive #
BLC                                BLC of area to be searched
TRC                                TRC of area to be searched
DOINVER        -1.0         1.0    > 0 => images 3,4 & output 2
                                          are of rms
                                   else they are const/(rms**2)
-----------------------------------------------------------------
WTSUM
Type: Task
Use:  WTSUM does a weighted sum of two or more images, writing out

            Out(x,y) =  Sum (Wi(x,y) Ii(x,y))
                        ---------------------
                            Sum (Wi(x,y))

      as well as the sum of the weights.  Note that the Ii must be
      exactly matching image planes or cubes.  The weights may be single
      planes (matching in x and y but not z) or cubes matching in all 3
      axes.  NO TESTS ARE PERFORMED TO INSURE THE VALIDITY OF
      COORDINATES: use HGEOM, SUBIM, etc. to make sure things line up.

      The task sums TWO weighted images when all four names are filled
      in.  If IN2NAME = ' ', then it sums IN2SEQ-INSEQ+1 images whose
      name parameters all match the first except for having consecutive
      sequence numvers.  In that case, the weight images must all match
      the 3rd image name parameters with consecutive sequence numbers
      going from IN3SEQ through IN3SEQ+IN2SEQ-INSEQ.

      For this to make correct sense, the weight images should all be
      the same constant divided by sigma(x,y)**2.  If DOINVER is true,
      then the "weight" images and output image WWTSUM are handled as
      rms images rather than weight images.
Adverbs:
  INNAME......First image name (name).  blank=>any
  INCLASS.....First image name (class).  blank=>any
  INSEQ.......First image name (seq #).  0=>any
  INDISK......Disk drive # for the first image.  0=>any
  IN2NAME.....Second image name (name).
              blank=> loop from INSEQ through IN2SEQ
  IN2CLASS....Second image name (class).  blank=>any
              Ignored if IN2NAME = ' '.
  IN2SEQ......Second image name (seq #).  0=>any
  IN2DISK.....Disk drive # for the second image.  0=>any
              Ignored if IN2NAME = ' '.
  IN3NAME.....First weight name (name).  blank=>any
  IN3CLASS....First weight name (class).  blank=>any
  IN3SEQ......First weight name (seq #).  0=>any
  IN3DISK.....Disk drive # for the first weight.  0=>any
  IN4NAME.....Second weight name (name).  blank=>any
              Ignored if IN2NAME = ' '.
  IN4CLASS....Second weight name (class).  blank=>any
              Ignored if IN2NAME = ' '.
  IN4SEQ......Second weight name (seq #).  0=>any
              Ignored if IN2NAME = ' '.
  IN4DISK.....Disk drive # for the second weight.  0=>any
              Ignored if IN2NAME = ' '.
  OUTNAME.....Output image name (name)
  OUTCLASS....Output image name (class)  Class WWTSUM is used
              for the sum of the weights.
  OUTSEQ......Output image name (seq #)
  OUTDISK.....Output image disk drive #
  BLC.........BLC of area to be searched, 0 => 1,1
  TRC.........TRC of area to be searched, 0 => NCOLS,NROWS
  DOINVERS....The correct weights for summing are a constant divided by
              the rms squared.  If DOINVERS is false (<= 0), input
              "weight" images (3 and 4) and output image WWTSUM are
              assumed to have this form.  If DOINVERS is true (> 0),
              they are assumed to be images of the rms.
-----------------------------------------------------------------
