; SDIMG
;---------------------------------------------------------------
;! Task to select and image random-position single-dish data
;# TASK SINGLEDISH AP IMAGING
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1997, 1999-2000, 2007
;;  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
;-----------------------------------------------------------------------
SDIMG     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SDIMG     Select & grid random-position single-dish measurements
INNAME                             Input UV file name (name)
INCLASS                            Input UV file name (class)
INSEQ             0.0     9999.0   Input UV file name (seq. #)
INDISK            0.0        9.0   Input UV file disk unit #
                                   Cal. info for input:
DOCALIB          -1.0        2.0   If >0 calibrate data
GAINUSE                            CS table to apply
FLAGVER                            Flag table version
STOKES                             Stokes' parameter to image.
BIF               0.0              IF (if any) to select
BCHAN             0.0     4096.0   First spectral channel
ECHAN             0.0     4096.0   Last spectral channel
OUTNAME                            Output UV file name (name)
OUTCLASS                           Output UV file name (class)
OUTSEQ            0.0     9999.0   Output UV file name (seq. #)
OUTDISK           0.0        9.0   Output UV file disk unit #.
OPTYPE                             Projection code e.g. '-SIN'
APARM                              1,2,3 = RA (h,m,s)
                                   4,5,6 = Dec (d,m,s)
IMSIZE         32.       4096.     Image size (X,Y) in pixels
CELLSIZE    0.000001     4096.     Cell size in arc seconds
ROTATE                             Rotate image CCW (degrees)
SHIFT                              (X,Y) image shift in asec
UVWTFN                             UV dist. weight function
                                     'UN' => uniform count
                                     'WT' => uniform weights
                                     other => natural
UVBOX           0.        128.     Additional rows and columns
                                   used in weighting. Use 0.
REWEIGHT                           (1) <= 0 -> interp image
                                       =  1 -> convolved image
                                       =  2 -> weight image
                                       =  3 -> 1/sigma**2 image
                                   (2) Min convolved weight
                                       = REWEIGHT(2) *
                                         max(convolved weight)
                                       < 0 => use abs value
XTYPE         -20.         20.     Conv. function type in x
                                     default spheroidal
                                     New round types - SEE HELP
YTYPE         -20.         20.     Conv. function type in y
                                     default spheroidal
XPARM                              Conv. function parms for x
YPARM                              Conv. function parms for y
BADDISK                            Disk drive #'s to avoid
----------------------------------------------------------------
SDIMG
Task:  This task will select random position single dish data in AIPS uv
       form in a specified field of view about a specified position and
       project the coordinates onto the specified coordinate system.
       Calibration and flagging may be applied during the selection
       process.  It will then convolve the data onto a grid.  The input
       data may be in any sort order - they will be sorted by SDIMG into
       the order needed for gridding.

       Task SDGRD is recommended for most single-dish imaging.  However,
       SDIMG has been made available to do images too large for SDGRD.
       It does this by having one or even two scratch file copies of the
       input data so that the projecting may be done ahead of a sort on
       the projected coordinates.  Uniform weighting is probably not
       desirable in single-dish imaging, but it is available in SDIMG.
       It is not offered by SDGRD.
Adverbs:
  INNAME.....Input single-dish data file name (name).
  INCLASS....Input single-dish data file name (class).
  INSEQ......Input single-dish data file name (seq. #).
  INDISK.....Disk drive # of input single-dish data file.
  DOCALIB....If true (>0) then calibrate the data using information in
             the specified CS table.
  GAINUSE....Version number of the CS table to apply to the
             data if DOCALIB=1.  0 = highest numbered.
  FLAGVER....Specifies the version of the flagging table to be
             applied. 0 => highest numbered table.
             <0 => no flagging to be applied.
  STOKES.....Stokes' type of the desired image:
             'I' => I polarization,
             'Q' => Q polarization,
             'U' => U polarization,
             'V' => V polarization,
             'RR' => right circular polarization,
             'LL' => left circular polarization,
             'XX' => horizontal linear polarization
             'YY' => vertical linear polarization
             other => 'I'
  BIF........IF number to grid (only one is done).  0 => 1.
  BCHAN......First spectral channel to grid, 0 => 1.
  ECHAN......Last spectral channel to grid; <BCHAN => max.
  OUTNAME....Output file name (name).  blank => INNAME
  OUTCLASS...Output file name (class).  blank => INCLASS
  OUTSEQ.....Output file name (seq. #). 0 => lowest unique
  OUTDISK....Disk drive # of output UV file.  0 => highest with
             space for the file.
  OPTYPE.....Projection code:
             '-TAN' = tangent projection (optical),
             '-SIN' = sine projection (normal interferometer),
             '-ARC' = arc projection (Schmidt camera, single
                      dish images),
             '-NCP' = North celestial pole (WSRT),
             '-STG' = stereographic projection,
             '-AIT' = Aitoff projection, (large field)
             '-GLS' = Global sinusoidal projection (large field)
             '-MER' = Mercator projection,
             '    ' => '-SIN'
             See AIPS memo nos. 27 and 46 for more detail.
  APARM......1,2,3 are the RA as (h,m,s)
             4,5,6 are the Dec, as (d,m,s)
             The specified position is the CENTER of the RA and DEC
             range before the application of the shifts (if any).
             Default: uv data header RA and DEC, or, if they are 0, uv
             data header Observed RA and Dec.  If the data coordinates
             are relative Az-El (i.e. beam switched data), then there is
             no default and 0,0 would be the normal center.
             If APARM(4) is -0 then use APARM(4)=-0.1.
  IMSIZE.....(X,Y) image size in pixels.  Must be even and
             between 32 and 4096.
  CELLSIZE...(X,Y) cell size in arc seconds.
  ROTATE.....Rotate image CCW by ROTATE degrees.
  SHIFT......Probably wouldn't do what you expect: shifts the reference
             pixel by SHIFT(1)/CELL(1), -SHIFT(2)/CELL(2).  The
             reference value is set by APARM (see above).  For a normal
             Ra-Dec image, if both SHIFTs are > 0, the center of the
             image will be at a higher Ra and higher Dec than the
             reference point.
  UVWTFN.....Spatial weighting function for data:
             'UN' => "Uniform" (spatial weights = 1/# pts in
                      the cell)
             'WT' => "uniform weights" (spatial weights =
                      1 / sum of data weights in cell)
             other => "Natural" (all spatial weights = 1)
  UVBOX......(U,V) box size for smoothing.   See HELP UVBOX.
  ZEROSP.....The first value is used to set the minimum sum of
             convolving function weights (times data weights
             scaled down by the maximum data weight). 0 => 0.01
  REWEIGHT...(1) Selects the kind of output image:
                <= 0 => interpolated image (convolved image
                        divided by a convolved image with the
                        data replaced by 1.0's).
                 = 1 => convolved image of data.
                 = 2 => convolved image with data replaced by 1,
                        i.e an image of the data weights (sum of
                        input data weight * uniform weight
                        correction * convolving function at each
                        cell)
                 = 3 => image of K/sigma**2 for an interpolated
                        image assuming the input weights are
                        K/sigma**2 for the data samples
             (2) Minimum convolved weight (image with data
                 replaced by 1.0's) to remain unblanked =
                 REWEIGHT(2) * max(convolved weight).
                 < 0 => use abs(convolved weight) compared to
                        abs(REWEIGHT(2)*max(convolved weight))
                 0 => -0.01. for interpolation output and no
                        blanking for convolution and weight
                        outputs
  XTYPE......Convolution function type in X-direction
                1=Pillbox, 2=exponential, 3=Sinc, 4=Exp*Sinc,
                5=Spheroidal, 6=Exp*BESSJ1(x)/x
                = 0 or > 6 (& < 11) -> 5.
                11 - 16 => circular functions in radius corresponding to
                1 - 6 types above; YTYPE, YPARM are ignored.
             If XTYPE < 0, then abs(xtype) is used and some of the XPARM
             values are assumed to be in arc seconds rather than cells.
             See HELP UV1TYPE through HELP UV6TYPE for details.
  YTYPE.....Convolution function type in Y-direction
  XPARM.....Array containing parameters for XTYPE.
            See HELP UVnTYPE when n=convolution type.
            XPARM(5) is number samples of convolution function
            used per image cell for circular functions - 100 is
            used for X/Y separable functions (types 1-6)
  YPARM.....Array containing parameters for YTYPE.
  BADDISK...Disk drive #'s to avoid for scratch files
----------------------------------------------------------------
