NAME: 
  lcfit
 PURPOSE: 
  Fit a lightcurve function (Fourier series plus phase coefficient).
 DESCRIPTION:
 CATEGORY:
  Function fitting
 CALLING SEQUENCE:
  lcfit,lon,phang,data,sig,nterms,c,csig
 INPUTS:
  lon    - Longitude of sub-earth point (0 to 360).
  phang  - Phase angle (Sun-Object-Earth angle in degrees).
  data   - Measured values.
  sig    - Uncertainties of the data.
  nterms - Number of fourier terms to fit.  (2*nterms+1 unknowns)
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  NODISPLAY - Flag, if set suppresses all plots from this routine.
  TITLE - Title to put on plot (default = no title)
  DYMF - The normal magnitude range on the plots is +/- 0.2 mag about the
           mean of the extrema of the data.  This keyword lets you affect
           this scaling.  The range is +/- 0.2/dymf (default is dymf=1)
 OUTPUTS:
  c - fourier series coefficients (see fourfunc)
  csig - uncertainties of the coefficients
 KEYWORD OUTPUT PARAMETERS:
  YFIT - Final resulting fitted position for each input data point.
  CHISQ - Goodness-of-fit statistic for fit.
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  94/10/10, Written by Marc W. Buie, Lowell Observatory
  2008/03/16, MWB, added some keywords
  2008/11/20, MWB, fixed bug that could cause returned value of CHISQ to be bad
  2020/04/29, MWB, some cleanup, slight change to now DYMF is used.