Index: /trunk/psphot/src/psphotApResid.c
===================================================================
--- /trunk/psphot/src/psphotApResid.c	(revision 8136)
+++ /trunk/psphot/src/psphotApResid.c	(revision 8137)
@@ -5,4 +5,6 @@
 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 
 
+    int Nfail = 0;
+    int Nskip = 0;
     int Npsf;
     bool status;
@@ -13,5 +15,5 @@
 
     // S/N limit to perform full non-linear fits
-    float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");
+    float MAX_AP_OFFSET = psMetadataLookupF32 (&status, recipe, "MAX_AP_OFFSET");
 
     // set limits on the aperture magnitudes 
@@ -36,4 +38,5 @@
     for (int i = 0; i < sources->n; i++) {
 	source = sources->data[i];
+	model = source->modelPSF;
 
 	if (source->type != PM_SOURCE_TYPE_STAR) continue; 
@@ -43,12 +46,10 @@
 	if (source->mode &  PM_SOURCE_MODE_POOR) continue;
 
-	model = source->modelPSF;
-	if (model == NULL) continue;
-
-	// XXX tune independently?
-	if (source->moments->SN < 2*FIT_SN_LIM) continue;
-
 	// get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures
-	if (!pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH)) continue;
+	// will fail if below S/N threshold or model is missing
+	if (!pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH)) {
+	    Nskip ++;
+	    continue;
+	}
 
 	apResid->data.F64[Npsf] = source->apMag - source->psfMag;
@@ -65,5 +66,10 @@
 	// XXX need to see if all data were tossed?
 	// XXX need to subtract median?
-	if (fabs(apResid->data.F64[Npsf]) > 0.2) continue;
+	// XXX need to put this in the config data...
+	// if (fabs(apResid->data.F64[Npsf]) > 0.2) continue;
+	if (fabs(apResid->data.F64[Npsf]) > MAX_AP_OFFSET) {
+	    Nfail ++;
+	    continue;
+	}
 
 	dMag->data.F64[Npsf] = model->dparams->data.F32[1] / model->params->data.F32[1];
@@ -78,5 +84,6 @@
 	Npsf ++;
     }
-    psLogMsg ("psphot.apresid", 4, "measure aperture residuals : %f sec for %d objects\n", psTimerMark ("psphot"), Npsf);
+    psLogMsg ("psphot.apresid", 4, "measure aperture residuals : %f sec for %d objects (%d skipped, %d failed, %d invalid)\n", 
+	      psTimerMark ("psphot"), Npsf, Nskip, Nfail, sources->n - Npsf - Nskip - Nfail);
 
     // APTREND options : NONE SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL 
