;SOUSP
;-----------------------------------------------------------------------
;! fits source spectral index from SU table or adverbs
;# TASK UV CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 2010-2012
;;  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
;-----------------------------------------------------------------------
SOUSP     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SOUSP     Fits, plots, returns spectral index parameters
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 name (SOURCES(1) only)
CALCODE                            Calibrator code
QUAL             -1.0              Source qualifier -1 => any
ORDER                              Order of fit
NOISE                              Noise in Jy for each freq
                                      0 => all same
FLDSIZE                            (Flux, freq) in (Jy, GHz)
                                      0 => use source table
DOCONFRM         -1.0        1.0   > 0 => replace SU table
                                      values with fit
SYMBOL            0.0       24.0   Symbol to use on plot
FACTOR            0.0       10.0   Scale plot symbols
PIXRANGE                           Control the Y plot range
DOTV                               > 0 => plot on TV, 0 no plots
                                   < 0 => make 2 plot files
GRCHAN            0.0        7.0   TV graphics channel to use
SPECINDX @                         Spectral index
SPECURVE @                         Spectral index curvature
----------------------------------------------------------------
SOUSP
Task:  This task fits fluxes for a source to determine the spectral
       index and spectral index curvature:
           log10 (flux) = A + SPECINDX * log10(f) +
               SPECURVE(1) * [log10(f)]^2 + ...
       where A is log10 of the flux at 1 GHz and f is the frequency in
       GHz.  It can then plot the fit on the TV or plot files in both
       log ang linear space.  It will return the adverbs SPECINDX and
       SPECURVE for use in other tasks such as BPASS.
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....Name of source - only SOURCES(1) is used. ' ' not allowed
  CALCODE....SOURCES(1) may occur more than once in the source table
             with different calibator codes.  CALCODE may then be used
             to select which one you want.
                  '    ' => 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. SOURCES(1) and QUAL, in the selection of the
             source for which to determine the solution.
  QUAL.......Source qualifier: -1 => any, 0 is a real value.
  ORDER......<= 1 => fit spectral index only, 2 also fit SPECURVE(1),
             3 also fit SPECURVE(2), 4 also fit SPECURVE(3).  You will
             normally not wish to use more than 2.
  NOISE......Noise value for frequencies 1 up to 64.  If FLDSIZE is
             not used, then these apply to the fluxes in the SU table
             for the named source.  Otherwise, they apply to the
             fluxes and frequencies listed in FLDSIZE.
  FLDSIZE....FLDSIZE(1,i) is the flux for the i'th frequency to be fit
             in Jy and FLDSIZE(2,i) is the frequency in GHz.  The
             number of frequencies to be fit is determined by the
             number of FLDSIZE pairs that are both > 0.  If all are 0,
             then the SU table is used to provide the fluxes for the
             various IF frequencies.
  DOCONFRM...> 0 => ask after plotting if the SU table values should
                    be replaced by the fit values - a YES or yes
                    answer must be given to make this happen.  This is
                    only done if all of FLDSIZE is 0.
             <= 0 => do not change the fluxes in the SU table and do
                    not ask about it.
  SYMBOL.....1: Plus sign (default)   12: Five pointed star
             2: Cross (X)             13: Star of David
             3: Circle                14: Seven-pointed star
             4: Box                   15: Eight-pointed star
             5: Triangle              16: Nine-pointed star
             6: Diamond               17: Ten-pointed star
             7: Pentagon              18: 11-pointed star
             8: Hexagon               19: 12-pointed star
             9: Septagon              20: 13-pointed star
             10: Octagon              21: 14-pointed star
             11: Nine-gon             22: Plus with gap
                                      23: vertical line
                                      24: Cross with gap
  FACTOR.....Scale plot symbols by FACTOR     0 -> 1.
             If FACTOR < 0, draw lines between the points and use
             abs(FACTOR) to scale the points plotted.
  PIXRANGE...If PIXRANGE(2) > PIXRANGE(1), the plot will only cover
             that range in flux.  Otherwise it will cover the full
             trange of the data (only).
  DOTV.......> 0 => plot directly on the TV device, otherwise make a
             plot file for later display on one or more devices
             (including the TV if desired).
  GRCHAN.....Graphics channel (1 - 7) to use for line drawing.
             A value of 0 causes more than one graphics channel to be
             used.
  SPECINDX...Spectral index defined above.
  SPECURVE...Spectral index curvature parameters based on a reference
             frequency of 1 GHz and base-10 logarithms.
----------------------------------------------------------------

