Index: trunk/ppSub/src/ppSubReadout.c
===================================================================
--- trunk/ppSub/src/ppSubReadout.c	(revision 18289)
+++ trunk/ppSub/src/ppSubReadout.c	(revision 18396)
@@ -13,4 +13,7 @@
 #define WCS_TOLERANCE 0.001             // Tolerance for WCS
 #define TESTING                         // For test output
+
+#define SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
+                     PM_SOURCE_MODE_CR_LIMIT) // Mask to apply to input sources
 
 
@@ -307,4 +310,62 @@
     }
 
+#if 0
+    // XXX Under development
+
+    // QA: photometry of known sources with measured PSF
+    if (sourcesRO && psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
+        sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
+
+
+
+        // For each source, need to:
+        // * generate appropriate model
+        // * select pixels
+        // * define fit radius
+        // Don't need to measure sky (psphotFitSourcesLinear does that)
+
+        psArray *dummy = psArrayAlloc(1); // Dummy array of sources, for psphotFitSourcesLinear with 1 source
+        for (long i = 0; i < sources->n; i++) {
+            pmSource *source = sources->data[i];
+            if (!source || (source->mode & SOURCE_MASK)) {
+                continue;
+            }
+
+            float origMag = source->psfMag; // Original magnitude
+
+            // Coordinates of source
+            float x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
+            float y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
+
+            model = pmModelFromPSFforXY(psf, x, y, NAN);
+            if (!fakeModel) {
+                psWarning("Can't generate model");
+                continue;
+            }
+            if (!pmSourceDefinePixels(fakeSource, readout, x, y, fakeRadius)) {
+                psErrorClear();
+                continue;
+            }
+pmModel *pmModelFromPSFforXY (
+    const pmPSF *psf,
+    float Xo,
+    float Yo,
+    float Io
+    );
+
+bool pmSourceDefinePixels(
+    pmSource *mySource,                 ///< source to be re-defined
+    const pmReadout *readout,  ///< base the source on this readout
+    psF32 x,                            ///< center coords of source
+    psF32 y,                            ///< center coords of source
+    psF32 Radius                        ///< size of box on source
+);
+
+
+bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
+
+    }
+#endif
+
     // Photometry stage 2: find and measure sources on the subtracted image
     if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
