Index: trunk/psModules/src/pmSubtractSky.c
===================================================================
--- trunk/psModules/src/pmSubtractSky.c	(revision 4030)
+++ trunk/psModules/src/pmSubtractSky.c	(revision 4425)
@@ -6,9 +6,11 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-25 20:28:32 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-29 01:39:10 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-xd *
+ *
+ *      
+ *
  */
 
@@ -20,14 +22,18 @@
 
 /******************************************************************************
-p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an
+DetermineNumBits(data): This routine takes an enum psStatsOptions as an
 argument and returns the number of non-zero bits.
+ 
+XXX: This code is duplicated in the ReadoutCombine file.
  *****************************************************************************/
-psStatsOptions p_psDetermineNumBits(psStatsOptions data)
+static psS32 DetermineNumBits(psStatsOptions data)
 {
+    psTrace("SubtractSky.DetermineNumBits", 4, "Calling DetermineNumBits(0x%x)\n", data);
+
     psS32 i;
     psU64 tmpData = data;
     psS32 numBits = 0;
 
-    for (i=0;i<8 * sizeof(psStatsOptions);i++) {
+    for (i=0;i<(8 * sizeof(psStatsOptions));i++) {
         if (0x0001 & tmpData) {
             numBits++;
@@ -35,4 +41,7 @@
         tmpData = tmpData >> 1;
     }
+
+    psTrace("SubtractSky.DetermineNumBits", 4,
+            "Calling DetermineNumBits(0x%x) -> %d\n", data, numBits);
     return(numBits);
 }
@@ -43,6 +52,9 @@
 option set according to the precedence set in the SDRS.
  *****************************************************************************/
-psU64 getHighestPriorityStatOption(psU64 statOptions)
+static psU64 getHighestPriorityStatOption(psU64 statOptions)
 {
+    psTrace("SubtractSky.getHighestPriorityStatOption", 4,
+            "Calling getHighestPriorityStatOption(0x%x)\n", statOptions);
+
     if (statOptions & PS_STAT_SAMPLE_MEAN) {
         return(PS_STAT_SAMPLE_MEAN);
@@ -72,8 +84,11 @@
 requirements change and we might need a custom reBin function.
  *****************************************************************************/
-psImage *binImage(psImage *origImage,
-                  int binFactor,
-                  psStatsOptions statOptions)
+/*
+static psImage *binImage(psImage *origImage,
+                         int binFactor,
+                         psStatsOptions statOptions)
 {
+    psTrace("SubtractSky.binImage", 4, "Calling binImage(%d)\n", binFactor);
+ 
     if (binFactor <= 0) {
         psLogMsg(__func__, PS_LOG_WARN,
@@ -84,9 +99,9 @@
         return(origImage);
     }
-
+ 
     psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32);
     psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_U8);
     psStats *myStats = psStatsAlloc(statOptions);
-
+ 
     for (psS32 row = 0; row < origImage->numRows ; row+=binFactor) {
         for (psS32 col = 0; col < origImage->numCols ; col+=binFactor) {
@@ -113,5 +128,5 @@
             psF64 statValue;
             psBool rc = p_psGetStatValue(rc1, &statValue);
-
+ 
             if (rc == true) {
                 origImage->data.F32[row][col] = (psF32) statValue;
@@ -126,14 +141,21 @@
     psFree(binMask);
     psFree(myStats);
-
+ 
+    psTrace("SubtractSky.binImage", 4, "Exiting binImage(%d)\n", binFactor);
     return(origImage);
 }
+*/
 
 /******************************************************************************
 CalculatePolyTerms(xOrder, yOrder): this routine will calculate the number of
 coefficients (or terms) in a 2-D polynomial of order (xOrder, yOrder).
+ 
+XXX: Use your brain and figure out the analytical expression.
  *****************************************************************************/
-psS32 CalculatePolyTerms(psS32 xOrder, psS32 yOrder)
+static psS32 CalculatePolyTerms(psS32 xOrder, psS32 yOrder)
 {
+    psTrace("SubtractSky.CalculatePolyTerms", 4,
+            "Calling CalculatePolyTerms(%d, %d)\n", xOrder, yOrder);
+
     psS32 maxOrder = PS_MAX(xOrder, yOrder);
     psS32 localPolyTerms = 0;
@@ -148,4 +170,7 @@
         }
     }
+
+    psTrace("SubtractSky.CalculatePolyTerms", 4,
+            "Exiting CalculatePolyTerms(%d, %d) -> %d\n", xOrder, yOrder, localPolyTerms);
     return(localPolyTerms);
 }
@@ -162,6 +187,9 @@
     poly-order sky background polynomial.
  *****************************************************************************/
-psS32 **buildPolyTerms(psS32 xOrder, psS32 yOrder)
+static psS32 **buildPolyTerms(psS32 xOrder, psS32 yOrder)
 {
+    psTrace("SubtractSky.buildPolyTerms", 4,
+            "Calling buildPolyTerms(%d, %d)\n", xOrder, yOrder);
+
     psS32 i=0;
     psS32 order = 0;
@@ -196,4 +224,6 @@
     }
 
+    psTrace("SubtractSky.buildPolyTerms", 4,
+            "Exiting buildPolyTerms(%d, %d)\n", xOrder, yOrder);
     return(polyTerms);
 }
@@ -206,14 +236,20 @@
  
 XXX: Use a psImage for the p_psPolySums data structure?
+XXX: p_psPolySums: should this be a global?  Did you get the storage classifier
+     and name correct?
 XXX: Use variable size arrays for p_psPolySums[][].
 XXX: Must initialize p_psPolySums[][]?
  *****************************************************************************/
 #define PS_MAX_POLYNOMIAL_ORDER 20
+
 psF64 p_psPolySums[PS_MAX_POLYNOMIAL_ORDER+1][PS_MAX_POLYNOMIAL_ORDER+1];
-void buildSums(psF64 x,
-               psF64 y,
-               psS32 xOrder,
-               psS32 yOrder)
+static void buildSums(psF64 x,
+                      psF64 y,
+                      psS32 xOrder,
+                      psS32 yOrder)
 {
+    psTrace("SubtractSky.buildPolyTerms", 4,
+            "Calling buildPolyTerms(%d, %d)\n", xOrder, yOrder);
+
     psS32 i = 0;
     psS32 j = 0;
@@ -231,4 +267,6 @@
         xSum*= x;
     }
+    psTrace("SubtractSky.buildPolyTerms", 4,
+            "Exiting buildPolyTerms(%d, %d)\n", xOrder, yOrder);
 }
 
@@ -242,11 +280,13 @@
 used in this routine is based on that of the pilot project ADD, but is not
 documented anywhere.
+ 
+XXX: Different trace message facilities in use here.
  *****************************************************************************/
-psPolynomial2D *ImageFitPolynomial(psPolynomial2D *myPoly,
-                                   psImage *dataImage,
-                                   psImage *maskImage)
+static psPolynomial2D *ImageFitPolynomial(psPolynomial2D *myPoly,
+        psImage *dataImage,
+        psImage *maskImage)
 {
-    psTrace(".psModule.pmSubtractSky.ImageFitPolynomial", 4,
-            "---- ImageFitPolynomial() begin ----\n");
+    psTrace("SubtractSky.ImageFitPolynomial", 4,
+            "Calling ImageFitPolynomial()\n");
     PS_ASSERT_POLY_NON_NULL(myPoly, NULL);
     PS_ASSERT_POLY_TYPE(myPoly, PS_POLYNOMIAL_ORD, NULL);
@@ -404,6 +444,8 @@
     }
 
-    psTrace(".psModule.pmSubtractSky.ImageFitPolynomial", 4,
-            "---- ImageFitPolynomial() end successfully ----\n");
+    psTrace("SubtractSky.ImageFitPolynomial", 4,
+            "Exiting ImageFitPolynomial()\n");
+    //    psTrace(".psModule.pmSubtractSky.ImageFitPolynomial", 4,
+    //            "---- ImageFitPolynomial() end successfully ----\n");
     return(myPoly);
 }
@@ -416,4 +458,6 @@
  
 XXX: The SDR is silent about types.  PS_TYPE_F32 is implemented here.
+ 
+XXX: Sync the psTrace message facilities.
  *****************************************************************************/
 psReadout *pmSubtractSky(psReadout *in,
@@ -459,5 +503,5 @@
     if (stats != NULL) {
         statOptions = stats->options;
-        if (1 < p_psDetermineNumBits(statOptions)) {
+        if (1 < DetermineNumBits(statOptions)) {
             psLogMsg(__func__, PS_LOG_WARN, "WARNING: Multiple statistical options have been requested.\n");
             statOptions = getHighestPriorityStatOption(statOptions);
@@ -470,5 +514,5 @@
             stats->options = statOptions;
         }
-        if (0 == p_psDetermineNumBits(statOptions)) {
+        if (0 == DetermineNumBits(statOptions)) {
             psLogMsg(__func__, PS_LOG_WARN,
                      "WARNING: pmSubtractSky(): no stats->options was requested\n");
@@ -492,5 +536,5 @@
     // Create a new binned image mask.
     //
-    if ((binFactor <= 1) || (stats == NULL) || (0 == p_psDetermineNumBits(statOptions))) {
+    if ((binFactor <= 1) || (stats == NULL) || (0 == DetermineNumBits(statOptions))) {
         // No binning is required here.  Simply create a copy of the image
         // and a mask.
