; SHOUV
;---------------------------------------------------------------
;! displays uv data in various ways.
;# Task UV Calibration
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1997, 1999-2000, 2004, 2006, 2009-2010, 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
;-----------------------------------------------------------------------
SHOUV     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SHOUV:  Displays uv data in various ways.
INNAME                             UV data (name).
INCLASS                            UV data (class).
INSEQ             0.0    9999.0    UV data (seq. #).  0 => high
INDISK            0.0       9.0    Disk unit #.       0 => any
OPTYPE                             List type:
                                   'CLOS', 'SPEC', 'AVIF'
SOURCES                            Source list
CALCODE                            Calibrator code '    '=>all
TIMERANG                           Time range to list
STOKES                             Stokes type to list.
SELBAND                            Bandwidth to select (kHz)
SELFREQ                            Frequency to select (MHz)
FREQID                             Freq. ID to select.
                                   None selected => 1.
BIF               0.0      100.0   Lowest IF number 0=1
EIF               0.0      100.0   Highest IF number
BCHAN             0.0     2048.0   Low channel number 0=>1
ECHAN             0.0     2048.0   High channel number
ANTENNAS                           Antennas to list
UVRANGE           0.0              UV range in kilolambda
SUBARRAY          0.0     1000.0   Subarray, 0=>1
                                   Cal. info for input:
DOCALIB          -1.0      101.0   > 0 calibrate data & weights
                                   > 99 do NOT calibrate weights
GAINUSE                            CAL (CL or SN) table to apply
DOPOL            -1.0       10.0   If >0 correct polarization.
PDVER                              PD table to apply (DOPOL>0)
BLVER                              BL table to apply.
FLAGVER                            Flag table version
DOBAND           -1.0       10.0   If >0 apply bandpass cal.
                                   Method used depends on value
                                   of DOBAND (see HELP file).
BPVER                              Bandpass table version
SMOOTH                             Smoothing function. See
                                   HELP SMOOTH for details.
DPARM                              Control info:
                                   (1) 0=amp, 1=phase, 2=RMS
                                   (2) 0=vec avg, 1=scalar
                                   (3) No. digits per column
                                       5-7: amplitude;
                                       5-9: phase (def=5)
                                   (4) avg. time min
DOCRT            -3.0     132.0    > 0 -> use the terminal,
                                   else use the line printer
                                   > 72 => terminal width
OUTPRINT
                                   Printer disk file to save
BADDISK           0.0      10.0    Disk to avoid for scratch.
----------------------------------------------------------------
SHOUV
Type:  Task
Use:   Prints information in a uv data base in a variety of
       possible forms.  Numerous selection criteria are
       available and calibration and flagging may optionally be
       applied.
           SHOUV will work on multisource, indexed files or TB
       sorted single source files in some modes.
            Not all adverbs apply to all types of listing; the
       following notes when an adverb is used for only some
       listing types or its useage depends on the type.
Adverbs:
  INNAME.....UV file name (name).       Standard defaults.
  INCLASS....UV file name (class).      Standard defaults.
  INSEQ......UV file name (seq. #).     0 => highest.
  INDISK.....Disk unit #.               0 => any.
  OPTYPE.....Type of listing desired:
             'CLOS'=print closure phases for triples composed of
              the antennas in ANTENNAS as triplets, e.g. ANTE=
              1,2,3,5,6,7 will display triplets 1-2-3 and 5-6-7
             'SPEC'=displays selected channels and IFs.
             'AVIF'=like SPEC but all channels in each IF are
              averaged first.
  SOURCES....List of sources to be listed. '  '=> all; if any
             starts with a '-' then all except ANY source named.
  CALCODE....Calibrators may be selected on the basis of the
             calibrator code given in the SU table.
                  '    ' => any calibrator code selected
                  '*   ' => any non blank code (cal. only)
                  '-CAL' => blank codes only (no calibrators)
                  anything else = calibrator code to select.
             NB: The CALCODE test is applied in addition to the
             other selection tests
  TIMERANG...Time range of the data to be listed. In order:
             Start day, hour, min. sec,
             end day, hour, min. sec. Days relative to ref.
             date.
  STOKES.....The desired Stokes type of the listed data:
             'I','Q','U','V','RR','LL','RL','LR' ' '=>'I'
  SELBAND....Bandwidth of data to be selected. If more than
             one IF is present SELBAND is the width of the
             first IF required. Units = kHz, 0=> all
  SELFREQ....Frequency of data to be selected. If more than
             one IF is present SELFREQ is the frequency of the
             first IF required. Units = MHz, 0=> all
  FREQID.....Frequency identifier to select (you may determine
             which is applicable from the OPTYPE='SCAN' listing
             produced by LISTR. If either SELBAND or SELFREQ
             are set, their values overide that of FREQID.
             However, setting SELBAND and SELFREQ may result in
             an ambiguity.  In that case the task will request
             that you use FREQID.  If neither SELBAND, SELFREQ
             nor FREQID are specified then the first FQ id in
             the FQ table (usually 1) will be used.
  BIF........Lowest IF to list. 0=>1
  EIF........Highest IF to list. 0 =>highest
  BCHAN......First channel to list. 0=>1
  ECHAN......Last channel to list. 0=>highest
  ANTENNAS...A list of the antennas to  list.  The detailed use
             of ANTENNAS depends on OPTYPE.
  UVRANGE....Range of projected spacings to be listed in 1000's
             of wavelengths.  0  =>  1, 1.E10
  SUBARRAY...Subarray number to list. 0=>1.
  DOCALIB....If true (>0), calibrate the data using information in the
             specified Cal (CL) table for multi-source or SN table for
             single-source data.  Also calibrate the weights unless
             DOCALIB > 99 (use this for old non-physical weights).
  GAINUSE....Version number of the Cal. table to apply to the
             data if DOCALIB=1.  Refers to a CL table for
             multisource data of an SN table for single source.
  DOPOL......If > 0 then correct data for instrumental polarization as
             represented in the AN or PD table.  This correction is
             only useful if PCAL has been run or feed polarization
             parameters have been otherwise obtained.  See HELP DOPOL
             for available correction modes: 1 is normal, 2 and 3 are
             for VLBI.  1-3 use a PD table if available; 6, 7, 8 are
             the same but use the AN (continuum solution) even if a PD
             table is present.
  PDVER......PD table to apply if PCAL was run with SPECTRAL true and
             0 < DOPOL < 6.  <= 0 => highest.
  BLVER......Version number of the baseline based calibration
             (BL) table to appply. <0 => apply no BL table,
             0 => highest.
  FLAGVER....(multisource) specifies the version of the
             flagging table to be applied. 0 => highest
             numbered table.  <0 => no flagging to be applied.
  DOBAND.....(multi-source) If true (>0) then correct the data for the
             shape of the antenna bandpasses using the BP table
             specified by BPVER.  The correction has five modes:
             (a) if DOBAND=1 all entries for an antenna in the table
             are averaged together before correcting the data.
             (b) if DOBAND=2 the entry nearest in time (including
             solution weights) is used to correct the data.
             (c) if DOBAND=3 the table entries are interpolated in
             time (using solution weights) and the data are then
             corrected.
             (d) if DOBAND=4 the entry nearest in time (ignoring
             solution weights) is used to correct the data.
             (e) if DOBAND=5 the table entries are interpolated in
             time (ignoring solution weights) and the data are then
             corrected.
  BPVER......(multisource) specifies the version of the BP table
             to be applied
             plotted (if APARM(8)=2) or applied (if DOBAND > 0
             and APARM(8) .NE. 2). 0 => highest numbered table.
             <0 => no bandpass correction to be applied.
  SMOOTH.....Specifies the type of spectral smoothing to be applied to
             a uv database . The default is not to apply any smoothing.
             The elements of SMOOTH are as follows:
             SMOOTH(1) = type of smoothing to apply: 0 => no smoothing
               To smooth before applying bandpass calibration
                 1 => Hanning, 2 => Gaussian, 3 => Boxcar, 4 => Sinc
               To smooth after applying bandpass calibration
                 5 => Hanning, 6 => Gaussian, 7 => Boxcar, 8 => Sinc
             SMOOTH(2) = the "diameter" of the function, i.e. width
               between first nulls of Hanning triangle and sinc
               function, FWHM of Gaussian, width of Boxcar. Defaults
               (if < 0.1) are 4, 2, 2 and 3 channels for SMOOTH(1) =
               1 - 4 and 5 - 8, resp.
             SMOOTH(3) = the diameter over which the convolving
               function has value - in channels.  Defaults: 1,3,1,4
               times SMOOTH(2) used when input SMOOTH(3) < net
               SMOOTH(2).
  DPARM......Control info:
             1) controls the type of information to be printed:
                0 => amplitude,  1 => phase, 2 => RMS of
                amplitude.
             2) controls the type of averaging:
                0 => vector average,
                1 => amp scalar averaging. Amplitudes and phases
                     averaged separately.
             3) The number of digits per column for column
                based listings. The allowed range is 5 to 7 for
                amplitude and 5 to 9 for phase. The default value
                is 5 in both cases. Phase quantities will be
                printed in decimal form for column widths
                greater than 6.
             4) Averaging time in min.
  DOCRT......False (<= 0) use the line printer if OUTPRINT = ' '
                   else write named OUTPRINT file only.
                   When OUTPRINT is not blank, DOCRT=-2 suppresses the
                   page-feed character on page headers and DOCRT=-3
                   suppresses page headers and most other header
                   information.  When OUTPRINT is blank, the line
                   printer will be used.  SHOUV now counts the lines
                   to be printed before printing any and asks for
                   permission to continue if the count > 500.
             True  (> 0) use the terminal interactively.  The task will
                   use the actual terminal width as a display limit
                   unless 72 < DOCRT < width.  In that case, the display
                   limit will be DOCRT characters.
  OUTPRINT...Disk file name in which to save the line printer output.
             ' ' => use scratch and print immediately for interactive
             jobs - batch jobs use OUTPRINT = 'PRTFIL:BATCHjjj.nnn'
             (jjj= job #, nnn = user #).  When OUTPRINT is not blank,
             multiple outputs are concatenated, and the file is not
             actually printed.
  BADDISK....Disk numbers to avoid for scratch files.  Scratch
             files may be created by the sorting routines if
             calibration or flagging is applied.
----------------------------------------------------------------
SHOUV: Task to list uv data.
DOCUMENTOR: Bill Cotton NRAO/CV
RELATED PROGRAMS: LISTR, UVFLG

                             PURPOSE

     SHOUV is designed to display uv data in line printer listing form
as an aid in evaluating and editing data; several methods of
displaying the data are provided.  SHOUV should work on both single
and multi-source data files.
     The standard adverbs for calibration and editing (e.g. applying
CL, BL and FG tables to the data etc.) are provided.

                           COMMENTS

OPTYPE:
     OPTYPE='CLOS' requests a column listing of the "closure phase"
for one or more triplets of antennas.  For example the closure phase
of the triplet 1-2-3 is:
   Phase_1-2 - Phase_1-3 + Phase_2-3
This value is independent of atmospheric or geometric errors in the
interferometer model and is useful for detecting either errors in the
correlator (when used on calibrator source data) or for source
resolution.  Averaging is done before forming the closure phases.  All
spectral channels (BCHAN through ECHAN) and IFs (BIF though EIF) are
included in the average used to form the closure phase.
   The closure phase triplets are defined by the entries in array
ANTENNAS takes as triplets; up to 16 triplets may thus be requested.
For example:
   ANTENNAS=1,2,3, 6,7,8, 2,3,5
requests the triplets 1-2-3, 6-7-8 and 2-3-5.

     OPTYPE='SPEC' requests column listings of the amplitude of
phase of the baseline selected by the first two elements of
ANTENNAS.  Only channels/IF selected by BCHAN,ECHAN,BIF,EIF will
be displayed.  ANTENNAS=5,10 selects baseline 5-10

     OPTYPE='AVIF' is like 'SPEC' except that all channels in
each IF are averaged first.



DPARM:
     Control Information.
(1) specifies the type of information to be listed:
    0 => amplitude of the visibility,
    1 => phase of the visibility,
    2 => RMS of amplitude.
(2) specifies the type of averaging:
    0 => vector averaging of the selected visibilities before
         conversion to amplitude or phase.
    1 => "amp-scalar" averaging; amplitudes and phases are
         computed for the individual visibilities and averaged.
(3) specifies the number of digits per column in the output to
    be used for each value listed.  The allowed range is 5 to
    7 for amplitude and 5 to 9 for phase; the default in both cases
    is 5. Phase quantities will be printed in decimal form for
    column widths greater than 6.
(4) specifies the averaging time in minutes.
