NAME:
   clean
 PURPOSE: 
   Remove a PSF from an image via the ``clean'' algorithm.
 DESCRIPTION:
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
   clean,image,psf,xloc,yloc,maxdist,iters,new_image,resid $
       DISPLAY=display,VERBOSE=verbose
 INPUTS:
   image     - Original source image to be cleaned.
   psf       - PSF image at same sampling resolution as image.
   xloc      - X location of "object"
   yloc      - Y location of "object"
   maxdist   - Maximum distance from xyloc to look for local max.
   iters     - Number of cleaning iterations to perform.
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
   CROSS     - If set to a number greater than or equal to 0, the peak at
               each iteration is found by using a cross-correlation
               of the psf against the image rather than just using raw DN.
               If 0, then the full size of the psf is used.  If 1 or greater,
               a sub-region from the center that is 2*CROSS+1 pixels square
               is used as the convolution kernal.
   DISPLAY   - Display intermediate results, if 0, this is suppressed,
                 if non-zero, this is the interval for the display, that is,
                 DISPLAY=10 would cause a display every 10th iteration.
   GAIN      - "Gain" of the clean process, the default value is 0.05 and
                 is the scaled amount of the psf removed at each step.
   VERBOSE   - Verbose printout of intermediate steps to the screen.  Just
                 like display, VERBOSE=0 suppresses output, VERBOSE=n will
                 print information every nth iteration.
 OUTPUTS:
   new_image - Clean-ed image result.
   resid     - Remains of the original image after clean-ed image is removed.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
   1/26/94, written by Marc W. Buie, Lowell Observatory, algorithmic insight
              graciously provided by Tod Lauer (NOAO, Tucson).
   2/25/94, MWB, added GAIN and CROSS keywords.
   5/19/94, MWB, changed psf normalization from peak to total.  Should
              now be strictly flux conserving.
   5/21/94, MWB, Changed CROSS to allow for only a portion of psf for
              convolution.