Index: trunk/psModules/test/tst_pmSubtractSky.c
===================================================================
--- trunk/psModules/test/tst_pmSubtractSky.c	(revision 2757)
+++ trunk/psModules/test/tst_pmSubtractSky.c	(revision 2757)
@@ -0,0 +1,135 @@
+/** @file tst_pmSubtractSky.c
+ *
+ *  @brief Contains the tests for pmSubtractSky.c:
+ *
+ * test00: This code will ...
+ *
+ *  @author GLG, MHPCC
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-18 02:28:33 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+#include "psTest.h"
+#include "pslib.h"
+#include "pmSubtractSky.h"
+#define NUM_ROWS 5
+#define NUM_COLS 5
+#define POLY_X_ORDER 3
+#define POLY_Y_ORDER 5
+
+static int test00(void);
+testDescription tests[] = {
+                              {test00, 000, "pmSubtractSky", 0, false},
+                              {NULL}
+                          };
+
+float func(int i, int j)
+{
+    return((float) (i + j));
+}
+
+int main(int argc, char* argv[])
+{
+    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
+}
+
+int doSubtractSkySimple(int numCols, int numRows, int binFactor)
+{
+    int i;
+    int j;
+    int testStatus = 0;
+    psImage *tmpImage1 = psImageAlloc(numCols, numRows, PS_TYPE_F32);
+    psReadout *myReadout = psReadoutAlloc(numCols, numRows, tmpImage1);
+    psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+    psPolynomial2D *myPoly = psPolynomial2DAlloc(POLY_X_ORDER, POLY_Y_ORDER, PS_POLYNOMIAL_ORD);
+
+    for (i=0;i<numRows;i++) {
+        for (j=0;j<numCols;j++) {
+            myReadout->image->data.F32[i][j] = func(i, j);
+            //printf("data[%d][%d] is %.2f\n", i, j, myReadout->image->data.F32[i][j]);
+        }
+    }
+
+    myReadout = pmSubtractSky(myReadout, (void *) myPoly, PM_FIT_POLYNOMIAL,
+                              binFactor, myStats, 10.0);
+    for (i=0;i<numRows;i++) {
+        for (j=0;j<numCols;j++) {
+            if (1.0 < fabs(myReadout->image->data.F32[i][j])) {
+                printf("ERROR: image[%d][%d] is %f, should be 0.0\n", i, j, myReadout->image->data.F32[i][j]);
+                testStatus = 1;
+            }
+        }
+    }
+    psFree(myReadout);
+    psFree(myStats);
+    psFree(myPoly);
+    return(testStatus);
+}
+
+int doSubtractSkyWithObjects(int numCols, int numRows, int binFactor)
+{
+    int i;
+    int j;
+    int testStatus = 0;
+    psImage *tmpImage1 = psImageAlloc(numCols, numRows, PS_TYPE_F32);
+    psReadout *myReadout = psReadoutAlloc(numCols, numRows, tmpImage1);
+    psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+    psPolynomial2D *myPoly = psPolynomial2DAlloc(POLY_X_ORDER, POLY_Y_ORDER, PS_POLYNOMIAL_ORD);
+
+    for (i=0;i<numRows;i++) {
+        for (j=0;j<numCols;j++) {
+            myReadout->image->data.F32[i][j] = func(i, j);
+            //printf("data[%d][%d] is %.2f\n", i, j, myReadout->image->data.F32[i][j]);
+        }
+    }
+    // We insert a few bright spots in the image.
+    myReadout->image->data.F32[NUM_ROWS/4][NUM_COLS/4]+= 1000.0;
+    myReadout->image->data.F32[NUM_ROWS/4][3*NUM_COLS/4]+= 1000.0;
+    myReadout->image->data.F32[3*NUM_ROWS/4][NUM_COLS/4]+= 1000.0;
+    myReadout->image->data.F32[3*NUM_ROWS/4][3*NUM_COLS/4]+= 1000.0;
+    for (i=0;i<numRows;i++) {
+        for (j=0;j<numCols;j++) {
+            printf("data[%d][%d] is %.2f\n", i, j, myReadout->image->data.F32[i][j]);
+        }
+    }
+
+    myReadout = pmSubtractSky(myReadout, (void *) myPoly, PM_FIT_POLYNOMIAL,
+                              binFactor, myStats, 2.0);
+    for (i=0;i<numRows;i++) {
+        for (j=0;j<numCols;j++) {
+            if (1.0 < fabs(myReadout->image->data.F32[i][j])) {
+                printf("ERROR: image[%d][%d] is %f, should be 0.0\n", i, j, myReadout->image->data.F32[i][j]);
+                testStatus = 1;
+            }
+        }
+    }
+    psFree(myReadout);
+    psFree(myStats);
+    psFree(myPoly);
+    return(testStatus);
+}
+
+
+int test00( void )
+{
+    int testStatus = 0;
+
+    psTraceSetLevel(".", 0);
+    // Bin Factor == 1
+    //    testStatus |= doSubtractSkySimple(1, 1, 1);
+    //    testStatus |= doSubtractSkySimple(NUM_COLS, 1, 1);
+    //    testStatus |= doSubtractSkySimple(1, NUM_ROWS, 1);
+    //    testStatus |= doSubtractSkySimple(NUM_COLS, NUM_ROWS, 1);
+
+    // Bin Factor == 2
+    //    testStatus |= doSubtractSkySimple(1, 1, 2);
+    //    testStatus |= doSubtractSkySimple(NUM_COLS, 1, 2);
+    //    testStatus |= doSubtractSkySimple(1, NUM_ROWS, 2);
+    //    testStatus |= doSubtractSkySimple(NUM_COLS, NUM_ROWS, 2);
+
+    testStatus |= doSubtractSkyWithObjects(NUM_COLS, NUM_ROWS, 1);
+
+    return(testStatus);
+}
