; SMOOTH
;---------------------------------------------------------------
;! Specifies spectral smoothing
;# ADVERB UV
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 2004, 2013, 2020
;;  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.
Procedures:
   LINIMAGE......Build image cube from multi-IF data set.
Tasks:
   ACFIT.........Determine antenna gains from autocorrelations.
   ACLIP.........Edits suto-corr data for amplitudes, phases, and weights
                 out of range.
   ACSCL.........Corrects cross amplitudes using auto correlation
                 measurements.
   ALVAR.........Plots the Allan Variance statistic of a UV data set.
   ALVPR.........Prints statistics on the Allan Variance of a UV data set.
   ANBPL.........Plots and prints uv data converted to antenna based
                 values.
   AVSPC.........Averages uv-data in the frequency domain.
   BLCAL.........Compute closure offset corrections.
   BLCHN.........Compute closure offset corrections on a
                 channel-by-channel basis.
   BLING.........Find residual rate and delay on individual baselines.
   BPASS.........Computes spectral bandpass correction table.
   BPWAY.........Determines channel-dependent relative weights.
   BPWGT.........Calibrates data and scales weights by bandpass
                 correction.
   BSCAN.........Seeks best scan to use for phase cal, fringe search, ..
   CALIB.........Determines antenna calibration: complex gain.
   CAPLT.........Plots closure amplitude and model from CC file.
   CLIP..........Edits data based on amplitudes, phases, and weights out
                 of range.
   CLPLT.........Plots closure phase and model from CC file.
   CORER.........Calculates correlator statistics and flags bad ones.
   CPASS.........Computes polynomial spectral bandpass correction table.
   DECOR.........Measures the decorrelation between channels and IF of uv
                 data.
   DEFLG.........Edits data based on decorrelation over channels and time.
   DFTIM.........Makes image of DFT at arbitrary point showing time vs
                 frequency.
   DFTPL.........Plots DFT of a UV data set at arbitrary point versus
                 time.
   DIFRL.........Divides the RR data by LL data.
   EDITR.........Interactive baseline-oriented visibility editor using the
                 TV.
   EVAUV.........Subtracts & divides a model into UV data, does statistics
                 on results.
   FGCNT.........Counts samples comparing two flag tables.
   FGSPW.........Flags bad spectral windows.
   FINDR.........Find normal values for a uv data set.
   FLAGR.........Edit data based on internal RMS, amplitudes, weights.
   FLGIT.........Flags data based on the rms of the spectrum.
   FLOPM.........Reverses the spectral order of UV data, can fix VLA
                 error.
   FRING.........Fringe fit data to determine antenna calibration, delay,
                 rate.
   FRMAP.........Task to build a map using fringe rate spectra.
   FRPLT.........Task to plot fringe rate spectra.
   FTFLG.........Interactive flagging of UV data in channel-time using the
                 TV.
   FUDGE.........Modifies UV data with user's algorithm: paraform task.
   IBLED.........Interactive BaseLine based visibility EDitor.
   IMAGR.........Wide-field and/or wide-frequency Cleaning / imaging task.
   ISPEC.........Plots and prints spectrum of region of a cube.
   KRING.........Fringe fit data to determine antenna calibration, delay,
                 rate.
   LISTR.........Prints contents of UV data sets and assoc. calibration
                 tables.
   LPCAL.........Determines instrumental polarization for UV data.
   MAPBM.........Map VLA beam polarization.
   NOIFS.........Makes all IFs into single spectrum.
   OMFIT.........Fits sources and, optionally, a self-cal model to uv
                 data.
   PCAL..........Determines instrumental polarization for UV data.
   PHSRF.........Perform phase-referencing within a spectral line
                 database.
   POSSM.........Task to plot total and cross-power spectra.
   REWAY.........Computes weights based in rms in spectra.
   RFI...........Look for RFI in uv data.
   RFLAG.........Flags data set based on time and freq rms in fringe
                 visibilities.
   RLCAL.........Determines instrumental right-left phase versus time (a
                 self-cal).
   RLDIF.........Determines Right minus Left phase difference, corrects
                 cal files.
   RLDLY.........Fringe fit data to determine antenna R-L delay
                 difference.
   RSPEC.........Plots and prints spectrum of rms of a cube.
   SCIMG.........Full-featured imaging plus self-calibration loop with
                 editing.
   SCMAP.........Imaging plus self-calibration loop with editing.
   SHOUV.........Displays uv data in various ways.
   SPCAL.........Determines instrumental polzn. for spec. line UV data.
   SPFLG.........Interactive flagging of UV data in channel-TB using the
                 TV.
   SPLAT.........Applies calibration and splits or assemble selected
                 sources.
   SPLIT.........Converts multi-source to single-source UV files w
                 calibration.
   SPMOD.........Modify UV database by adding a model with spectral lines.
   SPRMS.........Plots spectral statistics of a selected subset of a uv
                 data set.
   SUFIX.........Modifies source numbers on uv data.
   TI2HA.........Modifies times in UV data to hour angles.
   TIORD.........Checks data for time baseline ordering, displays
                 failures.
   TRUEP.........Determines true antenna polarization from special data
                 sets.
   TVFLG.........Interactive flagging of UV data using the TV.
   UFLAG.........Plots and edits data using a uv-plane grid and the TV.
   UV2MS.........Append single-source file to multi-source file.
   UV2TB.........Converts UV autocorrelation spectra to tables.
   UVAVG.........Average or merge a sorted (BT, TB) uv database.
   UVBAS.........Averages several channels and subtracts from uv data.
   UVFIT.........Fits source models to uv data.
   UVFND.........Prints selected data from UV data set to search for
                 problems.
   UVFRE.........Makes one data set have the spectral structure of
                 another.
   UVGIT.........Fits source models to uv data.
   UVHGM.........Plots statistics of uv data files as histogram.
   UVHIM.........Makes image of the histogram on two user-chosen axes.
   UVHOL.........Prints holography data from a UV data base with
                 calibration.
   UVIMG.........Grid UV data into an "image".
   UVLIN.........Fits and removes continuum visibility spectrum, also can
                 flag.
   UVLSD.........Least squares fit to channels and divides the uv data.
   UVLSF.........Least squares fit to channels and subtracts from uv data.
   UVMLN.........Edits data based on the rms of the spectrum.
   UVMOD.........Modify UV database by adding a model incl spectral index.
   UVMTH......... Averages one data set and applied it to another.
   UVPLT.........Plots data from a UV data base in multiple ways.
   UVPRM.........Measures parameters from a UV data base.
   UVPRT.........Prints data from a UV data base with calibration.
   UVRFI.........Mitigate RFI by Fourier transform or fitting the circle.
   UVRMS.........Computes statistics of a selected subset of a uv data
                 set.
   VPLOT.........Plots uv data and model from CC file.
   WETHR.........Plots selected contents of WX tables, flags data based on
                 WX.
   WIPER.........Plots and edits data from a UV data base using the TV.
   XYDIF.........Find/apply X minus Y linear polarization phase
                 difference.
   XYMOD.........Compute linear polarization point source model, applies
                 to data.
----------------------------------------------------------------
