Index: /trunk/archive/pslib/include/psImages.h
===================================================================
--- /trunk/archive/pslib/include/psImages.h	(revision 214)
+++ /trunk/archive/pslib/include/psImages.h	(revision 215)
@@ -74,5 +74,5 @@
 	      int ny, 			///< width of region in y
 	      int direction,		///< direction of vector along slice
-	      psStatMode statmode	///< statistic applied to pixel group to find output value
+	      psStats *stats		///< defines statistics used to find output values
 );
 
@@ -85,5 +85,5 @@
 	    float ye, 			///< ending y coord of cut
 	    float dw, 			///< width of cut
-	    psStatMode statmode		///< statistic applied to pixel group to find output value
+	    psStats *stats		///< defines statistics used to find output values
     );
 
@@ -95,5 +95,5 @@
 		  float radius, 	///< outer radius of annulii
 		  float dr,		///< radial step size of annulii
-		  psStatMode statmode	///< statistic applied to pixel group to find output value
+		  psStats *stats		///< defines statistics used to find output values
     );
 
@@ -110,5 +110,5 @@
 psImageRebin (psImage *input, 		///< rebin this image
 	      float scale, 		///< rebinning scale: doutput = scale*dinput
-	      psStatMode statmode	///< statistic used in performing interpolation / summing
+	      psStats *stats		///< defines statistics used to find output values
 );
 
@@ -137,8 +137,7 @@
 
 /// Determine statistics for image (or subimage).
-/// Should we have one function for all stats, or multiple functions?
-/// How to represent the output values?
-void
-psImageGetStats (psImage *input, psStatMode statmode);
+psStats *
+psImageGetStats (psImage *input, 	///< image (or subimage) to calculate stats
+		 psStats *stats);	///< defines statistics to be calculated
 
 /// Construct a histogram from an image (or subimage).
@@ -149,8 +148,13 @@
 
 /// Fit a 2-D polynomial surface to an image.
-psFloatArrayArray *
+psPolynomial2D *
 psImageFitPolynomial (psImage *input, 	///< image to fit
-		      int xorder,	///< order of polynomial in x-dir
-		      int yorder	///< order of polynomial in y-dir
+		      psPolynomial2D *coeffs ///< coefficient structure carries in desired terms
+);
+
+/// Evaluate a 2-D polynomial surface to image pixels.
+int
+psImageEvalPolynomial (psImage *input, 	///< image to fit
+		       psPolynomial2D *coeffs ///< coefficient structure carries in desired terms
 );
 
Index: /trunk/archive/pslib/include/psStats.h
===================================================================
--- /trunk/archive/pslib/include/psStats.h	(revision 214)
+++ /trunk/archive/pslib/include/psStats.h	(revision 215)
@@ -5,16 +5,67 @@
 #include "psStdArrays.h"
 
+typedef enum {
+    PS_STAT_SAMPLE_MEAN           = 0x000001,
+    PS_STAT_SAMPLE_MEAN_ERROR     = 0x000002,
+    PS_STAT_SAMPLE_MEDIAN         = 0x000004,
+    PS_STAT_SAMPLE_MEDIAN_ERROR   = 0x000008,
+    PS_STAT_SAMPLE_STDEV          = 0x000010,
+    PS_STAT_SAMPLE_UQ 		  = 0x000020, 
+    PS_STAT_SAMPLE_LQ 		  = 0x000040,
+    PS_STAT_ROBUST_MEAN           = 0x000080,
+    PS_STAT_ROBUST_MEAN_ERROR     = 0x000100,
+    PS_STAT_ROBUST_MEAN_NVALUES   = 0x000200,
+    PS_STAT_ROBUST_MEDIAN         = 0x000400,
+    PS_STAT_ROBUST_MEDIAN_ERROR   = 0x000800,
+    PS_STAT_ROBUST_MEDIAN_NVALUES = 0x001000,
+    PS_STAT_ROBUST_STDEV          = 0x002000,
+    PS_STAT_ROBUST_UQ 		  = 0x004000, 
+    PS_STAT_ROBUST_LQ 		  = 0x008000,
+    PS_STAT_CLIPPED_MEAN          = 0x010000,
+    PS_STAT_CLIPPED_MEAN_ERROR    = 0x020000,
+    PS_STAT_CLIPPED_MEAN_NVALUES  = 0x040000,
+    PS_STAT_CLIPPED_MEAN_NSIGMA   = 0x080000,
+    PS_STAT_MAX     		  = 0x100000,     
+    PS_STAT_MIN     		  = 0x200000,
+    PS_STAT_NVALUES 		  = 0x400000
+} psStatsOptions;    			  
+
+/** generic statistics structure */
+typedef struct {
+    double sampleMean			//<! formal mean of sample
+    double sampleMeanError;		//<! error on formal mean
+    double sampleMedian			//<! formal median of sample
+    double sampleMedianError;		//<! error on formal median
+    double sampleStdev;			//<! standard deviation of sample
+    double sampleUQ;			//<! upper quartile of sample
+    double sampleLQ;			//<! lower quartile of sample
+    double robustMean			//<! robust mean of array
+    double robustMeanError;		//<! error on robust mean
+    int    robustMeanNvalues;		//<! number of measurements used for robust mean
+    double robustMedian			//<! robust median of array
+    double robustMedianError;		//<! error on robust median
+    int    robustMedianNvalues;		//<! number of measurements used for robust median
+    double robustStdev;			//<! robust standard deviation of array
+    double robustUQ;			//<! robust upper quartile
+    double robustLQ;			//<! robust lower quartile
+    double clippedMean			//<! Nsigma clipped mean
+    double clippedMeanError;		//<! error on clipped mean
+    int    clippedMeanNvalues;		//<! number of data points used for clipped mean
+    double clippedMeanNsigma;		//<! Nsigma clip used for clipped mean
+    double min;				//<! minimum data value in array
+    double max;				//<! maximum data value in array
+    int    nValues;			//<! number of data values in array
+    psStatsOptions options;		//<! bitmask of calculated values
+} psStats;
+
+
 /** Do Statistics on an array.  Returns a status value. */
-int
+psStats *
 psArrayStats(const psFloatArray *restrict myArray, //!< Array to be analysed
 	     const psIntArray *restrict maskArray, //!< Ignore elements where (maskArray & maskVal) != 0
 						   //!< May be NULL
 	     unsigned int maskVal,	//!< Only mask elements with one of these bits set in maskArray
-	     int numIter,	        //!< Number of clipping iterations (0 not to clip)
-	     float numSD,		//!< Number of s.d. to clip at
-	     float *restrict mean,	//!< Mean of array (or NULL)
-	     float *restrict sd,	//!< Standard deviation (or NULL)
-	     float *restrict med	//!< Median (or NULL)
-	     );
+	     psStats *stats		//!< stats structure defines stats to be calculated and how
+);
 
 /***********************************************************************************************************/
