Index: /branches/eam_branches/ipp-20110404/psphot/src/psphotMagnitudes.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psphot/src/psphotMagnitudes.c	(revision 31363)
+++ /branches/eam_branches/ipp-20110404/psphot/src/psphotMagnitudes.c	(revision 31364)
@@ -190,7 +190,22 @@
 	}
 
+	float xPos = source->peak->xf;
+	float yPos = source->peak->yf;
+
+	pmModel *model = source->modelPSF;
+	if (model) {
+	    xPos = model->params->data.F32[PM_PAR_XPOS];
+	    yPos = model->params->data.F32[PM_PAR_YPOS];
+	} else {
+	    bool useMoments = pmSourcePositionUseMoments(source);
+	    if (useMoments) {
+		xPos = source->moments->Mx;
+		yPos = source->moments->My;
+	    }
+	}
+
         // clear the mask bit and set the circular mask pixels
         psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal));
-        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", markVal);
+        psImageKeepCircle (source->maskObj, xPos, yPos, source->apRadius, "OR", markVal);
 
         status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
@@ -213,5 +228,5 @@
         if (backModel) {
             psAssert (binning, "if backModel is defined, so should binning be");
-            source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);
+            source->sky = psImageUnbinPixel(xPos, yPos, backModel->image, binning);
             if (isnan(source->sky) && false) {
                 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");
@@ -223,5 +238,5 @@
         if (backStdev) {
             psAssert (binning, "if backStdev is defined, so should binning be");
-            source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);
+            source->skyErr = psImageUnbinPixel(xPos, yPos, backStdev->image, binning);
             if (isnan(source->skyErr) && false) {
                 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");
