NAME: 
  slidefil
 PURPOSE: 
  Sliding spatial filter on time series data.
 DESCRIPTION:
  This program scan a data stream looking for short duration, non-random
  excursions.  Primarily designed for scanning stellar occultation data,
  you provide the data (y), the independent variable (x) and the filter
  widths.  The equivalent width within the sliding window is computed
  and returned alone with the x location for the window.  The spacing in
  x does not need to be precisely constant but should not vary by much
  across the window.

  The data are scanned from the specified starting and ending POINT numbers.
  This allows for x being double-valued with respect to the point index.

  The sliding aperture looks like:

     |----------------------|+++++X+++++|---------------------|
      ^                      ^     ^ center of window
      |                      edge of sliding window (hhw from center)
      +- edge of background window (bhw from center)

  A polynomial is fitted to the background points (-), default order is 1.
  This polynomial extrapolated across the "gap" (+).  This extrapolation
  is either divided into the window points (default), or subtracted (and
  and 1.0 is added back.  The sum of the window points multipled by the
  local dx is then the equivalent width of the signal in the window.

  This filter is designed for scanning normalized data (full intensity=1
  and no intensity=0).  The returned values of equivalent width are in
  the same units as x.

 CATEGORY:
  Numerical
 CALLING SEQUENCE:
  slidefil,x,y,bhw,hhw,start,stop,xout,ew
 INPUTS:
  x     - Independent vector (such as distance in km).
  y     - Data vector.
  bhw   - Half width (in units of x) of inner sliding window.
  hhw   - Half width (in units of x) of outer (background) window.
  start - Point number (not x) at start of scan
  stop  - Point number (not x) near end of scan (won't go past, may stop
             up to hhw-1 points early).

   If either start or stop are too close to the edge for a full window,
   the start and stop are adjusted inward as needed.

 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  DX       - This is the derivative of X.  If the length is not the same
                as X, or, if it is undefined, the derivative is computed
                and returned to the supplied argument.  If the length
                matches on the input, then this variable is assumed to
                be the derivative and not recomputed.  This can save
                significant CPU time on large vectors.
  FULLPLOT - Flag, enable full plotting of all data.
  NOPLOT   - Flag, supress all plots.
  ORDER    - Order of polynomial to fit to background (def=1)
  SILENT   - Flag, if true suppresses all printout to the IDL "console"
  SUBTRACT - Flag, if true - background is subtracted, otherwise background
               is ratioed.
  XUNITS   - String that describes the units of X (default=km)
 OUTPUTS:
 KEYWORD OUTPUT PARAMETERS:
  IDXOUT - point index number for output points.
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  1995/03/28 - Written by Marc W. Buie, Lowell Observatory
  2009/10/02, MWB, removed obsolete Poly_fit arguments