NAME: 
  colorsol
 PURPOSE: 
  Find the standard color of an unknown star.
 DESCRIPTION:
 CATEGORY:
  Photometry
 CALLING SEQUENCE:
  colorsol, stand,fil,jd,am,serial,inst,instsig, $
             color1,color2,trans1,trsig1,jdref1,trans2,trsig2,jdref2, $
             object,std1,stdsig1,std2,stdsig2,stdcol,stdcolsig

 INPUTS:
  stand    - String array of standard names.  (See coord.)
  fil      - String array of filter names for observations.
  jd       - Double precision array of the JD of observations.
  am       - Floating point array of the airmass of observations.
  serial   - Serial number of observation.
  inst     - Instrumental magnitude
  instsig  - Uncertainty of the instrumental magnitude
  color1   - Name of filter for the first color.
  color2   - Name of filter for the second color.
  trans1   - Transformation coefficients (vector) for first filter.
                trans1(0) = principal extinction coefficient
                trans1(1) = second order extinction coefficient
                trans1(2) = color term
                trans1(3) = zero-point
                trans1(4) = time-dependent extinction term
     if provided:
                trans1[5] = (f)  airmass squared term
                trans1[6] = (g)  color squared term
  trsig1   - Uncertainty on the transformation coefficients (vector).
  jdref1   - Time reference point for extinction (first filter).
  trans2   - Transformation coefficients (vector) for second filter.
  trsig2   - Transformation coefficients (vector) for second filter.
  jdref2   - Time reference point for extinction (second filter).

     tran and transig can either be 5-element vectors or 5xN element arrays.
                must match the number of transformation sets provided
  
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  BADFLAGS - Array of flags that mark data bad (if true).
  DATABASE - Name of MYSQL database to save reduced observations.
                 The default is 'phot'. 
  DB       - Flag, if set, reduced observations will be saved to database.
  DVERBOSE-  Code for dbphot and other routines for db transaction verbosity.
  FILTER1 -  Name of the first filter
  FILTER2 -  Name of the second filter
  FULL    -  Flag, if true, will enable the complete printout, otherwise
                just the final summary for each object will be printed.
  NOEDIT  -  If set, suppresses the interactive editing of the star data.
  NOPRINT -  Flag, if true, will inhibit the summary printout to the screen.
  PATH    -  If SAVE is set, this points to the directory where
                results should be written.
  REFAM - Optional air mass reference for the transformation.  The default
             is an airmass=0.
  REFCOLOR - Optional color reference for the color term transformation.
                 This term is normally C * (B-V) or some other standard
                 color.  As written, the reference color is zero and this
                 is the default.  By providing this value you are using
                     C * ( (B-V) - REFCOLOR ) for the term instead.
  REFID -    String uniquely identifying observing run. This is used in 
               updating the data table with the reduced observations in the 
               database. It must be specified if DB is used.
  SAVE    -  Flag, if true, will save the final photometry to an output file,
                and, if DB selected, to database.
  TABLE    - Name of table in MYSQL database to save reduced observations.
                The default is 'data'. 
  TIDX     - Indexing array, same length as the input observations.  This
                keyword is ignored if the input transformation vectors is
                a simple 5-element vector.  If the transformation is provided
                as a 5xN array then this keyword is REQUIRED.
             Each element gives the index into the set of transformation
             values.  This allows combining data that have different
             photometric transformation coefficients.

  RA       - Measured right ascension of object in that observation.  Do not
                use a catalog or ephemeris position, only real astrometry.
                default=no position, only needed for saving to database
  DEC      - Measured declination of object in that observation.  Do not
                use a catalog or ephemeris position, only real astrometry.
                default=no position, only needed for saving to database
 OUTPUTS:
  object    - Name(s) of program object.
   std1      - Standard magnitude of first filter.
   stdsig1   - Uncertainty of the standard magnitude.
   std2      - Standard magnitude of second filter.
   stdsig2   - Uncertainty of the standard magnitude.
   stdcol    - Standard color, first filter - second filter.
   stdcolsig - Uncertainty of the standard color.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 Data for objects completely removed from colorsol reduction due to bad
 flags will not be removed from the hard files.
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Marc W. Buie, Lowell Observatory
  96/11/25, MWB, added PATH, SAVE, FILTER1, and FILTER2 keywords
  97/02/11, MWB, added new transformation support (k(t))
  97/02/25, MWB, added NOEDIT keyword and actions
 2006/08/14, Peter L. Collins, Lowell Observatory
             add database support (save reduced observations) and header cleanup.
 2006/09/26, PLC, add INSTRUMENT keyword to pass through to dbphot.
 2006/10/17, PLC, modify effect of SAVE flag to control db update also.
 2006/12/07, PLC, replace instrument and rundate keywords by REFID and
                   change calls to dbphot.
 2006/12/10, PLC, fix bug involving TABLE not passing through to dbphot.
 2006/12/28, PLC, add DVERBOSE keyword, add 1 additional entry to 
                  the db data table per object for the solved color value, and
                  fix handling of hard files for refid length.
 2007/01/04, PLC, further fix for the hard files.
 2007/02/05, PLC, fix for adding color name to database entries. Improve logic
                  for bad flags and data scrubbing.
 2013/06/02, MWB, updated to support different transformation coefficients
                  for the input data.
 2013/06/18, MWB, added RA, DEC keywords
 2013/06/25, MWB, added REFCOLOR keyword
 2014/03/05, MWB, added REFAM keyword, added full set of second order terms
 2014/05/20, MWB, fixed bugs with array input for trans1 & trans2
 2015/10/10, MWB, fixed bug with color/colorsig indexing during solution