Index: trunk/psModules/src/detrend/pmSubtractBias.c
===================================================================
--- trunk/psModules/src/detrend/pmSubtractBias.c	(revision 7445)
+++ trunk/psModules/src/detrend/pmSubtractBias.c	(revision 7589)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-08 22:14:28 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-17 01:50:43 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -106,4 +106,22 @@
     psImage *subImage = sub->image;     // The image to be subtracted
     psImage *subMask  = sub->mask;      // The mask for the subtraction image
+
+    int xIpar = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.XPARITY");
+    int xSpar = psMetadataLookupS32(NULL, sub->parent->concepts, "CELL.XPARITY");
+    if (xIpar != xSpar) {
+        psError(PS_ERR_UNKNOWN, true, "images for subtraction do not have the same "
+                "CELL.XPARITY (%d vs %d).\n    pmSubtractBias must be upgraded to handle this situation\n",
+                xIpar, xSpar);
+        return false;
+    }
+
+    int yIpar = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.YPARITY");
+    int ySpar = psMetadataLookupS32(NULL, sub->parent->concepts, "CELL.YPARITY");
+    if (yIpar != ySpar) {
+        psError(PS_ERR_UNKNOWN, true, "images for subtraction do not have the same "
+                "CELL.YPARITY (%d vs %d).\n    pmSubtractBias must be upgraded to handle this situation\n",
+                xIpar, xSpar);
+        return false;
+    }
 
     // Offsets of the cells
@@ -293,6 +311,6 @@
 XXX: The SDRS does not specify type support.  F32 is implemented here.
  *****************************************************************************/
-pmReadout *pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts,
-                          const pmReadout *bias, const pmReadout *dark)
+bool pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts,
+                    const pmReadout *bias, const pmReadout *dark)
 {
     psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4,
@@ -319,5 +337,5 @@
                 overscanOpts->fitType != PM_FIT_POLY_CHEBY && overscanOpts->fitType != PM_FIT_SPLINE) {
             psError(PS_ERR_UNKNOWN, true, "Invalid fit type (%d).  Returning original image.\n", overscanOpts->fitType);
-            return(in);
+            return false;
         }
 
@@ -349,5 +367,5 @@
             if (! p_psGetStatValue(myStats, &reduced)) {
                 psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation.  Returning input image.\n");
-                return(in);
+                return false;
             }
             (void)psBinaryOp(image, image, "-", psScalarAlloc((float)reduced, PS_TYPE_F32));
@@ -391,5 +409,5 @@
                 psFree(pixels);
                 if (! reduced) {
-                    return in;
+                    return false;
                 }
 
@@ -435,5 +453,5 @@
                 psFree(pixels);
                 if (! reduced) {
-                    return in;
+                    return false;
                 }
 
@@ -452,5 +470,6 @@
     // Bias frame subtraction
     if (bias) {
-        SubtractFrame(in, bias, 1.0);
+        if (!SubtractFrame(in, bias, 1.0))
+            return false;
     }
 
@@ -459,9 +478,10 @@
         float inTime = psMetadataLookupF32(NULL, in->parent->concepts, "CELL.DARKTIME");
         float darkTime = psMetadataLookupF32(NULL, dark->parent->concepts, "CELL.DARKTIME");
-        SubtractFrame(in, dark, inTime/darkTime);
-    }
-
-    return in;
-}
-
-
+        if (!SubtractFrame(in, dark, inTime/darkTime))
+            return false;
+    }
+
+    return true;
+}
+
+
