; SDVEL
;---------------------------------------------------------------
;! shifts spectral-line single-dish data to a given velocity
;# TASK SPECTRAL CALIBRATION SINGLEDISH UV
;-----------------------------------------------------------------------
;;  Copyright (C) 1997-1998
;;  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
;-----------------------------------------------------------------------
SDVEL     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SDVEL     Task to shift spectral-line data to a given velocity
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 #
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 #
FLAGVER                            Flag table version
TIMERANG                           Time range to include
DPARM                              Compute and debug controls
                                   (1) 0 -> velocity set at 1st
                                            record of each scan
                                       1 -> velocity set at last
                                            record of each scan
                                       2 -> velocity set at last
                                            record of each scan
                                            preceeding an  OFF
                                       3 -> velocity set at 1st
                                            record of data set
                                   (2) 0 -> use ref. coordinate
                                       1 -> use coordinate of
                                            record
                                       2 -> use coordinate in
                                            COORDINA
                                   (3) Issue warning if shift >
                                       DPARM(3) channels.
                                   (4) Flag if shift > DPARM(4)
                                       channels.  0 -> Nchan
COORDINA                           Velocity reference RA/dec
BADDISK           0.0     9999.0   Disks to avoid for scratch
----------------------------------------------------------------
SDVEL
Task:  Shift a single-dish uv spectral-line data set in frequency space.
       The purpose of the task is to shift all spectra to a given
       velocity for the directions of observation.  This task assumes
       that the telescope has tracked - at some interval - the time
       variation of frequency to maintain an approximately constant
       velocity for the reference coordinate.  It then shifts each
       spectrum so that the reference velocity wrt the actual observed
       coordinate is in the reference channel.

       This is a subtle effect, previously ignored in spectral-line
       imaging.  However, for a coordinate 1.4 degrees from the
       reference (e.g., a 2 degree square field with a center
       reference), the error can be as large as 1.16 km/sec (LSR
       velocities) or 0.79 km/sec (heliocentric) observed with NRAO's
       12m telescope.  Both vary with time, reference coordinate, and
       telescope; the LSR velocity error changes significantly with time
       of year.  Narrow-band observations of wide fields, such as
       observations of cold molecular regions, may be seriously affected
       by this effect.  Fortunately, so long as the spectra are fully
       sampled in frequency, this effect can be fully corrected in
       single-dish data.  interferometer users are not so lucky.

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.
  OUTNAME....Output UV file name (name).     Standard defaults.
  OUTCLASS...Output UV file name (class).    Standard defaults.
  OUTSEQ.....Output UV file name (seq. #).   0 => highest.
  OUTDISK....Drive # of output UV file.      0 => highest with
             space for the file.
  FLAGVER....specifies the version of the flagging table to be applied.
             0 => highest numbered table.
             <0 => no flagging to be applied.
  TIMERANG...Time range to include: start day, hour, minute, second, end
             day, hour, minute, second.  end = 0 -> infinity.
  DPARM......Controls:
             (1) Tells the task when to compute the reference doppler
                 shift as
             0 -> at the starting record of EACH scan
             1 -> after each scan using the last time of the scan but
                  applying it to the next scan
             2 -> on each "off" scan (detected by a missing scan number)
                  using the last coordinate before the off.
             3 -> at the first record of the data set.
             The 12m probably now uses mode 0, it used to use mode 2.

             (2) Tells the task what coordinate to use in the Doppler
                 computation as
             0 -> data set reference coordinate
             1 -> coordinate of the particular record
             2 -> user specified coordinate in COORDINA
             The 12m used to use mode 1, now uses mode 0, but can use
             mode 2.

             (3) A warning is issued if the shift exceeds DPARM(3)
             channels.  0 -> NCHAN/20.  The task limits the number of
             consecutive samples warned to 10 but if there are then good
             samples, it will resume warnings on the next "bad".

             (4) A sample is deleted if the shift exceeds DPARM(4)
             channels.  0 -> NCHAN.  This may be used to detect and flag
             periods in which the antenna is blown way off course
.
  COORDINA...The RA and declination coordinates are found as:
             RA  = abs(CO(1)) + abs(CO(2))/60 + abs(CO(3))/3600
                 if any of CO(1), CO(2), CO(3) < 0: Xpos = -Xpos
             Dec = abs(CO(4)) + abs(CO(5))/60 + abs(CO(6))/3600
                 if any of CO(4), CO(5), CO(6) < 0: Ypos = -Ypos
             The units are standard FITS units (e.g degrees) except
             that right ascensions are in hours of time.
  BADDISK....A list of disks on which scratch files are not to be
             placed.  This will not affect the output file.
----------------------------------------------------------------
