NAME:
   synbias
 PURPOSE:
   Create a synthetic CCD bias frame with optional overscan.
 DESCRIPTION:
   Adds a bias level (overscan level) and simulated read noise to an
   arbitrary base image- an optional overscan area contains bias and
   read noise only. The sigma is specified through the read noise and gain, 
   and is normally distributed wih a mean of 0. The output is an
   integer array.
 CATEGORY:
   CCD data processing
 CALLING SEQUENCE:
   synbias,biasbase,biaslevel,gain,rdnoise,seed,biasframe
 INPUTS:
   biasbase = 2-D input array.  This is conceptually a constant, normally
              floating point, with each pixel in units of D/N [counts].
              It represent the bias structure introduced by the electronics.
   biaslevel  integer or float, bias (overscan) level, in units of D/N [counts]
   gain       hypothetical gain [e-/DN] for statistics.
   rdnoise    integer or float, [e-].  Sigma for bias is rdnoise/gain
   seed       for random number generator.

 OPTIONAL INPUT PARAMETERS:

 KEYWORD INPUT PARAMETERS:
   OVERSCAN - integer, number of columns for the explicit overscan area.
              if less than or equal to 0, there is no overscan area generated
              and the dimensions of the output array match biasbase.
   FITSFN  -  Fits file for the output dark frame. The default is to generate 
              no file.
   CRSNUM  -  average number of cosmic ray strikes per ccd area of image.
   CRSMAX  -  maximum D/N for cosmic ray strikes that will be added to the 
              output. Intensity of each crs is drawn uniformly over the
              range [CRSMIN,CRSMAX].
   CRSMIN  -  minimum D/N for cosmic ray strikes that will be added to the 
              output.

 KEYWORD OUTPUT PARAMETERS:
   CRSOUT  -  Output, number of cosmic rays added to the image.

 OUTPUTS:
   biasframe - 2-D array that is the synthetic bias image. It is dimensioned
               n x (m + o) where  n, m are the dimensions of biasbase and
               o is the number of overscan columns created. The overscan 
               area of the bias is biasframe[0:n-1, *] This is an array
               of ints and the units are D/N [counts]. Pixel values are
               calculated in floating point and rounded to nearest integer.
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
   2006 June 28, Written by Peter L. Collins, Lowell Observatory  
   2006/7/10,     PLC  add COSMIC keyword
   2006/7/12,     PLC  CRS keywords- other documentation and argument cleanups.
   2006/07/13,    PLC, add keywords CRSOUT and STARSOUT.
   2006/07/14, MWB, final cleanup and addition to library.