NAME:
   syncalib
 PURPOSE:
   Create a synthetic suite of calibration images: biases, darks and flats.
 DESCRIPTION:
 Creates a set of randomly generated bias, dark and flat images
 as FITS files suitable for input to mkcalib. The number of
 images of each type may be selected.
 CATEGORY:
   CCD data processing
 CALLING SEQUENCE:
   syncalib, root,nbias,ndark,nflat,seed
 INPUTS:
   root    - prefix of file names for calibration, typically YYMMDD- a
              '.' is automatically postpended to this name.
   nbias   - number of bias frames to make.
   ndark   - number of dark frames to make.
   nflat   - number of flat frames to make.
   seed    - random generator seed (which is passed transparently).
 OPTIONAL INPUT PARAMETERS:
 KEYWORD PARAMETERS:
   OVERSCAN -       integer, number of columns for the explicit overscan area.
                    if <=  0, there is no overscan area generated
                    and dimensions of the output images match the base images.
   DDIR     -       String, name of directory where files are to be written. 
   BIASSTARTFRAME - first fits file number for created biases. File names
                    are of the form root.FFF where FFF is the file number.
                    If not specified, file numbers start after the maximum
                    file number of the current population of DDIR.
   DARKSTARTFRAME - first fits file number for created darks. File names
                    are of the form root.FFF where FF is the file number.
                    If not specified, file numbers start after the maximum
                    file number of the current population of DDIR.
   FLATSTARTFRAME - first fits file number for created flats. File names
                    are of the form root.FFF where FF is the file number.
                    If not specified, file numbers start after the maximum
                    file number of the current population of DDIR.
   DARKEXP        - Adopted exposure time in seconds for dark frames- the 
                    default is 600 secs.
   FITSTAG        - Optional tag to add to files names (commonly .fits).  The
                       default is to NOT add such a tag.
   FLATMINEXP     - minimum exposure in seconds for flats- for each flat, an
                    exposure time is adopted as a uniform draw between
                    FLATMINEXP and FLATMAXEXP. The default for 
                    FLATMINEXP is 3 secs.
   FLATMAXEXP     - maximum exposure in seconds for flats- for each flat, an
                    exposure time is adopted as a uniform draw between
                    FLATMINEXP and FLATMAXEXP. The default for 
                    FLATMAXEXP is 25 secs.
   FLATSIGMIN     - minimum sky level in photons for flats- for each flat, a
                    signal level is adopted as a uniform draw between
                    FLATSIGMIN and FLATSIGMAX. The default for 
                    FLATSIGMIN is 8000 photons.
   FLATSIGMAX     - maximum sky level in photons for flats- for each flat, a
                    sky level is adopted as a uniform draw between
                    FLATSIGMIN and FLATSIGMAX. The default for 
                    FLATSIGMAX is 26000 photons.
   GAIN           - gain used for darks and flats. Default is 
                    2.0 photons or electrons per D/N.
   RDNOISE        - Read noise for biases, darks and flats. Default is
                    10 electrons per pixel.
   BIASLEVEL      - Bias (overscan) level for biases, darks, flats and 
                    overscan (in D/N).
   BIASBASE       - Name of FITS file holding the idealized bias image. The
                    default is syn.bias
   DARKBASE       - Name of FITS file holding the idealized dark image. The
                    default is syn.dark. If this does not exist AND 
                    ndark is 0 AND DARKEXP is at a default value, a
                    pattern of all zeros is generated on the fly.
   FLATBASE       - Name of FITS file holding the idealized flat image. The
                    default is syn.flat
   CLEANDATA      - Flag, if set, there will be no external blemishes added to
                    the calibration files. Otherwise, stars are added to 
                    flats and cosmic rays to all images except overscan areas.
   COSMICCOUNT    - Mean number of cosmic ray striks added to images.
   STARCOUNT      - Mean  number of stars added to flat images,
   VERBOSE  -       Flag, if set, will enable 1 line summary for each frame.
              
 OUTPUTS:
  All output is confined to files. Images are int arrays with a minimum
  FITS header including EXPTIME for darks and flats.
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 All frame numbers must be in the range 000-999.
 PROCEDURE:
 MODIFICATION HISTORY:
   2006/07/10, Written by Peter L. Collins, Lowell Observatory  
   2006/07/13, PLC, add VERBOSE and fix docunent header.
   2006/07/14, MWB, added FITSTAG keyword and added to library.