Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c	(revision 31326)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c	(revision 31327)
@@ -197,5 +197,5 @@
         // mask the given aperture and measure the apMag
         psImageKeepCircle (mask, xc, yc, radius, "OR", markVal);
-        if (!pmSourcePhotometryAper (&apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) {
+        if (!pmSourcePhotometryAper (NULL, &apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) {
 	    psFree (growth);
 	    psFree (view);
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourceMoments.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourceMoments.c	(revision 31326)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourceMoments.c	(revision 31327)
@@ -130,8 +130,16 @@
     Sum = 0.0;  // the second pass may include slightly different pixels, re-determine Sum
 
+    // float dX = source->moments->Mx - source->peak->xf;
+    // float dY = source->moments->My - source->peak->yf;
+    // float dR = hypot(dX, dY);
+    // float Xo = (dR < 2.0) ? source->moments->Mx : source->peak->xf;
+    // float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf;
+    float Xo = source->moments->Mx;
+    float Yo = source->moments->My;
+
     // center of mass in subimage.  Note: the calculation below uses pixel index, so we correct
     // xCM, yCM from pixel coords to pixel index here.
-    psF32 xCM = source->moments->Mx - 0.5 - source->pixels->col0; // coord of peak in subimage
-    psF32 yCM = source->moments->My - 0.5 - source->pixels->row0; // coord of peak in subimage
+    psF32 xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage
+    psF32 yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage
 
     for (psS32 row = 0; row < source->pixels->numRows ; row++) {
@@ -142,5 +150,7 @@
 	psF32 *vPix = source->pixels->data.F32[row];
 	psF32 *vWgt = source->variance->data.F32[row];
+
 	psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
+	// psImageMaskType  *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
 	for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
@@ -280,5 +290,7 @@
 	psF32 *vPix = source->pixels->data.F32[row];
 	psF32 *vWgt = source->variance->data.F32[row];
+
 	psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
+	// psImageMaskType  *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
 	for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
@@ -391,5 +403,7 @@
 	psF32 *vPix = source->pixels->data.F32[row];
 	psF32 *vWgt = source->variance->data.F32[row];
+
 	psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
+	// psImageMaskType *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
 	for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.c	(revision 31326)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.c	(revision 31327)
@@ -102,5 +102,4 @@
     bool isPSF;
     float x, y;
-    float rflux;
     float SN;
     pmModel *model;
@@ -246,12 +245,4 @@
 	    // XXX correct the apFlux?
         }
-        if (mode & PM_SOURCE_PHOT_APCORR) {
-            // XXX this should be removed -- we no longer fit for the 'sky bias'
-	    // XXX is this happening???
-            rflux   = pow (10.0, 0.4*source->psfMag);
-	    psAssert (psf->skyBias == 0.0, "sky bias not 0");
-	    psAssert (psf->skySat == 0.0, "sky sat not 0");
-            source->apMag -= PS_SQR(source->apRadius)*rflux * psf->skyBias + psf->skySat / rflux;
-        }
     }
     if (mode & PM_SOURCE_PHOT_INTERP) {
@@ -309,14 +300,14 @@
 
     bool status;
-    status = pmSourcePhotometryAper(&source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal);
+    int nPix = 0;
+    status = pmSourcePhotometryAper(&nPix, &source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal);
     if (status) {
 	source->mode |= PM_SOURCE_MODE_AP_MAGS;
     }
-
     return status;
 }
 
 // return source aperture magnitude
-bool pmSourcePhotometryAper (float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal)
+bool pmSourcePhotometryAper (int *nPixOut, float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(apMag, false);
@@ -331,4 +322,5 @@
     float apFlux = 0;
     float apFluxVar = 0;
+    int nPix = 0;
 
     if (DO_SKY) {
@@ -348,8 +340,11 @@
             apFlux += imData[iy][ix] - sky;
             apFluxVar += varData[iy][ix];
-        }
-    }
+	    nPix ++;
+        }
+    }
+    
     if (apFluxOut) *apFluxOut = apFlux;
     if (apFluxErr) *apFluxErr = sqrt(fabs(apFluxVar));
+    if (nPixOut) *nPixOut = nPix;
 
     if (apFlux <= 0) {
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.h
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.h	(revision 31326)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourcePhotometry.h	(revision 31327)
@@ -45,4 +45,5 @@
 
 bool pmSourcePhotometryAper(
+    int *nPixOut,
     float *apMag,
     float *apFluxOut,
