; HAFIX
;----------------------------------------------------------------------
;! Recomputes u,v,w when time is hour angle (UVdata is output of TI2HA)
;# Task UV
;-----------------------------------------------------------------------
;;  Copyright (C) 2007, 2009
;;  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
;-----------------------------------------------------------------------
HAFIX     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
HAFIX     Task to recompute u,v,w when time is hour angle.
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  0=VLA, 1=VLB, 2=GMRT,
                                      3=other  1 for EVLA
                                   2 => subarray number 0=>all
                                   3-4=>array center bx, meters
                                   5-6=>array center by, meters
                                   7-8=>array center bz, meters
                                   Time and frequency info.
                                   11 => UT1-UTC (sec)
                                   12 => IAT-UTC (sec). 0: use
                                   accumulated leap seconds.
                                   13 => time shift used for the
                                         correction, in second
                                   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
OPTYPE                             '    '=>UVW is recalculated
                                   for IAT+UVFIXPRM(13)
                                   'DELT'=>UVW_old+UVW(IAT+DT)
                                   -UVW(IAT)
                                   DT = UVFIXPRM(13)
----------------------------------------------------------------
HAFIX
Type:  Task
Use:   This task is a modification of UVFIX design to diagnose
       a possible time shift problem at the original UV data.
       The input UVdata are the output of the task TI2HA,
       which converted original IAT time into hour angle.
       This task reads a row of the input data, stores the original
       U,V,W, converts the given hour angle back to IAT time,
       recalculates U,V,W for this time and for the shifted time
       and finally adds the difference of the two sets of U,V,W
       to the original U,V,W.
       The idea is to correct the error at U,V,W because a possible
       error at time.
       The user can calculate (under control of OPTYPE) only one
       time shift UVW output. This optin is usefull to see by eyes
       the effect of the time shift.

       **************************************************************
       *   This task includes many options left from the UVFIX task *
       *   They can be used later on the user's need                *
       **************************************************************
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......THE ONLY PARAMETER USED NOW IS UVFIXPRM(13)!!!!!!.
     1 => now normally ignored.  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 it!)
     12 => IAT-UTC in seconds.  Default = value in AN file.  (Use it!)
      Typically = year-1961 which is OK until mid-1982; after 1982 it
      is off 1 (or more) second(s).  Accurate values for both UT1-UTC
      and IAT-UTC can be obtained from USNO Bulletin no. 7.  If this
      parameter is 0, HAFIX uses the value returned by the routine
      LPSEC. LPSEC will have to be updated everytime a leap second is
      added. The value as of July 1, 1993 was 28 seconds.
       ------------------------------------------------------------
     13 => The time shift, in seconds
           This is the only parameter used practically now.
       ------------------------------------------------------------
     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.
OPTYPE...'    ' => recalculate UVW for the IAT time recalculated from
                   the given hour angle and corrected
                   by  UVFIXPRM(13)
         'DELT' => correct the existing UVW by the  difference of U,V,W
                   calculated for the two IAT times:
                   IAT1-is the recalculated IAT from the given hour angle
                   IAT2-is IAT1 +  plus UVFIXPRM(13)
----------------------------------------------------------------

