Index: trunk/archive/modules/include/phase2.h
===================================================================
--- trunk/archive/modules/include/phase2.h	(revision 1105)
+++ trunk/archive/modules/include/phase2.h	(revision 1113)
@@ -108,12 +108,12 @@
 } psOverscanAxis;
 
-/** Fit type for bias */
+/** Fit types */
 typedef enum {
-    PS_OVERSCAN_FIT_NONE,		///< No fit to bias
-    PS_OVERSCAN_FIT_LINEAR,		///< Do linear interpolation on bias
-    PS_OVERSCAN_FIT_POLYNOMIAL,		///< Fit polynomial to bias
-    PS_OVERSCAN_FIT_CHEBYSHEV,		///< Fit chebyshev to bias
-    PS_OVERSCAN_FIT_SPLINE		///< Fit cubic splines to bias
-} psBiasFit;
+    PS_FIT_NONE,			///< No fit
+    PS_FIT_LINEAR,			///< Do linear interpolation
+    PS_FIT_POLYNOMIAL,			///< Fit polynomial
+    PS_FIT_CHEBYSHEV,			///< Fit chebyshev
+    PS_FIT_SPLINE			///< Fit cubic splines
+} psFit;
 
 /** Subtracts an overscan and bias from the input image. */
@@ -122,5 +122,5 @@
 				               ///< Also outputted
 				psOverscanAxis overscanAxis, ///< Overscan axis
-				psBiasFit fit, ///< How to fit the bias
+				psFit fit, ///< How to fit the bias
 				int nBin, ///< Number of bins for overscan vector before fitting
 				const psList *regions, ///< Linked list of psImageRegion types.
@@ -139,10 +139,15 @@
 
 
-/** Applies the correction for detector non-linearity.  Non-linearity coefficients are determined from the
- *  image metadata.
+/** Applies the correction for detector non-linearity.  Non-linearity coefficients are provided by the caller.
+ *  Two functions: one to do via a polynomial, the other via a lookup table.
  */
-psReadout *psPhase2CorrectNonLinearity(psReadout *in, ///< Input image to be corrected, and output
-				       const psPolynomial1D *coeff ///< Polynomial with which to correct
-				       );
+psReadout *psPhase2NonLinearityPolynomial(psReadout *in, ///< Input image to be corrected, and output
+					  const psPolynomial1D *coeff ///< Polynomial with which to correct
+					  );
+
+psReadout *psPhase2NonLinearityLookup(psReadout *in, ///< Input image to be corrected, and output
+				      const psVector *inFlux, ///< Input flux values
+				      const psVector *outFlux ///< Output flux values
+				      );
 
 /** Flat-fields the image. */
@@ -151,15 +156,11 @@
 			     );
 
-/** Subtracts the sky background. */
+/** Simple sky subtraction */
 psReadout *psPhase2SubtractSky(psReadout *in, ///< Input image to be sky-subtracted, and output
-			       psPolynomial2D *poly, ///< Polynomial specification, returns coeffcients
-			       psVector *outNorms, ///< Normalisations of the template sky images: output
-			       const psList *skyImages, ///< Template sky images: a list of type psImage, or
-							///< NULL
-			       const psList *catalog, ///< Sources nearby to mask when measuring the
-						      ///< background: a list of type psObject, or NULL
-			       float radiusMultiply, ///< Multiplying factor of object radius for mask
-			       float radiusAdd, ///< Additive factor to grow the object masks
-			       int binFactor ///< Binning factor to use on image before solving for polynomial
+			       void *fitSpec, ///< Polynomial/Spline specification, returns coeffcients
+			       psFit fit, ///< Fit type
+			       int binFactor, ///< Binning factor to use on image before solving for polynomial
+			       psStats *stats, ///< Statistics to use in binning
+			       float clipSD ///< Standard deviations to clip at after binning.
 			       );
 
@@ -168,6 +169,15 @@
 /* Masking */
 
+/** Mask values */
+typedef enum {
+    PS_MASK_TRAP,			///< The pixel is a charge trap
+    PS_MASK_BADCOL,			///< The pixel is a bad column
+    PS_MASK_SAT,			///< The pixel is saturated
+    PS_MASK_FLAT,			///< The pixel is non-positive in the flat-field
+    PS_MASK_CR_MORPH			///< The pixel is determined to be a cosmic ray, from morphology
+} psMaskValue;
+
 /** Returns an image that has the bad pixels masked.  Also masks saturated pixels */
-psReadout *psPhase2MaskBadPixels(psReadout *in ///< Image to be masked, and output
+psReadout *psPhase2MaskBadPixels(psReadout *in, ///< Image to be masked, and output
 				 const psImage *mask, ///< Bad pixel mask to apply
 				 int maskVal, ///< Mask the pixels for which mask & maskVal > 0.
