Index: /branches/eam_branch_20070830/psphot/src/psphotApResid.c
===================================================================
--- /branches/eam_branch_20070830/psphot/src/psphotApResid.c	(revision 14731)
+++ /branches/eam_branch_20070830/psphot/src/psphotApResid.c	(revision 14732)
@@ -56,6 +56,4 @@
     psVector *xPos    = psVectorAllocEmpty (300, PS_TYPE_F64);
     psVector *yPos    = psVectorAllocEmpty (300, PS_TYPE_F64);
-    psVector *flux    = psVectorAllocEmpty (300, PS_TYPE_F64);
-    psVector *r2rflux = psVectorAllocEmpty (300, PS_TYPE_F64);
     psVector *apResid = psVectorAllocEmpty (300, PS_TYPE_F64);
     psVector *dMag    = psVectorAllocEmpty (300, PS_TYPE_F64);
@@ -90,17 +88,16 @@
         }
 
-        // sanity clipping : if the model is so discrepant, but your expectation in the recipe
-        apResid->data.F64[Npsf] = source->apMag - source->psfMag;
-
-        if ((MAX_AP_OFFSET > 0) && (fabs(apResid->data.F64[Npsf]) > MAX_AP_OFFSET)) {
+	// aperture residual for this source
+	float dap = source->apMag - source->psfMag;
+
+        // sanity clipping : if the model is very discrepant, put your expectation in the recipe
+        if ((MAX_AP_OFFSET > 0) && (fabs(dap) > MAX_AP_OFFSET)) {
             Nfail ++;
             continue;
         }
 
+        apResid->data.F64[Npsf] = dap
         xPos->data.F64[Npsf]    = model->params->data.F32[PM_PAR_XPOS];
         yPos->data.F64[Npsf]    = model->params->data.F32[PM_PAR_YPOS];
-
-        flux->data.F64[Npsf]    = pow(10.0, -0.4*source->psfMag);
-        r2rflux->data.F64[Npsf] = PS_SQR(model->radiusFit) / flux->data.F64[Npsf];
 
         mask->data.U8[Npsf] = 0;
@@ -118,6 +115,4 @@
         psVectorExtend (xPos,    100, 1);
         psVectorExtend (yPos,    100, 1);
-        psVectorExtend (flux,    100, 1);
-        psVectorExtend (r2rflux, 100, 1);
         psVectorExtend (dMag,    100, 1);
         psVectorExtend (apResid, 100, 1);
@@ -139,4 +134,5 @@
     }
 
+    // XXX deprecating the old code which allowed the ApResid to be fitted as a function of flux and r^2/flux
     // APTREND options : NONE CONSTANT SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL
     // APTREND options are used in the switch block below
@@ -149,4 +145,5 @@
     }
 
+    // XXX is this asymmetric clipping still needed?  this analysis should come after neighbors are subtracted...
     // 3hi/1lo sigma clipping on the rflux vs metric fit
     psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
