Index: /branches/czw_branch/20130702/ippconfig/gpc1/ppStack.config
===================================================================
--- /branches/czw_branch/20130702/ippconfig/gpc1/ppStack.config	(revision 35930)
+++ /branches/czw_branch/20130702/ippconfig/gpc1/ppStack.config	(revision 35931)
@@ -63,4 +63,5 @@
     PSF.INPUT.THRESH        F32   10.0
     PSF.INPUT.ASYMMETRY     F32   0.2
+    PSF.TARGET.AS.MAX 	    BOOL  TRUE
    MATCH.REJ        F32    4.0
    SAFE		 BOOL	F
Index: /branches/czw_branch/20130702/ippconfig/recipes/ppStack.config
===================================================================
--- /branches/czw_branch/20130702/ippconfig/recipes/ppStack.config	(revision 35930)
+++ /branches/czw_branch/20130702/ippconfig/recipes/ppStack.config	(revision 35931)
@@ -95,4 +95,6 @@
 PSF.INPUT.THRESH        F32  NAN	# Set minimum limit below which we do not exclude an input (defaults to 0.0)
 PSF.INPUT.ASYMMETRY     F32  NAN	# Set difference in mixture model populations to consider equal.
+PSF.TARGET.AS.MAX       BOOL F          # Set the target PSF FWHM as the maximum of accepted input FWHM values.
+PSF.TARGET.AS.MAX.EPSILON F32 0.1       # Amount to set the target PSF FWHM larger than the maximum input. Target = eps + max(input)
 
 TEMP.IMAGE	STR	conv.im.fits	# Suffix for temporary convolved images
Index: /trunk/ppStack/src/ppStackPrepare.c
===================================================================
--- /trunk/ppStack/src/ppStackPrepare.c	(revision 35930)
+++ /trunk/ppStack/src/ppStackPrepare.c	(revision 35931)
@@ -257,9 +257,10 @@
 
     bool mdok = false;
-    bool  simpleClip = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.SIMPLE");
+    bool  simpleClip = psMetadataLookupBool(&mdok, recipe, "PSF.INPUT.CLIP.SIMPLE");
     float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm
     float clipFWHMnSig = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.NSIGMA"); // sigma clipping of inputs
     float threshFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.THRESH"); // FWHM size that we refuse to clip below
     float asymmetryFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.ASYMMETRY"); // max bimodal asymmetry
+
     
     psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message
@@ -477,6 +478,21 @@
                          "Target PSF for stack", options->psf);
         options->targetSeeing = pmPSFtoFWHM(options->psf, 0.5 * numCols, 0.5 * numRows); // FWHM for target
-        psLogMsg("ppStack", PS_LOG_INFO, "Target seeing FWHM: %f\n", options->targetSeeing);
-
+
+
+	bool psfTargetAsMax = psMetadataLookupBool(&mdok, recipe, "PSF.TARGET.AS.MAX");
+	if (psfTargetAsMax) { // Should we use the largest input as the target?
+	  float psfTargetEpsilon = psMetadataLookupF32(&mdok,recipe,"PSF.TARGET.AS.MAX.EPSILON");
+	  if (!mdok) { psfTargetEpsilon = 0.0; }
+	  options->targetSeeing = 0.0;
+	  for (int i = 0; i < num; i++) {
+            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
+	    options->targetSeeing = PS_MAX(options->targetSeeing,options->inputSeeing->data.F32[i]);
+	  }
+	  psLogMsg("ppStack", PS_LOG_INFO, "Using MAX accepted input FWHM as target (max: %f epsilon: %f target %f)\n",
+		   options->targetSeeing,psfTargetEpsilon,options->targetSeeing + psfTargetEpsilon);
+	  options->targetSeeing = options->targetSeeing + psfTargetEpsilon;
+	}
+        psLogMsg("ppStack", PS_LOG_INFO, "Target seeing FWHM: %f\n", options->targetSeeing);	
+	
         pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSTACK.TARGET.PSF"); // Output chip
         psMetadataAddPtr(outChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN,
