Index: trunk/ippconfig/gpc1/psphot.config
===================================================================
--- trunk/ippconfig/gpc1/psphot.config	(revision 35028)
+++ trunk/ippconfig/gpc1/psphot.config	(revision 35038)
@@ -53,4 +53,7 @@
   PSPHOT.EXT.DIFF.ALTERNATE	    BOOL TRUE
   PSPHOT.EXT.DIFF.ALTERNATE.THRESH  F32	 1.25
+
+  PSPHOT.EXT.FIT.ALL.SOURCES	    BOOL TRUE
+  PSPHOT.EXT.FIT.ALL.THRESH	    F32	 1000
 END
 
@@ -59,4 +62,7 @@
   PSPHOT.EXT.DIFF.ALTERNATE	    BOOL TRUE
   PSPHOT.EXT.DIFF.ALTERNATE.THRESH  F32	 1.25
+
+  PSPHOT.EXT.FIT.ALL.SOURCES	    BOOL TRUE
+  PSPHOT.EXT.FIT.ALL.THRESH	    F32	 1000
 END
 
Index: trunk/ippconfig/recipes/psphot.config
===================================================================
--- trunk/ippconfig/recipes/psphot.config	(revision 35028)
+++ trunk/ippconfig/recipes/psphot.config	(revision 35038)
@@ -347,4 +347,6 @@
 PSPHOT.EXT.DIFF.ALTERNATE	    BOOL  FALSE           # use alternate extended source calculation; designed for diff trails
 PSPHOT.EXT.DIFF.ALTERNATE.THRESH    F32	  1.5		  # threshold for alternate extended source calculations
+PSPHOT.EXT.FIT.ALL.SOURCES	    BOOL  FALSE           # Apply extended object fits to all sources
+PSPHOT.EXT.FIT.ALL.THRESH	    F32	  1000		  # Set density threshold above which to not fit all sources
 PSPHOT.CR.GROW                      S32   1               # Number of pixels to grow CR mask
 PSPHOT.CR.NSIGMA.SOFTEN             F32   0.0025          # Softening parameter for weights
Index: trunk/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 35028)
+++ trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 35038)
@@ -538,8 +538,9 @@
     psF32 **imageData = readout->image->data.F32;// Dereference image
     psF32 **varianceData = readout->variance ? readout->variance->data.F32 : NULL; // Dereference variance map
-
+    float maskFrac = 0.0;
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
             if (maskData[y][x] & maskVal) {
+  	        maskFrac += 1;
                 imageData[y][x] = NAN;
                 if (varianceData) {
@@ -549,5 +550,7 @@
         }
     }
-
+    maskFrac = maskFrac / (1.0 * numRows * numCols);
+    psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "READOUT.MASK.FRAC", PS_META_REPLACE,
+		     "fraction of pixels masked by pmReadoutMaskApply",maskFrac);
     return true;
 }
Index: trunk/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 35028)
+++ trunk/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 35038)
@@ -830,5 +830,5 @@
             psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_MAG",         0, "Kron Mag",                                   kronMag);
 
-            @PS1_DV1,PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
+            @PS1_DV0,PS1_DV1@ psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
             @ALL,!PS1_DV0,!PS1_DV1@ psMetadataAddS32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
             psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE",       0, "name of model",                              pmModelClassGetName (model->type));
Index: trunk/psphot/src/psphotSourceSize.c
===================================================================
--- trunk/psphot/src/psphotSourceSize.c	(revision 35028)
+++ 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?
