Index: /branches/eam_branches/ipp-20101103/psphot/src/Makefile.am
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/Makefile.am	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/Makefile.am	(revision 29914)
@@ -125,4 +125,5 @@
 	psphotReadoutFindPSF.c	       \
 	psphotReadoutKnownSources.c    \
+	psphotReadoutForcedKnownSources.c    \
 	psphotReadoutMinimal.c	       \
 	psphotModelBackground.c	       \
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphot.h
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphot.h	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphot.h	(revision 29914)
@@ -27,4 +27,5 @@
 bool            psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
 bool            psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
+bool            psphotReadoutForcedKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
 bool            psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule);
 
@@ -312,4 +313,7 @@
 int psphotFileruleCount(const pmConfig *config, const char *filerule);
 
+bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
+
+
 /**** psphotStack prototypes ****/
 
@@ -434,3 +438,5 @@
 pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize);
 
+bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule);
+
 #endif
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotEfficiency.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotEfficiency.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotEfficiency.c	(revision 29914)
@@ -511,4 +511,7 @@
     psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, PM_DETEFF_ANALYSIS, PS_META_REPLACE | PS_DATA_UNKNOWN,
                      "Detection efficiency", de);
+    psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "DETEFF.MAGREF", 
+        PS_META_REPLACE, "Magnitude reference", magLim);
+
     psFree(de);
 
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotMergeSources.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotMergeSources.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotMergeSources.c	(revision 29914)
@@ -163,4 +163,69 @@
 }
 
+// copy the known sources (as external) to the detection list of the given filerule
+bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
+
+    bool status = false;
+
+    // select the appropriate recipe information
+    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
+    psAssert (recipe, "missing recipe?");
+
+    // determine properties (sky, moments) of initial sources
+    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
+    psAssert (status, "missing SKY_OUTER_RADIUS in recipe?");
+
+    // XXX this seems like an arbitrary number...
+    OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius
+
+    // find the currently selected readout 
+    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest
+    psAssert (file, "missing file?");
+
+    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
+    psAssert (readout, "missing readout?");
+
+    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
+    if (!detections) {
+	detections = pmDetectionsAlloc();
+	detections->newSources = psArrayAllocEmpty (100);
+	// save detections on the readout->analysis
+	if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) {
+	    psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
+	    return false;
+	}
+    } else {
+	psMemIncrRefCounter(detections); // so we can free the detections below
+    }
+
+    // copy the sources from inSources to the new detection structure
+    for (int i = 0; i < inSources->n; i++) {
+      pmSource *inSource = inSources->data[i];
+
+      pmSource *newSource = pmSourceCopy(inSource);
+      newSource->mode |= PM_SOURCE_MODE_EXTERNAL;
+      
+      // drop the loaded source modelPSF
+      psFree (newSource->modelPSF);
+      // source->modelPSF = NULL;  check this!
+
+      // drop the references to the original image pixels:
+      pmSourceFreePixels (newSource);
+
+      // allocate image, weight, mask for the new image for each peak (square of radius OUTER)
+      pmSourceDefinePixels (newSource, readout, newSource->peak->x, newSource->peak->y, OUTER);
+
+      newSource->imageID = 0;
+      // XXX reset the source ID? raised questions about the meaning of this ID...
+      // P_PM_SOURCE_SET_ID(source, i);
+
+      psArrayAdd (detections->newSources, 100, newSource);
+    }
+    psLogMsg ("psphot", 3, "%ld known sources supplied", detections->newSources->n);
+
+    psFree (detections);
+    return true;
+}
+
 // extract the input sources corresponding to this readout
 // XXX this function needs to be updated to work with the new context of psphot inputs
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotOutput.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotOutput.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotOutput.c	(revision 29914)
@@ -9,5 +9,8 @@
     psStringAppend(&name, "%s.NUM", filerule);
     int num = psMetadataLookupS32 (&status, config->arguments, name);
-    psAssert (status, "programming error: must define %s", name);
+    if (!status) {
+      // we only explicitly define (filerule.NUM) if we have more than 1
+      num = 1;
+    }
     psFree (name);
     return num;
@@ -125,4 +128,34 @@
     }
     fclose (f);
+    return true;
+}
+
+bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
+bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule) {
+
+    int num = psphotFileruleCount(config, filerule);
+
+    // loop over the available readouts
+    for (int i = 0; i < num; i++) {
+	if (!psphotCleanInputsReadout (config, view, filerule, i)) {
+	  psError (PSPHOT_ERR_CONFIG, false, "failed to clean inputs for %s entry %d", filerule, i);
+	    return false;
+	}
+    }
+    return true;
+}
+
+bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
+
+    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
+    PS_ASSERT (file, false);
+
+    pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
+
+    // XXX anything else to remove?
+    if (psMetadataLookup(readout->analysis, "PSPHOT.DETECTIONS")) {
+	psMetadataRemoveKey(readout->analysis, "PSPHOT.DETECTIONS");
+    }
+
     return true;
 }
@@ -282,4 +315,6 @@
     psMetadataItemSupplement (&status, header, analysis, "MSKY_NY");
 
+    psMetadataItemSupplement (&status, header, analysis, "DETEFF.MAGREF");
+
     psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout"));
 
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotParseCamera.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotParseCamera.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotParseCamera.c	(revision 29914)
@@ -39,6 +39,4 @@
         return NULL;
     }
-    // specify the number of psphot input images
-    psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
 
     // define the additional input/output files associated with psphot
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotRadiusChecks.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotRadiusChecks.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotRadiusChecks.c	(revision 29914)
@@ -135,8 +135,5 @@
     EXT_FIT_MAX_RADIUS = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_RADIUS");
 
-    float skyMean  = psMetadataLookupF32 (&status, readout->analysis, "SKY_MEAN");
     float skyStdev = psMetadataLookupF32 (&status, readout->analysis, "SKY_STDEV");
-
-    fprintf (stderr, "sky: %f +/- %f\n", skyMean, skyStdev);
 
     EXT_FIT_SKY_SIG = skyStdev;
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotReadout.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotReadout.c	(revision 29913)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotReadout.c	(revision 29914)
@@ -27,4 +27,10 @@
     psAssert (breakPt, "configuration error: set BREAK_POINT");
 
+    // remove cruft from the input analysis structure
+    if (!psphotCleanInputs (config, view, filerule)) {
+        psError (PSPHOT_ERR_PROG, false, "trouble setting up the inputs");
+        return false;
+    }
+
     // set the photcode for this image
     if (!psphotAddPhotcode (config, view, filerule)) {
Index: /branches/eam_branches/ipp-20101103/psphot/src/psphotReadoutForcedKnownSources.c
===================================================================
--- /branches/eam_branches/ipp-20101103/psphot/src/psphotReadoutForcedKnownSources.c	(revision 29914)
+++ /branches/eam_branches/ipp-20101103/psphot/src/psphotReadoutForcedKnownSources.c	(revision 29914)
@@ -0,0 +1,56 @@
+# include "psphotInternal.h"
+
+// in this psphotReadout-variant, we are only measuring the photometry for known source
+// position, using a supplied PSF
+bool psphotReadoutForcedKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
+
+    psTimerStart ("psphotReadout");
+
+    // remove cruft from the input analysis structure
+    if (!psphotCleanInputs (config, view, filerule)) {
+        psError (PSPHOT_ERR_PROG, false, "trouble setting up the inputs");
+        return false;
+    }
+
+    // set the photcode for this image
+    if (!psphotAddPhotcode(config, view, filerule)) {
+        psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
+        return false;
+    }
+
+    // Generate the mask and weight images, including the user-defined analysis region of interest
+    psphotSetMaskAndVariance (config, view, filerule);
+
+    // Note that in this implementation, we do NOT model the background and we do not
+    // attempt to detect the sources in the image
+
+    if (!psphotAddKnownSources (config, view, filerule, inSources)) {
+	psError(PSPHOT_ERR_UNKNOWN, false, "failure to load supplied sources");
+	return false;
+    }
+
+    if (!psphotLoadPSF (config, view, filerule)) {
+    	// this only happens if we had a programming error in psphotLoadPSF
+        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
+        return psphotReadoutCleanup (config, view, filerule);
+    }
+
+    // construct an initial model for each object
+    psphotGuessModels (config, view, filerule);
+
+    // merge the newly selected sources into the existing list
+    // NOTE: merge OLD and NEW
+    psphotMergeSources (config, view, filerule); 
+
+    // linear PSF fit to source peaks
+    psphotFitSourcesLinear (config, view, filerule, false);
+
+    // calculate source magnitudes
+    psphotMagnitudes(config, view, filerule);
+
+    // drop the references to the image pixels held by each source
+    psphotSourceFreePixels (config, view, filerule);
+
+    // create the exported-metadata and free local data
+    return psphotReadoutCleanup (config, view, filerule);
+}
