NAME:
  gradeflat
 PURPOSE:   (one line only)
  Automatic quality grading of a set of CCD flat images against a superflat
 DESCRIPTION:
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
  gradeflat,cube,flat,grade,fail
 INPUTS:
  cube - 3-d cube of original flat images, if you need to subtract overscan
              and crop, this should be done prior to building the cube
  flat - 2-d image which is the superflat frame
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
 OUTPUTS:
  grade - This is the grade of this cube/flat pair.  This is related to
             a unit of standard deviation.  A bad set of data will have
             a large value, typically much greater than 3.   A good set of
             data will be comfortably less than 3.
  fail  - This is the number of frames that fail the test of being consistent
             with the ensemble of frames.  This number will be somewhere
             between 0 and the number of frames in the cube.  Don't expect
             this number to be zero but it should be small.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
  This tool is ok but could be better.
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Marc W. Buie, Southwest Research Institute, 2015/04/26