; BSCOR
;---------------------------------------------------------------
;! Combines two beam-switched images
;# TASK ANALYSIS SINGLEDISH OOP
;-----------------------------------------------------------------------
;;  Copyright (C) 1996-1997, 1999
;;  Associated Universities, Inc. Washington DC, USA.
;;  Eric W. Greisen
;;
;;  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
;-----------------------------------------------------------------------
BSCOR     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
BSCOR     Combines beam-switched images
INNAME                             Input "plus" beam name
INCLASS                            Input "plus" beam class
INSEQ             0.0     9999.0   Input "plus" beam seq. #
INDISK            0.0        9.0   Input "plus" beam disk #
IN2NAME                            Cutoff "minus" beam name
IN2CLASS                           Cutoff "minus" beam class
IN2SEQ            0.0     9999.0   Cutoff "minus" beam seq. #
IN2DISK           0.0        9.0   Cutoff "minus" beam disk #
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 #.
BLC                                Bottom left corner of input
TRC                                Top right corner of input
FACTOR                             Correct the beam throws by
                                   multiplying by FACTOR
ORDER                              Baseline order (0 or 1)
DPARM                              Parameters: (see HELP)
                                   (1) scale factor plus image
                                       over minus (0 -> 1)
                                   (2) > 0 => apply scale before
                                       differencing, else apply
                                       scale with convolution
                                   (3-4) x-pixel baseline region
                                       1 for both images
                                   (5-6) x-pixel baseline region
                                       2 for both images
DOALIGN                            How closely coordinates agree
----------------------------------------------------------------
BSCOR
Task:  Combines the two images of beam-switched data.  A constant
       baseline is fit to two windows in each row and subtracted
       from that row.  Then (optionally) the plus image is scaled
       with respect to the minus image.  The two are then differenced
       and convolved with a one-dimensional function on a row by row
       basis to combine the two images.
Adverbs:
  INNAME.....Input plus beam image name.     Standard defaults.
  INCLASS....Input plus beam image class.    Standard defaults.
  INSEQ......Input plus beam image seq. #.   0 => highest.
  INDISK.....Disk drive # of plus beam image. 0 => any.
  IN2NAME....Input minus beam image name.    ' ' => INNAME
  IN2CLASS...Input minus beam image class.   ' ' => INCLASS
                                             (with + -> -)
  IN2SEQ.....Input minus beam image seq. #.   0 => INSEQ
  IN2DISK....Disk drive # of minus beam image. 0 => INDISK
  OUTNAME....Output image name (name).   Standard defaults.
  OUTCLASS...Output image name (class).  Standard defaults.
  OUTSEQ.....Output image name (seq. #).    Standard defaults.
  OUTDISK....Disk drive # of output image.  0 => highest number
             with sufficient space.
  BLC........Bottom right corner in input image of desired
             subimage.  Default is entire image.
  TRC........Top right corner in input image of desired
             subimage.  Default is entire image.
  FACTOR.....Change the beam throws by FACTOR.
  ORDER......Order of baseline removed from each row of each image.
             Only 0 and 1 are allowed.
  DPARM......Parameters:
             (1) The plus beam may be scaled by DPARM(1) wrt the minus
                 beam.  (You may need to use IMFIT to determine this
                 ratio.  Be sure to fit a baseline as well as a
                 Gaussian.)  0 => 1.
             (2) The ratio may be applied at two different stages:
                 if DPARM(2) > 0, the images are scaled before they are
                 differenced.  Otherwise, the scaling is done through a
                 modification of the convolution function.
             (3) Start x pixel of both images to use for the first of
                 2 baseline regions.  0 => 1.  N.B. this applies after
                 BLC(1) has been applied.
             (4) End x pixel of both images to use for first baseline
                 region.  0 => all (not a good default).
                 N.B. above N.B.
             (5) Start x pixel of both images to use for the second of
                 2 baseline regions.  0 => none.  N.B. above N.B.
             (6) End x pixel of both images to use for second baseline
                 region.  0 => all (an okay default).
             It has been found by experimentation that it is essential
             to use the same baseline regions for both images.
  DOALIGN....The alignement of the two images is checked at a level
             determined by DOALIGN.
             = 1 => they must agree
             = 0 => axis 1 must agree, 2 need only be close
             = -1 => types and dimensions must agree
             = -2 => only dimensions are checked
----------------------------------------------------------------
