Index: branches/ipp-2-0/psModules/src/objects/pmSource.c
===================================================================
--- branches/ipp-2-0/psModules/src/objects/pmSource.c	(revision 13287)
+++ branches/ipp-2-0/psModules/src/objects/pmSource.c	(revision 13328)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-26 01:20:29 $
+ *  @version $Revision: 1.27.2.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-10 17:10:20 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -799,4 +799,9 @@
 	}
 
+	psF32 **target = source->pixels->data.F32;
+	if (mode & PM_MODEL_OP_NOISE) {
+	  target = source->noise->data.F32;
+	}
+
 	// XXX need to respect the source and model masks?
 	for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
@@ -807,7 +812,7 @@
 		float value = Io*source->modelFlux->data.F32[iy][ix];
 		if (add) {
-		    source->pixels->data.F32[oy][ox] += value;
+		    target[oy][ox] += value;
 		} else {
-		    source->pixels->data.F32[oy][ox] -= value;
+		    target[oy][ox] -= value;
 		}
 	    }
@@ -816,8 +821,11 @@
     } 
 
+    psImage *target = source->pixels;
+    if (mode & PM_MODEL_OP_NOISE) {
+	target = source->noise;
     if (add) {
-	status = pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
+	status = pmModelAdd (target, source->maskObj, model, PM_MODEL_OP_FULL);
     } else {
-	status = pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
+	status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL);
     }
 
