Index: /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.c
===================================================================
--- /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.c	(revision 14731)
+++ /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.c	(revision 14731)
@@ -0,0 +1,65 @@
+/** @file  pmTrend2D.c
+ *
+ *  @author EAM, IfA
+ *
+ *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-04 18:35:51 $
+ *
+ *  Copyright 2004 Institute for Astronomy, University of Hawaii
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+# include <pslib.h>
+# include "pmTrend2D.h"
+
+static void pmTrend2DFree (pmTrend2D *trend) {
+
+    if (trend == NULL) 
+        return;
+
+    psFree (trend->poly);
+    psFree (trend->map);
+    return;
+}
+
+pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, int nXout, int nYout, int nXtrend, int nYtrend, psStats *stats)
+{
+    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
+    psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree);
+
+    trend->map = NULL;
+    trend->poly = NULL;
+    trend->stats = psMemIncrRefCounter (stats);
+	
+    switch (mode) {
+      case PM_TREND_POLY_ORD:
+	trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend);
+	break;
+
+      case PM_TREND_POLY_CHEB:
+	trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend);
+	break;
+
+      case PM_TREND_MAP:
+	// XXX *** I need the output image dimensions here!
+
+	// function is defined over the range 0-1000, 0-1000
+	psImageBinning *binning = psImageBinningAlloc();
+	binning->nXfine = nXout;
+	binning->nYfine = nYout;
+	binning->nXruff = nXtrend;
+	binning->nYruff = nYtrend;
+
+	trend->map = psImageMapAlloc (NULL, binning, stats);
+	psFree (binning);
+	break;
+
+      default:
+	psAbort ("error");
+    }
+    return (trend);
+}
Index: /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.h
===================================================================
--- /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.h	(revision 14731)
+++ /branches/eam_branch_20070830/psModules/src/objects/pmTrend2D.h	(revision 14731)
@@ -0,0 +1,37 @@
+/* @file  pmTrend2D.h
+ *
+ * functions to represent ways of modeling a 2D trend
+ *
+ * @author EAM, IfA
+ *
+ * @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-09-04 18:35:51 $
+ * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
+# ifndef PM_TREND_2D_H
+# define PM_TREND_2d_H
+
+/// @addtogroup Objects Object Detection / Analysis Functions
+/// @{
+
+typedef enum {
+  PM_TREND_POLY_ORD,
+  PM_TREND_POLY_CHEB,
+  PM_TREND_MAP,
+} pmTrend2DMode;
+
+typedef struct {
+  psPolynomial2D *poly;
+  psImageMap *map;
+  pmTrend2DMode mode; // POLY_ORD, POLY_CHEB, MAP
+} pmTrend2D;
+
+// allocate a pmTrend2D structure.  nX,nY is order for the polynomials, max number of grid cells for
+// psImageMap
+pmTrend2D *pmTrend2DAlloc (pmTrend2DMode mode, int nXout, int nYout, int nXtrend, int nYtrend, psStats *stats);
+
+bool pmTrend2DFit (pmTrend2D *trend, psVector *x, psVector *y, psVector *f, psVector *df);
+
+/// @}
+# endif
