Index: /trunk/psModules/src/objects/pmModel.h
===================================================================
--- /trunk/psModules/src/objects/pmModel.h	(revision 13334)
+++ /trunk/psModules/src/objects/pmModel.h	(revision 13335)
@@ -5,6 +5,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-04-26 01:20:29 $
+ * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-05-10 19:48:35 $
  *
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -33,8 +33,9 @@
     PM_MODEL_OP_RES0 	= 0x02,
     PM_MODEL_OP_RES1 	= 0x04,
-    PM_MODEL_OP_FULL   = 0x07,
+    PM_MODEL_OP_FULL    = 0x07,
     PM_MODEL_OP_SKY  	= 0x08,
-    PM_MODEL_OP_CENTER = 0x10,
+    PM_MODEL_OP_CENTER  = 0x10,
     PM_MODEL_OP_NORM  	= 0x20,
+    PM_MODEL_OP_NOISE  	= 0x40,
 } pmModelOpMode;
 
Index: /trunk/psModules/src/objects/pmSource.c
===================================================================
--- /trunk/psModules/src/objects/pmSource.c	(revision 13334)
+++ /trunk/psModules/src/objects/pmSource.c	(revision 13335)
@@ -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.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-10 19:48:35 $
  *
  *  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);
     }
 
