; CVEL
;---------------------------------------------------------------
;! shifts spectral-line UV data to a given velocity
;# TASK SPECTRAL CALIBRATION VLA VLBI UV
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1999
;;  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
;-----------------------------------------------------------------------
CVEL      LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CVEL      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 #
SOURCES                            Source list to shift, other
                                   sources will be passed
                                   unshifted. Ignored for
                                   single source files.
                                   '*' or ' ' => all;
QUAL            -10.0              Source qualifier to shift,
                                   Sources with other quals
                                   will be passed unshifted.
                                   -1 => no selection by qual
TIMERANG                           Time range to shift
SELBAND                            Bandwidth to select (kHz)
SELFREQ                            Frequency to select (MHz)
FREQID                             Freq. ID to select.
SUBARRAY          0.0     1000.0   Subarray, 0=>1
FLAGVER                            Flag table version
DOBAND           -1.0       10.0   If >0 apply bandpass cal.
                                   Method used depends on value
                                   of DOBAND (see HELP file).
BPVER                              Bandpass table version
GAINUSE                            CL table version which
                                   contains the time/antenna
                                   dependent frequency offsets.
                                   0 => 1.

                                   APARMS(1:6) will define the
                                   velocity parameters needed
                                   for single source files. The
                                   parameters you define here
                                   will override any of those
                                   set with ALTDEF. If any of
                                   APARM(1)-(6) are set CVEL
                                   will assume all are set.
                                   These are ignored in the case
                                   of multi-source files, you
                                   should use SETJY for them.
APARM                              (1) => for single source file
                                       the velocity of a given
                                       pixel (m/s).
                                   (2) => the pixel to which
                                       APARM(1) refers.
                                   (3) defines the velocity type
                                       0 => LSR, 1 => HELIO
                                   (4) the velocity definition:
                                       0 => optical, 1 => radio
                                   (5) aparms 5 & 6 define the
                                       rest frequency of the
                                       line in Hz; the value
                                       used is the sum of
                                       APARM(5) + APARM(6).
                                       See helpfile.
                                   (7) 0 => VLBI data
                                       1 => VLA/ATCA/LBA/ATLBA
                                   (8) if > 0 then do not print
                                       messages about large
                                       channel shifts, used if
                                       deliberately want a large
                                       shift.
                                   (9)  0 => not smooth spectra
                                            while shifting
                                       >0 => smooth AC spectra
                                            by Hanning
                                       >1 => smooth XC spectra
                                            by Hanning also
BADDISK           0.0     9999.0   Disks to avoid for scratch
----------------------------------------------------------------
CVEL
Task:  Shift a uv spectral line data set in frequency space.
The purpose of the task is to shift all spectra to a given
velocity; this will correct data observed with a fixed frequency
for the effects of the Earth's rotation and its motion within
the Solar System and towards the Local Standard of Rest.
   CVEL will work on both single and multi-source files. For
multi-source files the velocity to which the spectra are to be
shifted should be entered into the source (SU) table using the
task SETJY, this should be done for each source you wish to
shift. You then specify those sources with the SOURCE command
in CVEL, all other sources will be written to the output uv
file with their spectra unshifted. For single source files the
necessary velocity data are passed to the task using APARM(1) -
APARM(6)
   The shift that is reported is a shift of the profile with
respect to the channels, i.e. a shift of -0.4 will shift the
profile to the left.
   The task will attempt to determine if it is processing
data from the VLBA correlator by examining the ANAME keyword
in the AN(tenna) table. If it is 'VLBA' then CVEL assumes that
all data have been fringe-rotated to the same reference point
(the centre of the Earth) and will determine the velocity
correction accordingly.
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.
  SOURCES....Source list to shift. All sources named will be
             shifted to the velocity found in the SU table.
             All other sources will be passed to the output
             file unshifted. Ignored for single source files.
             Some rules apply: '*' or ' ' = all;
             a "-" before a source	
             name means shift all except ANY source named.
  QUAL.......Only sources with a source qualifier number in the
             SU table matching QUAL will be used.
             If QUAL is -1, then selection by a qualifier
             is ignored. Selection by a qualifier is ignored
             for single source file also.
  TIMERANG...Time range of the data to be shifted. In order:
             Start day, hour, min. sec,
             end day, hour, min. sec. Days relative to ref.
             date.
  SELBAND....Bandwidth of data to be selected. If more than
             one IF is present SELBAND is the width of the
             first IF required. Units = kHz. For data which
             contain multiple bandwidths/frequencies the task
             will insist that some form of selection be made
             by frequency or bandwidth.
  SELFREQ....Frequency of data to be selected. If more than
             one IF is present SELFREQ is the frequency of the
             first IF required. Units = MHz.
  FREQID.....Frequency identifier to select (you may determine
             which is applicable from the OPTYPE='SCAN' listing
             produced by LISTR). If either SELBAND or SELFREQ
             are set, their values overide that of FREQID.
             However, setting SELBAND and SELFREQ may result in
             an ambiguity.  In that case, the task will request
             that you use FREQID.
  SUBARRAY...Subarray number to use. 0=>1
  FLAGVER....specifies the version of the flagging table to be
             applied. 0 => highest numbered table.
             <0 => no flagging to be applied.
  DOBAND.....If true (>0) then correct the data for the shape of the
             antenna bandpasses using the BP table specified by BPVER.
             The correction has five modes:
             (a) if DOBAND=1 all entries for an antenna in the table
             are averaged together before correcting the data.
             (b) if DOBAND=2 the entry nearest in time (including
             solution weights) is used to correct the data.
             (c) if DOBAND=3 the table entries are interpolated in
             time (using solution weights) and the data are then
             corrected.
             (d) if DOBAND=4 the entry nearest in time (ignoring
             solution weights) is used to correct the data.
             (e) if DOBAND=5 the table entries are interpolated in
             time (ignoring solution weights) and the data are then
             corrected.
  BPVER......Specifies the version of the BP table to apply.
  GAINUSE....version number of the CL table from which CVEL will
             extract the tima and antenna dependent frequency
             offsets. For instance, if some attempt was made to
             occasionally correct for the doppler offsets these
             offsets would be recorded in the CL table. For CVEL
             to determine the true observing frequency at any
             given time it must add up the reference freq. in
             the catalogue header, the IF offset freq for IF >
             1, the peculiar source freq. offset and the time
             and antenna dependent freq. stored in the CL table.
             If the data have been SPLIT, or CLCAL has generated
             a new CL table there is no guarantee that the time
             dependent offsets will be taken into account.
             0 => 1
  APARM......Control information:
             The control information is used to specify the
             necessary velocity parameters for single source
             files. The parameters you define here will
             override any of those you set with ALTDEF. If any
             of APARM(1) to (6) are set then the task assumes
             that all are set.
             APARM(1): the velocity of a given pixel (channel)
                in the spectrum (m/s).
             APARM(2): the pixel (channel) to which APARM(1)
                refers.
             APARM(3): the velocity type, 0 => LSR,
                1 => heliocentric
             APARM(4): the velocity definition, 0 > optical,
                1 => radio
             APARM(5) & APARM(6): define the restfrequency of
                the molecular transition in Hz; the value used
                is the sum of APARM(5) and APARM(6) (need the
                extra precision).
             APARM(7): 0 => VLBI data
                       1 => VLA/ATCA/LBA/ATLBA data
                                       - uses opposite handed
                                       coordinate system.
             APARM(8): if > 0 then do not print messages about
                large channel shifts, used if deliberately
                want a large shift.
             APARM(9): 0 => not smooth spectra while shifting
                      >0 => smooth autocorrelation spectra by Hanning
                      >1 => smooth cross-correlation spectra by Hanning
                            as well.
                It is strongly recomended to smooth spectra in the case
                of strong narrow features. Otherwise various ringing
                effects including 180 degree phase jumps between
                adjacent channels can occur.
  BADDISK....A list of disks on which scratch files are not to
             be placed.  This will not affect the output file.
----------------------------------------------------------------
