NAME:
  gettran
 PURPOSE:
  Find and return transformation solution for a given night and instrument
 DESCRIPTION:
 CATEGORY:
  Photometry
 CALLING SEQUENCE:
  gettran,inst,date,filter,color1,color2,tran,transig,jdref,refcolor,refam,
          found,fitted,nobs,chi2,quality, 
          DB=db,DATABASE=database,TABLENAME=tablename,PATH=path,
          SILENT=silent

 INPUTS:
  inst     - Instrument code
  date     - YYMMDD string of date of observation
  filter   - Landolt filter code 01234 is UBVRI
  color1   - filter code for first color
  color2   - filter code for second color (uses color index of C1-C2)

 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  NODB     - flag, if not set will use MYSQL server
                The file name is of the form (e.g.) transf_b.bmv.
                This mode is deprecated and is not supported.
  DATABASE - Name of MYSQL database for transformation search.
                The default is 'PHOT'. Used only when NODB is not set.
                If TABLENAME specifies a database via the '.' notation, this
                keyword (as well as its default) is ignored.
  TABLENAME- Name of table in MYSQL database for transformation search.
                The default is 'transf'. Used only when NODB is not set.
                If string is of the form 'a.b' then a is taken to be the
                name of the database and b is the tablename. Note that
                if neither TABLENAME nor DATABASE is specified the photometry
                table is located at 'phot.transf'
  FILEPATH - the single directory path for the file used for the 
                transformation search in legacy mode. The default is 
                '/net/frakir/raid/buie/Reduced/'. Used only when NODB is set.

  SILENT   - flag, if set, failures are silent
  VERBOSE  - flag, if set, prints information including all db queries.

 OUTPUTS:
  tran     - Transformation coefficients (vector)
                tran[0] = principal extinction coefficient
                tran[1] = second order extinction coefficient
                tran[2] = color term
                tran[3] = zero-point
                tran[4] = time-dependent extinction term
                tran[5] = (f)  airmass squared term
                tran[6] = (g)  color squared term
  transig  - uncertainties corresponding to trans.
  jdref    - Time reference point for extinction- non-zero if ktime used.
  refcolor - Color reference for the color term transformation.
                 This term is normally C * (B-V) or some other standard
                 color.  This formulation uses
                     C * ( (B-V) - REFCOLOR ) for the term instead.
  refam - Air mass reference for the transformation.
  found    - 1 if valid data found for the input parameters.
  fitted   - array of ints for trans- non-zero if the corresponding values
                fitted, otherwise forced. Fitted is defined
                only when gettran uses MYSQL.
  nobs     - number of observations, defined only when gettran
                uses MYSQL.
  chi2     - chi-square value, defined only when gettrans 
                uses MYSQL.
  quality  - quality flag, enum string among "good" "bad" suspect" "unknown"
                defined only when gettran uses MYSQL.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 GETTRAN currently fails if the enum strings in database corresponding to
    the arguments fitted and quality have the 'error' value.
 GETTRAN cannot access the comments field in the MYSQL table.

 Only the database supports the extra transformation terms and references.
   The missing values are returned as zeroes.  The flat file method is
   deprecated and should be avoided.

 PROCEDURE:
 MODIFICATION HISTORY:
 96/10/17 - Written by Marc W. Buie, Lowell Observatory
 97/2/6, MWB, added time dependent extinction term
 2004/02/09, MWB, changed path to transf files.
 2006/4/03,  Peter L. Collins, Lowell observatory
                extended for MYSQL operation and some additional fields.
 2006/08/07, MWB, fixed problem with keywords
 2006/10/04, PLC, get fitted array in the right order (ktime and zeropt 
                  swapped). Previous matching errors in the order of the 
                  fitted array were corrected in puttran, gettran and the
                  transf table of the phot database.
 2006/12/27, PLC, rationalization of data base keywords.
 2014/03/05, MWB, added refcolor, refam, and full second-order terms
       WARNING!  The calling sequence is different and DB has been changed
       to NODB and the file method is now deprecated.  If you were using DB
       before and forget to change you'll be protected.  If not, you must
       be very careful about this change.