Index: trunk/psModules/src/pmFlatField.c
===================================================================
--- trunk/psModules/src/pmFlatField.c	(revision 1832)
+++ trunk/psModules/src/pmFlatField.c	(revision 1849)
@@ -18,6 +18,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-20 20:36:46 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-22 19:58:57 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 #include<math.h>
 
+#include "pslib.h"
 #include "pmFlatField.h"
 #include "pmMaskBadPixels.h"
@@ -50,5 +51,4 @@
     // Check for nulls
     if (in == NULL) {
-        psError(__func__, " : Line %d - Null not allowed for input readout", __LINE__);
         return false;
     } else if(flat==NULL) {
@@ -71,19 +71,11 @@
 
     // Check input image and its mask are not larger than flat image
-    if(inImage->numRows > flatImage->numRows) {
-        psError(__func__, " : Line %d - Input image exceeds mask image in number of rows. (%d vs %d).",
-                __LINE__, inImage->numRows, flatImage->numRows);
+    if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
+        psError(__func__, " : Line %d - Input image size exceeds that of flat image: (%d, %d) vs (%d, %d)",
+                __LINE__, inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
         return false;
-    } else if(inImage->numCols > flatImage->numCols) {
-        psError(__func__, " : Line %d - Input image exceeds mask image in number of columns. (%d vs %d).",
-                __LINE__, inImage->numCols, flatImage->numCols);
-        return false;
-    } else if(inMask->numRows > flatImage->numRows) {
-        psError(__func__, " : Line %d - Input image mask exceeds mask image in number of rows. (%d vs %d).",
-                __LINE__, inImage->numRows, flatImage->numRows);
-        return false;
-    } else if(inMask->numCols > flatImage->numCols) {
-        psError(__func__, " : Line %d - Input image mask exceeds mask image in number of columns. (%d vs %d).",
-                __LINE__, inImage->numCols, flatImage->numCols);
+    } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) {
+        psError(__func__, " : Line %d - Input image mask size exceeds that of flat image: (%d, %d) vs (%d, %d)",
+                __LINE__, inMask->numRows, inMask->numCols, flatImage->numRows, flatImage->numCols);
         return false;
     }
@@ -94,27 +86,15 @@
 
     // Check that offsets are within image limits
-    if(totOffRow > flatImage->numRows-1) {
-        psError(__func__, " : Line %d - Initial row offset exceeds that of mask image. (%d vs %d).",
-                __LINE__, totOffRow, flatImage->numRows);
+    if(totOffRow>=flatImage->numRows || totOffCol>=flatImage->numCols) {
+        psError(__func__, " : Line %d - Total offset >= flat image size: (%d, %d) vs (%d, %d)",
+                __LINE__, totOffRow, totOffCol, flatImage->numRows, flatImage->numCols);
         return false;
-    } else if(totOffCol > flatImage->numCols-1) {
-        psError(__func__, " : Line %d - Initial column offset exceeds that of mask image. (%d vs %d).",
-                __LINE__, totOffCol, flatImage->numCols);
+    } else if(totOffRow>=inImage->numRows || totOffCol>=inImage->numCols) {
+        psError(__func__, " : Line %d - Total offset >= input image: (%d, %d) vs (%d, %d)",
+                __LINE__, totOffRow, totOffCol, inImage->numRows, inImage->numCols);
         return false;
-    } else if(totOffRow > inImage->numRows-1) {
-        psError(__func__, " : Line %d - Initial row offset exceeds that of input image. (%d vs %d).",
-                __LINE__, totOffRow, inImage->numRows);
-        return false;
-    } else if(totOffCol > inImage->numCols-1) {
-        psError(__func__, " : Line %d - Initial column offset exceeds that of input image. (%d vs %d).",
-                __LINE__, totOffCol, inImage->numCols);
-        return false;
-    } else if(totOffRow > inMask->numRows-1) {
-        psError(__func__, " : Line %d - Initial row offset exceeds that of input image mask. (%d vs %d).",
-                __LINE__, totOffRow, inMask->numRows);
-        return false;
-    } else if(totOffCol > inMask->numCols-1) {
-        psError(__func__, " : Line %d - Initial column offset exceeds that of input image mask. (%d vs %d).",
-                __LINE__, totOffCol, inMask->numCols);
+    } else if(totOffRow>=inMask->numRows || totOffCol>=inMask->numCols) {
+        psError(__func__, " : Line %d - Total offset >= input image mask: (%d, %d) vs (%d, %d)",
+                __LINE__, totOffRow, totOffCol, inMask->numRows, inMask->numCols);
         return false;
     }
@@ -136,5 +116,5 @@
         return false;
     } else if(inType != flatType) {
-        psError(__func__, " : Line %d - Input and flat image types differ. (%d vs %d)", __LINE__, inType,
+        psError(__func__, " : Line %d - Input and flat image types differ: (%d vs %d)", __LINE__, inType,
                 flatType);
         return false;
@@ -149,5 +129,5 @@
             if(flatImage->data.TYPE[j][i] <= 0.0) {                                                          \
                 /* Negative or zero flat pixels shall be masked in input image as  PM_MASK_FLAT */           \
-                inMask->data.PS_TYPE_MASK_DATA[j][i] = PM_MASK_FLAT;                                         \
+                inMask->data.PS_TYPE_MASK_DATA[j][i] |= PM_MASK_FLAT;                                        \
             }                                                                                                \
         }                                                                                                    \
@@ -178,5 +158,4 @@
     }
 
-    printf("");
     return true;
 }
