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,found,
          fitted,nobs,chi2,quality, 
          DB=db,DATABASE=database,TABLENAME=tablename,FILE=file,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:
  DB       - flag, if set will use MYSQL server and validly populate outputs
                fitted, nobs, chi2, quality and comments.
                By default, the program uses the legacy mode of using a file
                of tabulated values for the transformation data. Only the
                trans, transig, jdref and found outputs are populated.
                The file name is of the form (e.g.) transf_b.bmv.
  DATABASE - Name of MYSQL database for transformation search.
                The default is 'PHOT'. Used only when DB 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 DB 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 FILE set.

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

 OUTPUTS:
  tran     - 5 transformation coefficients, k, k2, kcolor, 0pt, ktime
  transig  - uncertainties corresponding to trans.
  jdref    - Time reference point for extinction- non-zero if ktime used.
  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. Currently fitted is defined
                only when gettran uses MYSQL.
  nobs     - number of observations, currently defined only when gettran
                uses MYSQL.
  chi2     - chi-square value, currently defined only when gettrans 
                uses MYSQL.
  quality  - quality flag, enum string among "good" "bad" suspect" "unknown"
                currently defined only when gettran uses MYSQL.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 if DB is set the data base selected is opened, query'd and closed.
 if FILE is set the file selected is opened for read, read and closed.

 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.

 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.