Index: /trunk/psphot/src/psphotFindPeaks.c
===================================================================
--- /trunk/psphot/src/psphotFindPeaks.c	(revision 11185)
+++ /trunk/psphot/src/psphotFindPeaks.c	(revision 11186)
@@ -2,6 +2,7 @@
 
 // In this function, we smooth the image, then search for the peaks 
-psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe) {
+psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass) {
 
+    float SIGMA_SMTH, NSIGMA_SMTH, NSIGMA_PEAK;
     bool  status = false;
 
@@ -9,15 +10,24 @@
     psTimerStart ("psphot");
 
-    float SIGMA  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
-    float NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
+    if (pass == 1) {
+	SIGMA_SMTH  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
+	NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
+    } else {
+	bool status_x, status_y;
+	float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X");
+	float FWHM_Y = psMetadataLookupF32 (&status_y, recipe, "FWHM_Y");
+	if (!status_x | !status_y) psAbort ("psphotFindPeaks", "FWHM_X or FWHM_Y not defined");
+	SIGMA_SMTH  = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0)));
+	NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
+    }
 
     // smooth the image, applying the mask as we go
     psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);
-    psImageSmoothMaskF32 (smooth_im, readout->mask, 0xff, SIGMA, NSIGMA);
+    psImageSmoothMaskF32 (smooth_im, readout->mask, 0xff, SIGMA_SMTH, NSIGMA_SMTH);
     psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark ("psphot"));
 
     // smooth the weight, applying the mask as we go
     psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32);
-    psImageSmoothMaskF32 (smooth_wt, readout->mask, 0xff, SIGMA/sqrt(2), NSIGMA);
+    psImageSmoothMaskF32 (smooth_wt, readout->mask, 0xff, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH);
     psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark ("psphot"));
 
@@ -52,7 +62,11 @@
 
     // signal/noise limit for the detected peaks
-    NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT");
-
-    // we need to define the threshold based on the value of NSIGMA and the applied smoothing
+    if (pass == 1) {
+	NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT");
+    } else {
+	NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2");
+    }	
+    
+    // we need to define the threshold based on the value of NSIGMA_PEAK and the applied smoothing
     // gaussian SIGMA.  a peak in the significance image has an effective S/N for faint sources
     // of (S = Io*2pi*sigma_eff^2) / sqrt(Var), where sigma_eff^2 = sigma_obs^2 + sigma_sm^2.
@@ -64,6 +78,6 @@
     // S/N = sqrt(Io)*4*pi*sigma_sm^2
     // thus, the threshold is: 
-    float effArea = 4.0*M_PI*PS_SQR(SIGMA);
-    float threshold = PS_SQR(NSIGMA) / effArea;
+    float effArea = 4.0*M_PI*PS_SQR(SIGMA_SMTH);
+    float threshold = PS_SQR(NSIGMA_PEAK) / effArea;
 
     // find the peaks in the smoothed image
