; PCASS
;---------------------------------------------------------------
;! Finds amplitude bandpass shape from pulse-cal table data
;# Task SPECTRAL UV CALIBRATION VLBI
;-----------------------------------------------------------------------
;;  Copyright (C) 2016-2018
;;  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
;-----------------------------------------------------------------------
PCASS     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
PCASS     Fits pulse-cal tables for amplitude bandpass
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 #
INVERS            0.0              Table version to plot
FREQID            0.0              Frequency ID code included
SUBARRAY          0.0              Subarray to include 0 -> all
CALSOUR                            Bandpass calibration sources
                                      ' ' -> all sources
BPARM                              (1) > 0 use vector amplitude
                                   (2) > 0 incl residual phase
                                   (3) > 0 take PC as power not
                                           voltage amp
                                   (4) > 0 average all scans
                                           together, else each
                                           cal scan makes a BP
                                           record each antenna
BADDISK                            Disks to avoid for scratch
----------------------------------------------------------------
PCFIT
Type:  Task
Use:   To fit pulse-cal amplitudes to generate a bandpass table.
       Use PCRMS with APARM(6) > 0 to generate an edited PC table
       version containing all edge channels.  This will avoid internal
       bad PC channels and bad times in the averages but leave the
       edge channels for fitting the edges of the bandpass.  The PC
       spectrum is interpolated to the set of visibility frequencies
       in writing the BP table.

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.
  INVERS.....Specifies the version of the PC table to be read as
             input.   0 -> highest.
  FREQID.....Specifies which frequency ID to include.  0 => all
  SUBARRAY...The subarray number to include.  0 => all
  CALSOUR....List of sources for which bandpass response functions are
             to be determined.  All ' ' = all sources; a "-" before a
             source name means all except ANY source named.
  BPARM......The task computes the scan average of the PC table
             amplitudes plus the residual (phase-corrected only) reals
             and imaginaries.  Which of these are used is controlled
             by
             (1) > 0 -> use vector aveage for amplitude, else use
                        scalar average
             (2) > 0 -> use vector average of residuals for phase,
                        else BP phase set to 0.
             (3) > 0 -> take the PC amplitudes as powers rather than
                        voltages (so the BP amplitude is the sqrt of
                        the PC amplitude).  Else take the PC amp as a
                        voltage just like the BP values.
                        Zero is probably correct, try +1 for sqrt or
                        -1 for square if you want to experiment.
             (4) > 0 -> average all calibration scans together for an
                        antenna before writing a single BP record for
                        that antenna.
                 <=0 -> produce a BP record for each calibration scan
                        for each antenna.
  BADDISK....The disk numbers to avoid for scratch files (sorting
             tables mostly).
----------------------------------------------------------------
