NAME:
    wfc3model
 PURPOSE: (one line)
    Generate synthetic PSF images for the HST WFC3 UVIS Camera.
 DESCRIPTION:
    A generated PSF is added to the output array.  If the array is not
 defined, it is created with dimensions 4096 by 2048.  Successive calls
 will add objects (PSF's) to the array.
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
    wfc3model, chip, xsrc, ysrc, inten, filter, bmvnum, back, image
 INPUTS:
    chip    : CCD number (1 or 2) for UVIS1 or UVIS2, use 3 for IR channel
 xsrc, ysrc : Position of the PSF in the output array.
    inten   : Intensity of PSF relative to TinyTim output PSF
    filter  : Filter name in the form Fxxx(W,LP,M,N).
    bmvnum  : B-V list value (TinyTim V7.0 values):
                BMVNUM    TYPE       B-V
                1           O5      -0.34
                2           O8F     -0.32
                3           O6      -0.31
                4           B1V     -0.27
                5           B3V     -0.21
                6           B6V     -0.12
                7           A0V     -0.04
                8           A5V      0.12
                9           F6V      0.37
               10           F8V      0.48
               11           G2V      0.56
               12           G5V      0.66
               13           G8V      0.75
               14           K4V      0.92
               15           K7V      1.28
               16           M1.5V    1.45
               17           M3V      1.44
             This can be a scalar to be applied to all objects or it can
              be a vector but the length must match xsrc,ysrc,inten
    back    : Background to be added.

 KEYWORD PARAMETERS:
;  DISTORT   : If set the input x,y are taken to be in an undistorted reference
;              plane. They will be converted to the instrumental (distorted)
;              frame before generating the psf's for the model image, which is 
;              in distorted space as always.
  GRID      : Grid spacing for psf files.
  HSTPATH   : Alternate path for HST PSF's.
  JITTER    : If set contains the gaussian smearing to apply to the image.
                This number set the 1/e half width of the jitter in pixels.
                If not set, no smearing is applied. This calculation is done
                in double precision or float according to the type of image.
                The values passed to the exp function
                         ( e - (((x/j)^2 + y/j)^2/2) )
                are restricted to a maximum based on the computational
                precision to avoid floating point underflow.
              Another option is to provide a jitter kernel externally.  This
                allows being a bit more creative and handling something like
                a smearing funciton.
               
  NEW       : If set, clears the output array to zeros before building the
              PSF image(s).

  OBJRAD    : Radius of object in pixels.  If not set, assumed to be a point
              source.  If set and radius is greater than 0.5, then PSF is
              convolved with a circular function of this radius.  This models
              the object as a Lambert disk, crude but useful for barely
              resolved objects.  Keep in mind that this is absolutely wrong
              for objects that are clearly resolved.
  PSFSIZE   : Size of requested PSF, in arcseconds (default: 5).
  VERBOSE   : If set, prints informational message.
  XSIZE     : size of output array to generate, default full image
  YSIZE     : size of output array to generate, default full image
  XOFFSET   : X offset to apply to input coordinates to convert to absolute
                chip values (used if you only want to compute a sub-array)
  YOFFSET   : Y offset to apply to input coordinates to convert to absolute
                chip values (used if you only want to compute a sub-array)
  Z4        : setting for fourth (focus) Zernicke coefficient (default=0).

 OUTPUTS:
    image  : The image array into which the PSF is placed.
 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:
    The Tiny Tim programs are used, via the procedure HSTPSF, to generate
 a distorted PSF at the nearest grid location to the 
 requested position. (This grid and default spacing are defined in hstpsf).
 MODIFICATION HISTORY:
  Cloned from pc2model.pro,
    Written by Marc W. Buie, Southwest Research Institute, 2009/09/01
  2011/03/22, MWB, added IR camera support, added XSIZE/YSIZE keywords
  2014/07/08, MWB, added new option for input jitter/smearing kernel
  2014/09/23, MWB, reversed jitter kernel for true convolution