; VLANT
;---------------------------------------------------------------
;! applies VLA/EVLA antenna position corrections from OPs files
;# Task Calibration VLA
;-----------------------------------------------------------------------
;;  Copyright (C) 2007-2009, 2011-2012, 2016
;;  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
;-----------------------------------------------------------------------
VLANT     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
VLANT    Task to apply VLA antenna position corrections from OPs
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 #
SUBARRAY          0.0              Input subarray = AN file
GAINVER                            Input CL table 0=>high
DOINVERS         -1.0        1.0   > 0 => undo the correction
VCODE                              'NOAN' do not do antenna corr
                                   'NOEL' do not do atm delay
                                   else do both
----------------------------------------------------------------
VLANT
Task:  This task determines the antenna position corrections applied
       by the VLA operations staff after your observation that apply
       to that observation.  It copies an input CL table and applies
       these antenna position corrections to the antenna phases.

       WARNING: THIS TASK WILL CHANGE THE ANTENNA TABLE.  Careful
       observers might wish to make a copy of the AN table (e.g. with
       TASAV) before running VLANT.  Note the DOINVERS option added
       to allow the change to the AN table to be undone.  The undo
       also applies to the CL table so be careful with GAINVER.

       This task works with data from the VLA Correlator through
       January 2010 and for the EVLA correlator thereafter.  Note that
       the coordinate system used in the two environments is
       different, so the numbers in the tables are different.  The
       two environments therefore use files by slightly different
       names.

       VLANT now also applies corrections to the CL table for an error
       in the atmospheric delay present in the EVLA on-line system
       from IAT date August 9, 2016 to November 15, 2016.  The
       correction will be applied automatically if your data are
       affected and will be skipped iF your data do not fall in this
       time range.
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.
  SUBARRAY...Which subarray to correct.  This selects the AN table
             that will be considered and updated.
  GAINVER....Input CL table version. If GAINVER is equal zero or
             greater than the total number of the CL tables
             then GAINVER is equal to the last existing CL table.
             A new CL table will always be created if any corrections
             are made.
  VCODE......'NOAN' says to do the atmospheric delay correction if
                    appropriate but to do no antenna position
                    correction
             'NOEL' says the opposite
             else do both when appropriate
----------------------------------------------------------------

The EVLA atmospheric delay correction formula from Barry Clark

  DELAY = D * cot(el)*csc(el) * cos(Az_o - Az_a) * E_t

where f is the frequency of that channel
        D is the distance from the array center to the antenna
        el is the elevation of the observation
        Az_o is the azimuth of the observation
        Az_a is the azimuth of the arm the antenna is on
        E_t is the error term as tabulated below (units of ns/meter)

E_t   -1.0e-6   ns/m  August 9 - November 15 (0h UT)

where

VLA_X = -1601185.4;
VLA_Y = -5041977.5;
VLA_Z = 3554875.9;
Arm azimuths are N:355, E:115, W:236, close enough.

Phase in radians is then
   Phase = 2 * pi * f * DELAY

So if the delay difference between calibrator and target is 0.01ns at
30 GHz, the phase difference is 1.8 radians or > 100 degrees.
