Index: /branches/eam_branch_20080324/psphot/src/psphotExtendedSourceAnalysis.c
===================================================================
--- /branches/eam_branch_20080324/psphot/src/psphotExtendedSourceAnalysis.c	(revision 17335)
+++ /branches/eam_branch_20080324/psphot/src/psphotExtendedSourceAnalysis.c	(revision 17336)
@@ -1,3 +1,3 @@
-# include "psphot.h"
+# include "psphotInternal.h"
 
 // aperture-like measurements for extended sources
@@ -6,5 +6,4 @@
     bool status;
     int Next = 0;
-    int Nconvolve = 0;
     int Npetro = 0;
     int Nisophot = 0;
@@ -44,81 +43,82 @@
     for (int i = 0; i < sources->n; i++) {
 
-        pmSource *source = sources->data[i];
+	pmSource *source = sources->data[i];
 
-        // skip PSF-like and non-astronomical objects
-        if (source->type == PM_SOURCE_TYPE_STAR) continue;
-        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
-        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
+	// skip PSF-like and non-astronomical objects
+	if (source->type == PM_SOURCE_TYPE_STAR) continue;
+	if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
+	if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
 
-        // limit selection to some SN limit
-        assert (source->peak); // how can a source not have a peak?
-        if (source->peak->SN < SN_LIM) continue;
+	// limit selection to some SN limit
+	assert (source->peak); // how can a source not have a peak?
+	if (source->peak->SN < SN_LIM) continue;
 
-        // limit selection by analysis region
-        if (source->peak->x < AnalysisRegion.x0) continue;
-        if (source->peak->y < AnalysisRegion.y0) continue;
-        if (source->peak->x > AnalysisRegion.x1) continue;
-        if (source->peak->y > AnalysisRegion.y1) continue;
+	// limit selection by analysis region
+	if (source->peak->x < AnalysisRegion.x0) continue;
+	if (source->peak->y < AnalysisRegion.y0) continue;
+	if (source->peak->x > AnalysisRegion.x1) continue;
+	if (source->peak->y > AnalysisRegion.y1) continue;
 
-        // replace object in image
-        if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
-            pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
-        }
-        Next ++;
+	// replace object in image
+	if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
+	    pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
+	}
+	Next ++;
 
 	// if we request any of these measurements, we require the radial profile
 	if (doPetrosian || doIsophotal || doAnnuli || doKron) {
-	  if (!psphotRadialProfile (source, recipe, maskVal)) {
-	    psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate radial profile");
-	    return false;
-	  }
+	    if (!psphotRadialProfile (source, recipe, maskVal)) {
+		// all measurements below require the radial profile; skip them all
+		// re-subtract the object, leave local sky
+		psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+		pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
+		source->mode |= PM_SOURCE_MODE_SUBTRACTED;
+		continue;
+	    }
 	}
-
-	// XXX probably should not give up if we fail on any of the measurements unless it is due to
-	// a programming error.
 
 	// Isophotal Mags
 	if (doIsophotal) {
-	  if (!psphotIsophotal (source, recipe, maskVal)) {
-	    psError(PSPHOT_ERR_UNKNOWN, false, "failure in Isophotal analysis");
-	    return false;
-	  }
-	  psTrace ("psphot", 5, "measure isophotal mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
-	  Nisophot ++;
+	    if (!psphotIsophotal (source, recipe, maskVal)) {
+		psTrace ("psphot", 5, "failed to measure isophotal mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+	    } else {
+		psTrace ("psphot", 5, "measured isophotal mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+		Nisophot ++;
+	    }
 	}
 
 	// Petrosian Mags
 	if (doPetrosian) {
-	  if (!psphotPetrosian (source, recipe, maskVal)) {
-	    psError(PSPHOT_ERR_UNKNOWN, false, "failure in Petrosian analysis");
-	    return false;
-	  }
-	  psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
-	  Npetro ++;
+	    if (!psphotPetrosian (source, recipe, maskVal)) {
+		psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+	    } else {
+		psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+		Npetro ++;
+	    }
 	}
 
 	// Kron Mags
 	if (doKron) {
-	  if (!psphotKron (source, recipe, maskVal)) {
-	    psError(PSPHOT_ERR_UNKNOWN, false, "failure in Kron analysis");
-	    return false;
-	  }
-	  psTrace ("psphot", 5, "measure kron mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
-	  Nkron ++;
+	    if (!psphotKron (source, recipe, maskVal)) {
+		psTrace ("psphot", 5, "failed to measure kron mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+	    } else {
+		psTrace ("psphot", 5, "measure kron mags for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+		Nkron ++;
+	    }
 	}
 
 	// Radial Annuli
 	if (doAnnuli) {
-	  if (!psphotAnnuli (source, recipe, maskVal)) {
-	    psError(PSPHOT_ERR_UNKNOWN, false, "failure in Annuli analysis");
-	    return false;
-	  } 
-	  psTrace ("psphot", 5, "measured annuli for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
-	  Nannuli ++;
+	    if (!psphotAnnuli (source, recipe, maskVal)) {
+		psError(PSPHOT_ERR_UNKNOWN, false, "failure in Annuli analysis");
+		return false;
+	    } 
+	    psTrace ("psphot", 5, "measured annuli for source at %7.1f, %7.1f", source->moments->x, source->moments->y);
+	    Nannuli ++;
 	}
 
-        // re-subtract the object, leave local sky
-        pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
-        source->mode |= PM_SOURCE_MODE_SUBTRACTED;
+	// re-subtract the object, leave local sky
+	pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
+	source->mode |= PM_SOURCE_MODE_SUBTRACTED;
     }
 
