Index: /trunk/psLib/src/astro/psCoord.c
===================================================================
--- /trunk/psLib/src/astro/psCoord.c	(revision 2057)
+++ /trunk/psLib/src/astro/psCoord.c	(revision 2058)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-25 01:38:30 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-12 20:53:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,14 +32,20 @@
 /******************************************************************************/
 
+#define PS_COT(X) (1.0 / atan(X))
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
 // None
 
-/******************************************************************************/
-/*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
+/*****************************************************************************/
+/*  GLOBAL VARIABLES                                                         */
+/*****************************************************************************/
 
 // None
 
 /*****************************************************************************/
-/*  GLOBAL VARIABLES                                                         */
+/*  FILE STATIC VARIABLES                                                    */
 /*****************************************************************************/
 
@@ -47,27 +53,14 @@
 
 /*****************************************************************************/
-/*  FILE STATIC VARIABLES                                                    */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
 
-static float p_psCot(float x);
 static float p_psArg(float x, float y);
 
 /******************************************************************************
-XXX: Do this with a macro.
- *****************************************************************************/
-float p_psCot(float x)
-{
-    return (1.0 / atan(x));
-}
-
-/******************************************************************************
 XXX: Verify this arc tan function.
- *****************************************************************************/
+XXX: macro
+ *****************************************************************************/
+
 float p_psArg(float x,
               float y)
@@ -240,5 +233,5 @@
 
     if (projection->type == PS_PROJ_TAN) {
-        R = p_psCot(coord->r) * (180.0 / M_PI);
+        R = PS_COT(coord->r) * (180.0 / M_PI);
         tmp->x = R * sin(coord->d);
         tmp->y = R * cos(coord->d);
Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2057)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2058)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-12 19:10:00 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 20:53:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -24,4 +24,6 @@
 #include "psMemory.h"
 #include "psAbort.h"
+#include "psError.h"
+#include "psConstants.h"
 #include "slalib.h"
 
@@ -199,9 +201,9 @@
 {
     if (fp != NULL) {
-        for (int i = 0; i < fp->nX; i++) {
+        for (int i = 0; i < fp->p_ps_xRows; i++) {
             psFree(fp->x[i]);
         }
 
-        for (int j = 0; j < fp->nY; j++) {
+        for (int j = 0; j < fp->p_ps_yRows; j++) {
             psFree(fp->y[j]);
         }
@@ -221,4 +223,5 @@
  * XXX: Verify that you interpreted the SDR correctly.
  *
+ * XXX: This assumes that x,y must be of type F64
  */
 psFixedPattern* psFixedPatternAlloc(double x0,
@@ -233,27 +236,37 @@
     int j;
 
+    PS_CHECK_NULL_IMAGE_RETURN_NULL(x);
+    PS_CHECK_NULL_IMAGE_RETURN_NULL(y);
+    PS_CHECK_IMAGE_TYPE_RETURN_NULL(x, PS_TYPE_F64);
+    PS_CHECK_IMAGE_TYPE_RETURN_NULL(y, PS_TYPE_F64);
+
     tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));
-    tmp->nX = x->numCols;
-    tmp->nY = y->numRows;
+    // XXX: Is this correct?
+    tmp->nX = (x->numCols * x->numRows);
+    tmp->nY = (y->numCols * y->numRows);
     tmp->x0 = x0;
     tmp->y0 = y0;
     tmp->xScale = xScale;
     tmp->yScale = yScale;
-    tmp->x = (double **) psAlloc(x->numRows * sizeof(float *));
+    tmp->p_ps_xRows = x->numRows;
+    tmp->p_ps_xCols = x->numCols;
+    tmp->p_ps_yRows = y->numRows;
+    tmp->p_ps_yCols = y->numCols;
+    tmp->x = (double **) psAlloc(x->numRows * sizeof(double *));
     for (i=0;i<x->numRows;i++) {
-        (tmp->x)[i] = (double *) psAlloc(x->numCols * sizeof(float));
+        (tmp->x)[i] = (double *) psAlloc(x->numCols * sizeof(double));
     }
     for (i=0;i<x->numRows;i++) {
-        for (j=0;j<x->numRows;j++) {
+        for (j=0;j<x->numCols;j++) {
             (tmp->x)[i][j] = x->data.F64[i][j];
         }
     }
 
-    tmp->y = (double **) psAlloc(y->numRows * sizeof(float *));
+    tmp->y = (double **) psAlloc(y->numRows * sizeof(double *));
     for (i=0;i<y->numRows;i++) {
-        (tmp->y)[i] = (double *) psAlloc(y->numCols * sizeof(float));
+        (tmp->y)[i] = (double *) psAlloc(y->numCols * sizeof(double));
     }
     for (i=0;i<y->numRows;i++) {
-        for (j=0;j<y->numRows;j++) {
+        for (j=0;j<y->numCols;j++) {
             (tmp->y)[i][j] = y->data.F64[i][j];
         }
Index: /trunk/psLib/src/astronomy/psAstrometry.h
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2057)
+++ /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2058)
@@ -8,6 +8,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-12 01:34:09 $
+*  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-12 20:53:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -78,4 +78,9 @@
     double xScale;                     ///< Scale of the grid in x direction
     double yScale;                     ///< Scale of the grid in x direction
+    /// XXX: I added the following memvers to facilitate the psFreeing of the x,y data structures.
+    int p_ps_xRows;                    ///< Number of rows in the x member
+    int p_ps_xCols;                    ///< Number of cols in the x member
+    int p_ps_yRows;                    ///< Number of rows in the y member
+    int p_ps_yCols;                    ///< Number of cols in the y member
     double **x;                        ///< The grid of offsets in x
     double **y;                        ///< The grid of offsets in y
Index: /trunk/psLib/src/astronomy/psCoord.c
===================================================================
--- /trunk/psLib/src/astronomy/psCoord.c	(revision 2057)
+++ /trunk/psLib/src/astronomy/psCoord.c	(revision 2058)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-25 01:38:30 $
+*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-12 20:53:02 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -32,14 +32,20 @@
 /******************************************************************************/
 
+#define PS_COT(X) (1.0 / atan(X))
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
 // None
 
-/******************************************************************************/
-/*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
+/*****************************************************************************/
+/*  GLOBAL VARIABLES                                                         */
+/*****************************************************************************/
 
 // None
 
 /*****************************************************************************/
-/*  GLOBAL VARIABLES                                                         */
+/*  FILE STATIC VARIABLES                                                    */
 /*****************************************************************************/
 
@@ -47,27 +53,14 @@
 
 /*****************************************************************************/
-/*  FILE STATIC VARIABLES                                                    */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
 
-static float p_psCot(float x);
 static float p_psArg(float x, float y);
 
 /******************************************************************************
-XXX: Do this with a macro.
- *****************************************************************************/
-float p_psCot(float x)
-{
-    return (1.0 / atan(x));
-}
-
-/******************************************************************************
 XXX: Verify this arc tan function.
- *****************************************************************************/
+XXX: macro
+ *****************************************************************************/
+
 float p_psArg(float x,
               float y)
@@ -240,5 +233,5 @@
 
     if (projection->type == PS_PROJ_TAN) {
-        R = p_psCot(coord->r) * (180.0 / M_PI);
+        R = PS_COT(coord->r) * (180.0 / M_PI);
         tmp->x = R * sin(coord->d);
         tmp->y = R * cos(coord->d);
Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 2057)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 2058)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-05 23:14:15 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 20:53:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -150,4 +150,11 @@
 }
 
+#define PS_CHECK_IMAGE_TYPE_RETURN_NULL(NAME, TYPE) \
+if (NAME->type.type != TYPE) { \
+    psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
+    return(NULL); \
+}
+
+
 #define PS_CHECK_NULL_1DPOLY_RETURN_NULL(NAME)                                                          \
 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
Index: /trunk/psLib/src/dataManip/psStats.c
===================================================================
--- /trunk/psLib/src/dataManip/psStats.c	(revision 2057)
+++ /trunk/psLib/src/dataManip/psStats.c	(revision 2058)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-05 23:14:15 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 20:53:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -520,5 +520,6 @@
     XXX: use a static variable for gaussianCoefs[] and compute them once.
  *****************************************************************************/
-psVector* p_psVectorsmoothHistGaussian(psHistogram* robustHistogram, float sigma)
+psVector* p_psVectorsmoothHistGaussian(psHistogram* robustHistogram,
+                                       float sigma)
 {
     int i = 0;                  // Loop index variable
@@ -543,4 +544,5 @@
             gaussianCoefs[i] = exp(expo / denom);
 
+            //printf("p_psVectorsmoothHistGaussian(): gaussianCoefs[%d] is %f\n", i, gaussianCoefs[i]);
             // NOTE: Gaussian smoothing just isn't working with low sigma
             // values.  The problem is that the Gaussian coefficients are
@@ -1200,5 +1202,6 @@
     // Smooth the histogram.
     // XXX: is that the right stdev?
-    robustHistogramVector = p_psVectorsmoothHistGaussian(robustHistogram, tmpStats->clippedStdev / 4.0f);
+    robustHistogramVector = p_psVectorsmoothHistGaussian(robustHistogram,
+                            tmpStats->clippedStdev / 4.0f);
 
     // The following was necessary to fit a gaussian to the data, since
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 2057)
+++ /trunk/psLib/src/math/psConstants.h	(revision 2058)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-05 23:14:15 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 20:53:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -150,4 +150,11 @@
 }
 
+#define PS_CHECK_IMAGE_TYPE_RETURN_NULL(NAME, TYPE) \
+if (NAME->type.type != TYPE) { \
+    psError(__func__,"Unallowable operation: %s has incorrect type.", #NAME); \
+    return(NULL); \
+}
+
+
 #define PS_CHECK_NULL_1DPOLY_RETURN_NULL(NAME)                                                          \
 if (NAME == NULL || NAME->coeff == NULL) {                                                         \
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 2057)
+++ /trunk/psLib/src/math/psStats.c	(revision 2058)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-05 23:14:15 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-12 20:53:02 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -520,5 +520,6 @@
     XXX: use a static variable for gaussianCoefs[] and compute them once.
  *****************************************************************************/
-psVector* p_psVectorsmoothHistGaussian(psHistogram* robustHistogram, float sigma)
+psVector* p_psVectorsmoothHistGaussian(psHistogram* robustHistogram,
+                                       float sigma)
 {
     int i = 0;                  // Loop index variable
@@ -543,4 +544,5 @@
             gaussianCoefs[i] = exp(expo / denom);
 
+            //printf("p_psVectorsmoothHistGaussian(): gaussianCoefs[%d] is %f\n", i, gaussianCoefs[i]);
             // NOTE: Gaussian smoothing just isn't working with low sigma
             // values.  The problem is that the Gaussian coefficients are
@@ -1200,5 +1202,6 @@
     // Smooth the histogram.
     // XXX: is that the right stdev?
-    robustHistogramVector = p_psVectorsmoothHistGaussian(robustHistogram, tmpStats->clippedStdev / 4.0f);
+    robustHistogramVector = p_psVectorsmoothHistGaussian(robustHistogram,
+                            tmpStats->clippedStdev / 4.0f);
 
     // The following was necessary to fit a gaussian to the data, since
