; CPASS
;---------------------------------------------------------------
;! computes polynomial spectral bandpass correction table
;# TASK CALIBRATION AP SPECTRAL
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1997, 1999-2003
;;  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
;-----------------------------------------------------------------------
CPASS     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CPASS     Task to generate a polynomial 'Bandpass' (BP) table.
USERID                             User number
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 #

                                   Data Selection
CALSOUR                            Bandpass calibrator sources.
QUAL            -10.0              Calibrator qualifier -1=>all
CALCODE                            Calibrator code '    '=>all
UVRANG                             UV range to select
TIMERANG                           Time range to select
STOKES                             Stokes type to select.
SELBAND                            Bandwidth to select (kHz)
SELFREQ                            Frequency to select (MHz)
FREQID                             Freq. ID to select.
BIF               0.0      100.0   Lowest IF number 0=>all
EIF               0.0      100.0   Highest IF number 0=>all
BCHAN             0.0     2048.0   Lowest channel number 0=>all
ECHAN             0.0     2048.0   Highest channel number 0=>all
SUBARRAY          0.0     1000.0   Subarray, 0=>all
ANTENNAS                           Antennas to select

                                   CLEAN map (optional)
IN2NAME                            Cleaned map name (name)
IN2CLASS                           Cleaned map name (class)
IN2SEQ            0.0     9999.0   Cleaned map name (seq. #)
IN2DISK           0.0        9.0   Cleaned map disk unit #
INVERS           -1.0    46655.0   CC file version #.
NCOMP                              # comps to use for model.
                                   1 value per field
FLUX                               Lowest CC component used.
NMAPS             0.0     4096.0   No. Clean map files
CMETHOD                            Modeling method:
                                   'DFT','GRID','    '
SMODEL                             Source model, 1=flux,2=x,3=y
                                   See HELP SMODEL for details.

                                   Control options
DOCALIB          -1.0        2.0   If >0 calibrate data
                                   = 2 calibrate weights
GAINUSE                            CL (or SN) table to apply
DOPOL            -1.0       10.0   If >0 correct polarization.
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
SOLINT                             Solution interval (mins)
                                   -1 => do whole time range
REFANT                             Reference antenna
OUTVERS                            BP table version to write
SMOOTH                             Smoothing function. See
                                   HELP SMOOTH for details.
ANTWT                              Ant. wts (0 => 1.)
BPASSPRM                           Control information:
                                   1: if > 0 use only the
                                      autocorrelation data.
                                   2: print level.
                                   3: If > 0 do not divide data
                                      by source model
                                   4: If > 0 store phases only
                                      in the BP table.
                                   5: If = 0 divide by 'channel
                                      0' before determining BP.
                                      If > 1 switch off the
                                      channel 0 divide option.
                                   6: min. amp. closure err
                                   7: min. ph. closure err
                                   8: > 0 => scalar average
                                   10: > 1 => normalize ampl.
                                      portion of bandpass by
                                      area under BP function.
                                      Useful for VLBI.
                                   11: > 1, mode to allow
                                      calibration and divide
                                      by channel 0. Useful for
                                      VLBI. Do not use if you
                                      don't understand. See HELP
CPARM                              Fit parameters:
                                   1: No. of terms.
                                   2: Max. no. iterations.
                                   3: Convergence tolerance.
                                   4: Pre-average interval (sec)
                                      Default: Auto -  5 min.
                                               Cross - 15 min.
                                   5: Fit type (1=Re/Im; 2=A/P)
                                   6: BP table for initial val.
                                   7: Fit phase only (1=> with
                                      ampl.; 2=> without)
                                   8: >0 => Autoscale
                                   9: >0 suppress data weighting
ICHANSEL                           Array of start and stop chan
                                   numbers, plus a channel
                                   increment and IF to be used
                                   to select channels to sum to
                                   find a 'channel 0'.  If all
                                   0, range set to inner 75% of
                                   observing band.

                                   'Channel 0' uv-data
IN3NAME                            Channel 0 uv name (name)
IN3CLASS                           Channel 0 uv name (class)
IN3SEQ            0.0     9999.0   Channel 0 uv name (seq. #)
IN3DISK           0.0        9.0   Channel 0 uv disk unit #
BADDISK           0.0     9999.0   Disks to avoid for scratch
----------------------------------------------------------------
CPASS
Task:  This task solves for antenna-based complex polynomial bandpasses.
       The resulting BP tables are applied using AIPS adverbs DOBAND and
       BPVER, in the same manner as standard bandpasses determined by
       BPASS. Solutions can be made for cross-power or auto-correlation
       bandpasses. In fitting data correlated at the VLBA, the
       antenna-based fringe rotation applied at the correlator is
       accounted for in the fit.
            Model images made with both values of IMAGR's DO3DIMAG
       option are handled correctly.
            Fitting of standard bandpasses may require a fair number
       of terms (CPARM(1)) and may therefore take a long time to
       compute.  CPASS is sometimes used on data that have had the
       time-averaged bandpass function corrected.  It then can use a
       few terms only with weaker sources to find modest time variable
       portions of the bandpass shape.
Adverbs:
  USERID.....Input file user number.  0 => logon user,
             32000 => any user.
  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.
  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. If the data
             file is a single source file no source name need
             be specified.
  QUAL.......Only sources with a source qualifier number in the
             SU table matching QUAL will be used if QUAL is not
             -1.
  CALCODE....Calibrators may be selected on the basis of the
             calibrator code:
                  '    ' => 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 tests, i.e. CALSOUR and QUAL, in the
             selection of sources for which to determine
             solutions.
  UVRANGE....Range (min, max) of projected baselines to include
             0,0 => all baselines (units: klamda)
  TIMERANG...Time range of the data to be selected. In order:
             Start day, hour, min. sec,
             end day, hour, min. sec. Days relative to ref.
             date.
  STOKES.....The desired Stokes type of the output data:
             'RR','LL',' '.  ' '=>all.
  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 which case the task will request
             that you use FREQID.
  BIF........First IF to select. 0=>all.
  EIF........Highest IF to select. 0=>all higher than BIF
  BCHAN......First channel to use in fit. 0=>all.
  ECHAN......Highest channel to use in fit.  All channels are read in
             and the solution applies to all channels.  The outermost
             channels may be excluded from the fitting process in this
             way.
  SUBARRAY...Subarray number to select. 0=>all.
  ANTENNAS...A list of the antennas for which bandpasses are
             to be determined..
             If any number is negative then all antennas listed
             are NOT to be used and all others are.
The following specify a CLEAN model to be used if a single
source was specified in SOURCES:
  IN2NAME....Cleaned map name (name).      Standard defaults.
             Note: a CLEAN image for only a single-source may
             be given although it may be in a multi-source file.
             If the source table contains a flux, then that flux will
             be used to scale the components model to obtain the
             stated total flux.  This is needed since initial Cleans
             may not obtain the full flux even though they represent
             all the essentials of the source structure.
  IN2CLASS...Cleaned map name (class).     Standard defaults.
  IN2SEQ.....Cleaned map name (seq. #).    0 -> highest.
  IN2DISK....Disk drive # of cleaned map.  0 => any.
  INVERS.....CC file version #.  0=> highest numbered version
  NCOMP......Number of Clean components to use for the model, one
             value per field.  If all values are zero, then all
             components in all fields are used.  If any value is not
             zero, then abs(NCOMP(i)) (or fewer depending on FLUX and
             negativity) components are used for field i, even if
             NCOMP(i) is zero.  If any of the NCOMP is less than 0,
             then components are only used in each field i up to
             abs(NCOMP(i)), FLUX, or the first negative whichever
             comes first.  If abs(NCOMP(i)) is greater than the number
             of components in field i, the actual number is used.  For
             example
                   NCOMP = -1,0
             says to use one component from field one unless it is
             negative or < FLUX and no components from any other
             field.  This would usually not be desirable.
                   NCOMP = -1000000
             says to use all components from each field up to the
             first negative in that field.
                   NCOMP = -200 100 23 0 300 5
             says to use no more than 200 components from field 1, 100
             from field 2, 23 from field 3, 300 from field 5, 5 from
             field 6 and none from any other field.  Fewer are used if
             a negative is encountered or the components go below
             FLUX.
  FLUX.......Only components > FLUX in absolute value are used in the
             model.
  NMAPS......Number of image files to use for model.  If more than one
             file is to be used, the NAME, CLASS, DISK and SEQ of the
             subsequent image files will be the same as the first file
             except that the LAST 3 or 4 characters of the CLASS will
             be an increasing sequence above that in IN2CLASS.  Thus,
             if INCLASS='ICL005', classes 'ICL005' through 'ICLnnn'
             or 'ICnnnn', where nnn = 5 + NMAPS - 1 will be used.  Old
             names (in which the 4'th character is not a number) are
             also supported: the last two characters are '01' through
             'E7' for fields 2 through 512.  In old names, the highest
             field number allowed is 512; in new names it is 4096.
  CMETHOD....This determines the method used to compute the
             model visibility values.
             'DFT' uses the direct Fourier transform, this
             method is the most accurate.
             'GRID' does a gridded-FFT interpolation model
             computation.
             '    ' allows the program to use the fastest
             method.
             NOTE: when using a model derived from data with
             different uv sampling it is best to use 'DFT'
  SMODEL.....A single component model to be used instead of a
             CLEAN components model; if abs (SMODEL) > 0 then
             use of this model is requested.
                SMODEL(1) = flux density (Jy)
                SMODEL(2) = X offset in sky (arcsec)
                SMODEL(3) = Y offset in sky (arcsec)
                SMODEL(4) = Model type:
                  0 => point model
                  1 => elliptical Gaussian and
                       SMODEL(5) = major axis size (arcsec)
                       SMODEL(6) = minor axis size (arcsec)
                       SMODEL(7) = P. A. of major axis (degrees)
                  2 => uniform sphere and
                       SMODEL(5) = radius (arcsec)
  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.  If > 1.5, also calibrate the weights
             (new for VLA, normal for VLBI).  The calibration is
             applied prior to the bandpass determination.
  GAINUSE....version number of the CL table to apply to
             multisource files or the SN table for single
             source files.  0 => highest.
  DOPOL......If > 0 then correct data for instrumental polarization as
             represented in the AN 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.
  BLVER......Version number of the baseline based calibration
             (BL) table to appply. <0 => apply no BL table,
             0 => highest.
  FLAGVER....specifies the version of the flagging table to be
             applied. 0 => highest numbered table.
             <0 => no flagging to be applied.
  DOBAND.....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......Specifies the version of the BP table to be applied.
             <0 => no bandpass correction done.
             ** NOTE - AIPS does not now have a way to "concatanate"
             ** BP tables.  Thus, if one determines a BP table having
             ** applied a BP table, one has no way to get that net
             ** calibration applied to the data.  Nonetheless, it may
             ** be of interest, for example, to use DOBAND=1 for
             ** example and then to see what is left as a
             ** time-variable BP, examining it with BPLOT.
  SOLINT.....the interval over which to average the data
             before solving for the bandpasses (MINS).
            (0 => scan, -1 => whole timerange)
  REFANT.....the antenna to use as a reference in the
             least squares solution.
  OUTVERS....the version of the BP table to fill. (0 => 1)
  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
               1 => Hanning
               2 => Gaussian
               3 => Boxcar
               4 => Sinc (i.e. sin(x)/x)
             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.
             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).
  ANTWT......Antenna weights for up to 30 antennas. (0=>1.0)
  BPASSPRM...Control information:
             (1) > 0 => fill BP table with autocorrelation
                   data only, ignoring the phases.
             (2)   print level
             (3) > 0 => do not divide data by a model of the
                   source. The default is that the data will
                   be divided by a source model, the model
                   used will be (in order of decreasing
                   priority):
                         (1)  the flux density specified in
                              the SU table
                         (2)  a point source model (SMODEL)
                         (3)  CLEAN components,
                   If BPASSPRM(5) = 0 the data will not be
                   divided by a source model.
             (4) > 0 => store only the phase of the complex
                   bandpass function in the BP table. You may
                   want to do this if, for instance, your data
                   have been normalized by the autocorrelation
                   data as is possible at the VLA.
             (5) = 0 => divide the line data by 'channel 0',
                   this is a useful operation if you wish to
                   determine your antenna based bandpasses from
                   uncalibrated data. Channel 0 is a 'VLAism'
                   for the vector averaged center 75% of the
                   observing band. If IN3NAME is specified
                   CPASS will use an external channel 0, else
                   it will generate one internally.
                   Note that this is on a record by record basis and,
                   if you have good phase stability, it might be
                   better to do the normalization on the SOLINT
                   average instead; see CPARM(8).
             (6)   If > 0, then the values of any amplitude
                   closure errors whose abs. percentage value
                   exceeds BPASSPRM(6) will be printed.
             (7)   If > 0, then the values of any phase closure
                   errors whose value exceeds BPASSPRM(7)
                   degrees will be printed.
             (8)   If > 0, then the amplitudes will be scalar
                   averaged before determining the solutions.
              (10) If > 0 then will normalize the amplitude
                   portion of the bandpass function by the area
                   under the curve (to force the area to = 1.0).
                   This is useful for VLBI data where a useful
                   'channel 0' is sometimes difficult to obtain.
              (11) If > 0 will then allow the user to apply
                   calibration and divide by channel 0. This is
                   disallowed in normal useage, however VLBI
                   users need this because they need to apply
                   delay and fringe rate solutions to the data
                   before dividing by channel 0 (delay is
                   especially important).
  CPARM..... Parameters relevant to the least-squares fit:
               (1) No. of terms to use in the polynomial
                   expansion.
               (2) Maximum number of iterations allowed.
               (3) Convergence limit.
               (4) Pre-average interval (seconds).
                   CPASS pre-averages the uv-data over sub-intervals
                   of each solution interval to improve the SNR before
                   the bandpass fit. For VLBA data the pre-average
                   interval should not be very long compared to
                   the time-scale over which the fringe-rate is
                   changing significantly at each antenna.
                   For low-SNR VLBA data, however, it is more important
                   to pre-average over a longer interval when solving
                   for cross-power bandpass solutions.
                   For VLA data the pre-average interval can be set to
                   a large value so that the entire solution interval
                   is averaged before the fit.
                   Default: Autocorrelation bandpass   -  5 min.
                            Cross-correlation bandpass - 15 min.
                   The data are not averaged beyond scan boundaries no
                   matter what the pre-averaging value is.
               (5) Fit type:
                    1: Chebyshev expansion of (Re, Im).
                    2: Chebyshev expansion of (Amp, Phs).
               (6) BP table to use for initial estimates of
                   the polynomial coefficients. Must be of
                   compatible type to the present fit.
               (7) Fit phase only ? (1 => fit for phase only
                   using initial amplitude solutions; 2 =>
                   fit for phase without reference to amplitude
                   data.
               (8) If >= 0 then auto-scale the data before the
                   fit to unit amplitude and zero mean phase.
                   See also BPASSPRM(5).  With data of good phase
                   stability, the scan average will produce a much
                   less noisy normalization than the record-by-record
                   divide by channel 0.  ***** You must use one (or
                   both) of these normalizations; the fitting routine
                   in CPASS does not work on un-normalized data. *****
               (9) The fitting is done using data weights.  If
                   CPARM(9) <= 0, the pre-average is used to find an
                   rms for each baseline and channel and the data
                   weight is set based on this rms tempered some by
                   the input weight.  If CPARM(9) > 0, the pre-average
                   rms is ignored.  If CPARM(9) > 1.5, the data
                   weights are set to one everywhere (except flagged
                   data of course).
  ICHANSEL.. Array of start, stop, and increment channel numbers plus
             an IF used for channel selection in the averaging to
             compute a channel 0.  Up to 20 sets if channels/IF may be
             entered.  The first having ICHANSEL(2,i) <= 0 terminates
             the list.  ICHANSEL(4,i) is the IF number, with <= 0
             meaning all IFs.  If an IF has no ICHANSEL set for it,
             then the inner 75% of that IF is used.  Note that these
             are absolute channel numbers; they are not relative to
             BCHAN.
The following specify a uv-file which can be used as an external
'channel 0'. If all the IN3* adverbs are blank, then the task
will determine channel 0 from the line data itself, unless
BPASSPRM(5) = 1, in which case no channel 0 division will be done.

  IN3NAME....Channel 0 uv name (name).      Standard defaults.
  IN3CLASS...Channel 0 uv name (class).     Standard defaults.
  IN3SEQ.....Channel 0 uv name (seq. #).    0 -> highest.
  IN3DISK....Disk drive # of Channel 0 uv   0 => any.
  BADDISK....A list of disks on which scratch files are not to
             be placed.  This will not affect the output file.
----------------------------------------------------------------
CPASS:  Task to determine the instrumental bandpass response
Documentor:  A. J. Kemball
Related Programs: BPASS, CALIB, POSSM, LISTR, SPLIT, TVFLG

OVERVIEW

This purpose of this task is to determine the antenna-based
instrumental bandpass response, modeled as a complex polynomial
expansion, using either autocorrelation or cross-correlation
calibrator data. This task is closely related in function to BPASS,
which in contrast determines the bandpass response on a channel by
channel basis. CPASS offers an alternative bandpass calibration method
which may be useful in some cases. In fitting the polynomial bandpass
response function, CPASS correctly models the antenna-based fringe
rotation applied to both autocorrelation and cross-correlation data by
the VLBA correlator, and is therefore useful for determining bandpass
solutions for high-frequency VLBA data. It has also proved useful in
deriving bandpass solutions for narrow-band VLBA data.

MODES OF OPERATION

CPASS has two major modes of operation:

 i) AUTOCORRELATION BANDPASSES

    In this mode CPASS uses only the autocorrelation data in
    determining the bandpass response function for each antenna.
    The phase response of the resulting solutions is zero. This mode
    is selected by setting BPASSPRM(1) = 1.

ii) CROSS-CORRELATION BANDPASSES

    In this mode CPASS factorises the baseline-based cross-power
    data on the specified continuum calibrator sources into
    antenna-based complex bandpass response functions using a
    non-linear least squares method. This is analogous to
    self-calibration except the solution at each antenna is a
    parametrized bandpass response. The phase response of the
    reference antenna is zero in this case and this mode is
    selected by setting BPASSPRM(1) = 0. In solving for cross-
    power bandpasses a phase-only solution may be performed with
    an existing AC bandpass solution used to fix the amplitude
    response.

GENERAL CONSIDERATIONS

The effect of calibrator source resolution can be minimized by
dividing the uv-data by a pre-determined source model or by the
so-called "channel-zero". These options are selected using BPASSPRM(3)
and BPASSPRM(5) respectively.

The polynomial bandpass solutions are written to the standard BP
tables used by BPASS and are applied using adverb DOBAND in the
standard manner. Multiple solutions can be appended to the same BP
table by running CPASS several times with the same output BP table
specified by OUTVERS.

The uv-data can be selected, calibrated, edited and smoothed prior to
the bandpass solutions using the standard AIPS adverbs for this
purpose (i.e. DOCALIB, GAINUSE, FLAGVER, BIF, EIF, SMOOTH etc.).

Comments on some specific adverbs follow:

SOLINT:
SOLINT defines the time interval to use in determining each bandpass
solution. The default (SOLINT = 0) determines a bandpass solution for
each scan defined in the NX table. Setting SOLINT = -1 will determine
only one bandpass solution for each antenna for the entire run.

REFANT:
REFANT defines the antenna to be used as the reference in the
least squares solution. A useful choice is an antenna with good
SNR, at the center of the array that was present for a significant
fraction of the observing run.

OUTVERS:
The version of the BP table to fill. The default (OUTVERS = 0)
will cause a new table to be generated. Solutions can be appended
to an existing BP table but BPASS and CPASS solutions cannot be
stored in the same table.

SMOOTH:
Specifies the type of spectral smoothing that can be applied
to the data before the bandpasses are determined. See
HELP SMOOTH for more details.

** WARNING ** If SMOOTH is specified then all channels of
the database must be present in a single file, it will not
work properly if for instance you have split your data into
4 files each of 16 channels. The rest of CPASS will work
with no problem in that mode but the SMOOTH option will
result in corrupted data.

See the HELP section for a full description of the BPASSPRM
parameters.

PARAMETERS CONTROLLING THE LEAST SQUARES FIT

The least squares fit is controlled using parameters specified in
adverb CPARM. This task uses a NETLIB routine by S.G. Nash (Siam
J. Numer. Anal. 21 (1984) which uses a truncated Newton algorithm.
CPASS can be somewhat slow when solving for a large number of free
parameters. The convergence can be monitoring by setting the print
level using BPASSPRM(2)=1, and CPASS re-started with different
least squares parameters to improve this if necessary.

A description of the least squares parameters is given below:

CPARM(1)...Number of terms to use in the polynomial expansion for
           the bandpass response function at each antenna. Reasonable
           values to use here are in the range 10-30. This number
           cannot exceed the number of frequency channels in each IF.
           Default: 20

CPARM(2)...Maximum number of iterations allowed. The least squares
           solution will terminate after this number of function
           evaluations.
           Default: 50

CPARM(3)...Convergence limit. This is the fractional convergence
           tolerance.
           Default: 0.001

CPARM(4)...Pre-average interval (seconds). CPASS pre-averages the
           uv-data over sub-intervals of each solution interval to
           improve the SNR before the bandpass fit. For VLBA data
           the pre-average interval should not be very long compared
           to the time-scale over which the fringe-rate is changing
           significantly at each antenna. For low-SNR VLBA data,
           however, it is more important to pre-average over a longer
           interval when solving for cross-power bandpass solutions.
           For VLA data the pre-average interval can be set to
           a large value so that the entire solution interval is
           averaged before the fit.
           Default: Autocorrelation bandpass   -  5 min.
                    Cross-correlation bandpass - 15 min.

CPARM(5)...Fit type. The task can solve for bandpass functions
           where either (Re,Im) or (Amp,Phs) are each expanded
           separately as Chebyshev series. The (Amp,Phs) solution
           is recommended, and the former may only be necessary
           if residual delays have not been removed before the
           bandpass fit.
           Default: 2 (amplitude and phase).

CPARM(6)...In solving for a cross-power bandpass, a pre-existing
           AC bandpass solution can be used either as a starting point
           for the fit or to fix the amplitude response of the
           bandpass solution. This BP table must have been fit
           using the same fit type (CPARM(5)) as is presently
           being used. Again, A&P is recommended.
           Default: 0 (do not read a BP table for initial values)

CPARM(7)...This parameter determines whether phase alone is fitted.
           CPARM(7) = 1 will fit for phase only using the amplitude
           response specified in CPARM(6). CPARM(7) = 2 will fit
           for phase alone without reference to the amplitude
           response.
           Default: 0

CPARM(8)...Auto-normalization. This parameter enables auto-scaling
           of the data to unit mean amplitude and zero mean phase
           after each pre-average interval. This is necessary to
           correct for calibrator resolution not previously removed.
           Default: 1 (auto-scaling enabled).

These parameters will be consolidated and revised as further
experience is gained with the algorithm.
------------------------------------------------------------------------












