Index: /trunk/archive/modules/include/phase2.h
===================================================================
--- /trunk/archive/modules/include/phase2.h	(revision 1437)
+++ /trunk/archive/modules/include/phase2.h	(revision 1438)
@@ -22,4 +22,86 @@
 /************************************************************************************************************/
 
+/* Bias/overscan subtraction and trim */
+
+/** Overscan axis */
+typedef enum {
+    PM_OVERSCAN_NONE,			///< No overscan subtraction
+    PM_OVERSCAN_ROWS,			///< Subtract rows
+    PM_OVERSCAN_COLUMNS, 		///< Subtract columns
+    PM_OVERSCAN_ALL			///< Subtract the statistic of all pixels in overscan region
+} pmOverscanAxis;
+
+/** Fit types */
+typedef enum {
+    PM_FIT_NONE,			///< No fit
+    PM_FIT_POLYNOMIAL,			///< Fit polynomial
+    PM_FIT_SPLINE			///< Fit cubic splines
+} pmFit;
+
+/** Subtracts an overscan and bias from the input image. */
+psReadout *pmSubtractBias(psReadout *in, ///< Input image to be de-biased, and output
+			  void *fitSpec, ///< Polynomial/Spline/Some other function(?) specification,
+			                 ///< Also outputted
+			  const psList *overscans, ///< Linked list of subimages of overscans
+			  pmOverscanAxis overscanAxis, ///< Overscan axis
+			  const psStats *stat, ///< Statistic to use
+			  int nBin, ///< Number of bins for overscan vector before fitting
+			  pmFit fit, ///< How to fit the bias
+			  const psReadout *bias ///< Bias (or dark) image to subtract
+    );
+
+/************************************************************************************************************/
+
+/* Correction for non-linearity */
+
+/** Non-linearity correction via polynomial */
+psReadout *pmNonLinearityPolynomial(psReadout *in, ///< Input image to be corrected, and output
+				    const psPolynomial1D *coeff ///< Polynomial with which to correct
+    );
+
+/** Non-linearity correction via lookup table */
+psReadout *pmNonLinearityLookup(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. */
+psReadout *pmFlatField(psReadout *in, ///< Input image to be flat-fielded, and output
+		       const psReadout *flat ///< Flat-field image
+    );
+
+/************************************************************************************************************/
+
+/* Masking */
+
+/** Mask values */
+typedef enum {
+    PM_MASK_TRAP,			///< The pixel is a charge trap
+    PM_MASK_BADCOL,			///< The pixel is a bad column
+    PM_MASK_SAT,			///< The pixel is saturated
+    PM_MASK_FLAT,			///< The pixel is non-positive in the flat-field
+    PM_MASK_CR_MORPH			///< The pixel is determined to be a cosmic ray, from morphology
+} pmMaskValue;
+
+/** Returns an image that has the bad pixels masked.  Also masks saturated pixels */
+psReadout *pmMaskBadPixels(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.
+			   float sat, ///< Saturation level: pixels brighter than this level are masked
+			   int grow ///< Radius to grow the bad pixels
+    );
+
+/************************************************************************************************************/
+/************************************************************************************************************/
+/************************************************************************************************************/
+
+/* Below functions are still under development */
+
+/************************************************************************************************************/
+/************************************************************************************************************/
+/************************************************************************************************************/
+
 /* Reading in an image */
 
@@ -48,140 +130,19 @@
 			  );
 
-
-/************************************************************************************************************/
-
-/* Convolution */
-
-/** A convolution kernel */
-typedef struct {
-    int xMin, yMin;			///< Most negative indices
-    int xMax, yMax;			///< Most positive indices
-    float **kernel;			///< The kernel data
-} psKernel;
-
-/** Constructor */
-psKernel *psKernelAlloc(int xMin,	///< Size of the kernel in the negative x direction
-			int xMax,	///< Size of the kernel in the positive x direction
-			int yMin,	///< Size of the kernel in the negative y direction
-			int yMax	///< Size of the kernel in the positive y direction
-			);
-/** Destructor */
-void psKernelFree(psKernel *myKernel	///< Kernel to destroy
-		  );
-
-/** Returns the kernel of OT shifts made during the course of the exposure. */
-psKernel *psPhase2GetKernel(const psVector *xShifts, ///< List of OT shifts in x; integers
-			    const psVector *yShifts ///< List of OT shifts in y; integers;
-						    ///< xshifts->n == yShifts->n
-			    );
-
-/** Returns an image that is the result of convolving the input image with the specified kernel. */
-psImage *psConvolveWithKernel(psImage *out, ///< Output image, or NULL
-			      const psImage *in, ///< Input image to be convolved
-			      const psKernel *kernel, ///< Kernel by which to convolve
-			      bool direct ///< Do direct convolution?  If not, use FFT
-			      );
-
-/************************************************************************************************************/
-
-/* Bias/overscan subtraction and trim */
-
-/** Image regions */
-typedef struct {
-    const int x0, y0;			///< Offset to region
-    const int nX, nY;			///< Size of region
-} psImageRegion;
-
-/** Constructor */
-psImageRegion *psImageRegionAlloc(int x0, ///< x offset to region
-				  int y0, ///< y offset to region
-				  int nX, ///< Size of region in x
-				  int nY ///< Size of region in y
-				  );
-/** Destructor */
-void psImageRegionFree(psImageRegion *reg ///< Region to destroy
-		       );
-
-/** A 1D cubic-spline */
-typedef struct {
-    int n;				///< Number of spline pieces
-    float *coeff[4];			///< Coefficients.  There are 4 coefficients for each spline piece.
-    float *coeffErr[4];			///< Errors in the coefficients.
-    bool *mask[4];			///< Mask for the coefficients.
-    float *domains;			///< The boundaries between each spline piece.  Size is n+1.
-} psSpline1D;
-
-/** Constructors */
-psSpline1D *psSpline1DAlloc(int n,	///< Number of spline pieces
-			    float min,	///< Minimum data value
-			    float max	///< Maximum data value
-			    );
-psSpline1D *psSpline1DAllocGeneric(const psVector *bounds ///< Boundaries between each spline piece.  Number
-							  ///< of spline pieces can hence be inferred.
+/************************************************************************************************************/
+
+/** Masks Cosmic Rays on the input image on the basis of morphology. */
+psReadout *psPhase2MaskCRs(psReadout *in, ///< Input image to be masked, and output
+			   int algorithm, ///< Algorithm number to use
+			   const void *params ///< Parameters for algorithm
+			   );
+
+/** Masks optical defects in the input image */
+psChip *psPhase2MaskOpticalDefects(psChip *in, ///< Image to be masked (with astrometry), and output
+				   const psDlist *catalog, ///< Catalog stars nearby: a list of psObjects
+				   int grow ///< Number of pixels to grow
 				   );
-/** Destructor */
-void psSpline1DFree(psSpline1D *mySpline ///< Spline to destroy
-		    );
-/** Evaluator */
-float psSpline1DEval(const psSpline1D *spline, ///< Spline to evaluate
-		     float x		///< Coordinates at which to evaluate
-		     );
-
-
-/** Overscan axis */
-typedef enum {
-    PS_OVERSCAN_NONE,			///< No overscan subtraction
-    PS_OVERSCAN_ROWS,			///< Subtract rows
-    PS_OVERSCAN_COLUMNS, 		///< Subtract columns
-    PS_OVERSCAN_ALL			///< Subtract the statistic of all pixels in overscan region
-} psOverscanAxis;
-
-/** Fit types */
-typedef enum {
-    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. */
-psReadout *psPhase2SubtractBias(psReadout *in, ///< Input image to be de-biased, and output
-				void *fitSpec, ///< Polynomial/Spline/Some other function(?) specification,
-				               ///< Also outputted
-				psOverscanAxis overscanAxis, ///< Overscan axis
-				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.
-				const psStats *stat, ///< Statistic to use
-				const psImage *bias ///< Bias (or dark) image to subtract
-				);
-
-/** Trims the input image to remove the edges corrupted by OT shifting, and the overscan. */
-psReadout *psPhase2Trim(psReadout *in,	///< Input image to be trimmed, and output
-			const psImageRegion *region ///< Region to keep
-			);
-
-/************************************************************************************************************/
-
-/* Reduce to counts proportional to photons */
-
-
-/** 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 *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. */
-psReadout *psPhase2FlatField(psReadout *in, ///< Input image to be flat-fielded, and output
-			     const psImage *flat ///< Flat-field image
-			     );
+
+/************************************************************************************************************/
 
 /** Simple sky subtraction */
@@ -196,37 +157,4 @@
 /************************************************************************************************************/
 
-/* 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
-				 const psImage *mask, ///< Bad pixel mask to apply
-				 int maskVal, ///< Mask the pixels for which mask & maskVal > 0.
-				 float sat, ///< Saturation level: pixels brighter than this level are masked
-				 int grow ///< Radius to grow the bad pixels
-				 );
-
-/** Masks Cosmic Rays on the input image on the basis of morphology. */
-psReadout *psPhase2MaskCRs(psReadout *in, ///< Input image to be masked, and output
-			   int algorithm, ///< Algorithm number to use
-			   const void *params ///< Parameters for algorithm
-			   );
-
-/** Masks optical defects in the input image */
-psChip *psPhase2MaskOpticalDefects(psChip *in, ///< Image to be masked (with astrometry), and output
-				   const psDlist *catalog, ///< Catalog stars nearby: a list of psObjects
-				   int grow ///< Number of pixels to grow
-				   );
-
-/************************************************************************************************************/
-
 /* Object finding */
 
