Index: branches/eam_branches/20090715/psphot/src/psphotChoosePSF.c
===================================================================
--- branches/eam_branches/20090715/psphot/src/psphotChoosePSF.c	(revision 25496)
+++ branches/eam_branches/20090715/psphot/src/psphotChoosePSF.c	(revision 25497)
@@ -73,6 +73,15 @@
     // get the fixed PSF fit radius
     // XXX check that PSF_FIT_RADIUS < SKY_OUTER_RADIUS
-    options->radius = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS");
-    assert (status);
+    // options->radius = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS");
+    // assert (status);
+
+    // XXX we have calculated a Gaussian window function, use that for both the PSF fit radius
+    // and the aperture radius (scaling SIGMA)
+    // XXX put the scale factors into the recipe
+    float gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA");
+    float fitScale = psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS_SCALE");
+    float apScale = psMetadataLookupF32(&status, recipe, "PSF_APERTURE_SCALE");
+    options->fitRadius = (int)(fitScale*gaussSigma);
+    options->apRadius = (int)(apScale*gaussSigma);
 
     // XXX ROBUST seems to be too agressive given the small numbers.
@@ -289,5 +298,5 @@
     // XXX test dump of psf star data and psf-subtracted image
     if (psTraceGetLevel("psphot.psfstars") > 5) {
-        psphotDumpPSFStars (readout, try, options->radius, maskVal, markVal);
+        psphotDumpPSFStars (readout, try, options->fitRadius, maskVal, markVal);
     }
 
Index: branches/eam_branches/20090715/psphot/src/psphotFitSourcesLinear.c
===================================================================
--- branches/eam_branches/20090715/psphot/src/psphotFitSourcesLinear.c	(revision 25496)
+++ branches/eam_branches/20090715/psphot/src/psphotFitSourcesLinear.c	(revision 25497)
@@ -264,5 +264,5 @@
         float x = model->params->data.F32[PM_PAR_XPOS];
         float y = model->params->data.F32[PM_PAR_YPOS];
-        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_IMAGE_MASK(markVal));
+        psImageMaskCircle (source->maskView, x, y, model->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal));
     }
 
Index: branches/eam_branches/20090715/psphot/src/psphotRadiusChecks.c
===================================================================
--- branches/eam_branches/20090715/psphot/src/psphotRadiusChecks.c	(revision 25496)
+++ branches/eam_branches/20090715/psphot/src/psphotRadiusChecks.c	(revision 25497)
@@ -35,16 +35,21 @@
 	}
     }
-    model->radiusFit = (RADIUS_TYPE)(radiusFit + PSF_FIT_PADDING);
+    model->fitRadius = (RADIUS_TYPE)(radiusFit + PSF_FIT_PADDING);
 
-    if (isnan(model->radiusFit)) psAbort("error in radius");
+    if (isnan(model->fitRadius)) psAbort("error in radius");
 	
     if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	model->radiusFit *= 2;
+	model->fitRadius *= 2;
     }
 
-    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
+    source->apRadius = model->fitRadius;
+    // XXX for now, use the same radius for aperture and fit
+    // XXX to use different radii, we will need to set the apRadius mask with a call to
+    // psImageKeepCircle in the function psphotMagnitudes_Threaded 
+
+    bool status = 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->radiusFit, "OR", markVal);
+    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal);
     return status;
 }
@@ -58,15 +63,20 @@
 
     // set the fit radius based on the object flux limit and the model
-    model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING);
-    if (isnan(model->radiusFit)) psAbort("error in radius");
+    model->fitRadius = (RADIUS_TYPE) (model->modelRadius (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING);
+    if (isnan(model->fitRadius)) psAbort("error in radius");
 	
     if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
-	model->radiusFit *= 2;
+	model->fitRadius *= 2;
     }
 
-    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
+    source->apRadius = model->fitRadius;
+    // XXX for now, use the same radius for aperture and fit
+    // XXX to use different radii, we will need to set the apRadius mask with a call to
+    // psImageKeepCircle in the function psphotMagnitudes_Threaded 
+
+    bool status = 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->radiusFit, "OR", markVal);
+    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal);
     return status;
 }
@@ -141,12 +151,17 @@
     float rawRadius = model->modelRadius (model->params, EXT_FIT_NSIGMA*moments->dSky);
 
-    model->radiusFit = rawRadius + EXT_FIT_PADDING;
-    if (isnan(model->radiusFit)) psAbort("error in radius");
+    model->fitRadius = rawRadius + EXT_FIT_PADDING;
+    if (isnan(model->fitRadius)) psAbort("error in radius");
+
+    // XXX this make the psf photometry for extended sources inconsistent with the other psf sources
+    // XXX for now, use the same radius for aperture and fit
+    // XXX to use different radii, we will need to set the apRadius mask with a call to
+    // psImageKeepCircle in the function psphotMagnitudes_Threaded 
 
     // redefine the pixels if needed
-    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
+    bool status = 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->radiusFit, "OR", markVal);
+    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal);
     return status;
 }
Index: branches/eam_branches/20090715/psphot/src/psphotSourceFits.c
===================================================================
--- branches/eam_branches/20090715/psphot/src/psphotSourceFits.c	(revision 25496)
+++ branches/eam_branches/20090715/psphot/src/psphotSourceFits.c	(revision 25497)
@@ -294,5 +294,5 @@
     // save new model
     source->modelEXT = EXT;
-    source->modelEXT->radiusFit = radius;
+    source->modelEXT->fitRadius = radius;
     source->type = PM_SOURCE_TYPE_EXTENDED;
     source->mode |= PM_SOURCE_MODE_EXTMODEL;
@@ -324,10 +324,10 @@
     source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     source->mode     |= PM_SOURCE_MODE_PAIR;
-    source->modelPSF->radiusFit = radius;
+    source->modelPSF->fitRadius = radius;
 
     // copy most data from the primary source (modelEXT, blends stay NULL)
     pmSource *newSrc = pmSourceCopy (source);
     newSrc->modelPSF = psMemIncrRefCounter (DBL->data[1]);
-    newSrc->modelPSF->radiusFit = radius;
+    newSrc->modelPSF->fitRadius = radius;
 
     // build cached models and subtract
