Index: /branches/eam_branch_20070817/ppSim/notes.txt
===================================================================
--- /branches/eam_branch_20070817/ppSim/notes.txt	(revision 14641)
+++ /branches/eam_branch_20070817/ppSim/notes.txt	(revision 14642)
@@ -1,2 +1,19 @@
+
+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
@@ -7,5 +24,5 @@
 * add generated stars to an output file (pmSource list?)
 * make star source an option (random / dvo database)
-* generate PSF from PSF model
+* add the gain to the metadata
 
 ppSimLoop:
Index: /branches/eam_branch_20070817/ppSim/src/ppSimCreate.c
===================================================================
--- /branches/eam_branch_20070817/ppSim/src/ppSimCreate.c	(revision 14641)
+++ /branches/eam_branch_20070817/ppSim/src/ppSimCreate.c	(revision 14642)
@@ -48,4 +48,13 @@
     }
 
+    // XXX only invoke this code for OBJECT types of images
+    // PPSIM.SOURCES carries the constructed, fake sources with their true parameters
+    pmFPAfile *simSources = pmFPAfileDefineOutput (config, file->fpa, "PPSIM.SOURCES");
+    if (!simSources) {
+        psError(PS_ERR_UNKNOWN, false, "Cannot find a rule for PPSIM.SOURCES");
+        return false;
+    }
+    simSources->save = true;
+
     pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level at which PHU goes
 
Index: /branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c
===================================================================
--- /branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c	(revision 14641)
+++ /branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c	(revision 14642)
@@ -8,4 +8,7 @@
     assert (readout);
     
+    // XXX is this needed?
+    // pmFPAfile *simSources = psMetadataLookupPtr(NULL, config->files, "PPSIM.SOURCES"); // Output sources
+
     pmCell *cell = readout->parent;
     pmChip *chip = cell->parent;
@@ -50,4 +53,6 @@
     int dY = PM_CELL_TO_CHIP (0.0, y0Cell, yParityCell, binning);
 
+    psArray *sources = psArrayAllocEmpty (stars->n);
+
     // add sources to the readout image & weight
     for (long i = 0; i < stars->n; i++) {
@@ -87,8 +92,11 @@
 	// insert the source flux in the image
 	pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
+	psArrayAdd (sources, 100,source);
     }
 
-    // XXX add the source array to the readout analysis
+    // NOTE: readout must be part of the pmFPAfile named "PPSIM.OUTPUT"
+    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);
 
+    // XXX many leaks in here, i think 
     return true;
 }
Index: /branches/eam_branch_20070817/ppSim/src/ppSimLoop.c
===================================================================
--- /branches/eam_branch_20070817/ppSim/src/ppSimLoop.c	(revision 14641)
+++ /branches/eam_branch_20070817/ppSim/src/ppSimLoop.c	(revision 14642)
@@ -28,4 +28,7 @@
 
     pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA
+
+    // XXX if we include the psphot analysis, we will need to activate the correct pmFPAfiles
+    // at the correct times.  ppSim operates on PPSIM.OUTPUT and PPSIM.SOURCES
 
     // load any needed files (eg, input image, PSF)
