Index: /branches/pap_branch_20090108/ppStack/src/ppStackMatch.c
===================================================================
--- /branches/pap_branch_20090108/ppStack/src/ppStackMatch.c	(revision 21113)
+++ /branches/pap_branch_20090108/ppStack/src/ppStackMatch.c	(revision 21114)
@@ -17,5 +17,5 @@
 #define FAINT_SOURCE_FRAC 1.0e-4         // Set minimum flux to this fraction of faintest source flux
 
-#define TESTING                         // Enable debugging output
+//#define TESTING                         // Enable debugging output
 
 #ifdef TESTING
@@ -160,65 +160,4 @@
      return unbinned;
 }
-
-
-
-
-#if 0
-#define BG_SIZE 64                      // Large box half-size in which to measure background
-
-// Generate a background model of the readout we're matching
-// We only need to set the background around the sources, not everywhere.
-psImage *stackBackgroundModel(pmReadout *ro, psMaskType maskVal, const psArray *sources, int size)
-{
-    psImage *image = ro->image, *mask = ro->mask; // Image and mask of readout
-    int numCols = image->numCols, numRows = image->numRows; // Size of image
-
-    psImage *bgImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Background image
-    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for measuring background
-    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
-
-    for (int i = 0; i < sources->n; i++) {
-        pmSource *source = sources->data[i]; // Source of interest
-        if (!source) {
-            continue;
-        }
-
-        float xSource, ySource;         // Coordinates of source
-        coordsFromSource(&xSource, &ySource, source);
-
-        int x = xSource + 0.5, y = ySource + 0.5; // Coordinates of source
-
-        int xMin = PS_MAX(x - BG_SIZE, 0), xMax = PS_MIN(x + BG_SIZE, numCols);
-        int yMin = PS_MAX(y - BG_SIZE, 0), yMax = PS_MIN(y + BG_SIZE, numCols);
-
-        psRegion region = psRegionSet(xMin, xMax, yMin, yMax); // Region of interest
-        psImage *subImage = psImageSubset(image, region); // Subimage
-        psImage *subMask = psImageSubset(mask, region); // Subimage mask
-        if (!psImageBackground(stats, NULL, subImage, subMask, maskVal, rng)) {
-            // Can't do anything about it
-            psErrorClear();
-            continue;
-        }
-        psFree(subImage);
-        psFree(subMask);
-
-        float value = stats->robustMedian; // Value to set background to
-
-        int uMin = PS_MAX(x - size, 0), uMax = PS_MIN(x + size, numCols);
-        int vMin = PS_MAX(y - size, 0), vMax = PS_MIN(y + size, numCols);
-
-        for (int v = vMin; v < vMax; v++) {
-            for (int u = uMin; u < uMax; u++) {
-                bgImage->data.F32[v][u] = value;
-            }
-        }
-    }
-
-    psFree(stats);
-    psFree(rng);
-
-    return bgImage;
-}
-#endif
 
 
@@ -355,30 +294,4 @@
             }
 
-            // Generate a fake image to match to
-            float minFlux = INFINITY;       // Minimum flux for fake image
-            {
-                psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for bg
-                if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal, rng)) {
-                    psWarning("Can't measure background for image.");
-                    psErrorClear();
-                } else {
-                    minFlux = bg->robustStdev;
-                }
-                psFree(bg);
-            }
-
-#if 0
-            float maxMag = -INFINITY;   // Maximum magnitude of sources
-            for (int i = 0; i < sources->n; i++) {
-                pmSource *source = sources->data[i]; // Source of interest
-                if (source->psfMag > maxMag && source->psfMag <= MAG_IGNORE &&
-                    !(source->mode & SOURCE_MASK)) {
-                    maxMag = source->psfMag;
-                }
-            }
-            minFlux = PS_MIN(FAINT_SOURCE_FRAC * powf(10.0, -0.4 * maxMag), minFlux);
-#endif
-
-
 #if 0
             // Testing the normalisation of the fake image
@@ -654,4 +567,6 @@
     psFree(bg);
 
+
+#if 0
 #define RADIUS 10                       // Radius of photometry
 #define MIN_ERR 0.05                    // Minimum photometric error, mag
@@ -708,4 +623,5 @@
     psFree(ratio);
     psFree(ratioMask);
+#endif
 
 #ifdef TESTING
