As of Mon Jul 15 19:28:07 2024

TYAPL: Undoes and re-does nominal sensitivity application


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 #
FREQID            0.0              Frequency ID number:  0 -> 1
SUBARRAY          0.0              Subarray: 0 -> 1
FLAGVER          -1.0              > 0 => apply flags to output
                                   data and TY/SY/SN tables
DOFLAG                             = 1,3 -> do NOT flag TY/SY
                                   = 2,3 -> do NOT flag SN
INEXT                              TY or SY for VLA or EVLA
INVERS                             Input ?Y table undo  0=>none
IN2VERS                            Input ?Y table redo  0=>none
OUTNAME                            Output UV file name (name)
OUTCLASS                           Output UV file name (class)
OUTSEQ                             Output UV file name (seq #)
OUTDISK                            Output UV file disk unit
OPTYPE                             'PGN' use SY post gain only
                                   'CL' write CL table =bad idea
                                   'CLP' write CL post gain only
REWEIGHT                           Additional SY scaling factors
                                   for visibilities, weights
DOWEIGHT         -1.0         1.0  < 0 => do NOT compute weights
                                          from SY values
                                   NOTE: 0 means do weights
CUTOFF            0.0         1.0  > 0 => if fraction of good SY
                                   values < CUTOFF, apply an
                                   average correction instead
FQCENTER                           >= 0 -> center frequency axis
CALIN                              Antenna efficiencies file
RPARM                              list of antenna to be set to
                                   the average of good antennas
BADDISK                            Disks to avoid for scratch


Task: For the EVLA, the SysPower table in the SDM records the switched
      power when the noise tube is on and the switched power when the
      noise tube is off.  If the AIPS files are obtained via OBIT ---
      AIPS "verb" BDF2AIPS --- then an SY table is available.  It may
      be applied to adjust the gains and the data weights.  If one has
      been applied, the application may be removed and a new SY table
      (i.e. one clipped and smoothed by TYSMO) may be applied.  This
      is much like the Tsys application done formerly for the VLA but
      there are differences.  For details, see EVLA Memo 145 by Rick
      Perley (May 2010).  TYSMO, SNEDT, EDITA, and SNPLT all
      understand SY tables and allow you to manipulate and/or view
      them.  The task uses the input INTTIM random parameter where
      available as the integration time and, if unavailable, assumes
      that the input weights are equal the integration time.  If you
      have done frequency averaging, this will not be true and the
      weights will be incorrect after TYAPL (if INTTIM is missing).

      Sometimes, the labeling of source numbers in the SY table does not
      match the source numbers in the visibility data.  This can cause
      TYAPL to spend a lot of time searching the SY table and can cause
      incorrect results.  31DEC23 task SYFIX will rewrite an SY table
      forcing the source numbers to match those in the uv data.

      Do not use TYAPL if your data includes observations of the Sun.
      Use appropriate tasks instead: SOLCL for VLA data and SYSOL for
      EVLA data.

      Note that TYAPL with SY tables requires valid values for Pdif,
      Psum, and the post-detector gains.  If you have flagged data in
      the SY table, TYAPL will flag the corresponding visibilities.
      TYSMO allows you to replace flagged samples in the SY table with
      averages from nearby samples.  You should consider doing this
      with all 3 data types before running TYAPL unlesss you want the
      data to be flagged.  The CUTOFF adverb allows you to specify a
      minimum fraction of the SY table values that must be good (per
      antenna, IF, polarization) in order to apply the table values.
      If there is a lower fraction, then the average over the good
      antennas for the particular IF and polarization will be applied
      to the "bad" antennas.

      TYAPL now has the ability to apply a flag table to the data as
      they are read.  Like UVCOP, up to 600001 flags are allowed to
      apply to a single time.  This ability was added so that you can
      use the required data copy in TYAPL instead of an additional
      data copy in UVCOP to reduce the size of the data and dispense
      with large flag tables generated by auto-flag tasks like RFLAG.

      Note that TYAPL should copy the data set for 3 reasons: 1. The
      system gains may do abrupt jumps usually at the original scan
      boundaries but sometimes at other times.  A CL table could
      handle these jumps if it was structured to match the original
      scans, but that original structure is often lost.  2. The data
      weights after TYAPL need to have the amplitude gains applied to
      them as well as the visibilities since any amplitude gains at
      that point should only reflect errors in the assumed Tcal's.
      However, it is completely incorrect to apply the amplitude gain
      from the SY table to the weights computed from the SY table.
      The CL tables contain a cumulative amplitude gain and there is
      no reasonable way to differentiate the SY table gains from the
      other gains later in the processing.  3. New weights are needed
      and TYAPL computes remarkably good ones.  This means the data
      set must be rewritten to supply those weights and it is
      completely unsafe to overwrite the input data set.

      For the VLA, Tsys is the nominal sensitivity and Tant is some
      form of system temperature.  FILLM, by default, scales the
      measured correlation coefficients by the instantaneous measured
      nominal sensitivities, producing data approximately in deci-Jy.
      FILLM can be told to load correlation coefficients only.  For
      calibration purposes, it is best to have the nominal
      sensitivites applied, but it may be better to use a clipped and
      time-smoothed version of those sensitivities.  TYSMO allows you
      to do that clipping and smoothing or, if you prefer interactive
      tasks, try SNEDT.  Then one can remove the nominal sensitivities
      applied by FILLM, if any, and apply smoothed nominal
      sensitivites (or leave the data as correlation coefficients if
      desired) with TYAPL.

      VLBI users warning: This task is not elaborately intelligent
      about looking through the TY table to match up Tsys measurements
      by source and time.  It is tested for and assumes the simple,
      all antennas at the same time and source form for the TY tables
      of the VLA.
  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.
  FREQID.....Frequency ID number to do       0 => 1
  SUBARRY....Subarray to do                  0 => 1
  FLAGVER....If > 0, apply the specified flag table version to the
             data and do not copy it to the output.  Unlike regular
             calibration routines (but like UVCOP), FLAGVER = 0 means
             no flagging.  The flag table is applied to any TY, SY,
             and SN tables as they are copied (spectral-channel
             independent flags only).
  DOFLAG.....Controls whether FLAGVER is applied to tables or not.
             = 0 => apply FLAGVER (if > 0).  If 1 => do not flag SY
             and TY tables, =2 => do not flag SN tables, =3 => do NOT
             flag SN, SY, or TY tables.
  INEXT......Input extension type: 'SY' for SysPower tables from the
             VLA, 'TY' for System Temperature tables from the (old)
             VLA.  ' ' takes whichever one it finds.
  INVERS.....Input version number of the TY table which was applied to
             the data and is to be unapplied.  0 => none
             If input file is in correlation coefficient form, it is
             an error to set INVERS > 0.
  IN2VERS....Input version number of the ?Y table that is to be
             applied after INVERS is undone.   0 => none
             If the data are not in correlation coefficient form on
             input or after INVERS is undone, then it is an error to
             set IN2VERS > 0.
             If INVERS <= 0 and IN2VERS <= 0, then the program will
             set IN2VERS to max ?Y version if the data are correlation
             coefficients and INVERS to max ?Y version if the data are
             in visibility form, leaving the other at 0.
  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....Output UV file disk unit.     0 => highest w space.
  OPTYPE.....'PGN' use the SY table post-gain only to adjust gains
             The following are a bad idea for reasons given above:
             'CL'  apply the TY or SY gains to the highest CL table
                   version and write a new CL table
             'CLP' write the SY table post gain into a new CL table
             In the case of the above three OPTYPEs, DOWEIGHT is set
             to -1.  If you do the CL operation, you must compute
             weights with REWAY and only with DOCAL true.
             Any other value of OPTYPE does the normal operations with
             Pdif and Psum from the SY table and will write a new data
             set with weights controlled by the user-chose value of
  REWEIGHT...Scale the visibilites by REWEIGHT(1) and the weights by
             REWEIGHT(2).  This option is allowed for now on SY tables
             only since the correct scaling is uncertain.  0 -> 1
  DOWEIGHT...>= 0 => compute weights from SY values, < 0 do not change
             input weights.  NOTE the non-standard use of the logical
             in which 0 is true.  If OPTYPE = 'PGN', 'CL', or 'CLP',
             DOWEIGHT is set to false.
  CUTOFF.....<= 0 => data for which there is not a valid SY table
                     value are flagged.
             > 0  => The SY table is examined in advance.  If the
                     fraction of valid SY table entries for a
                     particular polarization, IF, and antenna is less
                     than CUTOFF, the gain and weight factors for that
                     antenna, IF, and polarization will be taken to be
                     the average of those parameters for the antennas
                     that are not "skipped".  The data are not flagged.
  FQCENTER,..>  0 => Change frequency axis reference pixel to
                     Nchan / 2 + 1
             else => do not change reference pixel
  CALIN......The name of a text file to provide antenna efficiencies
             as a function of antenna, frequency, and polarization.
             By default, the system file is called:
             If it is missing, a small table which is antenna and
             polarization independent is used instead.
  RPARM......List of antennas to be "skipped" - i.e. corrected with the
             average of the corrections for good antennas.  Correction
             is a function of polarizations and IF.  Use this isf the SY
             values are not right but not obviously invalid.  CUTOFF is
             useful for obvious cases.
  BADDISK....The disk numbers to avoid for scratch files (sorting
             tables mostly).