Index: /trunk/ippconfig/recipes/psphot.config
===================================================================
--- /trunk/ippconfig/recipes/psphot.config	(revision 35467)
+++ /trunk/ippconfig/recipes/psphot.config	(revision 35468)
@@ -226,6 +226,6 @@
 
 # SDSS values (in SDSS pixels)
-#@RADIAL.ANNULAR.BINS.LOWER           F32     0.00 0.56 1.69 2.59 4.41  7.51 11.58 18.58 28.55 45.50  70.51 110.53 172.49 269.52 420.51 #
-#@RADIAL.ANNULAR.BINS.UPPER           F32     0.56 1.69 2.59 4.41 7.51 11.58 18.58 28.55 45.50 70.51 110.53 172.49 269.52 420.51 652.50 #
+# @RADIAL.ANNULAR.BINS.LOWER           F32     0.00 0.56 1.69 2.59 4.41  7.51 11.58 18.58 28.55 45.50  70.51 110.53 172.49 269.52 420.51 #
+# @RADIAL.ANNULAR.BINS.UPPER           F32     0.56 1.69 2.59 4.41 7.51 11.58 18.58 28.55 45.50 70.51 110.53 172.49 269.52 420.51 652.50 #
 
 # PS1 values? (all SDSS @ PS1 0.2 arcsec pixel scales)
@@ -233,7 +233,13 @@
 # @RADIAL.ANNULAR.BINS.UPPER           F32      1.2 3.4 5.2 8.8 15.0 23.2 37.2 57.1 91.0 141.0 221.1 345.0 539.1 841.0 1305.0 #
 
-# PS1 values? (revised fpr PS1 @0.25 arcsec pixel scales) 
-@RADIAL.ANNULAR.BINS.LOWER           F32      0.0 0.96 2.72 4.16 7.04 12.0 18.56 29.76 45.68 72.80 112.80    # perl parser fails without a comment ticket #1476 still?
-@RADIAL.ANNULAR.BINS.UPPER           F32      0.96 2.72 4.16 7.04 12.0 18.56 29.76 45.68 72.80 112.80 176.88 # perl parser fails without a comment ticket #1476 still?
+# PV1 PS1 values (revised for PS1 @0.25 arcsec pixel scales) 
+# @RADIAL.ANNULAR.BINS.LOWER           F32      0.00 0.96 2.72 4.16  7.04 12.00 18.56 29.76 45.68  72.80 112.80 # perl parser fails without a comment ticket #1476 still?
+# @RADIAL.ANNULAR.BINS.UPPER           F32      0.96 2.72 4.16 7.04 12.00 18.56 29.76 45.68 72.80 112.80 176.88 # perl parser fails without a comment ticket #1476 still?
+
+# PV2 PS1 values (dropped inner 2 apertures)
+@RADIAL.ANNULAR.BINS.LOWER           F32      0.00 4.16 7.04 12.00 18.56 29.76 45.68  72.80 112.80 # perl parser fails without a comment ticket #1476 still?
+@RADIAL.ANNULAR.BINS.UPPER           F32      4.16 7.04 12.0 18.56 29.76 45.68 72.80 112.80 176.88 # perl parser fails without a comment ticket #1476 still?
+
+RADIAL.ANNULAR.BINS.MIN              S32      4  # always measure apertures to this entry
 
 # In very dense fields it doesn't make sense to measure out to large radial apertures.
@@ -317,4 +323,5 @@
 TEST_FIT_X                          F32   NAN
 TEST_FIT_Y                          F32   NAN
+TEST_FIT_CONVOLVED		    BOOL  FALSE
 
 TEST_FIT_PAR0                       F32   NAN
Index: /trunk/psphot/src/psphotEvalPSF.c
===================================================================
--- /trunk/psphot/src/psphotEvalPSF.c	(revision 35467)
+++ /trunk/psphot/src/psphotEvalPSF.c	(revision 35468)
@@ -67,4 +67,101 @@
 	    psTrace ("psphot", 5, "satstar failed fit");
 	}
+	return false;
+    }
+
+    // unless we prove otherwise, this object is a star.
+    source->type = PM_SOURCE_TYPE_STAR;
+
+    // the following source->mode information pertains to modelPSF:
+    source->mode |= PM_SOURCE_MODE_PSFMODEL;
+
+    // if the object has fitted peak above saturation, label as SATSTAR
+    // this is a valid PSF object, but ignore the other quality tests
+    // remember: fit does not use saturated pixels (masked)
+    // XXX no extended object can saturate and stay extended...
+
+    // XXX this test is wrong : it should add back in the local sky from the model to test
+    // against saturation the local sky is saved in source->sky after psphotMagnitudes is called
+    if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
+	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
+	    psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
+	}
+	source->mode |=  PM_SOURCE_MODE_SATSTAR;
+	return true;
+    } 
+
+    // if the object has a fitted peak below 0.02, the source is not viable
+    // perhaps the fit did not converge cleanly
+    if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
+	source->mode |= PM_SOURCE_MODE_FAIL;
+	if (source->mode & PM_SOURCE_MODE_SATSTAR) {
+	    psTrace ("psphot", 5, "satstar failed fit (peak below 0)");
+	}
+	return false;
+    } 
+
+    // if the source was predicted to be a SATSTAR, but it fitted below saturation, 
+    // make a note to the user.
+    // XXX do not do this until we have a local measure of the sky in place
+    if (false && (source->mode & PM_SOURCE_MODE_SATSTAR)) {
+	psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
+	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
+    }
+
+    SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[PM_PAR_I0];
+    Chi = model->chisqNorm / model->nDOF;
+
+    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
+    keep = TRUE;
+    keep &= (SN > PSF_MIN_SN);
+    keep &= (Chi < PSF_MAX_CHI);
+
+    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
+	psTrace ("psphot", 5, "satstar fit results: %f, %f  %d :  SN: %f  Chisq: %f\n", 
+		     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, SN, Chi);
+    }
+
+    if (keep) {
+	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
+	    psTrace ("psphot", 7, "PSFSTAR kept (%f, %f  :  SN: %f Chisq: %f)\n", 
+		     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
+	}
+	return true;
+    }
+
+    // this source is not a star, warn if it was a PSFSTAR
+    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
+	psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  SN: %f  Chisq: %f)\n", 
+		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
+    } else {
+	psTrace ("psphot", 5, "fails PSF fit (%f, %f  :  SN: %f  Chisq: %f)\n", 
+		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
+    }
+
+    // poor-quality fit; only keep if nothing else works...
+    source->mode |= PM_SOURCE_MODE_POOR;
+    return false;
+}	
+
+// examine the model->status, fit parameters, etc and decide if the model succeeded
+// set the source->type and source->mode appropriately
+bool psphotEvalDBL (pmSource *source, pmModel *model) { 
+
+    // do we actually have a valid PSF model?
+    if (model == NULL) {
+	source->mode &= ~PM_SOURCE_MODE_FITTED;
+	return false;
+    }
+
+    // was the model actually fitted?
+    if (!(model->flags & PM_MODEL_STATUS_FITTED)) {
+	source->mode &= ~PM_SOURCE_MODE_FITTED; 
+	return false;
+    }
+    // did the model fit fail for one or another reason?
+    if (model->flags & (PM_MODEL_STATUS_BADARGS | 
+			PM_MODEL_STATUS_NONCONVERGE | 
+			PM_MODEL_STATUS_OFFIMAGE)) {
+	source->mode |= PM_SOURCE_MODE_FAIL;
 	return false;
     }
@@ -88,11 +185,7 @@
     } 
 
-    // if the object has a fitted peak below 0.02, the source is not viable
-    // perhaps the fit did not converge cleanly
+    // if the object has a fitted peak below 0, the fit did not converge cleanly
     if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
 	source->mode |= PM_SOURCE_MODE_FAIL;
-	if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	    psTrace ("psphot", 5, "satstar failed fit (peak below 0)");
-	}
 	return false;
     } 
@@ -104,93 +197,4 @@
 	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
     }
-
-    SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[PM_PAR_I0];
-    Chi = model->chisqNorm / model->nDOF;
-
-    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
-    keep = TRUE;
-    keep &= (SN > PSF_MIN_SN);
-    keep &= (Chi < PSF_MAX_CHI);
-
-    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	psTrace ("psphot", 5, "satstar fit results: %f, %f  %d :  SN: %f  Chisq: %f\n", 
-		     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, SN, Chi);
-    }
-
-    if (keep) {
-	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	    psTrace ("psphot", 7, "PSFSTAR kept (%f, %f  :  SN: %f Chisq: %f)\n", 
-		     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
-	}
-	return true;
-    }
-
-    // this source is not a star, warn if it was a PSFSTAR
-    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  SN: %f  Chisq: %f)\n", 
-		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
-    } else {
-	psTrace ("psphot", 5, "fails PSF fit (%f, %f  :  SN: %f  Chisq: %f)\n", 
-		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi);
-    }
-
-    // poor-quality fit; only keep if nothing else works...
-    source->mode |= PM_SOURCE_MODE_POOR;
-    return false;
-}	
-
-// examine the model->status, fit parameters, etc and decide if the model succeeded
-// set the source->type and source->mode appropriately
-bool psphotEvalDBL (pmSource *source, pmModel *model) { 
-
-    // do we actually have a valid PSF model?
-    if (model == NULL) {
-	source->mode &= ~PM_SOURCE_MODE_FITTED;
-	return false;
-    }
-
-    // was the model actually fitted?
-    if (!(model->flags & PM_MODEL_STATUS_FITTED)) {
-	source->mode &= ~PM_SOURCE_MODE_FITTED; 
-	return false;
-    }
-    // did the model fit fail for one or another reason?
-    if (model->flags & (PM_MODEL_STATUS_BADARGS | 
-			PM_MODEL_STATUS_NONCONVERGE | 
-			PM_MODEL_STATUS_OFFIMAGE)) {
-	source->mode |= PM_SOURCE_MODE_FAIL;
-	return false;
-    }
-
-    // unless we prove otherwise, this object is a star.
-    source->type = PM_SOURCE_TYPE_STAR;
-
-    // the following source->mode information pertains to modelPSF:
-    source->mode |= PM_SOURCE_MODE_PSFMODEL;
-
-    // if the object has fitted peak above saturation, label as SATSTAR
-    // this is a valid PSF object, but ignore the other quality tests
-    // remember: fit does not use saturated pixels (masked)
-    // XXX no extended object can saturate and stay extended...
-    if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
-	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	    psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
-	}
-	source->mode |=  PM_SOURCE_MODE_SATSTAR;
-	return true;
-    } 
-
-    // if the object has a fitted peak below 0, the fit did not converge cleanly
-    if (model->params->data.F32[PM_PAR_I0] <= 0.02) {
-	source->mode |= PM_SOURCE_MODE_FAIL;
-	return false;
-    } 
-
-    // if the source was predicted to be a SATSTAR, but it fitted below saturation, 
-    // make a note to the user
-    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
-	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
-    }
     return true;
 }	
Index: /trunk/psphot/src/psphotRadialApertures.c
===================================================================
--- /trunk/psphot/src/psphotRadialApertures.c	(revision 35467)
+++ /trunk/psphot/src/psphotRadialApertures.c	(revision 35468)
@@ -47,4 +47,5 @@
 static float outerRadius = NAN;
 static float SN_LIM = NAN;
+static int RADIAL_AP_MIN = 5;
 static psImageMaskType maskVal = 0;
 
@@ -115,4 +116,10 @@
     // S/N limit to perform full non-linear fits
     SN_LIM = psMetadataLookupF32 (&status, recipe, "RADIAL_APERTURES_SN_LIM");
+
+    // S/N limit to perform full non-linear fits
+    RADIAL_AP_MIN = psMetadataLookupS32 (&status, recipe, "RADIAL.ANNULAR.BINS.MIN");
+    if (!status) {
+      RADIAL_AP_MIN = 5;
+    }
 
     // source analysis is done in S/N order (brightest first)
@@ -310,8 +317,8 @@
 
     // find the largest aperture of interest (use only apertures with inner radii <=
-    // source->skyRadius)
+    // source->skyRadius, as long as i >= RADIAL_AP_MIN
     int lastAp = aperRadii->n;
-    for (int i = 0; i < aperRadii->n; i++) {
-	if (aperRadii->data.F32[i] < source->skyRadius) continue;
+    for (int i = RADIAL_AP_MIN; i < aperRadii->n; i++) {
+	if (aperRadii->data.F32[i] < source->skyRadius) continue; // measure out to this radius
 	lastAp = i + 1;
 	break;
