

2008.05.17

  pmFPAfiles used in ppSim:

  PPSIM.INPUT : an input image loaded by ppSim; the simulated features
  		may be added to this image.  In fact, the features are
  		generated in the output image, and the two images are
  		added (as images) together.

  PPSIM.OUTPUT  : the output image.  this file is used for the main
  		  ppSimLoop function

  PPSIM.CHIP    : chip-mosaiced version of the output image.  only
  		  generated if photometry is requested.  Is this
  		  actually used as an output image?

  PPSIM.REAL.SOURCES : real sources loaded by PPSIM.  these sources
  		       are subtracted from the image before testing
  		       for the detectability of the fake sources and
  		       before measuring the flux of fake or forced
  		       soures.  They should be the sources measured in
  		       a previous psphot run, though any input list
  		       could be used.  Results are very ill-defined if
  		       the sources do not correspond to actual image
  		       sources!

  PSPHOT.PSF.LOAD : input PSF model used to measure the input sources

  PPSIM.SOURCES : output fake sources (injected fake sources with real values) 
  PPSIM.FAKE.SOURCES : output fake photometry (measured photometry for all fake sources)
  PPSIM.FORCE.SOURCES : output force photometry
  
  ** used within psphot functions:
  PSPHOT.BACKMDL : model background generated by psphotModelBackground
  PSPHOT.BACKMDL.STDEV : model background error generated by psphotModelBackground
  PSPHOT.BACKGND : full-scale model background generated by psphotSubtractBackground
  PSPHOT.BACKSUB : background-subtracted image

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

