Index: trunk/psphot/src/psphotSourcePlots.c
===================================================================
--- trunk/psphot/src/psphotSourcePlots.c	(revision 13006)
+++ trunk/psphot/src/psphotSourcePlots.c	(revision 13900)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe) {
+bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe, psMaskType maskVal) {
 
     // bool status = false;
@@ -17,8 +17,8 @@
 
     // counters to track the size of the image and area used in a row
-    int dX = 0;				// starting corner of next box
-    int dY = 0;				// height of row so far
-    int NX = 20*DX;			// full width of output image
-    int NY = 0;				// total height of output image
+    int dX = 0;                         // starting corner of next box
+    int dY = 0;                         // height of row so far
+    int NX = 20*DX;                     // full width of output image
+    int NY = 0;                         // total height of output image
 
     // first, examine the PSF and SAT stars:
@@ -28,31 +28,31 @@
         pmSource *source = sources->data[i];
 
-	bool keep = false;
+        bool keep = false;
         keep |= (source->mode & PM_SOURCE_MODE_PSFSTAR);
         keep |= (source->mode & PM_SOURCE_MODE_SATSTAR);
-	if (!keep) continue;
+        if (!keep) continue;
 
-	// how does this subimage get placed into the output image?
-	// DX = source->pixels->numCols
-	// DY = source->pixels->numRows
+        // how does this subimage get placed into the output image?
+        // DX = source->pixels->numCols
+        // DY = source->pixels->numRows
 
-	if (dX + DX > NX) {
-	    // too wide for the rest of this row
-	    if (dX == 0) {
-		// alone on this row
-		NY += DY;
-		dX = 0;
-		dY = 0;
-	    } else {
-		// start the next row
-		NY += dY;
-		dX = DX;
-		dY = DY;
-	    }
-	} else {
-	    // extend this row
-	    dX += DX;
-	    dY = PS_MAX (dY, DY);
-	}
+        if (dX + DX > NX) {
+            // too wide for the rest of this row
+            if (dX == 0) {
+                // alone on this row
+                NY += DY;
+                dX = 0;
+                dY = 0;
+            } else {
+                // start the next row
+                NY += dY;
+                dX = DX;
+                dY = DY;
+            }
+        } else {
+            // extend this row
+            dX += DX;
+            dY = PS_MAX (dY, DY);
+        }
     }
 
@@ -61,11 +61,11 @@
     psImage *outsub = psImageAlloc (NX, NY, PS_TYPE_F32);
 
-    int Xo = 0;				// starting corner of next box
-    int Yo = 0;				// starting corner of next box
-    dY = 0;				// height of row so far
+    int Xo = 0;                         // starting corner of next box
+    int Yo = 0;                         // starting corner of next box
+    dY = 0;                             // height of row so far
 
     int nPSF = 0;
     int nSAT = 0;
-    int kapa = 0;			// file descriptor for plotting routine
+    int kapa = 0;                       // file descriptor for plotting routine
 
     // first, examine the PSF and SAT stars:
@@ -76,62 +76,62 @@
         pmSource *source = sources->data[i];
 
-	bool keep = false;
+        bool keep = false;
         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	    nPSF ++;
-	    keep = true;
-	}
+            nPSF ++;
+            keep = true;
+        }
         if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	    nSAT ++;
-	    keep = true;
-	}	    
-	if (!keep) continue;
+            nSAT ++;
+            keep = true;
+        }
+        if (!keep) continue;
 
-	// how does this subimage get placed into the output image?
-	// DX = source->pixels->numCols
-	// DY = source->pixels->numRows
+        // how does this subimage get placed into the output image?
+        // DX = source->pixels->numCols
+        // DY = source->pixels->numRows
 
-	if (Xo + DX > NX) {
-	    // too wide for the rest of this row
-	    if (Xo == 0) {
-		// place source alone on this row
-		psphotAddWithTest (source, true); // replace source if subtracted
-		psphotRadialPlot (&kapa, "radial.plots.ps", source);
-		psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
+        if (Xo + DX > NX) {
+            // too wide for the rest of this row
+            if (Xo == 0) {
+                // place source alone on this row
+                psphotAddWithTest (source, true, maskVal); // replace source if subtracted
+                psphotRadialPlot (&kapa, "radial.plots.ps", source);
+                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
 
-		psphotSubWithTest (source, false); // remove source (force)
-		psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
+                psphotSubWithTest (source, false, maskVal); // remove source (force)
+                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
 
-		psphotSetState (source, false); // replace source (has been subtracted)
-		Yo += DY;
-		Xo = 0;
-		dY = 0;
-	    } else {
-		// start the next row
-		Yo += dY;
-		Xo = 0;
-		psphotAddWithTest (source, true); // replace source if subtracted
-		psphotRadialPlot (&kapa, "radial.plots.ps", source);
-		psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
+                psphotSetState (source, false, maskVal); // replace source (has been subtracted)
+                Yo += DY;
+                Xo = 0;
+                dY = 0;
+            } else {
+                // start the next row
+                Yo += dY;
+                Xo = 0;
+                psphotAddWithTest (source, true, maskVal); // replace source if subtracted
+                psphotRadialPlot (&kapa, "radial.plots.ps", source);
+                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
 
-		psphotSubWithTest (source, false); // remove source (force)
-		psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
-		psphotSetState (source, false); // replace source (has been subtracted)
+                psphotSubWithTest (source, false, maskVal); // remove source (force)
+                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
+                psphotSetState (source, false, maskVal); // replace source (has been subtracted)
 
-		Xo = DX;
-		dY = DY;
-	    }
-	} else {
-	    // extend this row
-	    psphotAddWithTest (source, true); // replace source if subtracted
-	    psphotRadialPlot (&kapa, "radial.plots.ps", source);
-	    psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
+                Xo = DX;
+                dY = DY;
+            }
+        } else {
+            // extend this row
+            psphotAddWithTest (source, true, maskVal); // replace source if subtracted
+            psphotRadialPlot (&kapa, "radial.plots.ps", source);
+            psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
 
-	    psphotSubWithTest (source, false); // remove source (force)
-	    psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
-	    psphotSetState (source, false); // replace source (has been subtracted)
+            psphotSubWithTest (source, false, maskVal); // remove source (force)
+            psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
+            psphotSetState (source, false, maskVal); // replace source (has been subtracted)
 
-	    Xo += DX;
-	    dY = PS_MAX (dY, DY);
-	}
+            Xo += DX;
+            dY = PS_MAX (dY, DY);
+        }
     }
 
