NAME:
  lowess
 PURPOSE:
  Lowess smoothing of data.
 DESCRIPTION:

  This algorithm was gleaned from a description of LOWESS, standing
  for LOcally WEighted Scatterplot Smoother, found in "The Elements of
  Graphing Data", by William S. Cleveland, Wadsworth Advanced Books and
  Software.  This implementation is probably not the same as the one
  described.  I have tried to include the provision for using different
  weighting functions.  At the time of writing I don't know what effect
  different functions have upon the smoothing process.  This procedure
  in itself is not intended to be robust (as defined by Cleveland). By
  including the possiblity of varying weights for the data points it is
  possible to acheive robustness by multiple calls of this routine.

 CATEGORY:
  Numerical
 CALLING SEQUENCE:
  lowess,x,y,width,ysmoo,WEIGHT=weight
 INPUTS:
  x      - Independant variable values.
  y      - Dependant variable values.
  width  - Width of smoothing function (in same units sa X).
 OPTIONAL INPUT PARAMETERS:

 KEYWORD INPUT PARAMETERS:
  NEWX   - If provided, the smoothed curve is computed over this input
             range of x values rather than the input x range.  ysmoo
             will have the same length as NEWX if it is provided.
  ORDER  - Order of polynomial fit during the lowess smoothing. (default=1)
  WEIGHT - Weight to use for each point (default is to have equal weight)

 OUTPUTS:
  ysmoo  - Smoothed version of Y, same number of points as input x and y.
 KEYWORD OUTPUT PARAMETERS:

 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:
  By default, the weighting function is triangular where the weight is
  1 at the output point location, and drops linearly to zero +/- width from
  the output point.

 MODIFICATION HISTORY:
  98/06/16, Written by Marc W. Buie, Lowell Observatory
  2001/02/01, MWB, changed Polyfitw call to poly_fit equivalent
  2006/11/13, MWB, forced loop variables to LONG