NAME:
   ccdgain
 PURPOSE: (one line)
   Extract and plot CCD gain transfer curve from flat field image data.
 DESCRIPTION:
 CATEGORY:
   CCD data processing
 CALLING SEQUENCE:
   ccdgain,root,start,nframes,calibfile
 INPUTS:
   root     - Root of the image file name (no path, with period).
   start    - first frame number to process
   nframes  - number of frames to process
   calibfile - Calibration file, defailt is CALIBPATH/files.cal
 OPTIONAL INPUT PARAMETERS:
 KEYWORD PARAMETERS:
   CALIBPATH - Path for calibration files.  Default is PATH/calib

   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

   FILKEY = String - FITS keyword to read to get filter code, default = FILPOS
     Note: If you have multiple filter wheels AND you have a set of keywords
           in the form KEYn where n is a single digit number and KEY is a
           static string pattern (eg., FILT_0, FILT_1, etc.), then give this
           keyword as KEY* (ex: FILT_*).  When processed, you will get a
           string back from the concatenation of all the filter strings,
           separated by '+'.

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

   SECTION - 4 element vector which, if provide, defines the region of the
             array dimensions that are used to scale the mean
             of the arrays before combining (.  If combined in this
             manner, the arrays are combined weighted by the means.
                   [x1,x2,y1,y2]
             These coordinates apply to the pixel locations AFTER cropping.
             The default is to use the center 50% of the image but not any
             bigger than 200x200 subsection at the center.

 OUTPUTS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  93/04/03 - Initial conversion to procedure, Marc W. Buie, Lowell Obs.
  96/01/06 - MWB, added support for hardcopy under DOS/Windows
  97/03/15 - MWB, added use of MARKDATA
  2004/05/05, MWB, added some documentation and changed the plot
                     axes to conform to standard practice.  Also, changed
                     the action of the SECTION keyword to match the
                     similar action with SCALE keyword in mkflat.pro
  2006/07/14, MWB, changed to use CCDPROC instead of hardcoded calibration
  2006/07/25, MWB, slight mod to support multiple filter wheels