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;
Index: /trunk/psphot/src/pmObjects_EAM.h
===================================================================
--- /trunk/psphot/src/pmObjects_EAM.h	(revision 5048)
+++ /trunk/psphot/src/pmObjects_EAM.h	(revision 5049)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @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
@@ -156,5 +156,5 @@
     pmPeak *peak;			///< Description of peak pixel.
     psImage *pixels;			///< Rectangular region including object pixels.
-    psImage *noise;			///< Mask which marks pixels associated with objects.
+    psImage *weight;			///< Image variance.
     psImage *mask;			///< Mask which marks pixels associated with objects.
     pmMoments *moments;			///< Basic moments measure for the object.
Index: /trunk/psphot/src/pmPeaksSigmaLimit.c
===================================================================
--- /trunk/psphot/src/pmPeaksSigmaLimit.c	(revision 5048)
+++ /trunk/psphot/src/pmPeaksSigmaLimit.c	(revision 5049)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psArray *pmPeaksSigmaLimit (psImageData *imdata, psMetadata *config, psStats *sky) 
+psArray *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky) 
 {
     bool  status = false;
Index: /trunk/psphot/src/psImageData.c
===================================================================
--- /trunk/psphot/src/psImageData.c	(revision 5048)
+++ /trunk/psphot/src/psImageData.c	(revision 5049)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-static void psImageDataFree (psImageData *imdata) {
+static void eamReadoutFree (eamReadout *imdata) {
 
   if (imdata == NULL) return;
@@ -7,18 +7,18 @@
   psFree (imdata->image);
   psFree (imdata->header);
-  psFree (imdata->noise);
+  psFree (imdata->weight);
   psFree (imdata->mask);
   return;
 }
 
-psImageData *psImageDataAlloc (psImage *image, psImage *noise, psImage *mask, psMetadata *header) {
+eamReadout *eamReadoutAlloc (psImage *image, psImage *weight, psImage *mask, psMetadata *header) {
   
-    psImageData *imdata = psAlloc(sizeof(psImageData));
+    eamReadout *imdata = psAlloc(sizeof(eamReadout));
     imdata->image = image;
     imdata->header = header;
-    imdata->noise = noise;
+    imdata->weight = weight;
     imdata->mask = mask;
 
-    psMemSetDeallocator(imdata, (psFreeFunc) psImageDataFree);
+    psMemSetDeallocator(imdata, (psFreeFunc) eamReadoutFree);
     return (imdata);
 }
Index: /trunk/psphot/src/psLibUtils.h
===================================================================
--- /trunk/psphot/src/psLibUtils.h	(revision 5048)
+++ /trunk/psphot/src/psLibUtils.h	(revision 5049)
@@ -23,4 +23,12 @@
                                  const psVector *yErr,
                                  psMinimizeLMChi2Func func);
+
+bool psMinimizeGaussNewtonDelta_EAM (psVector *delta,
+				     const psVector *params,
+				     const psVector *paramMask,
+				     const psArray  *x,
+				     const psVector *y,
+				     const psVector *yErr,
+				     psMinimizeLMChi2Func func);
 
 // minimize 
Index: /trunk/psphot/src/psMinimize.c
===================================================================
--- /trunk/psphot/src/psMinimize.c	(revision 5048)
+++ /trunk/psphot/src/psMinimize.c	(revision 5049)
@@ -3,6 +3,6 @@
 
 // XXX EAM : this file contains my alternate implementations of psMinimizeLMChi2
-
 // XXX EAM this implementation of MinLM includes limits on params & dparams
+
 psBool psMinimizeLMChi2_EAM(psMinimization *min,
 			    psImage *covar,
@@ -11,5 +11,5 @@
 			    const psArray *x,
 			    const psVector *y,
-			    const psVector *yErr,
+			    const psVector *yWt,
 			    psMinimizeLMChi2Func func)
 {
@@ -60,18 +60,12 @@
     // the user provides the error or NULL.  we need to convert
     // to appropriate weights
-    dy = psVectorAlloc (y->n, PS_TYPE_F32);
-    if (yErr != NULL) {
-        for (int i = 0; i < dy->n; i++) {
-	    if (yErr->data.F32[i] == 0.0) {
-		dy->data.F32[i] = 1.0;
-		// mask this?  bad pixel, obviously...
-	    } else {
-		dy->data.F32[i] = 1.0 / PS_SQR (yErr->data.F32[i]);
-	    }
-        }
+    if (yWt != NULL) {
+	dy = (psVector *) yWt;
     } else {
-        for (int i = 0; i < dy->n; i++) {
-            dy->data.F32[i] = 1.0;
-        }
+	dy = psVectorAlloc (y->n, PS_TYPE_F32);
+	psVectorInit (dy, 1.0);
+//	for (int i = 0; i < dy->n; i++) {
+//            dy->data.F32[i] = 1.0;
+//        }
     }
 
@@ -82,5 +76,5 @@
 	return (false);
     }
-    # ifndef PS_NO_TRACE
+# ifndef PS_NO_TRACE
     // dump some useful info if trace is defined
     if (psTraceGetLevel (".psLib.dataManip.psMinimizeLMChi2") >= 5) {
@@ -92,5 +86,5 @@
 	p_psVectorPrintRow (psTraceGetDestination(), Params, "params guess");
     }
-    # endif /* PS_NO_TRACE */
+# endif /* PS_NO_TRACE */
 
     // iterate until the tolerance is reached, or give up
@@ -103,5 +97,5 @@
         psF64 dLinear = p_psMinLM_dLinear (Beta, beta, lambda);
 
-        # ifndef PS_NO_TRACE
+# ifndef PS_NO_TRACE
         // dump some useful info if trace is defined
         if (psTraceGetLevel (".psLib.dataManip.psMinimizeLMChi2") >= 5) {
@@ -113,5 +107,5 @@
             p_psVectorPrintRow (psTraceGetDestination(), Params, "params guess");
         }
-        # endif /* PS_NO_TRACE */
+# endif /* PS_NO_TRACE */
 
         // calculate Chisq for new guess, update Alpha & Beta
@@ -125,5 +119,5 @@
 
         psTrace (".psLib.dataManip.psMinimizeLMChi2", 4, "last chisq: %f, new chisq %f, delta: %f, rho: %f\n", min->value, Chisq, min->lastDelta, rho);
-        # ifndef PS_NO_TRACE
+# ifndef PS_NO_TRACE
         // dump some useful info if trace is defined
         if (psTraceGetLevel (".psLib.dataManip.psMinimizeLMChi2") >= 5) {
@@ -132,5 +126,5 @@
             p_psVectorPrint (psTraceGetDestination(), Params, "params guess");
         }
-        # endif /* PS_NO_TRACE */
+# endif /* PS_NO_TRACE */
 
         /* if (Chisq < min->value) {  */
@@ -151,5 +145,5 @@
     // construct & return the covariance matrix (if requested)
     if (covar != NULL) {
-      p_psMinLM_GuessABP_EAM (covar, Beta, Params, alpha, beta, params, paramMask, beta_lim, param_min, param_max, 0.0);
+	p_psMinLM_GuessABP_EAM (covar, Beta, Params, alpha, beta, params, paramMask, beta_lim, param_min, param_max, 0.0);
     }      
 
@@ -160,8 +154,10 @@
     psFree (Beta);
     psFree (Params);
-    psFree (dy);
+    if (yWt == NULL) {
+	psFree (dy);
+    }
 
     if (min->iter == min->maxIter) {
-      return (false);
+	return (false);
     } 
     return (true);
@@ -182,6 +178,6 @@
 {
 
-    # define USE_LU_DECOMP 1
-    # if (USE_LU_DECOMP)
+# define USE_LU_DECOMP 1
+# if (USE_LU_DECOMP)
     psVector *LUv = NULL;
     psImage  *LUm = NULL;
@@ -205,5 +201,5 @@
     Alpha = psMatrixInvert (Alpha, A, &det);
 
-    # else
+# else
     // gauss-jordan version
     psTrace (".psLib.dataManip.psMinLM_GuessABP", 5, "using Gauss-J version");
@@ -218,5 +214,5 @@
 
     psGaussJordan (Alpha, Beta);
-    # endif
+# endif
 
     // apply Beta to get new Params values
@@ -241,11 +237,53 @@
     }
 
-    # if (USE_LU_DECOMP)
+# if (USE_LU_DECOMP)
     psFree (A);
     psFree (LUm);
     psFree (LUv);
-    # endif
+# endif
 
     return true;
 }
 
+bool psMinimizeGaussNewtonDelta_EAM (psVector *delta,
+				     const psVector *params,
+				     const psVector *paramMask,
+				     const psArray  *x,
+				     const psVector *y,
+				     const psVector *yWt,
+				     psMinimizeLMChi2Func func)
+{
+
+    // allocate internal arrays (current vs Guess)
+    psImage  *alpha  = psImageAlloc  (params->n, params->n, PS_TYPE_F64);
+    psImage  *Alpha  = psImageAlloc  (params->n, params->n, PS_TYPE_F64);
+    psVector *beta   = psVectorAlloc (params->n, PS_TYPE_F64);
+    psVector *Params = psVectorAlloc (params->n, PS_TYPE_F64);
+    psVector *dy     = NULL;
+
+    // the user provides the error or NULL.  we need to convert
+    // to appropriate weights
+    if (yWt != NULL) {
+	dy = (psVector *) yWt;
+    } else {
+	dy = psVectorAlloc (y->n, PS_TYPE_F32);
+	psVectorInit (dy, 1.0);
+//        for (int i = 0; i < dy->n; i++) {
+//            dy->data.F32[i] = 1.0;
+//        }
+    }
+
+    p_psMinLM_SetABX (alpha, beta, params, paramMask, x, y, dy, func);
+    p_psMinLM_GuessABP (Alpha, delta, Params, alpha, beta, params, paramMask, 0.0);
+
+    psFree (alpha);
+    psFree (Alpha);
+    psFree (beta);
+    psFree (Params);
+    if (yWt == NULL) {
+	psFree (dy);
+    }
+    return (true);
+}
+
+
Index: /trunk/psphot/src/psphot.c
===================================================================
--- /trunk/psphot/src/psphot.c	(revision 5048)
+++ /trunk/psphot/src/psphot.c	(revision 5049)
@@ -4,5 +4,5 @@
 
     psMetadata  *config  = NULL;
-    psImageData *imdata  = NULL;
+    eamReadout  *imdata  = NULL;
     psArray     *sources = NULL;
     psArray     *peaks   = NULL;
@@ -14,5 +14,5 @@
 
     // load input data (image and config)
-    // create or load mask and noise images
+    // create or load mask and weight images
     // we have memory leaks here -- may be from psMetadata
     imdata = psphotSetup (config);
Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 5048)
+++ /trunk/psphot/src/psphot.h	(revision 5049)
@@ -13,18 +13,18 @@
     psImage *image;
     psImage *mask;
-    psImage *noise;
+    psImage *weight;
     psMetadata *header;
-} psImageData;
+} eamReadout;
 
 // top-level psphot functions
 psMetadata  *psphotArguments (int *argc, char **argv);
-psImageData *psphotSetup (psMetadata *config);
-psStats     *psphotImageStats (psImageData *imdata, psMetadata *config);
-psArray     *pmPeaksSigmaLimit (psImageData *imdata, psMetadata *config, psStats *sky);
-psArray     *psphotSourceStats (psImageData *imdata, psMetadata *config, psArray *allpeaks);
+eamReadout  *psphotSetup (psMetadata *config);
+psStats     *psphotImageStats (eamReadout *imdata, psMetadata *config);
+psArray     *pmPeaksSigmaLimit (eamReadout *imdata, psMetadata *config, psStats *sky);
+psArray     *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *allpeaks);
 pmPSF       *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky);
-bool         psphotApplyPSF (psImageData *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
-bool         psphotFitGalaxies (psImageData *imdata, psMetadata *config, psArray *sources, psStats *skyStats);
-void         psphotOutput (psImageData *imdata, psMetadata *config, psArray *sources);
+bool         psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+bool         psphotFitGalaxies (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats);
+void         psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources);
 
 bool         psphotMarkPSF (pmSource *source, float shapeNsigma, float minSN, float maxChi, float SATURATE);
@@ -32,15 +32,15 @@
 int 	     psphotSortBySN (const void **a, const void **b);
 int          psphotSaveImage (psMetadata *header, psImage *image, char *filename);
-bool 	     psphotDefinePixels (pmSource *mySource, const psImageData *imdata, psF32 x, psF32 y, psF32 Radius);
+bool 	     psphotDefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);
 
-// psImageData functions
-psImageData *psImageDataAlloc (psImage *image, psImage *noise, psImage *mask, psMetadata *header);
+// eamReadout functions
+eamReadout *eamReadoutAlloc (psImage *image, psImage *noise, psImage *mask, psMetadata *header);
 
 // output functions
-bool 	     pmSourcesWriteText (psImageData *imdata, char *filename, psArray *sources);
-bool 	     pmSourcesWriteOBJ (psImageData *imdata, char *filename, psArray *sources);
-bool 	     pmSourcesWriteCMP (psImageData *imdata, char *filename, psArray *sources);
-bool 	     pmSourcesWriteCMF (psImageData *imdata, char *filename, psArray *sources);
-bool 	     pmSourcesWriteSX (psImageData *imdata, char *filename, psArray *sources);
+bool 	     pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources);
+bool 	     pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources);
+bool 	     pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources);
+bool 	     pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources);
+bool 	     pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources);
 int  	     pmSourcesDophotType (pmSource *source);
 bool 	     pmPeaksWriteText (psArray *sources, char *filename);
Index: /trunk/psphot/src/psphotApplyPSF.c
===================================================================
--- /trunk/psphot/src/psphotApplyPSF.c	(revision 5048)
+++ /trunk/psphot/src/psphotApplyPSF.c	(revision 5049)
@@ -5,5 +5,5 @@
 // run this function to a specific flux limit?
 
-bool psphotApplyPSF (psImageData *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
+bool psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
 { 
     bool  status;
@@ -61,5 +61,5 @@
 	// XXX EAM : a better test would examine the source pixels
 	if (model->radius > OUTER_RADIUS) {
-	  // (re)-allocate image, noise, mask arrays for each peak (square of radius OUTER)
+	  // (re)-allocate image, weight, mask arrays for each peak (square of radius OUTER)
 	    psphotDefinePixels (source, imdata, x, y, model->radius);
 	}
Index: /trunk/psphot/src/psphotArguments.c
===================================================================
--- /trunk/psphot/src/psphotArguments.c	(revision 5048)
+++ /trunk/psphot/src/psphotArguments.c	(revision 5049)
@@ -22,9 +22,9 @@
   }
 
-  // optional noise image - add to config
-  char *noise = NULL;
-  if ((N = psArgumentGet (*argc, argv, "-noise"))) {
+  // optional weight image - add to config
+  char *weight = NULL;
+  if ((N = psArgumentGet (*argc, argv, "-weight"))) {
     psArgumentRemove (N, argc, argv);
-    noise = psStringCopy (argv[N]);
+    weight = psStringCopy (argv[N]);
     psArgumentRemove (N, argc, argv);
   }
@@ -46,5 +46,5 @@
   fprintf (stderr, "loaded config...\n");
 
-  // identify input image & optional noise & mask images
+  // identify input image & optional weight & mask images
   // command-line entries override config-file entries
   psMetadataAdd (config, PS_LIST_HEAD, "IMAGE",       mode, "", argv[1]);
@@ -54,6 +54,6 @@
     psMetadataAdd (config, PS_LIST_HEAD, "MASK_IMAGE", mode, "", mask);
   }
-  if (noise != NULL) {
-    psMetadataAdd (config, PS_LIST_HEAD, "NOISE_IMAGE", mode, "", noise);
+  if (weight != NULL) {
+    psMetadataAdd (config, PS_LIST_HEAD, "WEIGHT_IMAGE", mode, "", weight);
   }
   if (resid != NULL) {
@@ -68,5 +68,5 @@
     fprintf (stderr, "options: \n");
     fprintf (stderr, "  -mask  (filename)\n");
-    fprintf (stderr, "  -noise (filename)\n");
+    fprintf (stderr, "  -weight (filename)\n");
     fprintf (stderr, "  -resid (filename)\n");
     exit (2);
Index: /trunk/psphot/src/psphotDefinePixels.c
===================================================================
--- /trunk/psphot/src/psphotDefinePixels.c	(revision 5048)
+++ /trunk/psphot/src/psphotDefinePixels.c	(revision 5049)
@@ -2,5 +2,5 @@
 
 bool psphotDefinePixels(pmSource *mySource, 
-			const psImageData *imdata,
+			const eamReadout *imdata,
 			psF32 x, 
 			psF32 y,
@@ -14,5 +14,5 @@
 
     mySource->pixels = psImageSubset(imdata->image, srcRegion);
-    mySource->noise  = psImageSubset(imdata->noise, srcRegion);
+    mySource->weight = psImageSubset(imdata->weight, srcRegion);
     mySource->mask   = psImageSubset(imdata->mask,  srcRegion);
 
Index: /trunk/psphot/src/psphotFitGalaxies.c
===================================================================
--- /trunk/psphot/src/psphotFitGalaxies.c	(revision 5048)
+++ /trunk/psphot/src/psphotFitGalaxies.c	(revision 5049)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-bool psphotFitGalaxies (psImageData *imdata, psMetadata *config, psArray *sources, psStats *skyStats) 
+bool psphotFitGalaxies (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats) 
 { 
     bool  status, goodfit;
@@ -69,5 +69,5 @@
 	// XXX EAM : a better test would examine the source pixels
 	if (model->radius > OUTER_RADIUS) {
-	  // (re)-allocate image, noise, mask arrays for each peak (square of radius OUTER)
+	  // (re)-allocate image, weight, mask arrays for each peak (square of radius OUTER)
 	  psphotDefinePixels (source, imdata, x, y, model->radius);
 	}
Index: /trunk/psphot/src/psphotImageStats.c
===================================================================
--- /trunk/psphot/src/psphotImageStats.c	(revision 5048)
+++ /trunk/psphot/src/psphotImageStats.c	(revision 5049)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psStats *psphotImageStats (psImageData *imdata, psMetadata *config) 
+psStats *psphotImageStats (eamReadout *imdata, psMetadata *config) 
 { 
     psStats *stats = NULL;
Index: /trunk/psphot/src/psphotOutput.c
===================================================================
--- /trunk/psphot/src/psphotOutput.c	(revision 5048)
+++ /trunk/psphot/src/psphotOutput.c	(revision 5049)
@@ -2,5 +2,5 @@
 
 // output functions: we have several fixed modes (sx, obj, cmp)
-void psphotOutput (psImageData *imdata, psMetadata *config, psArray *sources) {
+void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources) {
 
     bool status;
@@ -47,5 +47,5 @@
 }
 
-bool pmSourcesWriteText (psImageData *imdata, char *filename, psArray *sources) {
+bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources) {
 
     char *name = (char *) psAlloc (strlen(filename) + 10);
@@ -68,5 +68,5 @@
 
 // dophot-style output list with fixed line width
-bool pmSourcesWriteOBJ (psImageData *imdata, char *filename, psArray *sources) {
+bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources) {
 
     int i, type, status;
@@ -159,5 +159,5 @@
 
 // elixir/sextractor-style output list with fixed line width
-bool pmSourcesWriteSX (psImageData *imdata, char *filename, psArray *sources) {
+bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources) {
 
     int i, status, flags;
@@ -257,5 +257,5 @@
 
 // elixir-style pseudo FITS table (header + ascii list)
-bool pmSourcesWriteCMP (psImageData *imdata, char *filename, psArray *sources) {
+bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources) {
 
     int i, type, status;
@@ -360,5 +360,5 @@
 
 // elixir-style FITS table output (header + table in 1st extension)
-bool pmSourcesWriteCMF (psImageData *imdata, char *filename, psArray *sources) {
+bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources) {
 
     // write imdata->header to file
Index: /trunk/psphot/src/psphotSetup.c
===================================================================
--- /trunk/psphot/src/psphotSetup.c	(revision 5048)
+++ /trunk/psphot/src/psphotSetup.c	(revision 5049)
@@ -5,11 +5,11 @@
 //   apply X/Y border info
 //   apply the SATURATE mask?
-// load or construct the noise 
+// load or construct the weight 
 
-psImageData *psphotSetup (psMetadata *config) 
+eamReadout *psphotSetup (psMetadata *config) 
 {
     psMetadata *header = NULL;
     psImage *image = NULL;
-    psImage *noise = NULL;
+    psImage *weight = NULL;
     psImage *mask = NULL;
     psRegion region = {0,0,0,0};	// a region representing the entire array
@@ -39,17 +39,18 @@
     psMetadataAdd (config, PS_LIST_TAIL, "GAIN",    PS_META_F32 | PS_META_REPLACE, "gain value used", GAIN);
 
-    // load the noise image if it is supplied, otherwise build from input
-    char *noiseName = psMetadataLookupPtr (&status, config, "NOISE");
+    // load the weight image if it is supplied, otherwise build from input
+    // by 'weight' we really mean variance image
+    char *weightName = psMetadataLookupPtr (&status, config, "WEIGHT");
     if (status == true) {
-	file = psFitsAlloc (noiseName);
-	noise = psFitsReadImage  (NULL, file, region, 0);
+	file = psFitsAlloc (weightName);
+	weight = psFitsReadImage  (NULL, file, region, 0);
 	psFree (file);
-	// psFree (noiseName); XXX - see psFree (input)
+	// psFree (weightName); XXX - see psFree (input)
     } else {
-	// build the noise image from the input image, RDNOISE, and GAIN
-	noise = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
+	// build the weight image from the input image, RDNOISE, and GAIN
+	weight = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
 	for (int iy = 0; iy < image->numRows; iy++) {
 	    for (int ix = 0; ix < image->numCols; ix++) {
-		noise->data.F32[iy][ix] = image->data.F32[iy][ix] / GAIN + PS_SQR(RDNOISE/GAIN);
+		weight->data.F32[iy][ix] = image->data.F32[iy][ix] / GAIN + PS_SQR(RDNOISE/GAIN);
 	    }
 	}
@@ -92,5 +93,5 @@
 
     // save the image data & return it
-    psImageData *imdata = psImageDataAlloc(image, noise, mask, header);
+    eamReadout *imdata = eamReadoutAlloc(image, weight, mask, header);
     return (imdata);
 }
Index: /trunk/psphot/src/psphotSourceStats.c
===================================================================
--- /trunk/psphot/src/psphotSourceStats.c	(revision 5048)
+++ /trunk/psphot/src/psphotSourceStats.c	(revision 5049)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psArray *psphotSourceStats (psImageData *imdata, psMetadata *config, psArray *peaks) 
+psArray *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *peaks) 
 {
     bool     status  = false;
@@ -22,5 +22,5 @@
 	source->peak = (pmPeak *)psMemCopy(peaks->data[i]);
 
-	// allocate image, noise, mask arrays for each peak (square of radius OUTER)
+	// allocate image, weight, mask arrays for each peak (square of radius OUTER)
 	// XXX EAM : this has 12 leaks (v.5)
 	psphotDefinePixels (source, imdata, source->peak->x, source->peak->y, OUTER);
Index: /trunk/psphot/src/psphotSubtractPSF.c
===================================================================
--- /trunk/psphot/src/psphotSubtractPSF.c	(revision 5048)
+++ /trunk/psphot/src/psphotSubtractPSF.c	(revision 5049)
@@ -31,5 +31,5 @@
   model->params->data.F32[0] = sky;
 
-  // XXX EAM : amplify the noise matrix a la dophot?
+  // XXX EAM : amplify the weight matrix a la dophot?
 
   return (true);
