Index: trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtraction.c	(revision 20466)
+++ trunk/psModules/src/imcombine/pmSubtraction.c	(revision 20505)
@@ -29,6 +29,4 @@
 #define PIXEL_LIST_BUFFER 100           // Number of entries to add to pixel list at a time
 #define MIN_SAMPLE_STATS    7           // Minimum number to use sample statistics; otherwise use quartiles
-
-//#define SYS_ERROR 0.00                  // Relative error in derived convolution kernel pixels
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -459,21 +457,23 @@
 
 // Generate an image that can be used to track systematic errors
-static psImage *subtractionSysErrImage(const psImage *image     // Image from which to make sys err image
+static psImage *subtractionSysErrImage(const psImage *image, // Image from which to make sys err image
+                                       float sysError // Relative systematic error
                                        )
 {
-#ifndef SYS_ERROR
-    return NULL;
-#else
+    if (!isfinite(sysError) || sysError == 0.0) {
+        return NULL;
+    }
+
     int numCols = image->numCols, numRows = image->numRows; // Size of image
     psImage *sys = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Systematic error image
 
+    float sysError2 = PS_SQR(sysError); // Square of the systematic error
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            sys->data.F32[y][x] = PS_SQR(image->data.F32[y][x]) * PS_SQR(SYS_ERROR);
+            sys->data.F32[y][x] = PS_SQR(image->data.F32[y][x]) * sysError2;
         }
     }
 
     return sys;
-#endif
 }
 
@@ -1089,5 +1089,5 @@
 bool pmSubtractionConvolve(pmReadout *out1, pmReadout *out2, const pmReadout *ro1, const pmReadout *ro2,
                            psImage *subMask, psMaskType maskBad, psMaskType maskPoor, float poorFrac,
-                           const psRegion *region, const pmSubtractionKernels *kernels,
+                           float sysError, const psRegion *region, const pmSubtractionKernels *kernels,
                            bool doBG, bool useFFT)
 {
@@ -1197,5 +1197,5 @@
     psImage *sys1 = NULL, *sys2 = NULL; // Systematic error images
     if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
-        sys1 = subtractionSysErrImage(ro1->image);
+        sys1 = subtractionSysErrImage(ro1->image, sysError);
         if (threaded && sys1) {
             psMutexInit(sys1);
@@ -1203,5 +1203,5 @@
     }
     if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
-        sys2 = subtractionSysErrImage(ro2->image);
+        sys2 = subtractionSysErrImage(ro2->image, sysError);
         if (threaded && sys2) {
             psMutexInit(sys2);
