NAME:
  gradedark
 PURPOSE:   (one line only)
  Automatic quality grading of a set of CCD dark images against a superdark
 DESCRIPTION:
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
  gradedark,cube,dark,grade
 INPUTS:
  cube - 3-d cube of original dark images, if you need to subtract overscan
              and crop, this should be done prior to building the cube
              This should already have the bias removed and converted to
              ADU/second.
  dark - 2-d image which is the superdark frame
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  MAXBAD   - Maximum number of bad rows allowed per frame before flagging
               the cube as bad.  (default=25)
 OUTPUTS:
  grade - This is the number of images that fail the test of being consistent
             with the ensemble of images.
 KEYWORD OUTPUT PARAMETERS:
  ROWTEST - array with a length equal to the number of rows in the image
             This contains the number of frames that fail the goodness test
             for each row.   This metric is rather hard to use but provided
             for completeness.
  FILETEST - array with a length equal to the number of images.  This array
               records the number of rows in each image that fail the
               goodness test.
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Marc W. Buie, Southwest Research Institute, 2018/07/24
    cloned from gradebias.  Identical except for name but provided in case
    there are different grading methods for darks some day.