Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotEllipticalContour.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotEllipticalContour.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotEllipticalContour.c	(revision 36327)
@@ -64,4 +64,5 @@
 	psFree (y);
 	psFree (yErr);
+	source->mode2 |= PM_SOURCE_MODE2_ELPROF_FEW_PTS;
 	return false;
     }
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c	(revision 36327)
@@ -445,4 +445,12 @@
     // psTraceSetLevel ("psLib.math.psMinimizeLMChi2_Alt", 5);
 
+    pmModelStatus badModel = PM_MODEL_STATUS_NONE;
+    badModel |= PM_MODEL_STATUS_BADARGS;
+    badModel |= PM_MODEL_STATUS_OFFIMAGE;
+    badModel |= PM_MODEL_STATUS_NAN_CHISQ;
+    badModel |= PM_MODEL_SERSIC_PCM_FAIL_GUESS;
+    badModel |= PM_MODEL_SERSIC_PCM_FAIL_GRID;
+    badModel |= PM_MODEL_PCM_FAIL_GUESS;
+
     // choose the sources of interest
     for (int i = 0; i < sources->n; i++) {
@@ -532,4 +540,6 @@
 	  }
 
+	  source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_RUN;
+
           // check on the model type
           pmModelType modelType = psMetadataLookupS32 (&status, model, "MODEL_TYPE");
@@ -548,4 +558,5 @@
                   psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My);
 		  Nfail ++;
+		  source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL;
                   continue;
               }
@@ -553,5 +564,5 @@
 		       source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter);
               Nconvolve ++;
-              if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) {
+              if (!(modelFit->flags & badModel)) {
                   NconvolvePass ++;
 		  source->mode |= PM_SOURCE_MODE_EXTENDED_FIT;
@@ -567,9 +578,10 @@
 		      Nfail ++;
 		      doneFits = true;
+		      source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_FAIL;
 		      continue;
 		  }
 		  psTrace ("psphot", 4, "fit plain model for %f, %f : %s chisq = %f (npix: %d, niter: %d)\n", source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter);
 		  Nplain ++;
-		  if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) {
+		  if (!(modelFit->flags & badModel)) {
 		      NplainPass ++;
 		      source->mode |= PM_SOURCE_MODE_EXTENDED_FIT;
@@ -595,4 +607,5 @@
 			  fprintf (stderr, "update window : %f %f : %f -> %f\n", source->peak->xf, source->peak->yf, fitRadius, 2*fitRadius);
 			  psphotSetWindowTrail (&fitRadius, &windowRadius, readout, source, markVal, fitRadius*2.0);
+			  source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_RETRY;
 		      }
 		  }
@@ -600,4 +613,5 @@
           }
 	  // XXX really need to do this in a cleaner way:
+	  // XXX I'm not sure I can get to this statement with a null modelFit
 	  if (!modelFit) continue;
 
@@ -615,9 +629,9 @@
             pmModel *model = source->modelFits->data[i];
 
+	    // skip the really bad fits
             if (!(model->flags & PM_MODEL_STATUS_FITTED)) continue;
-
-            if (model->flags & (PM_MODEL_STATUS_BADARGS)) continue;
+            if (model->flags & badModel) continue;
+
             // if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue;
-            if (model->flags & (PM_MODEL_STATUS_OFFIMAGE)) continue;
 
             if ((minModel < 0) || (model->chisq < minChisq)) {
@@ -646,4 +660,5 @@
           pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
 
+	  source->mode2 |= PM_SOURCE_MODE2_EXT_FITS_NONE;
           continue;
         }
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianRadialBins.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianRadialBins.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianRadialBins.c	(revision 36327)
@@ -186,4 +186,5 @@
 	psFree(values);
 	psFree(stats);
+	source->mode2 |= PM_SOURCE_MODE2_PETRO_RADBIN_NAN_CENTER;
 	return true;
     }
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianStats.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianStats.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotPetrosianStats.c	(revision 36327)
@@ -21,4 +21,5 @@
     if (!profile->binSB) {
 	psLogMsg ("psphot", PS_LOG_DETAIL, "no petrosian profile, skipping source %f, %f", source->peak->xf, source->peak->yf);
+	source->mode2 |= PM_SOURCE_MODE2_PETRO_NO_PROFILE;
 	return true;
     }
@@ -118,8 +119,9 @@
 		petRadius    = InterpolateValues     (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO);
 		petRadiusErr = InterpolateValuesErrX (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO, 0.0, petRatioErr->data.F32[nOut]);
+		source->mode2 |= PM_SOURCE_MODE2_PETRO_RATIO_ZEROBIN;
 	    } else {
 	      // petRadius    = InterpolateValues     (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO);
 	      if (nOut > 1) {
-		petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-2],   &refRadius->data.F32[nOut-2],   PETROSIAN_RATIO);
+		petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-2], &refRadius->data.F32[nOut-2],   PETROSIAN_RATIO);
 	      } else {
 		petRadius    = InterpolateValuesQuadratic (&petRatio->data.F32[nOut-3], &refRadius->data.F32[nOut-3], PETROSIAN_RATIO);
@@ -158,4 +160,5 @@
 	    fprintf (stderr, "nan pet radius\n");
 	}
+	source->mode2 |= PM_SOURCE_MODE2_PETRO_INSIG_RATIO;
     }
 
@@ -190,4 +193,5 @@
     bool found50 = false;
     bool found90 = false;
+
     // XXX use bisection to do this faster:
     for (int i = 0; !(found50 && found90) && i < refRadius->n; i++) {
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotRadialBins.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotRadialBins.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotRadialBins.c	(revision 36327)
@@ -44,12 +44,8 @@
     psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER");
     psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER");
-    if (!radMin || !radMin->n) {
-	psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMin missing or empty)");
-	return false;
-    }
-    if (!radMax || !radMax->n) {
-	psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMax missing or empty)");
-	return false;
-    }
+    psAssert (radMin, "RADIAL.ANNULAR.BINS.LOWER is missing from recipe");
+    psAssert (radMin->n, "RADIAL.ANNULAR.BINS.LOWER is empty in recipe");
+    psAssert (radMax, "RADIAL.ANNULAR.BINS.UPPER is missing from recipe");
+    psAssert (radMax->n, "RADIAL.ANNULAR.BINS.UPPER is empty in recipe");
 
     psVector *binSB      = psVectorAllocEmpty(radMin->n, PS_TYPE_F32); // surface brightness of radial bin
@@ -161,4 +157,5 @@
 	psFree(values);
 	psFree(stats);
+	source->mode2 |= PM_SOURCE_MODE2_RADBIN_NAN_CENTER;
 	return true;
     }
Index: /branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c
===================================================================
--- /branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c	(revision 36326)
+++ /branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c	(revision 36327)
@@ -582,9 +582,7 @@
     maskVal |= markVal;
 
-    // allocate the model
+    // allocate the model (this can only fail on a config error)
     pmModel *model = pmModelAlloc(modelType);
-    if (!model) {
-	return NULL;
-    }
+    psAssert (model, "invalid extended model name");
 
     float t1, t2, t3, t4, t5;
@@ -622,5 +620,5 @@
 	if (!psphotSersicModelGuessPCM (pcm, source, maskVal, psfSize)) {
 	    psFree (pcm);
-	    model->flags |= PM_MODEL_STATUS_BADARGS;
+	    model->flags |= PM_MODEL_SERSIC_PCM_FAIL_GUESS;
 	    return model;
 	}
@@ -631,5 +629,5 @@
 	if (!psphotFitSersicShapeAndIndexGridAuto (pcm, readout, source, &options, maskVal, markVal, psfSize)) {
 	    psFree (pcm);
-	    model->flags |= PM_MODEL_STATUS_BADARGS;
+	    model->flags |= PM_MODEL_SERSIC_PCM_FAIL_GRID;
 	    psError(PS_ERR_UNKNOWN, true, "Failed to find a index & shape");
 	    psErrorClear (); // clear the polynomial error
@@ -640,5 +638,5 @@
 	if (!pmSourceModelGuessPCM (pcm, source, maskVal, markVal)) {
 	    psFree (pcm);
-	    model->flags |= PM_MODEL_STATUS_BADARGS;
+	    model->flags |= PM_MODEL_PCM_FAIL_GUESS;
 	    return model;
 	}
