; SDMOD
;---------------------------------------------------------------
;! modifies single-dish UV data with model sources
;# TASK UV SINGLEDISH MODELING
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1996, 2000
;;  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
;-----------------------------------------------------------------------
SDMOD     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
sdmod     Task to add model sources to single-dish data
INNAME                             Input UV file name
INCLASS                            Input UV file class
INSEQ             0.0     9999.0   Input UV file seq. #
INDISK            0.0        9.0   Input UV file disk unit #
IN2NAME                            Input model image name
IN2CLASS                           Input model image class
IN2SEQ            0.0     9999.0   Input model image seq. #
IN2DISK           0.0        9.0   Input model image disk #
OUTNAME                            Output UV file name
OUTCLASS                           Output UV file class
OUTSEQ           -1.0     9999.0   Output UV file seq. #
OUTDISK           0.0        9.0   Output UV file disk unit #.
OPTYPE                             'IMAG' => use model image
                                   else use Gaussians
BCHAN             0.0     9999.    First channel to include
ECHAN             0.0     9999.    Last channel to include
BIF               0.0      999.    First IF to include
EIF               0.0      999.    Last IF to include
NGAUSS            0.0       4.0    Number of components
GMAX                               Peak of component (K)
GPOS                               (X,Y) position (arc sec)
GWIDTH                             (BMAJ, BMIN, BPA) of comp.
                                     (arc sec, arc sec, deg)
APARM                              Center channel, fwhm for each
                                   component.  0 => chan indep.
FLUX            -1.0       100.0   >= 0 RMS noise (K) to add to
                                   model; < 0 add model to data
BPARM                              1: >0 => beam-switched cont.
                                   2: Throw scale factor 0 -> 1
                                   3: Rotate throw CCW (degrees)
                                   4: RA or Az increment
                                   5: Dec or El increment
                                   6: RA or Az shift
                                   7 Dec or El shift
                                   8: > 0 Coordinates corrected
                                      before model computation
----------------------------------------------------------------
SDMOD
Task:  This task will SUBTRACT a model FROM single-dish "uv" data (if
       FLUX < 0) or replace those data with a model plus random noise.
       The model consists of up to four Gaussians, each of which will be
       convolved with the "Clean beam" parameters in the data header
       which are meant in this case to be the single-dish beamwidth.
       Alternatively, the model can be an image which is subtracted from
       the data or which replaces the data.
Adverbs:
  INNAME.....Input UV file name (name).      Standard defaults.
  INCLASS....Input UV file name (class).     Standard defaults.
  INSEQ......Input UV file name (seq. #).    0 => highest.
  INDISK.....Disk drive # of input UV file.  0 => any.
  IN2NAME....Input model image name (name).      Standard defaults.
  IN2CLASS...Input model image name (class).     Standard defaults.
  IN2SEQ.....Input model image name (seq. #).    0 => highest.
  IN2DISK....Disk drive # of input model image.  0 => any.
  OUTNAME....Output UV file name (name).     Standard defaults.
  OUTCLASS...Output UV file name (class).    Standard defaults.
  OUTSEQ.....Output UV file name (seq. #).   0 => highest unique
  OUTDISK....Disk drive # of output UV file. 0 => highest with
             space for the file.
  OPTYPE.....Operation: 'IMAG' => use IN2NAME et al. to provide an image
             of the model (taken to be a continuum image)
  BCHAN......First spectral channel to include: 0 => 1
  ECHAN......Last spectral channel to include: 0 => highest
  BIF........First IF to include: 0 => 1
  EIF........Last IF to include: 0 => highest.
  NGAUSS.....Number of sources in model: 1 - 4  Used if OPTYPE is not
             'IMAG' .
  GMAX.......Peak brightness of component in the units of the "uv" data
             (normally Kelvins).  To subtract a component from the data,
             set GMAX < 0.  The peak used is GMAX if the component or
             the antenna beam have 0 width, otherwise it is reduced by
             the ration of the area of the input component to the
             convolved component.
  GPOS.......(X,Y) position of the component in arc seconds from the
             reference position.  GPOS(1,*)/cos(declination) is the
             offset in right ascension,  (> 0 -> the component is East
             of the reference point) and GPOS(2,*) is the offset in
             declination (> 0 place the component North of the refernce
             position.)
  GWIDTH.....The Gaussian widths: GWID(1,*) is the major axis, GWID(2,*)
             is the minor axis both in arc sec and GPOS(3,*) is the
             position angle (from North to East to major axis) in
             degrees.  Each component will be convolved with the
             single-dish beam width (found in the header) before being
             applied to the data.
  APARM......List of center and fwhm in channels (in the input uv data
             set) for Gaussian spectral form for the components.  A
             width of zero => channel independent.  Thus 29, 3, 37, 5, 0
             specifies the first 2 components are also Gaussian in
             channels centered on input channels 29 and 37 with fwhms of
             3 and 5 channels, and the other 2 components (if any) are
             constant in frequency.
  FLUX.......>= 0 => Replace the input data with the model plux noise of
                     rms = FLUX in the units of the uv data (usually K)
             < 0  => Add the model (with no noise) to the input data.
             FLUX is used with both Gaussians and IMAGe.
  BPARM......Parameters for modeling beam-switched continuum data.
             (1) > 0 => these are such data.  The main effect of this
                 is to include the throw and to ignore the recorded
                 center coordinate.  The channel adverbs are ignored.
             (2) Correction factor for the throw.  0 => 1
             (3) Rotation of throw from horizontal CCW in degrees.
             Parameters applying to all data sets:
             (4) RA or Az increment in arc seconds (0 => none).  The
                 coordinates are forced to be the nearest integer
                 multiples of this increment.
             (5) Dec or El increment in arc seconds (0 => none).  The
                 coordinates are forced to be the nearest integer
                 multiples of this increment.
             (6) RA or Az shift in arc seconds applied after the
                 increment correction.
             (7) Dec or El shift in arc seconds applied after the
                 increment correction.
             (8) > 0 => correct the coordinates and then compute the
                 model, else compute the model and then correct the
                 coordinates.
----------------------------------------------------------------
