
2008.05.15

  For fake and force photometry, we need to load the known existing
  sources, then perform a complete linear fit solution to the complete
  set of both real (known) sources plus the fake and/or forced
  photometry positions (as PSFs).  The fake and forced photometry
  positions need to be measured independently.  This provides the real
  photometry for these sources ** in the presence of the other real
  sources **.  In order to test the detectability of the fake sources
  (or the forced sources, for that matter), we need to generate the
  smoothed detection image, and determine the peak value at the
  positions of the sources.  

  ppSimPhotomReadout outline:

  * we have three source lists (loaded before the function is called):
    * realSources : these are loaded from a CMF-style file (or equiv)
    * fakeSources : these are defined internally, and need a link from
		    the input fake source to the measured fake source
    * forceSources : these are loaded from a DVO database via getstar

  * we require a supplied PSF

  * need to subtract the background (before or after subtracting the
    sources?)

  * subtract the real sources
  * model the background
  * build the detection image
  * measure the detectability of the fake and force sources
  * replace the real sources

  * merge real + fake sources
  * linear fit to merged source list
  * replace the sources (make 'no-subtract' option?)

  * merge real + forced sources
  * linear fit to merged source list
  * replace the sources (make 'no-subtract' option?)



ppSim development work still needed:

* save sources in output files
* load input image

* optionally apply detrend data (bias, dark, etc).  when adding data
  to a loaded image, we only need to inject fake stars.

* examine the range of star fluxes.  (too many are being generated).  
* check the overlap between the real and random star fluxes

* generate stars with / without known exposure correction (ie, stars
  could be generated with known fluxes or know magnitudes)

* generate galaxies (objects with random values for major, minor, theta)
* generate convolved galaxies

* should not have to supply ZP, Seeing, PA, Scale on command line for all ppSim runs
* DVO.CATDIR path://SIMTEST is not being interpolated?
* -D PSASTRO:DVO.CATDIR is not being interpretted?

* fake stars do not have random magnitudes?
* add generated stars to an output file (pmSource list?)
* make star source an option (random / dvo database)
* add the gain to the metadata

ppSimLoop:

  * load catalogs stars (ra, dec, mag, x, y)
  * generate random stars (ra, dec, mag, x, y)
  * loop over chip,cell,readout
  ** generate output images (signal, variance)
  ** add the bias
  ** add the dark
  ** add the sky signal 
  ** add the stars (modified by the flat, shutter)
  ** add the galaxies (modified by the flat, shutter)
  ** add the poisson noise
  ** add the overscan + readnoise
  ** save the stars
  ** save the galaxies

  ** update the concept info
  ** update the header wcs info
  ** write out the image data

