Index: trunk/psModules/src/pmObjects.c
===================================================================
--- trunk/psModules/src/pmObjects.c	(revision 4579)
+++ trunk/psModules/src/pmObjects.c	(revision 4770)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-19 01:44:48 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-08-16 01:10:34 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -20,12 +20,12 @@
 
 /******************************************************************************
-pmPeakAlloc(): Allocate the psPeak data structure and set appropriate members.
-*****************************************************************************/
-psPeak *pmPeakAlloc(psS32 x,
+pmPeakAlloc(): Allocate the pmPeak data structure and set appropriate members.
+*****************************************************************************/
+pmPeak *pmPeakAlloc(psS32 x,
                     psS32 y,
                     psF32 counts,
-                    psPeakType class)
-{
-    psPeak *tmp = (psPeak *) psAlloc(sizeof(psPeak));
+                    pmPeakType class)
+{
+    pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak));
     tmp->x = x;
     tmp->y = y;
@@ -37,10 +37,10 @@
 
 /******************************************************************************
-pmMomentsAlloc(): Allocate the psMoments structure and initialize the members
+pmMomentsAlloc(): Allocate the pmMoments structure and initialize the members
 to zero.
 *****************************************************************************/
-psMoments *pmMomentsAlloc()
-{
-    psMoments *tmp = (psMoments *) psAlloc(sizeof(psMoments));
+pmMoments *pmMomentsAlloc()
+{
+    pmMoments *tmp = (pmMoments *) psAlloc(sizeof(pmMoments));
     tmp->x = 0.0;
     tmp->y = 0.0;
@@ -56,5 +56,5 @@
 }
 
-static void modelFree(psModel *tmp)
+static void modelFree(pmModel *tmp)
 {
     psFree(tmp->params);
@@ -63,11 +63,11 @@
 
 /******************************************************************************
-pmModelAlloc(): Allocate the psModel structure, along with its parameters,
+pmModelAlloc(): Allocate the pmModel structure, along with its parameters,
 and initialize the type member.  Initialize the params to 0.0.
 XXX EAM: changing params and dparams to psVector
 *****************************************************************************/
-psModel *pmModelAlloc(psModelType type)
-{
-    psModel *tmp = (psModel *) psAlloc(sizeof(psModel));
+pmModel *pmModelAlloc(pmModelType type)
+{
+    pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel));
 
     tmp->type = type;
@@ -99,5 +99,5 @@
         break;
     default:
-        psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
+        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
         return(NULL);
     }
@@ -116,5 +116,5 @@
 We might need to increase the reference counter and decrease it here.
 *****************************************************************************/
-static void sourceFree(psSource *tmp)
+static void sourceFree(pmSource *tmp)
 {
     psFree(tmp->peak);
@@ -122,19 +122,21 @@
     //    psFree(tmp->mask);
     psFree(tmp->moments);
-    psFree(tmp->models);
-}
-
-/******************************************************************************
-pmSourceAlloc(): Allocate the psSource structure and initialize its members
+    psFree(tmp->modelPSF);
+    psFree(tmp->modelFLT);
+}
+
+/******************************************************************************
+pmSourceAlloc(): Allocate the pmSource structure and initialize its members
 to NULL.
 *****************************************************************************/
-psSource *pmSourceAlloc()
-{
-    psSource *tmp = (psSource *) psAlloc(sizeof(psSource));
+pmSource *pmSourceAlloc()
+{
+    pmSource *tmp = (pmSource *) psAlloc(sizeof(pmSource));
     tmp->peak = NULL;
     tmp->pixels = NULL;
     tmp->mask = NULL;
     tmp->moments = NULL;
-    tmp->models = NULL;
+    tmp->modelPSF = NULL;
+    tmp->modelFLT = NULL;
     tmp->type = 0;
     psMemSetDeallocator(tmp, (psFreeFunc) sourceFree);
@@ -272,7 +274,7 @@
                               psS32 col,
                               psF32 counts,
-                              psPeakType type)
-{
-    psPeak *tmpPeak = pmPeakAlloc(col, row, counts, type);
+                              pmPeakType type)
+{
+    pmPeak *tmpPeak = pmPeakAlloc(col, row, counts, type);
 
     if (list == NULL) {
@@ -379,5 +381,5 @@
         // Step through all local peaks in this row.
         for (psU32 i = 0 ; i < row1->n ; i++ ) {
-            psPeakType myType = PM_PEAK_UNDEF;
+            pmPeakType myType = PM_PEAK_UNDEF;
             col = row1->data.U32[i];
 
@@ -527,5 +529,5 @@
     //    printf("pmCullPeaks(): list size is %d\n", peaks->size);
     while (tmpListElem != NULL) {
-        psPeak *tmpPeak = (psPeak *) tmpListElem->data;
+        pmPeak *tmpPeak = (pmPeak *) tmpListElem->data;
         if ((tmpPeak->counts > maxValue) ||
                 ((valid != NULL) &&
@@ -553,5 +555,5 @@
 
     for (int i = 0; i < peaks->n; i++) {
-        psPeak *tmpPeak = (psPeak *) peaks->data[i];
+        pmPeak *tmpPeak = (pmPeak *) peaks->data[i];
         if (tmpPeak->counts > maxValue)
             continue;
@@ -566,8 +568,8 @@
 
 /******************************************************************************
-psSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): this
-routine creates a new psSource data structure and sets the following members:
-    ->psPeak
-    ->psMoments->sky
+pmSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): this
+routine creates a new pmSource data structure and sets the following members:
+    ->pmPeak
+    ->pmMoments->sky
  
 The sky value is set from the pixels in the square annulus surrounding the
@@ -590,5 +592,5 @@
      or they use the image row/column offsets.
  
-XXX: Should we simply set psSource->peak = peak?  If so, should we increase
+XXX: Should we simply set pmSource->peak = peak?  If so, should we increase
 the reference counter?  Or, should we copy the data structure?
  
@@ -602,6 +604,6 @@
      members.
 *****************************************************************************/
-psSource *pmSourceLocalSky(const psImage *image,
-                           const psPeak *peak,
+pmSource *pmSourceLocalSky(const psImage *image,
+                           const pmPeak *peak,
                            psStatsOptions statsOptions,
                            psF32 innerRadius,
@@ -723,6 +725,6 @@
     // Create the output mySource, and set appropriate members.
     //
-    psSource *mySource = pmSourceAlloc();
-    mySource->peak = (psPeak *) peak;
+    pmSource *mySource = pmSourceAlloc();
+    mySource->peak = (pmPeak *) peak;
     mySource->moments = pmMomentsAlloc();
     psF64 tmpF64;
@@ -746,5 +748,5 @@
 XXX: macro this for performance.
 *****************************************************************************/
-static bool checkRadius(psPeak *peak,
+static bool checkRadius(pmPeak *peak,
                         psF32 radius,
                         psS32 x,
@@ -781,11 +783,11 @@
 /******************************************************************************
 pmSourceMoments(source, radius): this function takes a subImage defined in the
-psSource data structure, along with the peak location, and determines the
+pmSource data structure, along with the peak location, and determines the
 various moments associated with that peak.
  
 Requires the following to have been created:
-    psSource
-    psSource->peak
-    psSource->pixels
+    pmSource
+    pmSource->peak
+    pmSource->pixels
  
 XXX: The peak calculations are done in image coords, not subImage coords.
@@ -793,5 +795,5 @@
 XXX: mask values?
 *****************************************************************************/
-psSource *pmSourceMoments(psSource *source,
+pmSource *pmSourceMoments(pmSource *source,
                           psF32 radius)
 {
@@ -925,6 +927,6 @@
 int pmComparePeakAscend (const void **a, const void **b)
 {
-    psPeak *A = *(psPeak **)a;
-    psPeak *B = *(psPeak **)b;
+    pmPeak *A = *(pmPeak **)a;
+    pmPeak *B = *(pmPeak **)b;
 
     psF32 diff;
@@ -940,6 +942,6 @@
 int pmComparePeakDescend (const void **a, const void **b)
 {
-    psPeak *A = *(psPeak **)a;
-    psPeak *B = *(psPeak **)b;
+    pmPeak *A = *(pmPeak **)a;
+    pmPeak *B = *(pmPeak **)b;
 
     psF32 diff;
@@ -992,5 +994,5 @@
         for (psS32 i = 0 ; i < sources->n ; i++)
         {
-            psSource *tmpSrc = (psSource *) sources->data[i];
+            pmSource *tmpSrc = (pmSource *) sources->data[i];
             PS_ASSERT_PTR_NON_NULL(tmpSrc, false); // just skip this one?
             PS_ASSERT_PTR_NON_NULL(tmpSrc->moments, false); // just skip this one?
@@ -1027,5 +1029,5 @@
     // measure statistics on Sx, Sy if Sx, Sy within range of clump
     {
-        psPeak *clump;
+        pmPeak *clump;
         psF32 minSx, maxSx;
         psF32 minSy, maxSy;
@@ -1054,5 +1056,5 @@
         for (psS32 i = 0 ; i < sources->n ; i++)
         {
-            psSource *tmpSrc = (psSource *) sources->data[i];
+            pmSource *tmpSrc = (pmSource *) sources->data[i];
 
             if (tmpSrc->moments->Sx < minSx)
@@ -1103,5 +1105,5 @@
     for (psS32 i = 0 ; i < sources->n ; i++) {
 
-        psSource *tmpSrc = (psSource *) sources->data[i];
+        pmSource *tmpSrc = (pmSource *) sources->data[i];
 
         tmpSrc->peak->class = 0;
@@ -1197,5 +1199,5 @@
      the pmSourceSetLocal() function.
 *****************************************************************************/
-bool pmSourceSetPixelsCircle(psSource *source,
+bool pmSourceSetPixelsCircle(pmSource *source,
                              const psImage *image,
                              psF32 radius)
@@ -1293,7 +1295,7 @@
 /******************************************************************************
 pmSourceModelGuess(source, image, model): This function allocates a new
-psModel structure and stores it in the psSource data structure specified in
+pmModel structure and stores it in the pmSource data structure specified in
 the argument list.  The model type is specified in the argument list.  The
-params array in that psModel structure are allocated, and then set to the
+params array in that pmModel structure are allocated, and then set to the
 appropriate values.  This function returns true if everything was successful.
  
@@ -1306,8 +1308,11 @@
 image, not subImage coords.  Therefore, the calls to the model evaluation
 functions will be in image, not subImage coords.  Remember this.
-*****************************************************************************/
-bool pmSourceModelGuess(psSource *source,
+ 
+XXX: The source->models member used to be allocated here.  Now I assume
+->modelPSF should be allocated
+*****************************************************************************/
+bool pmSourceModelGuess(pmSource *source,
                         const psImage *image,
-                        psModelType model)
+                        pmModelType model)
 {
     PS_ASSERT_PTR_NON_NULL(source, false);
@@ -1316,7 +1321,7 @@
     PS_ASSERT_IMAGE_NON_NULL(image, false);
     PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false);
-    if (source->models != NULL) {
-        psLogMsg(__func__, PS_LOG_WARN, "WARNING: source->models was non-NULL; calling psFree(source->models).\n");
-        psFree(source->models);
+    if (source->modelPSF != NULL) {
+        psLogMsg(__func__, PS_LOG_WARN, "WARNING: source->modelPSF was non-NULL; calling psFree(source->modelPSF).\n");
+        psFree(source->modelPSF);
     }
     if (!((model == PS_MODEL_GAUSS) ||
@@ -1330,7 +1335,7 @@
     }
 
-    source->models = pmModelAlloc(model);
-
-    psVector *params = source->models->params;
+    source->modelPSF = pmModelAlloc(model);
+
+    psVector *params = source->modelPSF->params;
 
     switch (model) {
@@ -1364,6 +1369,6 @@
         params->data.F32[6] = source->moments->Sxy;
         // XXX: What are these?
-        // source->models->params[7] = B2;
-        // source->models->params[8] = B3;
+        // source->modelPSF->params[7] = B2;
+        // source->modelPSF->params[8] = B3;
         return(true);
 
@@ -1420,5 +1425,5 @@
 /******************************************************************************
 evalModel(source, level, row): a private function which evaluates the
-source->model function at the specified coords.  The coords are subImage, not
+source->modelPSF function at the specified coords.  The coords are subImage, not
 image coords.
  
@@ -1430,5 +1435,5 @@
 the coords is in subImage or image space.
  
-XXX: This should probably be a public psModules function.
+XXX: This should probably be a public pmModules function.
  
 XXX: Use static vectors for x.
@@ -1439,17 +1444,17 @@
 testing.  Try to reproduce that and debug.
 *****************************************************************************/
-static psF32 evalModel(psSource *src,
+static psF32 evalModel(pmSource *src,
                        psU32 row,
                        psU32 col)
 {
     PS_ASSERT_PTR_NON_NULL(src, false);
-    PS_ASSERT_PTR_NON_NULL(src->models, false);
-    PS_ASSERT_PTR_NON_NULL(src->models->params, false);
-
-    // XXX: The following step will not be necessary if the models->params
+    PS_ASSERT_PTR_NON_NULL(src->modelPSF, false);
+    PS_ASSERT_PTR_NON_NULL(src->modelPSF->params, false);
+
+    // XXX: The following step will not be necessary if the modelPSF->params
     // member is a psVector.  Suggest to IfA.
 
-    // XXX EAM: done: models->params is now a vector
-    psVector *params = src->models->params;
+    // XXX EAM: done: modelPSF->params is now a vector
+    psVector *params = src->modelPSF->params;
 
     //
@@ -1461,5 +1466,5 @@
     psF32 tmpF;
 
-    switch (src->models->type) {
+    switch (src->modelPSF->type) {
     case PS_MODEL_GAUSS:
         tmpF = pmMinLM_Gauss2D(NULL, params, x);
@@ -1481,5 +1486,5 @@
         break;
     default:
-        psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
+        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
         return(NAN);
     }
@@ -1500,5 +1505,5 @@
 XXX: The result is returned in image coords.
 *****************************************************************************/
-static psF32 findValue(psSource *source,
+static psF32 findValue(pmSource *source,
                        psF32 level,
                        psU32 row,
@@ -1575,5 +1580,5 @@
 XXX: The top, bottom of the contour is not correctly determined.
 *****************************************************************************/
-psArray *pmSourceContour(psSource *source,
+psArray *pmSourceContour(pmSource *source,
                          const psImage *image,
                          psF32 level,
@@ -1585,5 +1590,5 @@
     PS_ASSERT_PTR_NON_NULL(source->peak, false);
     PS_ASSERT_PTR_NON_NULL(source->pixels, false);
-    PS_ASSERT_PTR_NON_NULL(source->models, false);
+    PS_ASSERT_PTR_NON_NULL(source->modelPSF, false);
 
     //
@@ -1692,5 +1697,5 @@
 XXX: Probably should remove the "image" argument.
 *****************************************************************************/
-bool pmSourceFitModel(psSource *source,
+bool pmSourceFitModel(pmSource *source,
                       const psImage *image)
 {
@@ -1699,5 +1704,5 @@
     PS_ASSERT_PTR_NON_NULL(source->peak, false);
     PS_ASSERT_PTR_NON_NULL(source->pixels, false);
-    PS_ASSERT_PTR_NON_NULL(source->models, false);
+    PS_ASSERT_PTR_NON_NULL(source->modelPSF, false);
     PS_ASSERT_IMAGE_NON_NULL(image, false);
     PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false);
@@ -1742,7 +1747,7 @@
                             PM_SOURCE_FIT_MODEL_TOLERANCE);
 
-    psVector *params = source->models->params;
-
-    switch (source->models->type) {
+    psVector *params = source->modelPSF->params;
+
+    switch (source->modelPSF->type) {
     case PS_MODEL_GAUSS:
         rc = psMinimizeLMChi2(myMin, NULL, params, NULL, x, y, yErr, pmMinLM_Gauss2D);
@@ -1764,12 +1769,12 @@
         break;
     default:
-        psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
+        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
         rc = false;
     }
     // XXX EAM: we need to do something (give an error?) if rc is false
     // XXX EAM: save the resulting chisq, nDOF, nIter
-    source->models->chisq = myMin->value;
-    source->models->nDOF  = y->n - params->n;
-    source->models->nIter = myMin->iter;
+    source->modelPSF->chisq = myMin->value;
+    source->modelPSF->nDOF  = y->n - params->n;
+    source->modelPSF->nIter = myMin->iter;
 
     psFree(x);
@@ -1780,5 +1785,5 @@
 
 static bool sourceAddOrSubModel(psImage *image,
-                                psSource *src,
+                                pmSource *src,
                                 bool center,
                                 psS32 flag)
@@ -1788,10 +1793,10 @@
     PS_ASSERT_PTR_NON_NULL(src->peak, false);
     PS_ASSERT_PTR_NON_NULL(src->pixels, false);
-    PS_ASSERT_PTR_NON_NULL(src->models, false);
+    PS_ASSERT_PTR_NON_NULL(src->modelPSF, false);
     PS_ASSERT_IMAGE_NON_NULL(image, false);
     PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false);
 
     psVector *x = psVectorAlloc(2, PS_TYPE_F32);
-    psVector *params = src->models->params;
+    psVector *params = src->modelPSF->params;
 
     for (psS32 i = 0; i < src->pixels->numRows; i++) {
@@ -1808,5 +1813,5 @@
             x->data.F32[0] = (float) imageCol;
             x->data.F32[1] = (float) imageRow;
-            switch (src->models->type) {
+            switch (src->modelPSF->type) {
             case PS_MODEL_GAUSS:
                 pixelValue = pmMinLM_Gauss2D(NULL, params, x);
@@ -1828,5 +1833,5 @@
                 break;
             default:
-                psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
+                psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
                 psFree(x);
                 return(false);
@@ -1851,5 +1856,5 @@
  *****************************************************************************/
 bool pmSourceAddModel(psImage *image,
-                      psSource *src,
+                      pmSource *src,
                       bool center)
 {
@@ -1860,5 +1865,5 @@
  *****************************************************************************/
 bool pmSourceSubModel(psImage *image,
-                      psSource *src,
+                      pmSource *src,
                       bool center)
 {
