; TYSMO
;---------------------------------------------------------------
;! smooths and filters a calibration TY table
;# Task Calibration VLA
;-----------------------------------------------------------------------
;;  Copyright (C) 2007
;;  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
;-----------------------------------------------------------------------
TYSMO     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
TYSMO     Task which smooths/filters system temperature tables
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 #
SOURCES                            Source list ' '=>all.
DOBTWEEN        -1.0         1.0   > 0 -> smooth all sources
                                   together; else separate them
SELBAND                            Bandwidth to select (kHz)
SELFREQ                            Frequency to select (MHz)
FREQID                             Freq. ID to select, 0=>all
BIF               0.0      100.0   Lowest IF number 0=>all
EIF               0.0      100.0   Highest IF number 0=>all
TIMERANG                           Time range to use.
ANTENNAS                           Antennas to correct.
SUBARRAY          0.0     9999.0   Subarray; 0 => all.
SAMPTYPE                           Smoothing function
BPARM                              Smoothing parameters
CUTOFF            0.0              Cutoff for functional forms
DOBLANK                            Blanked value interpolation
CPARM                              Range of allowed T's
INVERS                             Input TY table; 0=>highest
OUTVERS                            Output TY table; 0=>new
BADDISK           0.0     9999.0   Disks to avoid for scratch
----------------------------------------------------------------
TYSMO
Task: This task edits and smooths a TY table.  First the antenna and
   system temperatures are clipped to be in reasonable ranges.  Then
   they are time smoothed.  Blanked values will be interpolated or not
   under control of DOBLANK.   For some telescopes Tsys and Tant are
   what they are labled to be.  For the VLA, Tsys is the nominal
   sensitivity and Tant is some form of system temperature.

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.
  SOURCES....list of sources to process: '*' = all;
             a "-" before a source name means all except ANY source
             named.
  DOBTWEEN...> 0 => smooth all TY values regardless of source.
             <= 0 => smooth only TY values from the same source.
             Well-separated calibrators may have different spill-over
             and background temperatures, so one would not want to
             smooth them together.  This can be achieved via doing one
             source at a time, but DOBTWEEN allows one to do all
             sources at once - at least if the choice is a simple one.
  FREQID.....Frequency identifier to select (you may determine which
             is applicable from the OPTYPE='SCAN' listing produced by
             LISTR).
  BIF........First IF to process. 0=>all.
  EIF........Highest IF to process. 0=>all higher than BIF
  TIMERANG...Time range of the data to be used. In order:
             Start day, hour, min. sec, end day, hour, min. sec.
             Days relative to reference date.
  ANTENNAS...A list of the antennas to be modified.  If any number is
             negative then all antennas listed are NOT to be modified.
             All 0 => use all.
  SUBARRAY...The subarray to modify.  0 -> all.
  SAMPTYPE...The type of smoothing.
                'BOX ' = boxcar smoothing (default)
                'MWF ' = Median window filter
                'GAUS' = Gaussian
                'EXP ' = Exponential
                'LINE' = Linear (1 - abs(t-t0)/sigma)
                '2PT ' = Two-point
                '2PTH' = Two-point + "Hanning"
  BPARM......Parameters for smoothing function.
             Function support full-width width in hours.
               (1) => support time for Tsys,  (0 -> skip)
               (2) => support time for Tant,  (0 -> skip)
             Added parameter (FWHM) for GAUS, EXP, LINE
               (6) => smoothing FWHM time for Tsys,
               (7) => smoothing FWHM time for Tant,
             In all cases, the substitution for blanked and good
             solutions is governed by DOBLANK (see below)
  CUTOFF.....Cutoff for GAUS, EXP, LINE.  The sum of the weighting
             function in the support region must exceed CUTOFF for the
             smoothed value to be regarded as valid.  Be careful, a
             value of 1.5 means that the sample itself must be good
             and the sum over other good samples in the support range
             must exceed 0.5.  < 1.e-6 => 1.e-6.
  DOBLANK....Blanked value interpolation:
             > 0: replace previously blanked values with smoothed
                  values, leave previously good values unchanged.
             = 0: replace previously blanked and previously good
                  values with smoothed values.
             < 0: replace previously good values with smoothed values,
                  leave previously blanked values blanked.
  CPARM......Data can be clipped by comparison with a median window
             filter.  The width of the Median window is specified in
             CPARM(1-2).  The maximum allowed deviation is given in
             CPARM(6-7). 0 => all values are OK.
               (1) => smoothing time for Tsys,
               (2) => smoothing time for Tant
               (6) => Max. deviation for Tsys,
               (7) => Max. deviation for Tant,
  INVERS.....input version number of the TY table to smooth.
             0 => Highest.
  OUTVERS....output version of TY table to write.
             0 => create new table (recommended)
  BADDISK....A list of disks on which scratch files are not to be
             placed.  This will not affect the output file.
----------------------------------------------------------------
