; CLCORPRM
;---------------------------------------------------------------
;! Parameter adverb array for task CLCOR
;# ADVERB CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 2020
;;  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
;-----------------------------------------------------------------------
CLCORPRM  LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
----------------------------------------------------------------
CLCORPRM
Type: Adverb   (Real(20))
Use:  The task specific parameters for CLCOR.  The details depend on the
      OPCODE selected.
Null value:  Usually 0.
Tasks:
  CLCOR....Applies user-selected corrections to the calibration CL
           table.  CLCORPRM usage depends on OPCODE - see below.
  DFCOR....Applies differential corrections to the calibration CL table
  RLCOR....Corrects a data set for R-L phase differences.
           CLCORPRM provides right-left phase difference for IFs BIF
           to EIF (as OPCODE 'POLR')
  RLDIF....Determines Right minus Left phase difference, corrects cal
           files.  CLCORPRM is an output adverb giving right-left
           phase differences if SPECTRAL<0 suitable for input to
           CLCOR OPCODE 'POLR'.
  XYDIF....Find/apply X minus Y linear polarization phase difference.
           CLCORPRM is an output adverb giving X-Y phase differences if
           SPECTRAL<0 suitable for input to CLCOR OPCODE 'POLR'.

Details for CLCOR: Contents are given as a function of the value of
OPCODE.  Note that more details and examples are given in the CLCOR help
;and explain files.

  'POLR' => Modify Right-Left phase difference using phases in CLCORPRM
            (deg); up to 20 IFs may be processed at a time.
  'PHAS' => Rotate phase of residual gain by CLCORPRM (deg); up to 20
            IFs may be processed at a time
  'RATE' => Rotate phase of residual gain versus time.  CLCORPRM(1)
            degrees constant term. CLCORPRM(2) = rate of change of phase
            (degrees/day).  CLCORPRM(3) - (6) = day, hr, min, sec at
            which the "zero" phase (CLCORPRM(1)) is specified.
  'OPAC' => apply atmospheric opacity amplitude corrections using zenith
            opacity of CLCORPRM(1) nepers.
  'ADEL' => Correct phases, delays and rates for neutral atmospheric
            delay.
            CLCORPRM(1) = total pressure (mbars) at station, NOT at sea
                          level.
            CLCORPRM(2) = partial pressure of water.
            CLCORPRM(3) = Temperature (C)
            CLCORPRM(4) = Tropospheric lapse rate (K/km) (should be
                          negative)
            CLCORPRM(5) = Height of tropopause (km)
            CLCORPRM(6) = Scale height of water vapor (km).
  'GAIN' => Correct using polynominal gain curve for antenna
            **VOLTAGE** gain as a function of the zenith angle (ZA) in
            degrees.
               correction = CLCORPRM(1) + ZA * CLCORPRM(2) +
                            ZA * ZA * CLCORPRM(3) etc.
  'POGN' => Correct using polynominal gain curve for antenna
            ** POWER ** gain as a function of the zenith angle (ZA) in
            degrees.
               correction = CLCORPRM(1) + ZA * CLCORPRM(2) +
                  ZA * ZA * CLCORPRM(3) etc.
  'CLOC' => Correct residual delay and model parms for the effects of a
            linear clock drift at a particular antenna.
            CLCORPRM(1) = rate of change of station clock (nanosec/day)
            CLCORPRM(2) = clock value at the "zero" time specified by
                          CLCORPRM(3)-(6) (nanosec)
            CLCORPRM(3) - (6) = day, hr, min, sec at which the "zero"
                         clock (CLCORPRM(2)) is specified.
            CLCORPRM(7) : correction has three modes:
               if = 0 then the clock drift is added as a small
                      correction and CLCORPRM(2) is ignored.
               if = 1 then the total correction set by the CLCORPRMs is
                      added.
               if = 2 then the values present in the CL table are
                      replaced by those defined by
                      CLCORPRM(1)-CLCORPRM(6).
  'PANG' => Add or remove parallactic anglecorrections from CL table
           entries. CLCORPRM(1) > 0 => Add corrections
           CLCORPRM(1) =< 0 => Remove corrections
  'PONT' => Correct for predictable pointing offset of an antenna.
            CLCORPRM(1) is the linear rate of change of antenna gain as
                        the pointing drifts.
  'IONS' => Make ionospheric Faraday rotation corrections using one of
            several models.  CLCORPRM(1) = Model type: 1 = Chiu model
            CLCORPRM(3) = Sunspot no.
  'ANTP' => Correct antenna and/or source position; antenna / source
            corrections are values to be added to the old positions in
            meters / sec of arc.  The antenna (only one) must be
            specified in the case of antenna correction.  The source
            (only one) must be specified in the case of source
            correction.

            !!!!!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!
            Starting June 2001 CLCOR corrects the AN and/or the SU
            table, if the relevant correction of the antenna or/and the
            source is carried out.  So the application of the corrected
            CL table is required to match the data.  Once CLCOR has been
            run, then the CL table must not be deleted and the
            correction can be undone only by doing it again with
            opposite sign.  If you might forget applying this, then use
            the task SPLAT to apply it immediately.
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            1 = "X" correction in meters.
            2 = "Y" correction in meters.
            3 = "Z" correction in meters.
            4   No longer used
            5 = Correction in the picture plane towards the RA direction
                in sec of arc. So it is RA correction, multiplied by
                COS(DECL).
            6 = Declination correction in sec of arc
            7   No longer used
            8 = drift of the source right ascension in mas/hr
            9 = drift of the source declination in mas/hr
            CLCORPRM(8,9) are used if INFILE is blank.  The source
            position is shifted by CLCORP(8,9) times the time where the
            time is relative to zero hours IAT on the start date of the
            observation.
  'ANTC' => Correct antenna and/or source position;  The same as ANTP
            except that ANTP corrects the apparent source position while
            ANTC corrects the position of epoch.
  'PCAL' => MkIII manual phase cal; replace the gain correction in the
            CL table with unit vectors with phases given in CLCORPRM.
            CLCORPRM(1) corresponds to BIF etc.   Phases are given in
            degrees.
  'PCFX' => Patch up missing phase cals.  CLCORPRM gives the expected
            relationship between phase cals and uses any non blanked
            values.
  'SBDL' => Add a delay to the IF residual delays.  Values given in
            CLCORPRM correspond to IFs BIF, BIF+1,... EIF in nanosec.
  'MBDL' => Change the multi-band delay by introducing the corresponded
            slope at phase vs IF frequency dependence.  Values given in
            CLCORPRM correspond to IFs BIF, BIF+1,... EIF in nanosec.
  'SSLO' => Correct the phase only for an incorrect frequency used to
            calculate the phase at the VLA.  CLCORPRM(1) gives the
            frequency error in MHz.
  'ANAX' => Correct the delay, rate and phase for antenna axis offset.
            CLCORPRM is an array of axis offsets in meters corresponding
            to the antenna list given. Note that with 'ANAX' the antenna
            table is also modified.
  'ATMO' => apply atmospheric and clock delay corrections using the
            information for the antennas and times given in the input
            file.  The file format:
               The first line is number of the data rows.  DELZN adds
               the date and the JD in case the DELZN file has a
               different reference date from the current input file.
               The remaining lines specify the data with one line for
               each antenna/time.  Each line is formatted thus:
               Column 1: antenna name; The name can be done either by
                         the antenna number (two digits) or by the
                         relevant antenna name (two symbols)
               Column 2-5: day, hour, min, sec
               Column 6: zenith atmosphere delay, in cm
               Column 7: clock delay, in cm
               Column 8: derivative of the zenith atmosphere delay, in
                         sec/sec*1.0E14
               Column 9: derivative of the clock delay (clock drift), in
                         sec/sec*1.0E14
               This format is in agreement with the DELZN output.
               The values of the delays and its derivatives should
               correspond to the desired correction.  The corrections
               for the interferometer delay and phase are added (with
               sign) to the relevant columns of the CL table, which in
               turn are added to the data when calibration is applied.
            CLCORPRM(1): What correction to make in CL table?
                         0 => only atmosphere
                         1 => atmosphere + clocks
  'TROP' => Similar to 'ATMO' except the zenith atmospheric (column 6 in
            INFILE) is the TOTAL zenith delay, (typically between
            150-400cm).  This will be subtracted from the atmospheric
            delay applied by the correlator, which is in the ATMOS
            column in the CL table.  Make sure there is something
            sensible in this column (i.e. loosely between 5-15 nsec) or
            you will get nonsense.  NOTE THAT EXPERIMENTS CORRELATED
            BETWEEN NOVEMBER 2002 AND FEBRUARY 2004 AT THE VLBA
            CORRELATOR THE ATMOS COLUMN IN THE CL, MC, AND IM TABLES ARE
            WRONG, SO YOU SHOULD NOT USE THIS OPTION.  Other than this
            'TROP' runs identically to 'ATMO'
  'DISP' => Correction of dispersive delays as a function of elevation;
            file contains:
               The first line is number of the data rows.
               The remaining lines specify the data with one line for
               each antenna/time as:
                  Column 1: antenna number;
                  Column 2-5: day, hour, min, sec
                  Column 6: zenith dispersive delay, in 1/cm
                  Column 7: derivative of the zenith dispersive delay,
                            n sec/m^2/sec*1.0E14
  'SUND' => Correction of the extra time delay caused by the bending of
            the light ray passing through the gravitational field of the
            solar system planets.  The VLBA correlator (before September
            2004) carries out this correction considering the source
            locates at the infinity.  This option removed the correlator
            correction and put the correction taking into account the
            actual position of the source inside of the solar system.
            The correction is carried out only for the one source
            (located at the solar system) given at the adverb SOURCE.
            CLCORPRM(1): What correction to make in CL table?
               0 => correct actual space craft position minus infinite
                    position.  The infinite position correction carried
                    out by correlator is substituted by actual space
                    craft position.
               1 => correct just actual space craft position
            CLCORPRM(2): Print out the test data? 0 => yes, 1 => no
            CLCORPRM(3): Print the additional test data?
               0 => no:  If CLCORPRM(2) equal 0 then delays for each
                         antenna/time are printed out
               1 => yes: If CLCORPRM(2) equal 0 then positions of the
                         spacecraft, the first planet in the list,
                         baseline are printed out additionally
  'EOPS' => Correction of UT1-UTC and the Earth's pole position. The
            UT1-UTC and the Earth's pole position need to be corrected
            if the wrong values used during correlation.
            OPTYPE=EOPS can be used only for data sets with proper CT
            tables, namely data from the old VLBA correlator, DiFX
            correlators, and, since November 2015, the EVLA.
            The actual EOP is interpolated for the time of observation
            The default behavior, with CLCORPRM=0, is to use the same
            sequence of days ([-2,2] or [-1,3]) as is used for the
            majority of cases of the correlator for data sets that were
            not concatenated in FITLD.  For special cases (mainly for
            more than one day observation), CLCORPRM can be set to
            interpolate over a different range of dates.
            CLCORPRM(1) Number of days preceding OBSDAT (given in the
                        data header) NEGATIVE NOT APPROPRIATE
                        <= 0.0 => 1   (Use 0.1 if you want 0 as would be
                        appropriate if the first data start at time ~ 1
                        day)
            CLCORPRM(2) number of days starting from the first selected
                        day <= 0.0 => 5  (Required to have real data for
                        the full date range, but there is harm if you do
                        not get enough for concatenated data sets)
  'IONO' => apply ionosphere and clock delay corrections using the
            information for the antennas and times given in the input
            file.  Format of data at the input file is identical to
            OPCODE = 'ATMO'. The differences with 'ATMO':
               1.Phase-delay has the opposite sign
               2.Different mapping functions
                    for 'ATMO'    1/SIN(EL)
                    for 'IONO'    1/COS(Z_i),  where
                       SIN(Z_i) = (R/(R+h_i)) * COS(EL)
                       R is the Earth radius
                       h_i is the ionosphere height
            See Thomson, Moran & Swenson 2nd edition page 560, eq
            13.139 and 13.140
----------------------------------------------------------------
