NAME:
    nicmodel
 PURPOSE: (one line)
    Generate synthetic PSF images for the HST NICMOS Camera
 DESCRIPTION:
    A generated PSF is added to the output array.  If the array is not
 defined, it is created with dimensions 256 by 256.  Successive calls
 will add objects (PSF's) to the array.
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
    nicmodel, camera, xsrc, ysrc, inten, filter, bmvnum, back, image
 INPUTS:
    camera  : Camera number (1, 2, or 3)
 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 V6.2 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
    back    : Background to be added.

 KEYWORD PARAMETERS:
  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 is in units of 1/e half width.  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.
               
  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.
  PSFSIZE   : Size of requested PSF, in arcseconds (default: 5).
  SAMPFACT  : Sample factor (default: 6).
  VERBOSE   : If set, prints informational message.
  Z4        : setting for fourth (focus) Zernicke coefficient. If not set,
              the default value for the WFPC2 instrument generated by HSTPSF 
              will be used.

 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 (usually) 2X (7.5 micron spacing) PSF at the nearest grid location to the 
 requested position. (This grid and default spacing are defined in hstpsf).
    From the interpolated maximum returned by hstpsf, shift amounts for x
 and y are computed.
    The PSF is shifted by these amounts and then compressed to a 1X
 (15 micron spacing) PSF.
    Finally, the resulting PSF is multiplied by the intensity parameter and
 added into the output array.
    Calls external procedures BADPAR, BOXM, HSTPSF, and SSHIFT2D.
 MODIFICATION HISTORY:
      cloned from pc2model.pro
  2010/08/25, Written by Marc W. Buie, Southwest Research Institute