Index: trunk/psphot/src/psphotSourceSize.c
===================================================================
--- trunk/psphot/src/psphotSourceSize.c	(revision 34769)
+++ trunk/psphot/src/psphotSourceSize.c	(revision 35038)
@@ -13,4 +13,7 @@
     bool altDiffExt;
     float altDiffExtThresh;
+    bool extFitAll;
+    bool extFitAllReadout;
+    float extFitAllThresh;
     float soft;
     int grow;
@@ -127,4 +130,10 @@
     // Threshold for this alternate method
     options.altDiffExtThresh = psMetadataLookupF32(&status, recipe, "PSPHOT.EXT.DIFF.ALTERNATE.THRESH");
+    assert (status);
+    // Option to enable fitting of all objects with extended model.
+    options.extFitAll = psMetadataLookupBool(&status, recipe, "PSPHOT.EXT.FIT.ALL.SOURCES");
+    assert (status);
+    // Fitting everything is fine, but if the source density is high, we probably shouldn't.
+    options.extFitAllThresh = psMetadataLookupF32(&status, recipe, "PSPHOT.EXT.FIT.ALL.THRESH");
     assert (status);
     
@@ -413,5 +422,18 @@
 
     psLogMsg("psModules.objects", PS_LOG_INFO, "Source Size classifications: %4s %4s %4s %4s %4s", "Npsf", "Next", "Nsat", "Ncr", "Nskip");
-
+    // Determine if this readout is above the threshold to ext fit all sources
+    if (options->extFitAll) {
+      float maskFrac = psMetadataLookupF32(&status,readout->analysis,"READOUT.MASK.FRAC");
+      if (status) {
+	maskFrac = 0.0;
+      }
+      if (sources->n * (1.0 - maskFrac) > options->extFitAllThresh) {
+	options->extFitAllReadout = false;
+      }
+      else {
+	options->extFitAllReadout = true;
+      }
+    }
+    
     if (!psphotSourceClassRegion (NULL, &psfClump, sources, recipe, psf, options)) {
 	psLogMsg ("psphot", 4, "Failed to determine source classification for full image\n");
@@ -420,5 +442,5 @@
     }
     return true;
-
+    
     int nRegions = psMetadataLookupS32 (&status, readout->analysis, "PSF.CLUMP.NREGIONS");
     for (int i = 0; i < nRegions; i ++) {
@@ -426,8 +448,8 @@
         psMetadata *regionMD = psMetadataLookupPtr (&status, readout->analysis, regionName);
         psAssert (regionMD, "regions must be defined by earlier call to psphotRoughClassRegion");
-
+	
         psRegion *region = psMetadataLookupPtr (&status, regionMD, "REGION");
         psAssert (region, "regions must be defined by earlier call to psphotRoughClassRegion");
-
+	
         // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y
         psfClump.X  = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X");   psAssert (status, "missing PSF.CLUMP.X");
@@ -559,4 +581,9 @@
         // * SAT stars should not be faint, but defects may?
 
+	// If the recipe requests we do extended source fits to everything, set
+	// the EXT_LIMIT flag
+	if (options->extFitAllReadout) {
+	  source->mode |= PM_SOURCE_MODE_EXT_LIMIT;
+	}
         // Defects may not always match CRs from peak curvature analysis
         // Defects may also be marked as SATSTAR -- XXX deactivate this flag?
