; CXIMAGR
;---------------------------------------------------------------
;! Grid UV data into a complex image, Fourier transform, Clean
;# PROCEDURE UV IMAGING
;-----------------------------------------------------------------------
;;  Copyright (C) 2020
;;  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
;-----------------------------------------------------------------------
CXIMAGR   LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CXIMAGR:  Task to make and Clean complex images
INNAME                             UV data (name).
INCLASS                            UV data (class).
INSEQ             0.0    9999.0    UV data (seq. #).  0 => high
INDISK                             Disk unit #.       0 => any
OUTNAME                            Image data (name).
OUTSEQ            0.0    9999.0    Image data (seq. #). 0=>high
OUTDISK                            Disk unit #.       0 => any
BIF               0.0      100.0   Lowest IF number 0=1
EIF               0.0      100.0   Highest IF number
BCHAN             0.0     2048.0   Low channel number 0=>1
ECHAN             0.0     2048.0   High channel number
DPARM                              Control info:
                                   (7) > 0 => do NOT divide by
                                       the summed weights
                                   (8) > 0 -> use XTYPE, YTYPE
                                       and interpolate to grid
                                   (10) Use data weight to the
                                       power 1/DPARM(10)
SCALR3         -1.          1.     > 0 => do not grid Hermitian
IMSIZE            1.0   16384.0    Output image size in x,y
CELLSIZE        0.000001           Cell size (arc sec)
DOROBUST       -1.0         1.0    > 0 use ROBUST weighting
ROBUST         -5.0         5.0    Brigg's robustness parameter
NITER                              Maximum # of CLEAN components
                                      <= 0 -> no CXCLN
GAIN               0.0         2.0 CLEAN loop gain
FLUX               0.0             Min. residual in window (Jy)
BMAJ                               FWHM(asec) maj. axis CLEAN
                                   restoring beam.
                                   0 -> proc will fit QBM001
BMIN                               FWHM(asec) min. axis CLEAN
                                   restoring beam.
BPA             -360.0       360.0 CLEAN beam position angle
NBOXES             0.0        50.0 Number of boxes for CLEAN
CLBOX              0.0      4096.0 Four coordinates for each box
BADDISK                            Disk to avoid for scratch.
----------------------------------------------------------------
CXIMAG
Type:  Procedure
Use:   Grids UV data to make images in U and V of the real and imaginary
       parts of the data and of the sampling function using UVIMG.  Then
       it runs FFT on these "images" to make complex map-plane images.
       Finally, and optonally, it runs CXCLN.  The u-v plane images
       are assigned classes CXreal, CXimag, and CXbeam.  The mape plane
       images are given classes QIM001, UIM001, QBM001, UBM001, QCL001,
       and UCL001.  (These classes are to satisfy the requirements of
       CXCLN.)

       The input data should be a single-source, fully calibrated data
       set.  All included spectral channels will be "averaged".

       DPARM(8) was added to signal your intention to use convolving
       functions when interpolating to the grid.  This may be desirable
       for this operation.  The spheroidal convolving function is used.
       DOROBUST was added to allow for ROBUST-tempered uniform
       weighting.

Adverbs:
  INNAME.....UV file name (name).          Standard defaults.
  INCLASS....UV file name (class).         Standard defaults.
  INSEQ......UV file name (seq. #).        0 => highest.
  INDISK.....Disk unit #.                  0 => any.
  OUTNAME....Image file name (name).       Standard defaults.
  OUTSEQ.....Image file name (seq. #).     0 => highest.
  OUTDISK....Output disk unit #.           Standard defaults.
  BIF........Lowest IF to grid.  IF will be axis 4.
  EIF........Highest IF to grid.      0 => highest.
  BCHAN......First channel to grid.   0 => 1.
  ECHAN......Last channel to grid.    0 => highest.
  DPARM......Control info: (1-6, 9 set by proc)
             (7) > 0 => do NOT divide by the count (or sum of
                        convolution weights).  Makes image a convolution
                        such as done by IMAGR, UVMAP, et al.
                 <= 0 => do divide by the sum of counts or convolution
                        function weights in each cell.  Makes image an
                        interpolation of the data.
             (8) >  0 => use spheroidal convolution function rather than
                        a 1-cell pillbox.
                 <= 0 => put each sample at the nearest grid cell.
             (10) > 0 => use data weight when gridding to the power
                        1/DPARM(10)
                  NOTE WELL: data weights are ignored if DPARM(10) is
                  not set!
  SCALR3.....> 0 -> do NOT grid the Hermitian point of the visibility
  IMSIZE.....X,Y output image size, NO DEFAULT, power of 2 strongly
             recommended
  CELLSIZE...The "Q" and "U" image cell sizes in seconds of arc.
             NO DEFAULT.
  DOROBUST...> 0 => Do uniform -> natural weighting
             If > 0, then DPARM(7) is set to 1 so that weighting is
             done by this process rather than normalizing by counts
             or sum of weights.
  ROBUST.....Brigg's robustmess parameter.  -4 uniform, 4 natural
             See help file for details.
  GAIN........The CLEAN loop gain.  0 => 0.10
  NITER.......CLEAN iteration limit.  <= 0 -> no CXCLN
  FLUX........Stop CLEAN when abs(resid. image max in CLEAN
              window) < FLUX (Jy).
  BMAJ........The FWHM (asec) major axis of the restoring beam.
              The parameters of the restoring beam should be provided.
              If <= 0, the procedure will try JMFIT on the QBM001
              image.
  BMIN........The FWHM (asec) minor axis of the restoring beam.
  BPA.........The position angle in the unrotated image of BMAJ.
  NBOXES......Number (<=50) of rectangular search boxes.  0 => 1
  CLBOX.......A 4x50 array with the BLC and TRC of each box.
              0 => use inner quarter of input map (first box)
              0 => ignore box (boxes 2 - 50)
  BADDISK....Disk numbers to avoid for scratch files.  Scratch
             files may be created by the sorting routines if
             calibration or flagging is applied.
----------------------------------------------------------------
