Index: trunk/psModules/src/pmNonLinear.c
===================================================================
--- trunk/psModules/src/pmNonLinear.c	(revision 2857)
+++ trunk/psModules/src/pmNonLinear.c	(revision 2915)
@@ -5,8 +5,10 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-30 22:22:00 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-05 23:25:24 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ *
+ *  XXX: The SDR is silent about image types.  Only F32 was implemented.
  *
  */
@@ -28,20 +30,20 @@
  *****************************************************************************/
 
-psReadout *pmNonLinearityPolynomial(psReadout *in,
-                                    const psPolynomial1D *coeff)
+psReadout *pmNonLinearityPolynomial(psReadout *inputReadout,
+                                    const psPolynomial1D *input1DPoly)
 {
-    PS_PTR_CHECK_NULL(in,NULL);
-    PS_PTR_CHECK_NULL(in->image, NULL);
-    PS_PTR_CHECK_NULL(coeff,NULL);
+    PS_PTR_CHECK_NULL(inputReadout, NULL);
+    PS_PTR_CHECK_NULL(inputReadout->image, NULL);
+    PS_PTR_CHECK_NULL(input1DPoly, NULL);
 
     psS32 i;
     psS32 j;
 
-    for (i=0;i<(in->image)->numRows;i++) {
-        for (j=0;j<(in->image)->numCols;j++) {
-            (in->image)->data.F32[i][j] = psPolynomial1DEval(coeff, (in->image)->data.F32[i][j]);
+    for (i=0;i<(inputReadout->image)->numRows;i++) {
+        for (j=0;j<(inputReadout->image)->numCols;j++) {
+            (inputReadout->image)->data.F32[i][j] = psPolynomial1DEval(input1DPoly, (inputReadout->image)->data.F32[i][j]);
         }
     }
-    return(in);
+    return(inputReadout);
 }
 
@@ -54,16 +56,25 @@
 be set to the value from outFlux.
  *****************************************************************************/
-psReadout *pmNonLinearityLookup(psReadout *in,
+psReadout *pmNonLinearityLookup(psReadout *inputReadout,
                                 const psVector *inFlux,
                                 const psVector *outFlux)
 {
-    PS_PTR_CHECK_NULL(in,NULL);
-    PS_PTR_CHECK_NULL(in->image,NULL);
+    PS_PTR_CHECK_NULL(inputReadout,NULL);
+    PS_PTR_CHECK_NULL(inputReadout->image,NULL);
     PS_PTR_CHECK_NULL(inFlux,NULL);
+    psS32 tableSize = inFlux->n;
+    if (inFlux->n < 2) {
+        psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements.  Returning inputReadout image.");
+        return(inputReadout);
+    }
     PS_PTR_CHECK_NULL(outFlux,NULL);
+    if (inFlux->n != outFlux->n) {
+        tableSize = PS_MIN(inFlux->n, outFlux->n);
+        psLogMsg(__func__, PS_LOG_WARN,
+                 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n);
+    }
 
     psS32 i;
     psS32 j;
-    psS32 tableSize = inFlux->n;
     psS32 binNum;
     psScalar x;
@@ -72,16 +83,7 @@
 
     x.type.type = PS_TYPE_F32;
-    if (inFlux->n != outFlux->n) {
-        tableSize = PS_MIN(inFlux->n, outFlux->n);
-        psLogMsg(__func__, PS_LOG_WARN,
-                 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n);
-    }
-    if (inFlux->n < 2) {
-        psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements.  Returning in image.");
-        return(in);
-    }
-    for (i=0;i<(in->image)->numRows;i++) {
-        for (j=0;j<(in->image)->numCols;j++) {
-            x.data.F32 = (in->image)->data.F32[i][j];
+    for (i=0;i<(inputReadout->image)->numRows;i++) {
+        for (j=0;j<(inputReadout->image)->numCols;j++) {
+            x.data.F32 = (inputReadout->image)->data.F32[i][j];
 
             binNum = p_psVectorBinDisect((psVector *)inFlux, &x);
@@ -89,16 +91,16 @@
             if (binNum == -2) {
                 // We get here if x is below the table lookup range.
-                (in->image)->data.F32[i][j] = outFlux->data.F32[0];
+                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[0];
                 numPixels++;
 
             } else if (binNum == -1) {
                 // We get here if x is above the table lookup range.
-                (in->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1];
+                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1];
 
                 numPixels++;
             } else if (binNum < -2) {
                 // We get here if there was some other problem.
-                psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect().  Returning in image.");
-                return(in);
+                psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect().  Returning inputReadout image.");
+                return(inputReadout);
                 numPixels++;
             } else {
@@ -106,6 +108,6 @@
                 slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) /
                         (inFlux->data.F32[binNum+1]  - inFlux->data.F32[binNum]);
-                (in->image)->data.F32[i][j] = outFlux->data.F32[binNum] +
-                                              ((x.data.F32 - inFlux->data.F32[binNum]) * slope);
+                (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[binNum] +
+                                                        ((x.data.F32 - inFlux->data.F32[binNum]) * slope);
             }
         }
@@ -115,4 +117,4 @@
                  "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels);
     }
-    return(in);
+    return(inputReadout);
 }
