Index: trunk/psModules/src/pmSubtractSky.c
===================================================================
--- trunk/psModules/src/pmSubtractSky.c	(revision 2585)
+++ trunk/psModules/src/pmSubtractSky.c	(revision 2586)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-01 21:26:17 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-01 21:27:26 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -143,87 +143,86 @@
 
     psStatsOptions statOptions = stats->options;
-    if (1 < p_psDetermineNumBits(statOptions) {
-            //XXX  psWarning(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
-            statOptions = getHighestPriorityStatOption(statOptions)
-                              ;
-            }
-
-            // Bin the input image according to input parameters.
-            if ((binFactor <= 0) ||
-                    (stats == NULL)) {
-            if (binFactor <= 0) {
-                    psLogMsg(__func__, PS_LOG_WARN,
-                             "WARNING: pmSubtractSky(): binFactor is %d\n", binFactor);
-                }
-                if (stats == NULL) {
-                    psLogMsg(__func__, PS_LOG_WARN,
-                             "WARNING: pmSubtractSky(): input parameter stats is NULL\n");
-                }
-                binnedImage = origImage;
-            } else {
-                binnedImage = binImage(origImage, binFactor, statOptions);
-            }
-
-            // Clip pixels that are outside the acceptable range.
-            if (clipSD <= 0.0) {
+    if (1 < p_psDetermineNumBits(statOptions)) {
+        //XXX  psWarning(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
+        statOptions = getHighestPriorityStatOption(statOptions);
+    }
+
+    // Bin the input image according to input parameters.
+    if ((binFactor <= 0) ||
+            (stats == NULL)) {
+        if (binFactor <= 0) {
             psLogMsg(__func__, PS_LOG_WARN,
-                     "WARNING: pmSubtractSky(): clipSD is %f\n", clipSD)
-                ;
-            } else {
-                psF64 binnedMean;
-                psF64 binnedStdev;
-                psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
-                myStats =  psImageStats(myStats, binedImage, NULL, 0);
-                p_psGetStatValue(myStats, &binnedMean);
-
-                myStats->options = PS_STAT_SAMPLE_STDEV;
-                myStats =  psImageStats(myStats, binedImage, NULL, 0);
-                p_psGetStatValue(myStats, &binnedStdev);
-                psFree(myStats);
-
-                for (int row = 0; row < binnedImage->numRows ; row++) {
-                    for (int col = 0; col < binnedImage->numCols ; col++) {
-                        if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
-                                (clipSD * binnedStdev)) {
-                            binnedImage->mask.U8[row][col] = 1;
-                        }
-                    }
+                     "WARNING: pmSubtractSky(): binFactor is %d\n", binFactor);
+        }
+        if (stats == NULL) {
+            psLogMsg(__func__, PS_LOG_WARN,
+                     "WARNING: pmSubtractSky(): input parameter stats is NULL\n");
+        }
+        binnedImage = origImage;
+    } else {
+        binnedImage = binImage(origImage, binFactor, statOptions);
+    }
+
+    // Clip pixels that are outside the acceptable range.
+    if (clipSD <= 0.0) {
+        psLogMsg(__func__, PS_LOG_WARN,
+                 "WARNING: pmSubtractSky(): clipSD is %f\n", clipSD)
+        ;
+    } else {
+        psF64 binnedMean;
+        psF64 binnedStdev;
+        psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
+        myStats =  psImageStats(myStats, binedImage, NULL, 0);
+        p_psGetStatValue(myStats, &binnedMean);
+
+        myStats->options = PS_STAT_SAMPLE_STDEV;
+        myStats =  psImageStats(myStats, binedImage, NULL, 0);
+        p_psGetStatValue(myStats, &binnedStdev);
+        psFree(myStats);
+
+        for (int row = 0; row < binnedImage->numRows ; row++) {
+            for (int col = 0; col < binnedImage->numCols ; col++) {
+                if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
+                        (clipSD * binnedStdev)) {
+                    binnedImage->mask.U8[row][col] = 1;
                 }
             }
-
-            // XXX: fit the polynomial to the binned image
-            if (fit == PM_FIT_POLYNOMIAL) {
-            // Fit a polynomial to the old overscan vector.
-            myPoly = (psPolynomial2D *)
-                         fitSpec;
-                myPoly = psImageFitPolynomial(myPoly, origImage);
-                // XXX Do we need to do something with ordinate scaling if Chebyshev?
-                binnedImage = psImageEvalPolynomial(binnedImage, myPoly);
-
-            } else if (fit == PM_FIT_SPLINE) {
-            // Fit a spline to the old overscan vector.
-            mySpline = (psSpline1D *)
-                           fitSpec;
-                // XXX: What do we do?  We don't have 2-D splines.
-                return(in);
+        }
+    }
+
+    // XXX: fit the polynomial to the binned image
+    if (fit == PM_FIT_POLYNOMIAL) {
+        // Fit a polynomial to the old overscan vector.
+        myPoly = (psPolynomial2D *)
+                 fitSpec;
+        myPoly = psImageFitPolynomial(myPoly, origImage);
+        // XXX Do we need to do something with ordinate scaling if Chebyshev?
+        binnedImage = psImageEvalPolynomial(binnedImage, myPoly);
+
+    } else if (fit == PM_FIT_SPLINE) {
+        // Fit a spline to the old overscan vector.
+        mySpline = (psSpline1D *)
+                   fitSpec;
+        // XXX: What do we do?  We don't have 2-D splines.
+        return(in);
+    }
+
+    //Subtract the polynomially fitted image from the original image
+    if (binFactor <= 0) {
+        for (int row = 0; row < origImage->numRows ; row++) {
+            for (int col = 0; col < origImage->numCols ; col++) {
+                origImage->data.F32[row][col]-= binnedImage->data.F32[row][col];
             }
-
-            //Subtract the polynomially fitted image from the original image
-            if (binFactor <= 0) {
-            for (int row = 0; row < origImage->numRows ; row++) {
-                    for (int col = 0; col < origImage->numCols ; col++) {
-                        origImage->data.F32[row][col]-= binnedImage->data.F32[row][col];
-                    }
-                }
-            } else {
-                for (int row = 0; row < origImage->numRows ; row++) {
-                    for (int col = 0; col < origImage->numCols ; col++) {
-                        int binRow = row / binFactor;
-                        int binCol = col / binFactor;
-                        origImage->data.F32[row][col]-= binnedImage->data.F32[binRow][binCol];
-                    }
-                }
-
+        }
+    } else {
+        for (int row = 0; row < origImage->numRows ; row++) {
+            for (int col = 0; col < origImage->numCols ; col++) {
+                int binRow = row / binFactor;
+                int binCol = col / binFactor;
+                origImage->data.F32[row][col]-= binnedImage->data.F32[binRow][binCol];
             }
-            return(in);
-        }
+        }
+
+    }
+    return(in);
+}
