; UVFIX
;---------------------------------------------------------------
;! Recomputes u,v,w for a uv database
;# Task UV
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1997, 1999, 2003-2004, 2006-2010, 2013
;;  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
;-----------------------------------------------------------------------
UVFIX     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
UVFIX     Task to recompute u,v,w terms for a uv database.
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           -1.0     9999.0   Output UV file name (seq. #)
OUTDISK           0.0        9.0   Output UV file disk unit #.
SHIFT                              Position shift(RA,Dec) asec.
UVFIXPRM                              Array geometry
                                   1 => array if needed
                                   2 => subarray number 0=>all
                                   3-4=>array bx, meters
                                   5-6=>array by, meters
                                   7-8=>array bz, meters
                                   Time and frequency info.
                                   11 => UT1-UTC (sec)
                                   12 => time-UTC (sec).
                                   13 => clock error
                                   14 => Freq (Hz) If .LE.0 use
                                        value in AN file
                                   15 OB table number
                                      0 => 1
                                   16 Number of the orbiting
                                      antennas; 0=>there is no
                                      an orbiting antenna
                                   17 Besselian epoch of data
                                   18 differential aberration
                                       0 => include
                                       1 => not include
                                   20 > 0 do not compute u,v,w
INVERS           -1.0              Version of CL or FO table to
                                   use for Doppler offsets: 0->1
----------------------------------------------------------------
UVFIX
Type:  Task
Use:   Computes values of u, v, w for one or more subarrays in a uv
       database and can shift the tangent point of single-source data.
       Correct phase shifting is done, so even large shifts are
       allowed.  However, if the original u,v,w values require
       precession to J2000 or contain other significant "errors", then
       a more accurate shift will be obtained by running UVFIX twice,
       the first to correct the u,v,w's to the original (J2000)
       position and the second to shift the phases and u,v,w's to the
       new position.
           Any sort order will work, but time ordered data will
       probably run faster. NOTE: if the original sort order is
       neither 'TB' or 'BT' the output sort order is set to '**'.
           UVFIX may loop over subarrays if the same set of time
       and frequency correction values (UVFIXPRM) are applicable.
           If your data are multi-source data, UVFIX will run
       correctly, but no coordinate shifts are allowed.
           UVFIX includes differential abberation(Lorentz factor) now.
       Before April 98 this effect was calculated outside of AIPS.
       **************************************************************
       *   U, V, W are recalculated for J2000 in all cases.  If     *
       *   the "epoch" of the data is neither 1950.0 nor 2000.0,    *
       *   then the coordinates are taken as apparent coordinates   *
       *   of date and precessed to J2000.  If this is not correct  *
       *   do not use UVFIX.  1950.0 are converted from B1950 to    *
       *   J2000 meean coordinates.                                 *
       **************************************************************
           Orbiting antennas may be included.  The GMRT uses a
       reversed phase convention which is supported as well.

       Beginning in Septemver 2009, UVFIX will take into account
       Doppler tracking of the observed frequencies.  This only works
       if the Doppler offsets are recorded in either the CL table or
       an FO table.  This correction will also be turned off if the
       data set contains more than one FQID or is not in TB order.
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 unique.
  OUTDISK....Disk drive # of output UV file.0 => highest w room.
  SHIFT......Desired position shift in the tangent point coordinates
             in arcseconds at the source.  The new tangent point
             coordinates will be RA' = RA + SHIFT(1)/COS(DEC) and
             DEC' = DEC + SHIFT(2) where all coordinates are in
             arcseconds.  NOTE: SHIFT(1) changed meaning to be like
             other shifts in AIPS 2003-02-20.
  UVFIXPRM......Specifies array geometry.
     1 => array type, nomally ignored now.  If the array center is to
          be changed, then one must set this parameter to 3.
     2 => subarray number, 0 => loop over all.
     3+4 => array BX, meters. (ONLY if UVFIXPRM(1)=3)  Default is
            value in AN file
     5+6 => array BY, meters. (ONLY if UVFIXPRM(1)=3)  Default as BX.
     7+8 => array BZ, meters. (ONLY if UVFIXPRM(1)=3)  Default as BX.
      Here X is in the direction of the intersection of the
      meridian of the reference location (long=0 for earth
      centered) and the equator; Y is 90 deg. EAST along the
      equator from X; Z is in the direction of the N. pole.
      Note that:
         BX = UVFIXPRM(3) + UVFIXPRM(4),
         BY = UVFIXPRM(5) + UVFIXPRM(6),
         BZ = UVFIXPRM(7) + UVFIXPRM(8).
      The addition of two parameters allows the coordinates
      to be specified with more precision than a single adverb
      allows; on a 32-bit machines adverb values are only
      accurate to 7 significant digits.  The array center is changed
      only if the two values are not zero - set set 10**-20 if 0 is
      desired.
     11 => UT1-UTC in seconds.  Default = value in AN file.  (Use the
           default!)
     12 => (uv data time)-UTC in seconds.  Default = value in AN file
           under keyword DATUTC or, for the VLA (not EVLA), use the
           accumulated leap seconds..  (Use the default!)
           Accurate values for both UT1-UTC and IAT-UTC can be
           obtained from USNO Bulletin no. 7.  A table of leap seconds
           is maintained in AIPS.
     13 => Clock error.  ****  N.B. FILLM was corrected on 6 July 2007
           in version 31DEC07 to write data times centered within the
           integration.  Do not use this option for data loaded with
           that or later versions. ****  For data loaded with earlier
           versions of FILLM, the time labels are in error by half of
           the MODCOMP online averaging time. Usually 5 seconds. (no
           default).  The clock error is subtracted from times in the
           file.
     14 => Frequency in Hz. If <= 0, the value in the AN, FQ, and SU
           files will be used.
     15 OB table number; 0 => 1
     16 The antenna number of the orbiting antenna; 0=>there is no an
        orbiting antenna; It is assumed that there is at most one
        orbiting antenna.  Parameters #15 and #16 are not used for
        conventional (ground based) interferometry. Thus zeros are
        normally desirable.
     17 Besselian epoch of data.  When converting B1950 to J2000, the
        coordinates must first be converted to the observation date
        and then converted to J2000.  0 => 1979.3 which is okay for
        most VLA data.
     18 0 => include differential aberration(Lorentz factor)
        1 => not includes differential aberration(Lorentz factor)
     20 > 0 => Do not recompute U, V, W.  Users of the ATCA may want
        this option since the recomputation changes -NCP to -SIN
        projection for the U,V,W coordinates.  Under all other
        circumstances, this option is not desirable.
  INVERS........Specifies the version of the CL or FO table to use to
                find the Dopler offsets.  Normally, version 1 contains
                the Doppler offsets as written by the correlator,
                while later CL tables may be missing records or have
                other troubles.  If you have computed Doppler offsets
                that have been added to the data (CVEL), then you
                should specify the highest CL table.  0 -> highest.
----------------------------------------------------------------
