Index: trunk/psphot/src/pmObjects_EAM.c
===================================================================
--- trunk/psphot/src/pmObjects_EAM.c	(revision 5048)
+++ trunk/psphot/src/pmObjects_EAM.c	(revision 5049)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-14 01:35:20 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-14 02:06:55 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -102,5 +102,5 @@
     psFree(tmp->peak);
     psFree(tmp->pixels);
-    psFree(tmp->noise);
+    psFree(tmp->weight);
     psFree(tmp->mask);
     psFree(tmp->moments);
@@ -118,5 +118,5 @@
     tmp->peak = NULL;
     tmp->pixels = NULL;
-    tmp->noise = NULL;
+    tmp->weight = NULL;
     tmp->mask = NULL;
     tmp->moments = NULL;
@@ -662,5 +662,5 @@
     pmSource->peak
     pmSource->pixels
-    pmSource->noise
+    pmSource->weight
     pmSource->mask
  
@@ -678,5 +678,5 @@
     // PS_PTR_CHECK_NULL(source->peak, NULL);
     // PS_PTR_CHECK_NULL(source->pixels, NULL);
-    // PS_PTR_CHECK_NULL(source->noise, NULL);
+    // PS_PTR_CHECK_NULL(source->weight, NULL);
     PS_FLOAT_COMPARE(0.0, radius, NULL);
 
@@ -736,5 +736,5 @@
 	    // XXX EAM : check for valid S/N in pixel
 	    // XXX EAM : should this limit be user-defined?
-	    if (pDiff / sqrt(source->noise->data.F32[row][col]) < 1) continue;
+	    if (pDiff / sqrt(source->weight->data.F32[row][col]) < 1) continue;
 	    
 	    Sum += pDiff;
@@ -1461,10 +1461,10 @@
     PS_ASSERT_PTR_NON_NULL(source->pixels, false);
     PS_ASSERT_PTR_NON_NULL(source->mask, false);
-    PS_ASSERT_PTR_NON_NULL(source->noise, false);
+    PS_ASSERT_PTR_NON_NULL(source->weight, false);
     psBool fitStatus = true;
     psBool onPic     = true;
     psBool rc        = true;
 
-    // XXX EAM : is it necessary for the mask & noise to exist?  the
+    // XXX EAM : is it necessary for the mask & weight to exist?  the
     //           tests below could be conditions (!NULL)
 
@@ -1508,5 +1508,5 @@
                 x->data[tmpCnt] = (psPtr *) coord;
                 y->data.F32[tmpCnt] = source->pixels->data.F32[i][j];
-                yErr->data.F32[tmpCnt] = sqrt (source->noise->data.F32[i][j]);
+                yErr->data.F32[tmpCnt] = sqrt (source->weight->data.F32[i][j]);
 		// XXX EAM : note the wasted effort: we carry dY^2, take sqrt(), then 
 		//           the minimization function calculates sq()
@@ -1576,5 +1576,5 @@
 }
 
-// XXX EAM : new version with parameter range limits and noise enhancement
+// XXX EAM : new version with parameter range limits and weight enhancement
 bool pmSourceFitModel (pmSource *source,
 		       pmModel *model,
@@ -1586,7 +1586,7 @@
     PS_ASSERT_PTR_NON_NULL(source->pixels, false);
     PS_ASSERT_PTR_NON_NULL(source->mask, false);
-    PS_ASSERT_PTR_NON_NULL(source->noise, false);
-
-    // XXX EAM : is it necessary for the mask & noise to exist?  the
+    PS_ASSERT_PTR_NON_NULL(source->weight, false);
+
+    // XXX EAM : is it necessary for the mask & weight to exist?  the
     //           tests below could be conditions (!NULL)
 
@@ -1602,5 +1602,5 @@
     pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
 
-    // XXX EAM : I need to use the sky value to constrain the noise model
+    // XXX EAM : I need to use the sky value to constrain the weight model
     int nParams = PSF ? params->n - 4 : params->n;
     psF32 So = params->data.F32[0];
@@ -1641,11 +1641,13 @@
 		ymodel = modelFunc (NULL, model->params, coord);
 		
-		// this test enhances the noise based on deviation from the model flux
+		// this test enhances the weight based on deviation from the model flux
 		Ro = 1.0 + fabs (y->data.F32[tmpCnt] - ymodel) / sqrt(PS_SQR(ymodel - So) + PS_SQR(So));
 
-		// XXX EAM : note the wasted effort: we carry dY^2, take sqrt(), then 
-		//           the minimization function calculates sq(). 
-		//           should psMinimizeLMChi2 take dY^2?
-                yErr->data.F32[tmpCnt] = sqrt (source->noise->data.F32[i][j] * Ro);
+		// psMinimizeLMChi2_EAM takes wt = 1/dY^2
+		if (source->weight->data.F32[i][j] == 0) {
+		  yErr->data.F32[tmpCnt] = 0.0;
+		} else {
+		  yErr->data.F32[tmpCnt] = 1.0 / (source->weight->data.F32[i][j] * Ro);
+		}
                 tmpCnt++;
             }
@@ -1708,5 +1710,5 @@
     if (paramMask != NULL) {
 	psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
-	psMinimizeGaussNewtonDelta (delta, params, NULL, x, y, yErr, modelFunc);
+	psMinimizeGaussNewtonDelta_EAM (delta, params, NULL, x, y, yErr, modelFunc);
 	for (int i = 0; i < dparams->n; i++) {
 	    if (!paramMask->data.U8[i]) continue;
