Index: /branches/czw_branch/20100817/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- /branches/czw_branch/20100817/psModules/src/camera/pmFPAfileIO.c	(revision 29677)
+++ /branches/czw_branch/20100817/psModules/src/camera/pmFPAfileIO.c	(revision 29678)
@@ -552,5 +552,5 @@
       case PM_FPA_FILE_ASTROM_MODEL:
       case PM_FPA_FILE_ASTROM_REFSTARS:
-    case PM_FPA_FILE_LINEARITY:
+      case PM_FPA_FILE_LINEARITY:
         psTrace ("psModules.camera", 5, "closing %s (%s) (%d:%d:%d)\n", file->filename, file->name, view->chip, view->cell, view->readout);
         status = psFitsClose (file->fits);
@@ -631,5 +631,5 @@
       case PM_FPA_FILE_JPEG:
       case PM_FPA_FILE_KAPA:
-    case PM_FPA_FILE_LINEARITY:
+      case PM_FPA_FILE_LINEARITY:
         psTrace ("psModules.camera", 5, "nothing to free for %s (%s)\n", file->filename, file->name);
         return true;
Index: /branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.c
===================================================================
--- /branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.c	(revision 29677)
+++ /branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.c	(revision 29678)
@@ -27,45 +27,45 @@
 
 // set the bin closest to the corresponding value.  
-#define PS_BIN_FOR_VALUE(RESULT, VECTOR, VALUE) { \
-       	psVectorBinaryDisectResult result; \
-       	psScalar tmpScalar; \
-       	tmpScalar.type.type = PS_TYPE_F32; \
-	tmpScalar.data.F32 = (VALUE); \
-	RESULT = psVectorBinaryDisect (&result, VECTOR, &tmpScalar); \
-	switch (result) { \
-	  case PS_BINARY_DISECT_PASS: \
-            break; \
-	  case PS_BINARY_DISECT_OUTSIDE_RANGE: \
-            numPixels ++; \
-	    break; \
-	  case PS_BINARY_DISECT_INVALID_INPUT: \
-	  case PS_BINARY_DISECT_INVALID_TYPE: \
-	    psAbort ("programming error"); \
-	    break; \
+#define PS_BIN_FOR_VALUE(RESULT, VECTOR, VALUE) {			\
+       	psVectorBinaryDisectResult result;				\
+       	psScalar tmpScalar;						\
+       	tmpScalar.type.type = PS_TYPE_F32;				\
+	tmpScalar.data.F32 = (VALUE);					\
+	RESULT = psVectorBinaryDisect (&result, VECTOR, &tmpScalar);	\
+	switch (result) {						\
+	  case PS_BINARY_DISECT_PASS:					\
+            break;							\
+	  case PS_BINARY_DISECT_OUTSIDE_RANGE:				\
+            numPixels ++;						\
+	    break;							\
+	  case PS_BINARY_DISECT_INVALID_INPUT:				\
+	  case PS_BINARY_DISECT_INVALID_TYPE:				\
+	    psAbort ("programming error");				\
+	    break;							\
         } }
 
 
-# define PS_BIN_INTERPOLATE(RESULT, VECTOR, BOUNDS, BIN, VALUE) { \
-    float dX, dY, Xo, Yo, Xt;					  \
-    if (BIN == BOUNDS->n - 1) {					  \
-      dX = 0.5*(BOUNDS->data.F32[BIN+1] - BOUNDS->data.F32[BIN-1]);	\
-      dY = VECTOR->data.F32[BIN] - VECTOR->data.F32[BIN-1];		\
-      Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]);	\
-      Yo = VECTOR->data.F32[BIN];					\
-    } else {								\
-      dX = 0.5*(BOUNDS->data.F32[BIN+2] - BOUNDS->data.F32[BIN]);	\
-      dY = VECTOR->data.F32[BIN+1] - VECTOR->data.F32[BIN];		\
-      Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]);	\
-      Yo = VECTOR->data.F32[BIN];					\
-    }									\
-    if (dY != 0) {							\
-      Xt = (VALUE - Yo)*dX/dY + Xo;					\
-    } else {								\
-      Xt = Xo;								\
-    }									\
-    Xt = PS_MIN (BOUNDS->data.F32[BIN+1], PS_MAX(BOUNDS->data.F32[BIN], Xt)); \
-    psTrace("pmNonLinear", 6, "(Xo, Yo, dX, dY, Xt, Yt) is (%.2f %.2f %.2f %.2f %.2f %.2f)\n",	\
-	    Xo, Yo, dX, dY, Xt, VALUE);					\
-    RESULT = Xt; }
+# define PS_BIN_INTERPOLATE(RESULT, VECTOR, BOUNDS, BIN, VALUE) {	\
+	float dX, dY, Xo, Yo, Xt;					\
+	if (BIN == BOUNDS->n - 1) {					\
+	    dX = 0.5*(BOUNDS->data.F32[BIN+1] - BOUNDS->data.F32[BIN-1]); \
+	    dY = VECTOR->data.F32[BIN] - VECTOR->data.F32[BIN-1];	\
+	    Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]);	\
+	    Yo = VECTOR->data.F32[BIN];					\
+	} else {							\
+	    dX = 0.5*(BOUNDS->data.F32[BIN+2] - BOUNDS->data.F32[BIN]);	\
+	    dY = VECTOR->data.F32[BIN+1] - VECTOR->data.F32[BIN];	\
+	    Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]);	\
+	    Yo = VECTOR->data.F32[BIN];					\
+	}								\
+	if (dY != 0) {							\
+	    Xt = (VALUE - Yo)*dX/dY + Xo;				\
+	} else {							\
+	    Xt = Xo;							\
+	}								\
+	Xt = PS_MIN (BOUNDS->data.F32[BIN+1], PS_MAX(BOUNDS->data.F32[BIN], Xt)); \
+	psTrace("pmNonLinear", 6, "(Xo, Yo, dX, dY, Xt, Yt) is (%.2f %.2f %.2f %.2f %.2f %.2f)\n", \
+		Xo, Yo, dX, dY, Xt, VALUE);				\
+	RESULT = Xt; }
 
 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout, const psVector *inFlux, const psVector *outFlux)
@@ -119,163 +119,215 @@
 bool pmNonLinearityApply(pmReadout *inputReadout, psArray *Ltab)
 {
-  PS_ASSERT_PTR_NON_NULL(inputReadout, false);
-  PS_ASSERT_PTR_NON_NULL(inputReadout->image, false);
-  PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, false);
-  PS_ASSERT_PTR_NON_NULL(Ltab, false);
-
-  //  psS32 tableSize = Ltab->n;
-
-  psImage *image = inputReadout->image;
-  psS32 numSamples = 39;
-  
-  psS32 numBorder  = 10;
-  // Load default data.
-  psVector *default_row_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
-  psVector *default_col_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
-  psVector *row_correction_fluxes;
-  psVector *col_correction_fluxes;
-
-  psVector *default_row_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
-  psVector *default_col_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
-  psVector *row_correction_factors;
-  psVector *col_correction_factors;
-
-  int n = 0;
-  int m = 0;
-  for (int k = 0; k < Ltab->n; k++) { // Begin load default tables
-    psMetadata *row = Ltab->data[k];	
-    if (psMetadataLookupS32(NULL,row,"POSITION") != -1) {
-      continue;
-    }
-    if (psMetadataLookupS32(NULL,row,"DIRECTION") == 0) {
-      psVectorSet(default_row_correction_fluxes,n,psMetadataLookupF32(NULL,row,"FLUX"));
-      psVectorSet(default_row_correction_factors,n,psMetadataLookupF32(NULL,row,"FACTOR"));
-      n++;
-    }
-    else {
-      psVectorSet(default_col_correction_fluxes,m,psMetadataLookupF32(NULL,row,"FLUX"));
-      psVectorSet(default_col_correction_factors,m,psMetadataLookupF32(NULL,row,"FACTOR"));
-      m++;
-    }
-  } // End load default tables
-  
-  for (int i = 0; i < image->numRows; i++) { // Loop over rows : note: problem with discontinuity here
-    n = 0;
-    if ((i < numBorder)||(image->numRows - i < numBorder)) {     // Load row correction data
-      row_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
-      row_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
-
-      for (int k = 0; k < Ltab->n; k++) {
+    PS_ASSERT_PTR_NON_NULL(inputReadout, false);
+    PS_ASSERT_PTR_NON_NULL(inputReadout->image, false);
+    PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, false);
+    PS_ASSERT_PTR_NON_NULL(Ltab, false);
+
+    psTimerStart ("nonlinear");
+
+    psS32 numSamples = 39;
+    psS32 numBorder  = 10;
+
+    //  psS32 tableSize = Ltab->n;
+
+    psImage *image = inputReadout->image;
+
+    // Load default data.
+    psVector *default_row_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
+    psVector *default_col_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
+
+    psVector *default_row_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
+    psVector *default_col_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
+
+    // pre-allocate the correction vectors
+    psVector *row_correction_fluxes  = NULL;
+    psVector *col_correction_fluxes  = NULL;
+    psVector *row_correction_factors = NULL;
+    psVector *col_correction_factors = NULL;
+
+    int n = 0;
+    int m = 0;
+    for (int k = 0; k < Ltab->n; k++) { // Begin load default tables
 	psMetadata *row = Ltab->data[k];	
-	if ((psMetadataLookupS32(NULL,row,"DIRECTION") != 0)||
-	    (psMetadataLookupS32(NULL,row,"POSITION") != i + 1)) { // image data is 0 indexed, but correction data is 1 indexed.
-	  continue;
-	}
-	psVectorSet(row_correction_fluxes,n,psMetadataLookupF32(NULL,row,"FLUX"));
-	psVectorSet(row_correction_factors,n,psMetadataLookupF32(NULL,row,"FACTOR"));
-	//	psTrace("psModules.camera",6,"rows: %d\n",n);
-	n++;
-      }
-    } // End load specific row
-    else {
-      row_correction_fluxes = default_row_correction_fluxes;
-      row_correction_factors = default_row_correction_factors;
-    } // End load default row
-      
-    for (int j = 0; j < image->numCols; j++) { // Loop over columns
-      m = 0;
-
-      if ((j < numBorder)||(image->numCols - j < numBorder)) {       // Load col correction data
-	col_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32);
-	col_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32);
-	for (int k = 0; k < Ltab->n; k++) {
-	  psMetadata *row = Ltab->data[k];	
-	  if ((psMetadataLookupS32(NULL,row,"DIRECTION") != 1)||
-	      (psMetadataLookupS32(NULL,row,"POSITION") != j + 1)) {
+	if (psMetadataLookupS32(NULL,row,"POSITION") != -1) {
 	    continue;
-	  }
-	  psVectorSet(col_correction_fluxes,m,psMetadataLookupF32(NULL,row,"FLUX"));
-	  psVectorSet(col_correction_factors,m,psMetadataLookupF32(NULL,row,"FACTOR"));
-	  //	  psTrace("psModules.camera",6,"columns: %d\n",m);
-	  m++;
-	}
-      } // End load specific col
-      else {
-	col_correction_fluxes = default_col_correction_fluxes;
-	col_correction_factors = default_col_correction_factors;
-      } // End load default col
-
-      // Calculate correction factor contribution for this pixel.
-      psF32 factor_row = pmNonLinearityMeasure(image->data.F32[i][j],
-					       row_correction_fluxes,row_correction_factors);
-      psF32 factor_col = pmNonLinearityMeasure(image->data.F32[i][j],
-					       col_correction_fluxes,col_correction_factors);
-
-      if (((i <= 9)&&(j <= 9))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case.
-	psTrace("psModules.camera",6,"Linearity: %d %d %s %f %f %f %d %d\n",i,j,
-		psMetadataLookupStr(NULL,inputReadout->parent->concepts,"CELL.NAME"),
-		image->data.F32[i][j],factor_row,factor_col,numBorder,numSamples);
-	psTrace("psModules.camera",6,"Linearity: R: %d %d %d C: %d %d %d\n",
-		i,(i < numBorder),(image->numRows - i),
-		j,(j < numBorder),(image->numCols - j));
-
-/* 	psTrace("psModules.camera",6,"Linearity: V: "); */
-/* 	for (int k = 0; k < numSamples; k++) { */
-/* 	  psTrace("psModules.camera",6,"(%f %f) ", */
-/* 		  col_correction_fluxes->data.F32[k],col_correction_factors->data.F32[k]); */
-/* 	} */
-/* 	psTrace("psModules.camera",6,"\n"); */
-      } // End Test case
-
-      // Apply correction to image data
-      image->data.F32[i][j] = image->data.F32[i][j] * ( factor_row * factor_col ) ;
-
-      // Free correction if we allocated
-      if ((j < numBorder)||(image->numCols - j < numBorder)) {
-	psFree(col_correction_fluxes);
-	psFree(col_correction_factors);
-      }
-
-    } // End loop over columns
-
-    // Free correction if we allocated
-    if ((i < numBorder)||(image->numRows - i < numBorder)) {
-      psFree(row_correction_fluxes);
-      psFree(row_correction_factors);
-    }
-
-  } // End loop over rows
-
-  psFree(default_row_correction_fluxes);
-  psFree(default_row_correction_factors);
-  psFree(default_col_correction_fluxes);
-  psFree(default_col_correction_factors);
-  
-  return(true);
+	}
+	if (psMetadataLookupS32(NULL,row,"DIRECTION") == 0) {
+	    psVectorSet(default_row_correction_fluxes,n,psMetadataLookupF32(NULL,row,"FLUX"));
+	    psVectorSet(default_row_correction_factors,n,psMetadataLookupF32(NULL,row,"FACTOR"));
+	    n++;
+	}
+	else {
+	    psVectorSet(default_col_correction_fluxes,m,psMetadataLookupF32(NULL,row,"FLUX"));
+	    psVectorSet(default_col_correction_factors,m,psMetadataLookupF32(NULL,row,"FACTOR"));
+	    m++;
+	}
+    } // End load default tables
+  
+    psLogMsg ("psModules", PS_LOG_MINUTIA, "load default data from table: %f sec\n", psTimerMark ("nonlinear"));
+
+    // pre-allocate arrays with the correction vectors for the borders
+    psArray *x_lo_flux = psArrayAlloc(numBorder);
+    psArray *x_hi_flux = psArrayAlloc(numBorder);
+    psArray *y_lo_flux = psArrayAlloc(numBorder);
+    psArray *y_hi_flux = psArrayAlloc(numBorder);
+
+    psArray *x_lo_fact = psArrayAlloc(numBorder);
+    psArray *x_hi_fact = psArrayAlloc(numBorder);
+    psArray *y_lo_fact = psArrayAlloc(numBorder);
+    psArray *y_hi_fact = psArrayAlloc(numBorder);
+    for (int i = 0; i < numBorder; i++) {
+	// pre-allocate the correction vectors
+	x_lo_flux->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	x_hi_flux->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	y_lo_flux->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	y_hi_flux->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+
+	x_lo_fact->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	x_hi_fact->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	y_lo_fact->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+	y_hi_fact->data[i] = psVectorAllocEmpty(numSamples,PS_TYPE_F32);
+    }	
+
+    // parse out the full table:
+    for (int k = 0; k < Ltab->n; k++) {
+	psMetadata *row = Ltab->data[k];	
+	int dir = psMetadataLookupS32(NULL,row,"DIRECTION");
+	int pos = psMetadataLookupS32(NULL,row,"POSITION");
+
+	psVector *fluxVector = NULL;
+	psVector *factVector = NULL;
+
+	int seq = -1;
+	if ((dir == 0) && (pos < image->numCols/2)) {
+	    seq = pos - 1;
+	    if (seq < 0) continue;
+	    fluxVector = x_lo_flux->data[seq];
+	    factVector = x_lo_fact->data[seq];
+	} 
+	if ((dir == 0) && (pos > image->numCols/2)) {
+	    seq = pos - 1 + numBorder - image->numCols;
+	    if (seq >= image->numCols) continue;
+	    fluxVector = x_hi_flux->data[seq];
+	    factVector = x_hi_fact->data[seq];
+	}
+	if ((dir == 1) && (pos < image->numRows/2)) {
+	    seq = pos - 1;
+	    if (seq < 0) continue;
+	    fluxVector = y_lo_flux->data[seq];
+	    factVector = y_lo_fact->data[seq];
+	} 
+	if ((dir == 1) && (pos > image->numRows/2)) {
+	    seq = pos - 1 + numBorder - image->numRows;
+	    if (seq >= image->numRows) continue;
+	    fluxVector = y_hi_flux->data[seq];
+	    factVector = y_hi_fact->data[seq];
+	}
+
+	float flux = psMetadataLookupF32(NULL,row,"FLUX");
+	float factor = psMetadataLookupF32(NULL,row,"FACTOR");
+
+	psVectorAppend(fluxVector, flux);
+	psVectorAppend(factVector, factor);
+    }
+    psLogMsg ("psModules", PS_LOG_MINUTIA, "load border data from table: %f sec\n", psTimerMark ("nonlinear"));
+
+    for (int i = 0; i < image->numRows; i++) { // Loop over rows : note: problem with discontinuity here
+	row_correction_fluxes = NULL;
+	if (i < numBorder) {
+	    row_correction_fluxes  = y_lo_flux->data[i];
+	    row_correction_factors = y_lo_fact->data[i];
+	}
+	if (i > image->numRows - numBorder) {
+	    row_correction_fluxes  = y_hi_flux->data[i + numBorder - image->numRows];
+	    row_correction_factors = y_hi_fact->data[i + numBorder - image->numRows];
+	}
+	if (row_correction_fluxes == NULL) {
+	    row_correction_fluxes = default_row_correction_fluxes;
+	}
+
+	for (int j = 0; j < image->numCols; j++) { // Loop over columns
+	    col_correction_fluxes = NULL;
+	    if (j < numBorder) {
+		col_correction_fluxes  = x_lo_flux->data[j];
+		col_correction_factors = x_lo_fact->data[j];
+	    }
+	    if (j > image->numCols - numBorder) {
+		col_correction_fluxes  = x_hi_flux->data[j + numBorder - image->numCols];
+		col_correction_factors = x_hi_fact->data[j + numBorder - image->numCols];
+	    }
+	    if (col_correction_fluxes == NULL) {
+		col_correction_fluxes = default_col_correction_fluxes;
+	    }
+
+	    // Calculate correction factor contribution for this pixel.
+	    psF32 factor_row = pmNonLinearityMeasure(image->data.F32[i][j], row_correction_fluxes,row_correction_factors);
+	    psF32 factor_col = pmNonLinearityMeasure(image->data.F32[i][j], col_correction_fluxes,col_correction_factors);
+
+	    if (((i <= 9)&&(j <= 9))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case.
+		psTrace("psModules.camera",6,"Linearity: %d %d %s %f %f %f %d %d\n",i,j,
+			psMetadataLookupStr(NULL,inputReadout->parent->concepts,"CELL.NAME"),
+			image->data.F32[i][j],factor_row,factor_col,numBorder,numSamples);
+		psTrace("psModules.camera",6,"Linearity: R: %d %d %d C: %d %d %d\n",
+			i,(i < numBorder),(image->numRows - i),
+			j,(j < numBorder),(image->numCols - j));
+
+# if (0)
+		psTrace("psModules.camera",6,"Linearity: V: ");
+		for (int k = 0; k < numSamples; k++) {
+		    psTrace("psModules.camera",6,"(%f %f) ",
+			    col_correction_fluxes->data.F32[k],col_correction_factors->data.F32[k]);
+		}
+		psTrace("psModules.camera",6,"\n");
+# endif
+	    } // End Test case
+
+	    // Apply correction to image data
+	    image->data.F32[i][j] = image->data.F32[i][j] * ( factor_row * factor_col ) ;
+	} // End loop over columns
+    } // End loop over rows
+    psLogMsg ("psModules", PS_LOG_MINUTIA, "apply correction: %f sec\n", psTimerMark ("nonlinear"));
+
+    psFree(x_lo_flux);
+    psFree(x_hi_flux);
+    psFree(y_lo_flux);
+    psFree(y_hi_flux);
+
+    psFree(x_lo_fact);
+    psFree(x_hi_fact);
+    psFree(y_lo_fact);
+    psFree(y_hi_fact);
+
+    psFree(default_row_correction_fluxes);
+    psFree(default_row_correction_factors);
+    psFree(default_col_correction_fluxes);
+    psFree(default_col_correction_factors);
+  
+    return(true);
 }
 
 psF32 pmNonLinearityMeasure(psF32 flux, psVector *correction_fluxes, psVector *correction_factors) {
-  //  psS32 numPixels = 0;
-  psF32 result = 0;
-  psU32 bin = 0;
-
-  bin = correction_fluxes->n - 1;
-  if (flux < correction_fluxes->data.F32[0]) {
-    return(1.0);
-  }
-  if (flux > correction_fluxes->data.F32[bin]) {
-    return(1.0);
-  }
-  
-  for (int i = 0; i < correction_fluxes->n - 1; i++) {
-    if ((flux >= correction_fluxes->data.F32[i])&&
-	(flux <  correction_fluxes->data.F32[i+1])) {
-      result = correction_factors->data.F32[i] +
-	(flux - correction_fluxes->data.F32[i]) *
-	((correction_factors->data.F32[i+1] - correction_factors->data.F32[i]) /
-	 (correction_fluxes->data.F32[i+1] - correction_fluxes->data.F32[i]));
-      continue;
-    }
-  }
+    //  psS32 numPixels = 0;
+    psF32 result = 0;
+    psU32 bin = 0;
+
+    bin = correction_fluxes->n - 1;
+    if (flux < correction_fluxes->data.F32[0]) {
+	return(1.0);
+    }
+    if (flux > correction_fluxes->data.F32[bin]) {
+	return(1.0);
+    }
+  
+    for (int i = 0; i < correction_fluxes->n - 1; i++) {
+	if ((flux >= correction_fluxes->data.F32[i])&&
+	    (flux <  correction_fluxes->data.F32[i+1])) {
+	    result = correction_factors->data.F32[i] +
+		(flux - correction_fluxes->data.F32[i]) *
+		((correction_factors->data.F32[i+1] - correction_factors->data.F32[i]) /
+		 (correction_fluxes->data.F32[i+1] - correction_fluxes->data.F32[i]));
+	    continue;
+	}
+    }
 
 /*   PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */
@@ -285,11 +337,11 @@
   
 /*   PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */
-  if (!isfinite(result)) {
-    result = 1.0;
-  }
-  if (result <= 0) {
-    result = 1.0;
-  }
-  return(result);
+    if (!isfinite(result)) {
+	result = 1.0;
+    }
+    if (result <= 0) {
+	result = 1.0;
+    }
+    return(result);
 }
   
