; SMOOTH
;---------------------------------------------------------------
;! Specifies spectral smoothing
;# ADVERB UV
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 2004, 2013
;;  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
;-----------------------------------------------------------------------
;---------------------------------------------------------------
SMOOTH    LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
----------------------------------------------------------------
SMOOTH
Type: Adverb  (REAL(3))
Use:  SMOOTH specifies the type of spectral smoothing to be applied to
      a uv database or other spectra. 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 applied before bandpass calibration
            2 => Gaussian applied before bandpass calibration
            3 => Boxcar applied before bandpass calibration
            4 => Sinc (i.e. sin(x)/x) applied before bandpass cal.
            5 => Hanning applied after bandpass calibration
            6 => Gaussian applied after bandpass calibration
            7 => Boxcar applied after bandpass calibration
            8 => Sinc (i.e. sin(x)/x) applied after bandpass cal.
          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).
      When applied to uv data, it is important to decide whether the
      smoothing should be applied before or after application of the
      bandpass calibration.  If SMOOTH was used in BPASS (or CPASS),
      then the same SMOOTH must be used with all the data (and
      SMOOTH(1) must be 1 through 4).  If SMOOTH was not used in
      BPASS, then SMOOTH(1) must be 5 - 8 for correct results.

Null Value:  0
      A null value of SMOOTH(1) means no smoothing is desired;
      the useage of null values for other parameters depend on
      the application.  The usual defaults are listed above.

Discussion:
      Frequency smoothing of UV data interacts with data flagging in
      ways that are not entirely intuitive.  In fact, it is strongly
      recommended that any data smoothing to be applied before the
      bandpass be done, once and for all (with e.g. SPLAT), before any
      channel-dependent flagging is done.  Data with RFI frequently
      requires a Hanning smooth up front to reduce ringing.  Do this
      with SPLAT once and for all eraly in your data reduction.

      Post bandpass smoothing also interacts with flags and the
      computatin of Stokes parameters.  A SMOOTH of, e.g. 6,0,0
      functions as follows:
         1. Smooth each polarization separately ignoring flagged
         channels and maintaining the flagging.
         2. Combine polarizations to make the Stokes parameters.

       This can be particularly odd with Stokes I - which is taken to
       be (RR+LL)/2 unless one of RR and LL is flagged, in which case
       the other is taken.  Thus smooth values of RR and LL are
       averaged but isolated channels of only RR or LL also appear.
       These isolated channels will have smoothed values appropriate
       to RR or to LL but not to the average unless RR and LL are
       nearly identical.  Thus single channels will stick out from the
       otherwise smooth spectrum.

       Even with Stokes F (formal I), Q, U, and V, odd results may
       arise.  Flagging of one of the two observed polarizations for
       these parameters leads to flagging of the result at the
       particular flagged channel.  But, if one of e.g. RL and LR is
       not flagged, then those unflagged values will affect the
       adjacent channels in the smoothing that preceeds the Stokes
       computation.  Thus, at a good channel, the results will be
       different from the results if all polarizations rather than
       just 1 are flagged at the flagged channels.

       POSSM has a special option where the spectra are averaged with
       no smoothing and then smoothed just before displaying them.  In
       this way, most of the complications described above are
       avoided.
----------------------------------------------------------------
