Index: /branches/eam_branches/ipp-20101205/ppSim/src/Makefile.am
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/Makefile.am	(revision 30150)
+++ /branches/eam_branches/ipp-20101205/ppSim/src/Makefile.am	(revision 30151)
@@ -47,8 +47,4 @@
 	ppSimUtils.c              \
 	ppSimLoop.c		  \
-	ppSimLoadSpots.c	  \
-	ppSimPhotom.c		  \
-	ppSimPhotomFiles.c	  \
-	ppSimLoadForceSources.c	  \
 	ppSimMergeReadouts.c	  \
 	ppSimDetections.c	  \
@@ -59,8 +55,4 @@
 	ppSimBadCTE.c             \
 	ppSimVersion.c
-
-# these functions have been broken by the API change in psphot (Jan 2010)
-#	ppSimPhotomReadoutFake.c  
-#	ppSimPhotomReadoutForce.c 
 
 ppSimSequence_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS)
Index: /branches/eam_branches/ipp-20101205/ppSim/src/ppSimCreate.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimCreate.c	(revision 30150)
+++ /branches/eam_branches/ipp-20101205/ppSim/src/ppSimCreate.c	(revision 30151)
@@ -132,65 +132,19 @@
     bool doPhotom = psMetadataLookupBool(&status, recipe, "PHOTOM"); // Density of fakes
     if (doPhotom) {
-
-        // XXX at the moment, we can perform photometry on the fake sources and the forced
-        // photometry positions, but not one or the other.  Also, we only support photometry in
-        // the context of an image previously analysed by psphot.  Add support for:
-        // * photometry of a pure fake image (requires peak detection and psf creation)
-        // * photometry of forced source positions without fake image (this might work, it just
-        // requires not generating any fake features).
-
-        if (!input) {
-            psError(PS_ERR_UNKNOWN, false, "input image not found; currently required for photometry");
-            return NULL;
-        }
-
-        // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?)
-        pmFPAfile *fakeImage = pmFPAfileDefineChipMosaic(config, output->fpa, "PPSIM.FAKE.CHIP");
-        if (!fakeImage) {
-            psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FAKE.CHIP"));
-            psFree(fpa);
-            return NULL;
-        }
-        if (fakeImage->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PPSIM.FAKE.CHIP is not of type IMAGE");
-            psFree(fpa);
-            return NULL;
-        }
-
-        // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?)
-        pmFPAfile *forceImage = NULL;
-        if (input) {
-            forceImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSIM.FORCE.CHIP");
-            if (!forceImage) {
-                psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.FORCE.CHIP"));
-                psFree(fpa);
-                return NULL;
-            }
-            if (forceImage->type != PM_FPA_FILE_IMAGE) {
-                psError(PS_ERR_IO, true, "PPSIM.FORCE.CHIP is not of type IMAGE");
-                psFree(fpa);
-                return NULL;
-            }
-        }
-
-        // define associated psphot input/output files
-        if (!ppSimPhotomFiles (config, fakeImage, forceImage)) {
-            psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
-            psFree(fpa);
-            return NULL;
-        }
-    } else {
-        // have we supplied a psf model?  this happens in ppSimPhotomFiles if we request a photometry
-        // analysis.  however, even if we do not, a psf model may be used to generate the fake
-        // sources.
-        if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
-            // tie the psf file to the chipMosaic
-            pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
-            if (!status) {
-                psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
-                psFree(fpa);
-                return NULL;
-            }
-        }
+	psError(PS_ERR_UNKNOWN, false, "in-line photometry in ppSim had been deprecated");
+	return NULL;
+    }
+
+    // have we supplied a psf model?  this happens in ppSimPhotomFiles if we request a photometry
+    // analysis.  however, even if we do not, a psf model may be used to generate the fake
+    // sources.
+    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
+	// tie the psf file to the chipMosaic
+	pmFPAfileBindFromArgs(&status, output, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
+	if (!status) {
+	    psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
+	    psFree(fpa);
+	    return NULL;
+	}
     }
 
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimLoadForceSources.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimLoadForceSources.c	(revision 30150)
+++ 	(revision )
@@ -1,113 +1,0 @@
-# include "ppSim.h"
-
-// Reset a pointer: free and set to NULL
-#define RESET(PTR) \
-    psFree(PTR); \
-    PTR = NULL;
-
-psArray *ppSimLoadForceSources(pmConfig *config, const pmFPAview *view) {
-
-    bool status;
-
-    pmFPAfile *outFile = psMetadataLookupPtr(NULL, config->files, "PPSIM.OUTPUT");
-    psAssert(outFile, "missing PPSIM.OUTPUT");
-    psAssert(outFile->fpa, "missing fpr for PPSIM.OUTPUT");
-
-    pmChip *outChip = pmFPAviewThisChip (view, outFile->fpa);
-    pmPSF *psf = psMetadataLookupPtr (&status, outChip->analysis, "PSPHOT.PSF");
-    assert (psf);
-
-    psArray *spots = psMetadataLookupPtr(&status, outFile->fpa->analysis, "FORCED.SPOTS");
-    PS_ASSERT_PTR_NON_NULL (spots, NULL);
-
-    // in this program, we are looping over the output image, rather than the input as in ppImage
-    pmFPAfile *srcFile = psMetadataLookupPtr(NULL, config->files, "PPSIM.REAL.SOURCES");
-    psAssert(srcFile, "missing PPSIM.REAL.SOURCES");
-
-    // select the fpa and chip from PPSIM.REAL.SOURCES, which carries the astrometry in the headers
-    pmFPA     *fpa     = srcFile->fpa;
-    pmChip    *chip    = pmFPAviewThisChip (view, fpa);
-
-    // we use the readout for the PPSIM.FORCE.CHIP, which contains the chip-mosaicked image(s)
-    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.CHIP");
-
-    // XXX we should have only one cell and readout per chip, right?
-
-    // read WCS from existing output from psphot & psastro
-    // XXX can we be more flexible?  ie, use the header of PPSIM.FORCE.CHIP?
-    bool bilevelAstrometry = false;
-    status = psastroAstromGuessSetFPA (fpa, &bilevelAstrometry);
-    psAssert (status, "failed to set astrometry");
-
-    // the pixel scale is only used to set the focal-plane coordinate system
-    // setting this value to 1 makes this system have the units of pixels
-    float pixelScale = 1.0;
-    status = psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry);
-    psAssert (status, "failed to set astrometry");
-
-    float minX = 0.0;
-    float maxX = readout->image->numCols;
-    float minY = 0.0;
-    float maxY = readout->image->numRows;
-
-    // the sources is a subset within range of this chip
-    psArray *sources = psArrayAllocEmpty (100);
-
-    // Select the spots within range of this readout.  Project the spots to this chip
-    for (int i = 0; i < spots->n; i++) {
-        pmAstromObj *obj = spots->data[i];
-
-        psProject (obj->TP, obj->sky, fpa->toSky);
-        psPlaneTransformApply (obj->FP, fpa->fromTPA, obj->TP);
-        psPlaneTransformApply (obj->chip, chip->fromFPA, obj->FP);
-
-        // limit the X,Y range of the objs to the selected chip
-        if (obj->chip->x < minX) continue;
-        if (obj->chip->x > maxX) continue;
-        if (obj->chip->y < minY) continue;
-        if (obj->chip->y > maxY) continue;
-
-        // convert the pmAstromObj to pmSource
-
-        // instantiate a model for the PSF at this location, Io = 1.0
-        pmModel *model = pmModelFromPSFforXY (psf, obj->chip->x, obj->chip->y, 1.0);
-
-        // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
-        // XXX use a fixed radius??
-        // float radius = model->modelRadius (model->params, roughNoise);
-        // radius = PS_MAX (radius, 1.0);
-        float radius = 5.0;
-
-        // construct a source, with model flux pixels set, based on the model
-        pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
-
-        // XXX set the mag & err values (should this be done in pmSourceFromModel?)
-        // XXX i should be applying the gain and the correct effective area
-        // psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
-        // psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
-
-        // these are not really needed since we will be fitting for them
-        source->psfMag = NAN;
-        source->errMag = NAN;
-
-        // insert the source flux in the image
-        // XXX not sure the offset is really 0,0
-        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, 0.0, 0.0);
-        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, 0.0, 0.0);
-
-        // Blow away the image parts of the source, which makes the memory explode
-        RESET(source->pixels);
-        RESET(source->variance);
-        RESET(source->maskObj);
-        RESET(source->maskView);
-        RESET(source->modelFlux);
-        RESET(source->psfImage);
-        RESET(source->blends);
-
-        psArrayAdd (sources, 100, source);
-        psFree(source);                 // Drop local reference
-    }
-    psTrace ("psastro", 4, "Added %ld sources\n", sources->n);
-
-    return sources;
-}
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimLoadSpots.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimLoadSpots.c	(revision 30150)
+++ 	(revision )
@@ -1,71 +1,0 @@
-# include "ppSim.h"
-
-// Load the relevant forced-photometry positions for this field.  This function does not determine
-// the pixel coordinates, merely the celestial coordinates for sources in the general vicinity.  The
-// sources are saved on the fpa->analysis metadata as FORCED.SPOTS.  We always create an entry; it
-// will be empty if no sources were selected or forced photometry is not desired.
-bool ppSimLoadSpots (pmFPA *fpa, pmConfig *config) {
-
-    bool status;
-
-
-    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
-
-    bool forcedPhot = psMetadataLookupBool(&status, recipe, "FORCED.PHOT"); // Density of fakes
-    if (!forcedPhot) {
-	psArray *spots = psArrayAllocEmpty (1);
-	psMetadataAddArray (fpa->analysis, PS_LIST_TAIL, "FORCED.SPOTS", PS_META_REPLACE, "forced photometry positions", spots);
-	psFree (spots); // free the extra (local) reference; a copy remains on fpa->analysis
-	return true;
-    }
-
-    // We read the catalogue stars using psastroLoadRefstars
-    psMetadata *astroRecipe = psMetadataLookupPtr(NULL, config->recipes, PSASTRO_RECIPE);
-    if (!astroRecipe) {
-        psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE);
-        return false;
-    }
-
-    float ra0     = psMetadataLookupF32(NULL, recipe, "RA");        // Boresight RA (radians)
-    float dec0    = psMetadataLookupF32(NULL, recipe, "DEC");       // Boresight Dec (radians)
-    float scale   = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
-
-    if (isnan(ra0) || isnan(dec0)) {
-        psError(PS_ERR_UNKNOWN, false, "image boresite coords not defined.");
-	return false;
-    }
-
-    char *catdir = psMetadataLookupStr(NULL, recipe, "FORCED.CATDIR");
-
-    // Size of FPA
-    psRegion *bounds = ppSimFPABounds (fpa);
-    float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale;
-    psFree(bounds);
-
-    // modify the PSASTRO recipe to use the values desired for FORCED.PHOT.  we can use a view on
-    // the PSASTRO recipe because we are not calling psastro elsewhere in this program.  XXX need to
-    // use the WCS to define the overlap region
-    psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "PSASTRO.CATDIR",  PS_META_REPLACE, "", catdir);
-    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_META_REPLACE, "", ra0 - radius);
-    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "RA_MAX",  PS_META_REPLACE, "", ra0 + radius);
-    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", dec0 - radius);
-    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", dec0 + radius);
-    
-    // tell psastroLoadRefstars to ignore photcode and maglim
-    psMetadataAddStr(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.PHOTCODE",  PS_META_REPLACE, "", "NONE");
-    psMetadataAddF32(astroRecipe, PS_LIST_TAIL, "DVO.GETSTAR.MAG.MAX",  PS_META_REPLACE, "", NAN);
-
-    // load refstars from the catalog
-    psArray *spots = psastroLoadRefstars(config, "PSASTRO.INPUT");
-    if (!spots || spots->n == 0) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars.");
-        psFree(spots);
-        return false;
-    }
-    psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", spots->n);
-
-    psMetadataAddArray (fpa->analysis, PS_LIST_TAIL, "FORCED.SPOTS", PS_META_REPLACE, "forced photometry positions", spots);
-    psFree (spots); // free the extra (local) reference; a copy remains on fpa->analysis
-
-    return true;
-}
Index: /branches/eam_branches/ipp-20101205/ppSim/src/ppSimLoop.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimLoop.c	(revision 30150)
+++ /branches/eam_branches/ipp-20101205/ppSim/src/ppSimLoop.c	(revision 30151)
@@ -42,5 +42,5 @@
     if (type == PPSIM_TYPE_OBJECT) {
         // Load forced-photometry positions (these are placed on fpa->analysis for use in ppSimPhotomReadout)
-        if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
+        // if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
 
         // Load catalogue stars
@@ -58,7 +58,4 @@
 
     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)
@@ -209,5 +206,5 @@
 
         // we perform photometry on the readouts of this chip in the output
-        if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
+        // if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
 
         if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotom.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotom.c	(revision 30150)
+++ 	(revision )
@@ -1,65 +1,0 @@
-# include "ppSim.h"
-
-// In this function, we perform the psphot analysis routine for the chip-mosaicked images
-bool ppSimPhotom (pmConfig *config, pmFPAview *view) {
-
-    bool status;
-    pmCell *cell;
-    pmReadout *readout;
-
-    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
-
-    bool doPhotom = psMetadataLookupBool(&status, recipe, "PHOTOM"); // Density of fakes
-    if (!doPhotom) return true;
-    
-    psphotInit ();
-
-    psImageMaskType blankMask = 1;		// XXX not sure what this should be set to...
-    ppSimMosaicChip(config, blankMask, view, "PPSIM.FORCE.CHIP", "PPSIM.INPUT");
-    ppSimMosaicChip(config, blankMask, view, "PPSIM.FAKE.CHIP", "PPSIM.OUTPUT");
-
-    // use PPSIM.FAKE.CHIP as the base since it is guaranteed to exist (derived from PPSIM.OUTPUT)
-    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPSIM.FAKE.CHIP");
-    if (!status) {
-        psError(PSPHOT_ERR_CONFIG, false, "PPSIM.FAKE.CHIP I/O file is not defined");
-        return false;
-    }
-
-    // XXX If we want to be able to write out both the positive and residual images, we will
-    // need to define an additional pmFPAfile container, and then make a copy as is done for
-    // PPIMAGE.CHIP -> PSPHOT.INPUT in ppImage.  At the moment, PPSIM.CHIP will write out the
-    // mosaicked image with the sources subtracted.
-
-    // XXX if input -> PSPHOT.INPUT, which is tied to PPSIM.CHIP with pmFPAfileDefineFromFile,
-    // then the following code creates the chip copy:
-    // pmChip *oldChip = pmFPAviewThisChip (view, input->src);
-    // pmChip *newChip = pmFPAviewThisChip (view, input->fpa);
-    // pmChipCopy (newChip, oldChip);
-
-    // iterate over the cells and readout for this chip
-    while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
-        psLogMsg ("ppSimPhotom", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
-        if (! cell->process || ! cell->file_exists) { continue; }
-
-        // process each of the readouts
-        while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
-            if (! readout->data_exists) { continue; }
-
-// these are broken by the Jan 2010 API changes to psphot
-#if 0
-            // run the actual photometry analysis
-            if (!ppSimPhotomReadoutFake (config, view)) {
-                psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
-                return false;
-            }
-            if (!ppSimPhotomReadoutForce (config, view)) {
-                psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
-                return false;
-            }
-	    // ppSimDetectionLimits (config, view);
-#endif
-        }
-    }
-
-    return true;
-}
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomFiles.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomFiles.c	(revision 30150)
+++ 	(revision )
@@ -1,83 +1,0 @@
-# include "ppSim.h"
-
-// define the needed / desired I/O files
-bool ppSimPhotomFiles (pmConfig *config, pmFPAfile *fakeFile, pmFPAfile *forceFile) {
-
-    bool status = false;
-
-    // select recipe options supplied on command line
-    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
-
-    // optionally save the background model (small FITS image)
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
-        int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
-        int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
-        pmFPAfile *output = pmFPAfileDefineFromFile (config, fakeFile, DX, DY, "PSPHOT.BACKMDL");
-        if (!output) {
-            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
-            return false;
-        }
-        output->save = true;
-    }
-    // optionally save the background model's standard deviation (small FITS image)
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL.STDEV")) {
-        int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
-        int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
-        pmFPAfile *output = pmFPAfileDefineFromFile (config, fakeFile, DX, DY, "PSPHOT.BACKMDL.STDEV");
-        if (!output) {
-            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL.STDEV");
-            return false;
-        }
-        output->save = true;
-    }
-    // optionally save the full background image
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
-        pmFPAfile *output = pmFPAfileDefineFromFile (config, fakeFile,  1,  1, "PSPHOT.BACKGND");
-        if (!output) {
-            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND");
-            return false;
-        }
-        output->save = true;
-    }
-    // optionally save the background-subtracted image
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
-        pmFPAfile *output = pmFPAfileDefineFromFile (config, fakeFile,  1,  1, "PSPHOT.BACKSUB");
-        if (!output) {
-            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKSUB");
-            return false;
-        }
-        output->save = true;
-    }
-
-    // the input sources are required for sensible measurements of the fake or force sources
-    pmFPAfile *cmffile = pmFPAfileDefineFromArgs (&status, config, "PPSIM.REAL.SOURCES", "INPUT.SOURCES");
-    if (!cmffile) {
-      psError(PS_ERR_UNKNOWN, false, "input sources not found; required for photometry (or error with PPSIM.REAL.SOURCES filerule)");
-      return false;
-    }
-
-    // the fake sources are carried on the fakeFile->fpa structures (PPSIM.FAKE.CHIP)
-    pmFPAfile *outsources = pmFPAfileDefineOutput (config, fakeFile->fpa, "PPSIM.FAKE.SOURCES");
-    if (!outsources) {
-        psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PPSIM.FAKE.SOURCES");
-        return false;
-    }
-    outsources->save = true;
-
-    // the forced sources are carried on the forceFile->fpa structures (PPSIM.FORCE.CHIP)
-    pmFPAfile *outforced = pmFPAfileDefineOutput (config, forceFile->fpa, "PPSIM.FORCE.SOURCES");
-    if (!outforced) {
-        psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PPSIM.FORCE.SOURCES");
-        return false;
-    }
-    outforced->save = true;
-
-    // we bind the psffile to the chip-mosaicked image so we have a reference to the image 
-    pmFPAfile *psffile = pmFPAfileBindFromArgs(&status, fakeFile, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
-    if (!psffile) {
-      psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.PSF.LOAD");
-      return false;
-    }
-
-    return true;
-}
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadout.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadout.c	(revision 30150)
+++ 	(revision )
@@ -1,202 +1,0 @@
-# include "ppSim.h"
-
-psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) {
-
-    pmReadout *readout = pmFPAfileThisReadout (config->files, view, filename);
-    PS_ASSERT_PTR_NON_NULL (readout, NULL);
-
-    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
-    psAssert (detections, "missing detections?");
-
-    psArray *sources = detections->allSources;
-    return sources;
-}
-
-bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe) {
-
-    bool status;
-
-    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
-    if (!status) return NULL;
-
-    for (int i = 0; i < sources->n; i++) {
-	pmSource *source = sources->data[i];
-
-        // allocate image, weight, mask arrays for each peak (square of radius OUTER)
-        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
-    }
-    return true;
-}
-
-bool ppSimPhotomReadout(pmConfig *config, const pmFPAview *view) {
-
-    psTimerStart ("psphotReadout");
-
-    // select the current recipe
-    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
-    if (!recipe) {
-        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
-        return false;
-    }
-
-# if 0    
-    // set the photcode for this image
-    if (!psphotAddPhotcodeReadout (recipe, config, view, "PPSIM.CHIP", 0)) {
-        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
-        return false;
-    }
-# endif
-
-    // find the currently selected readout. 
-    // we always perform photometry on the mosaiced chip
-    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.CHIP");
-    PS_ASSERT_PTR_NON_NULL (readout, false);
-
-    // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile
-    psArray *realSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES");
-    PS_ASSERT_PTR_NON_NULL (realSources, false);
-
-    // the newly injected fake sources are saved on the PPSIM.OUTPUT pmFPAfile
-    psArray *injectedSources = ppSimSelectSources (config, view, "PPSIM.OUTPUT");
-    PS_ASSERT_PTR_NON_NULL (injectedSources, false);
-
-    // XXX need to define the source pixels
-    ppSimDefinePixels (realSources, readout, recipe);
-    ppSimDefinePixels (injectedSources, readout, recipe);
-
-    // make a copy of the fake-source parameters so these can be saved independently from the
-    // measured fake-source parameters
-    psArray *fakeSources = psArrayAlloc (injectedSources->n);
-    for (int i = 0; i < injectedSources->n; i++) {
-      fakeSources->data[i] = pmSourceCopyData (injectedSources->data[i]);
-    }
-
-    // load the forced source lists
-    psArray *forceSources = ppSimLoadForceSources (config, view);
-    psAssert (forceSources, "failed to load force photometry sources");
-
-    // Generate the mask and weight images, including the user-defined analysis region of interest
-    psphotSetMaskAndWeight (config, view, recipe);
-
-    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
-    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile 
-    pmPSF *psf = psphotLoadPSF (config, view, recipe);
-    assert (psf);
-
-    // remove all sources 
-    psphotRemoveAllSources (realSources, recipe);
-
-    // generate a background model (median, smoothed image)
-    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.CHIP", 0)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.CHIP", 0)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-
-    // add noise for real (subtracted) objects
-    psphotAddNoise (readout, realSources, recipe);
-
-    // XXX fake sources should measure peak->x,y, force sources should not
-    psImageMaskType maskVal = 0xff; 
-    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
-    ppSimDetections (significance, recipe, fakeSources);
-    ppSimDetections (significance, recipe, forceSources);
-    psFree (significance);
-
-    // remove noise for subtracted objects (ie, return to normal noise level)
-    psphotSubNoise (readout, realSources, recipe);
-
-    // replace all sources
-    psphotReplaceAllSources (realSources, recipe);
-
-    // construct an initial model for each object
-    psphotGuessModels (config, readout, realSources, psf);
-    psphotGuessModels (config, readout, fakeSources, psf);
-    psphotGuessModels (config, readout, forceSources, psf);
-    
-    psArray *sources = NULL;
-
-    // linear fit to real + fake sources
-    sources = ppSimMergeSources (realSources, fakeSources);
-    psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract
-    psphotReplaceAllSources (sources, recipe);
-    psFree (sources); // only frees the merged references
-
-    // linear fit to real + forced sources (if any were selected)
-    if (forceSources->n) {
-      sources = ppSimMergeSources (realSources, forceSources);
-      psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract
-      psphotReplaceAllSources (sources, recipe);
-      psFree (sources); // only frees the merged references
-    }
-
-    // XXX do we need to measure aperture photometry corrections?
-    // XXX do we store the pre and post correction magnitudes?
-    // XXX for the fake sources, these must be identically zero
-    // XXX for the force sources, need the apresid to put the mags on the correct system
-    if (0) {
-	if (!psphotApResid (readout, forceSources, recipe, psf)) {
-	    psLogMsg ("psphot", 3, "failed on psphotApResid");
-	    return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL);
-	}
-    }
-
-    // calculate source magnitudes (for which set??)
-    pmReadout *background = psphotSelectBackground (config, view, false);
-    psphotMagnitudes(config, background, view, fakeSources, psf);
-    psphotMagnitudes(config, background, view, forceSources, psf);
-
-    // drop the references to the image pixels held by each source
-    psphotSourceFreePixels (realSources);
-    psphotSourceFreePixels (fakeSources);
-    psphotSourceFreePixels (forceSources);
-
-    // create the exported-metadata and free local data
-    psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL);
-
-    // add forceSources to the readout (real and fake already there)
-    // these are outputs: we need to generate the fpa structure
-    
-    pmCell    *forceCell    = pmFPAfileThisCell (config->files, view, "PPSIM.FORCE.SOURCES"); psAssert (forceCell, "no cell?");
-    pmChip    *forceChip    = pmFPAfileThisChip (config->files, view, "PPSIM.FORCE.SOURCES"); psAssert (forceChip, "no chip?");
-    pmReadout *forceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.SOURCES");
-    if (!forceReadout) {
-	forceReadout = pmReadoutAlloc (forceCell);
-	psFree (forceReadout); // there is a copy on 'cell' as well
-    }
-    psAssert (forceReadout, "no forceReadout?");
-    pmChipSetDataStatus (forceChip, true);
-
-    pmDetections *detectionsForce = pmDetectionsAlloc();
-    detectionForce->allSources = forceSources;
-
-    // save detections on the readout->analysis
-    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "force sources", detectionsForce)) {
-	psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
-	return false;
-    }
-    psFree(detectionsForce);
-
-    pmCell    *fakeCell    = pmFPAfileThisCell (config->files, view, "PPSIM.FAKE.SOURCES"); psAssert (fakeCell, "no cell?");
-    pmChip    *fakeChip    = pmFPAfileThisChip (config->files, view, "PPSIM.FAKE.SOURCES"); psAssert (fakeChip, "no chip?");
-    pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES");
-    if (!fakeReadout) {
-	fakeReadout = pmReadoutAlloc (fakeCell);
-	psFree (fakeReadout); // there is a copy on 'cell' as well
-    }
-    psAssert (fakeReadout, "no fakeReadout?");
-    pmChipSetDataStatus (fakeChip, true);
-
-    pmDetections *detectionsFake = pmDetectionsAlloc();
-    detectionFake->allSources = fakeSources;
-
-    // save detections on the readout->analysis
-    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "fake sources", detectionsFake)) {
-	psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
-	return false;
-    }
-    psFree(detectionsFake);
-
-    return true;
-}
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadoutFake.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadoutFake.c	(revision 30150)
+++ 	(revision )
@@ -1,121 +1,0 @@
-# include "ppSim.h"
-
-// XXX this function is currently disabled -- need to update code below to distinguish the fake
-// and force positions, etc
-bool ppSimPhotomReadoutFake(pmConfig *config, const pmFPAview *view) {
-
-    psTimerStart ("psphotReadout");
-
-    // select the current recipe
-    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
-    if (!recipe) {
-        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
-        return false;
-    }
-
-    // *** in this section, perform the photometry for real + fake sources on PPSIM.FAKE.CHIP ***
-
-    // find the currently selected readout.
-    // we always perform photometry on the mosaiced chip
-    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.CHIP");
-    PS_ASSERT_PTR_NON_NULL (readout, false);
-
-    // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile
-    psArray *realMeasuredSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES");
-    PS_ASSERT_PTR_NON_NULL (realMeasuredSources, false);
-
-    // the newly injected fake sources are saved on the PPSIM.OUTPUT pmFPAfile
-    psArray *injectedSources = ppSimSelectSources (config, view, "PPSIM.OUTPUT");
-    PS_ASSERT_PTR_NON_NULL (injectedSources, false);
-
-    // Generate the mask and variance images, including the user-defined analysis region of interest
-    psphotSetMaskAndVariance (config, view);
-
-    // XXX need to define the source pixels
-    ppSimDefinePixels (realMeasuredSources, readout, recipe);
-    ppSimDefinePixels (injectedSources, readout, recipe);
-
-    // make a copy of the injected fake-source parameters so these can be saved independently
-    // from the measured fake-source parameters
-    psArray *fakeSources = psArrayAlloc (injectedSources->n);
-    for (int i = 0; i < injectedSources->n; i++) {
-      fakeSources->data[i] = pmSourceCopyData (injectedSources->data[i]);
-    }
-
-    // make a copy of the measured real-source parameters so these can be fitted here and in
-    // ppSimPhotomReadoutForce, if desired.
-    psArray *realSources = psArrayAlloc (realMeasuredSources->n);
-    for (int i = 0; i < realMeasuredSources->n; i++) {
-        realSources->data[i] = pmSourceCopyData (realMeasuredSources->data[i]);
-    }
-
-    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
-    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile
-    psphotLoadPSF (config, view);
-
-    // remove all sources
-    psphotRemoveAllSources (realSources, recipe);
-
-    // generate a background model (median, smoothed image)
-    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.FAKE.CHIP", 0)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.FAKE.CHIP", 0, recipe)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-
-    // add noise for real (subtracted) objects
-    psphotAddNoise (readout, realSources, recipe);
-
-    // XXX fake sources should measure peak->x,y, force sources should not
-    psImageMaskType maskVal = 0xff;
-    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
-    ppSimDetections (significance, recipe, fakeSources);
-    psFree (significance);
-
-    // remove noise for subtracted objects (ie, return to normal noise level)
-    psphotSubNoise (readout, realSources, recipe);
-
-    // replace all sources
-    psphotReplaceAllSources (realSources, recipe);
-
-    // construct an initial model for each object
-    psphotGuessModels (config, readout, realSources, psf);
-    psphotGuessModels (config, readout, fakeSources, psf);
-
-    // linear fit to real + fake sources
-    psArray *sources = ppSimMergeSources (realSources, fakeSources);
-    psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract
-    psphotReplaceAllSources (sources, recipe);
-    psFree (sources); // only frees the merged references
-
-    // calculate source magnitudes (for which set??)
-    psphotMagnitudes(config, readout, view, fakeSources, psf);
-
-    // drop the references to the image pixels held by each source
-    psphotSourceFreePixels (realSources);
-    psphotSourceFreePixels (fakeSources);
-
-    // create the exported-metadata and free local data
-    // XXX this places the sources on readout->analysis as PSPHOT.SOURCES.  modify?
-    // (or don't supply the sources, and do this with a different function)
-    psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL);
-
-    pmCell    *fakeCell    = pmFPAfileThisCell (config->files, view, "PPSIM.FAKE.SOURCES"); psAssert (fakeCell, "no cell?");
-    pmChip    *fakeChip    = pmFPAfileThisChip (config->files, view, "PPSIM.FAKE.SOURCES"); psAssert (fakeChip, "no chip?");
-    pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES");
-    if (!fakeReadout) {
-        fakeReadout = pmReadoutAlloc (fakeCell);
-        psFree (fakeReadout); // there is a copy on 'cell' as well
-    }
-    psAssert (fakeReadout, "no fakeReadout?");
-    pmChipSetDataStatus (fakeChip, true);
-
-    pmDetections *detections = pmDetectionsAlloc();
-    detection->allSources = fakeSources;
-
-    psMetadataAddArray (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE, "fake photometry ", detections);
-    psFree(detections);
-
-    return true;
-}
Index: anches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadoutForce.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppSim/src/ppSimPhotomReadoutForce.c	(revision 30150)
+++ 	(revision )
@@ -1,118 +1,0 @@
-# include "ppSim.h"
-
-bool ppSimPhotomReadoutForce(pmConfig *config, const pmFPAview *view) {
-
-    psTimerStart ("psphotReadout");
-
-    // select the current recipe
-    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
-    if (!recipe) {
-        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
-        return false;
-    }
-
-# if 0
-    // set the photcode for this image
-    if (!psphotAddPhotcodeReadout (recipe, config, view, "PPSIM.FAKE.CHIP", 0)) {
-        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
-        return false;
-    }
-# endif
-
-    // *** in this section, perform the photometry for real + force sources on PPSIM.FORCE.CHIP ***
-
-    // find the currently selected readout.
-    // we always perform photometry on the mosaiced chip
-    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.CHIP");
-    PS_ASSERT_PTR_NON_NULL (readout, false);
-
-    // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile
-    psArray *realMeasuredSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES");
-    PS_ASSERT_PTR_NON_NULL (realMeasuredSources, false);
-
-    // load the forced source lists
-    psArray *forceSources = ppSimLoadForceSources (config, view);
-    psAssert (forceSources, "failed to load force photometry sources");
-
-    // Generate the mask and variance images, including the user-defined analysis region of interest
-    psphotSetMaskAndVariance (config, view, recipe);
-
-    // XXX need to define the source pixels
-    ppSimDefinePixels (realMeasuredSources, readout, recipe);
-    ppSimDefinePixels (forceSources, readout, recipe);
-
-    // make a copy of the measured real-source parameters so these can be fitted here and in
-    // ppSimPhotomReadoutForce, if desired.
-    psArray *realSources = psArrayAlloc (realMeasuredSources->n);
-    for (int i = 0; i < realMeasuredSources->n; i++) {
-        realSources->data[i] = pmSourceCopyData (realMeasuredSources->data[i]);
-    }
-
-    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
-    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile
-    pmPSF *psf = psphotLoadPSF (config, view, recipe);
-    assert (psf);
-
-    // remove all sources
-    psphotRemoveAllSources (realSources, recipe);
-
-    // generate a background model (median, smoothed image)
-    if (!psphotModelBackgroundReadoutFileIndex (config, view, "PPSIM.FORCE.CHIP", 0)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-    if (!psphotSubtractBackgroundReadout (config, view, "PPSIM.FORCE.CHIP", 0)) {
-        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
-    }
-
-    // add noise for real (subtracted) objects
-    psphotAddNoise (readout, realSources, recipe);
-
-    // XXX fake sources should measure peak->x,y, force sources should not
-    psImageMaskType maskVal = 0xff;
-    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
-    ppSimDetections (significance, recipe, forceSources);
-    psFree (significance);
-
-    // remove noise for subtracted objects (ie, return to normal noise level)
-    psphotSubNoise (readout, realSources, recipe);
-
-    // replace all sources
-    psphotReplaceAllSources (realSources, recipe);
-
-    // construct an initial model for each object
-    psphotGuessModels (config, readout, realSources, psf);
-    psphotGuessModels (config, readout, forceSources, psf);
-
-    // linear fit to real + force sources
-    psArray *sources = ppSimMergeSources (realSources, forceSources);
-    psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); // XXX option to NOT subtract
-    psphotReplaceAllSources (sources, recipe);
-    psFree (sources); // only frees the merged references
-
-    // calculate source magnitudes (for which set??)
-    psphotMagnitudes(config, readout, view, forceSources, psf);
-
-    // drop the references to the image pixels held by each source
-    psphotSourceFreePixels (realSources);
-    psphotSourceFreePixels (forceSources);
-
-    // create the exported-metadata and free local data
-    psphotReadoutCleanup(config, readout, recipe, NULL, psf, NULL);
-
-    pmCell    *forceCell    = pmFPAfileThisCell (config->files, view, "PPSIM.FORCE.SOURCES"); psAssert (forceCell, "no cell?");
-    pmChip    *forceChip    = pmFPAfileThisChip (config->files, view, "PPSIM.FORCE.SOURCES"); psAssert (forceChip, "no chip?");
-    pmReadout *forceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.SOURCES");
-    if (!forceReadout) {
-        forceReadout = pmReadoutAlloc (forceCell);
-        psFree (forceReadout); // there is a copy on 'cell' as well
-    }
-    psAssert (forceReadout, "no forceReadout?");
-    pmChipSetDataStatus (forceChip, true);
-
-    pmDetections *detections = pmDetectionsAlloc();
-    detection->allSources = forceSources;
-    psMetadataAddArray (forceReadout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE, "force photometry ", detections);
-    psFree(detections);
-
-    return true;
-}
