Index: branches/eam_branches/ipp-20110404/psphot/src/psphotApResid.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotApResid.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotApResid.c	(revision 31437)
@@ -1,4 +1,4 @@
 # include "psphotInternal.h"
-// # define DEBUG
+# define DEBUG
 
 # define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; }
@@ -328,5 +328,21 @@
     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_META_REPLACE, "ap residual scatter", psf->dApResid);
     psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_META_REPLACE, "number of apresid stars", psf->nApResid);
-    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_META_REPLACE, "aperture loss (mag)", psf->growth ? psf->growth->apLoss : NAN);
+
+    // curve-of-growth offset
+    if (psf->growth) {
+	float gaussSigma = psMetadataLookupF32(&status, readout->analysis, "MOMENTS_GAUSS_SIGMA");
+	if (!status) {
+	    gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA");
+	}
+	float apScale = psMetadataLookupF32(&status, recipe, "PSF_APERTURE_SCALE");
+	float PSF_APERTURE = (int)(apScale*gaussSigma);
+	
+	float offset = pmGrowthCurveCorrect (psf->growth, PSF_APERTURE);
+	psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_META_REPLACE, "aperture loss (mag)", psf->growth->apLoss);
+	psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APREFOFF", PS_META_REPLACE, "offset to ref aperture", offset);
+    } else {
+	psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_META_REPLACE, "aperture loss (mag)", NAN);
+	psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APREFOFF", PS_META_REPLACE, "offset to ref aperture", NAN);
+    }
 
     psLogMsg ("psphot.apresid", PS_LOG_DETAIL, "aperture residual: %f +/- %f\n", psf->ApResid, psf->dApResid);
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotExtendedSourceFits.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotExtendedSourceFits.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotExtendedSourceFits.c	(revision 31437)
@@ -379,8 +379,6 @@
           assert (status);
 
-	  // fprintf (stderr, "xfit: %f, %f : %f\n", source->peak->xf, source->peak->yf, source->peak->SN); 
-
           // limit selection to some SN limit
-          assert (source->peak); // how can a source not have a peak?
+          // assert (source->peak); // how can a source not have a peak?
           if (sqrt(source->peak->detValue) < SNlim) {
 	      Nfaint ++;
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotMakeGrowthCurve.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotMakeGrowthCurve.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotMakeGrowthCurve.c	(revision 31437)
@@ -34,19 +34,23 @@
     psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS);
 
-# if (0)
-    bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");
-    if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) {
-        psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
-        psFree(psf->growth); psf->growth = NULL;
-        return false;
+    bool GROWTH_FROM_SOURCES = psMetadataLookupBool (&status, recipe, "GROWTH_FROM_SOURCES");
+    if (!status) GROWTH_FROM_SOURCES = false;
+
+    if (GROWTH_FROM_SOURCES) {
+	bool INTERPOLATE_AP = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP");
+	if (!pmGrowthCurveGenerateFromSources (readout, psf, sources, INTERPOLATE_AP, maskVal, markVal)) {
+	    psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
+	    psFree(psf->growth); psf->growth = NULL;
+	    return false;
+	}
+
+    } else {
+	bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");
+	if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) {
+	    psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
+	    psFree(psf->growth); psf->growth = NULL;
+	    return false;
+	}
     }
-# else
-    bool INTERPOLATE_AP = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP");
-    if (!pmGrowthCurveGenerateFromSources (readout, psf, sources, INTERPOLATE_AP, maskVal, markVal)) {
-        psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
-        psFree(psf->growth); psf->growth = NULL;
-        return false;
-    }
-# endif
 
     psLogMsg ("psphot", PS_LOG_MINUTIA, "built growth curve: %f sec\n", psTimerMark ("psphot.growth"));
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotOutput.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotOutput.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotOutput.c	(revision 31437)
@@ -251,4 +251,5 @@
     psMetadataItemSupplement (&status, header, analysis, "NPSFSTAR");
     psMetadataItemSupplement (&status, header, analysis, "APLOSS");
+    psMetadataItemSupplement (&status, header, analysis, "APREFOFF");
 
     psMetadataItemSupplement (&status, header, analysis, "FWHM_MAJ");
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotPetrosianStats.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotPetrosianStats.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotPetrosianStats.c	(revision 31437)
@@ -163,5 +163,5 @@
 	if (refRadius->data.F32[i] > apRadius) {
 	    if (i == 0) {
-		psWarning ("does this case make any sense? (refRadius[0] > apRadius)");
+		psWarning ("does this case make any sense? (refRadius[0] %f > apRadius %f)", refRadius->data.F32[i], apRadius);
 		continue;
 	    } else {
@@ -188,5 +188,5 @@
 	if (!found50 && (fluxSum->data.F32[i] > flux50)) {
 	    if (i == 0) {
-		psWarning ("does this case make any sense? (fluxSum[0] > flux50)");
+		psWarning ("does this case make any sense? (fluxSum[0] %f > flux50 %f)", fluxSum->data.F32[i], flux50);
 		continue;
 	    } else {
@@ -198,5 +198,5 @@
 	if (!found90 && (fluxSum->data.F32[i] > flux90)) {
 	    if (i == 0) {
-		psWarning ("does this case make any sense? (fluxSum[0] > flux90)");
+		psWarning ("does this case make any sense? (fluxSum[0] %f > flux90 %f)", fluxSum->data.F32[i], flux90);
 		continue;
 	    } else {
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotRadiusChecks.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotRadiusChecks.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotRadiusChecks.c	(revision 31437)
@@ -184,8 +184,5 @@
 bool psphotSetRadiusModel (pmModel *model, pmReadout *readout, pmSource *source, psImageMaskType markVal, bool deep) {
 
-    psF32 *PAR = model->params->data.F32;
-
-    pmMoments *moments = source->moments;
-    if (moments == NULL) return false;
+    pmPeak *peak = source->peak;
 
     // set the fit radius based on the object flux limit and the model
@@ -199,8 +196,8 @@
 
     // redefine the pixels if needed
-    pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius);
-
-    // set the mask to flag the excluded pixels
-    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal);
-    return true;
-}
+    pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, model->fitRadius);
+
+    // set the mask to flag the excluded pixels
+    psImageKeepCircle (source->maskObj, peak->xf, peak->yf, model->fitRadius, "OR", markVal);
+    return true;
+}
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotRoughClass.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotRoughClass.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotRoughClass.c	(revision 31437)
@@ -207,5 +207,9 @@
         return false;
     }
-    psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f : DX, DY: %f, %f : nStars %d of %d\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY, psfClump.nStars, psfClump.nTotal);
+    if (!havePSF) {
+	psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f : DX, DY: %f, %f : nStars %d of %d\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY, psfClump.nStars, psfClump.nTotal);
+    } else {
+	psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f : DX, DY: %f, %f : loaded from metadata\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY);
+    }
 
     // get basic parameters, or set defaults
Index: branches/eam_branches/ipp-20110404/psphot/src/psphotSourceFits.c
===================================================================
--- branches/eam_branches/ipp-20110404/psphot/src/psphotSourceFits.c	(revision 31384)
+++ branches/eam_branches/ipp-20110404/psphot/src/psphotSourceFits.c	(revision 31437)
@@ -493,5 +493,5 @@
     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     pmSourceFitModel (source, model, &options, maskVal);
-    // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
+    // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
 
     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
@@ -558,5 +558,5 @@
     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
-    // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
+    // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
 
     // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
