NAME: 
  mkdark
 PURPOSE: 
  Collect and combine CCD dark frames into a superdark frame
 DESCRIPTION:

  The files are assumed to be named as 'root'NNN where 'root' is the
  root of the file name that you supply and NNN is a three digit number.
  If your file name has an imbedded '.' then add it to the root.

  The specified range of files are all read in from FITS files.  Then each
  image has the overscan mean subtracted (if desired), cropped (as indicated),
  and then the input bias image is subtracted.  These images are then
  normalized to counts per second and then averaged.  The averaging
  is done with AVGCLIP.PRO which does a robust average of the image
  stack so that cosmic rays or other transient image defects are eliminated.

  When done, the resulting dark image is returned to the caller and the image
  is saved to a FITS file with the specified output filename.

 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
  mkdark,root,outsuf,start,nframes,bias,dark
 INPUTS:
  root    - Root of the file name (you must include . in the name).
  outsuf  - The suffix of the final output file.
  start   - First frame number to read (integer or long).
               Start can also be a vector of explicit frame numbers to load.
               In this case, nframes need not be specified and in fact will
               be ignored.
               Additionally, start can also be a string array containing the
               file names of all files to be read.  In this case, set nframes
               to 0 or someother innocuous integer.  Exclude is treated
               differently.  In this case, exclude is a vector of the same
               length as start and is 0 if the file is to be used, 1 if not.
  nframes - Number of frames to average.
  bias    - Name of bias frame image to subtract from each raw dark.
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:

   CROP     = region of original image to save, default=no cropping.
                 [x1,x2,y1,y2]

   DDIR    - Path to the raw data, default = ''

   EXCLUDE - Optional vector of image numbers that should be excluded from
                average.  Default is to include all frames.

   EXPKEY = String - FITS keyword to read to get exposure time, default = EXPTIME

   OVERSCAN = column overscan region to use for frame bias level,
                 default=no overscan subtraction.

   RDNOISE  - Read noise of CCD, e-/DN, default=10

 OUTPUTS:
  dark - Final robust averaged dark image scaled to counts per second.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  95/03/09 - Initial crude version written, Marc W. Buie, Lowell Observatory
  95/08/30, MWB, added OVERSCAN and CROP keywords
  95/11/22, MWB, add EXCLUDE keyword
  99/06/10, MWB, added EXPTIME keyword and added documentation.
  2001/02/23, MWB, added option to provide input file list.  Also, added
                     functions to make it consistent with mkbais,mkflat.
  2005/03/10, MWB, added DDIR keyword, converted bias input to string
  2006/07/14, MWB, added RDNOISE keyword