Index: trunk/psphot/src/psphotAddNoise.c
===================================================================
--- trunk/psphot/src/psphotAddNoise.c	(revision 13330)
+++ trunk/psphot/src/psphotAddNoise.c	(revision 13900)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add) {
+bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add, psMaskType maskVal) {
 
     bool status = false;
@@ -34,50 +34,50 @@
     // loop over all source
     for (int i = 0; i < sources->n; i++) {
-	pmSource *source = sources->data[i];
+        pmSource *source = sources->data[i];
 
-	// skip sources which were not subtracted
-	if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue;
+        // skip sources which were not subtracted
+        if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue;
 
-	// select appropriate model
-	pmModel *model = pmSourceGetModel (NULL, source);
-	if (model == NULL) continue;  // model must be defined
-	
-	if (add) {
-	    psTrace ("psphot", 4, "adding noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
-	} else {
-	    psTrace ("psphot", 4, "remove noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
-	}
+        // select appropriate model
+        pmModel *model = pmSourceGetModel (NULL, source);
+        if (model == NULL) continue;  // model must be defined
 
-	psF32 *PAR = model->params->data.F32;
+        if (add) {
+            psTrace ("psphot", 4, "adding noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
+        } else {
+            psTrace ("psphot", 4, "remove noise for object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
+        }
 
-	// save original values
-	float oldI0  = PAR[PM_PAR_I0];
-	oldshape.sx  = PAR[PM_PAR_SXX];
-	oldshape.sy  = PAR[PM_PAR_SYY];
-	oldshape.sxy = PAR[PM_PAR_SXY];
+        psF32 *PAR = model->params->data.F32;
 
-	// increase size and height of source
-	axes = psEllipseShapeToAxes (oldshape, 20.0);
-	axes.major *= SIZE;
-	axes.minor *= SIZE;
-	newshape = psEllipseAxesToShape (axes);
-	PAR[PM_PAR_I0]  = FACTOR*PS_SQR(oldI0);
-	PAR[PM_PAR_SXX] = newshape.sx;
-	PAR[PM_PAR_SYY] = newshape.sy;
-	PAR[PM_PAR_SXY] = newshape.sxy;
+        // save original values
+        float oldI0  = PAR[PM_PAR_I0];
+        oldshape.sx  = PAR[PM_PAR_SXX];
+        oldshape.sy  = PAR[PM_PAR_SYY];
+        oldshape.sxy = PAR[PM_PAR_SXY];
 
-	// XXX if we use pmSourceOp, the size (and possibly Io) will not be respected
-	pmSourceOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, add);
-	
-	// restore original values
-	PAR[PM_PAR_I0]  = oldI0;	
-	PAR[PM_PAR_SXX] = oldshape.sx;
-	PAR[PM_PAR_SYY] = oldshape.sy;
-	PAR[PM_PAR_SXY] = oldshape.sxy;
+        // increase size and height of source
+        axes = psEllipseShapeToAxes (oldshape, 20.0);
+        axes.major *= SIZE;
+        axes.minor *= SIZE;
+        newshape = psEllipseAxesToShape (axes);
+        PAR[PM_PAR_I0]  = FACTOR*PS_SQR(oldI0);
+        PAR[PM_PAR_SXX] = newshape.sx;
+        PAR[PM_PAR_SYY] = newshape.sy;
+        PAR[PM_PAR_SXY] = newshape.sxy;
+
+        // XXX if we use pmSourceOp, the size (and possibly Io) will not be respected
+        pmSourceOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, add, maskVal);
+
+        // restore original values
+        PAR[PM_PAR_I0]  = oldI0;
+        PAR[PM_PAR_SXX] = oldshape.sx;
+        PAR[PM_PAR_SYY] = oldshape.sy;
+        PAR[PM_PAR_SXY] = oldshape.sxy;
     }
     if (add) {
-	psLogMsg ("psphot.noise", PS_LOG_INFO, "add noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
+        psLogMsg ("psphot.noise", PS_LOG_INFO, "add noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
     } else {
-	psLogMsg ("psphot.noise", PS_LOG_INFO, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
+        psLogMsg ("psphot.noise", PS_LOG_INFO, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
     }
     return true;
