PURPOSE: (one line)
   Determine transformation coefficients from instrumental to standard mags.


   This will take a set of all-sky standard star measurements and derive
     the best fitting set of transformation coefficients from instrumental
     to standard magnitudes.

   Normally, you give this routine ALL the data taken with a single filter.
     Only those objects that are standards in this filter and the alternate
     color will be used in the fit.  Only those that should be standards
     can end up marked as bad from this program.

   My conventions for the photometric fit are begin with Hardie's
     nomenclature.  However, there are three additional terms I've added:
     the first order expansion term of extinction with respect to time
     and the full second-order expansion in airmass and color.
     The basic formula for the transformation is:

       m0 = m - kX - n(t-t0)X - k"CX + eC + fX^2 + gC^2 + Z

           m  = instrumental magnitude
           k  = extinction coefficient, mag/airmass
           X  = airmass
           n  = coefficient of the 1st order expansion of extinction as a
                  function of time
           t  = Time of observation (in hours)
           t0 = Reference time for n, time dependent correction is zero at
                  this time, usually is the middle of the observation set.
           k" = second order extinction coefficient
           C  = Standard system color of the object
           e  = color term
           f  = second-order term in airmass squared
           g  = second-order term in color squared
           Z  = zero point
           m0 = Standard magnitude

   The fitting process takes advantage of the uncertainties on the instrumental
     magnitude and the uncertainties on the forced terms.  The uncertainties
     on the catalog standard magnitudes are ignored.  The coefficients, k",
     e, and n are considered to be auxillary coefficients and can be either
     fit for or forced.  k", e, f, and g can be forced to explicit values.
     n is either fit for or set to 0.  The extinction and zero-point are always
     fit for.


    [ RESID=resid,FILE=landfile,NOPLOT=noplot,OTHER=other,
      OLAB=olab,TITLE=title ]

  names  - String array of standard names.
  jd     - Julian date of observations.
  filter - Filter number of data. (0-U, 1-B, 2-V, 3-R, 4-I)
  color1 - First filter for color.
  color2 - Second filter for color.  (eg., B-V is 1,2)
  airm   - Vector of airmasses for observations.
  mag    - Vector of instrumental magnitudes.
  err    - Vector of uncertainties.
  bad    - Vector of flags, 0=good, 1=bad, default is good



  These keywords affect how the fit is done.  All except KTIME must be
    two-elements vectors, the first element is the value of the coefficient
    and the second element is the uncertainty on the coefficient.  The default
    is to fit for these terms.

  CTERM  - Optional, fixed color term.  If provided, the color term is
              assumed, not fitted.
  K2     - Second order extinction coefficient.  If provided, this term
              is assumed, not fitted.
  COLSQ  - Term proportional to the standard color squared
  AMSQ   - Term proportional to the airmass squared
  KTIME  - Flag, enable time dependent extinction.
  REFCOLOR - Reference color to use during the fit.  The old default value for
               this was implicitly zero.  Now it is the mean of all the good
               values used.
  REFAM    - Reference airmass to use during the fit.  The old default value
               for this was implicitly zero.  Now it is the middle of the range
               of airmass for all good values used.


  These keywords affect the plotting output

  NOPLOT   - Flag, if true inhibits the summary plots.
  OLAB     - Label for the plot of residuals vs. OTHER.
  OTHER    - If provided, allows plotting the residuals against some other
              variable, eg., exposure time.  Must match the length of
              the data input vectors.


  Other control options

  FILE     - Optional name for the Landolt "system" Standards catalog.
  NOEDIT   - Flag, if set inhibits final interactive editing of fitted points.
             This keyword has no effect and is not necessary if the current
             plotting device is 'PS'.
  RESID    - Flag, if true enables printing a full residual table.
  TITLE    - Title for plots.
  FILES    - Flag, if true requests saving information to summary files.
                This feature is deprecated in favor of saving to the database.
  NOSAVE  -  Flag, if true supresses saving information to databases or
             summary files. NOSAVE implies NOFILES.
  CHISCALE -Flag, if true rescales final solution to force reduced Chi=1.0
  TAGDATE  -String identifying date of data.
  TAGINST  -String identifying instrument.
  HISTFILE -File name of history file to update extintion values in.
             Only one line for TAGDATE/TAGINST is allowed.  If a duplicate
             is found, the appropriate line is replaced.
  MAGRESID - Edit bad values by mag residual, not sigma residuals
  NODB     - flag, if set will suppress saving data to the database.
  DATABASE - Name of MYSQL database for transformation fit. Passed 
                to puttran.  The default is 'phot'.
  DVERBOSE  - flag passed to gettran and puttran to set  db screen verbosity.
  TABLENAME- Name of table in MYSQL database for transformation search.
                Passed to puttran. The default is 'transf'.

  No explicit vector outputs.  All output is graphical, printed to the
    screen, or saved to external files.






  93/08/05, Initial version completed, Marc W. Buie, Lowell Observatory.
  93/10/05, MWB, added support for 1993 catalog.
  95/02/22, MWB, modified plots.
  96/10/16, MWB, added summary save to file, NOFILES, CHISCALE, TAG*, and
                   HISTFILE keywords actions added.
  96/11/22, MWB, changed to new master photometry catalog
  97/01/24, MWB, added MAGRESID flag
  97/2/7, MWB, massive rewrite
  2004/02/09, MWB, changed path to transf files.
  2006/08/02, MWB, added DB, DATABASE, TABLENAME keywords
  2006/10/16, PLC, added NOSAVE keyword
  2006/12/28, PLC, added DVERBOSE flag.
  2014/03/06, MWB, added REFCOLOR and REFAM keywords, added new transformation
                      terms.  Saving to files is deprecated, it still happens
                      but the new terms are not included in the save.  If you
                      want all of the information you must use the database.
                      The NOFILES keyword has been changed to FILES.
                      The DB keyword has been changed to NODB.