Index: trunk/psphot/src/mark_psf_source.c
===================================================================
--- trunk/psphot/src/mark_psf_source.c	(revision 4375)
+++ trunk/psphot/src/mark_psf_source.c	(revision 4574)
@@ -15,5 +15,5 @@
 // PS_SOURCE_BRIGHTSTAR 
 # define MIN_DS 0.01
-bool mark_psf_source (psSource *source, float shapeNsigma)
+bool mark_psf_source (psSource *source, float shapeNsigma, float SATURATE)
 { 
     float dSX, dSY, SX, SY, SN;
@@ -22,6 +22,17 @@
     if (source->modelPSF == NULL) return (false);
 
-    // SATSTAR objects are fitted with PSF regardless
-    if (source->type == PS_SOURCE_SATSTAR) return (true);
+    // if object has fitted peak above saturation, label as SATSTAR
+    // remember: fit does not use saturated pixels (masked)
+    if (source->modelPSF->params->data.F32[1] >= SATURATE) {
+	if (source->type == PS_SOURCE_PSFSTAR) {
+	    psLogMsg ("psphot", 3, "PSFSTAR marked saturated\n");
+	}
+	source->type = PS_SOURCE_SATSTAR;
+	return (true);
+    } 
+    if (source->type == PS_SOURCE_SATSTAR) {
+	psLogMsg ("psphot", 4, "SATSTAR marked bright (fitted peak below saturation)\n");
+	source->type = PS_SOURCE_BRIGHTSTAR;
+    }
 
     SN  = source->modelPSF->params->data.F32[1]/source->modelPSF->dparams->data.F32[1];
@@ -35,25 +46,25 @@
     // sigma = 1 / SX
     // dsx = 1 / (SX * SN)
-    // dsx_o = hypot (1/SX*SN + MIN_DSX)
+    // dsx_o = hypot (1/(SX*SN), MIN_DSX)
 
     // assign PS_SOURCE_BRIGHTSTAR to bright objects within PSF region of dparams[]
     if ((fabs(nSx) < shapeNsigma) && (fabs(nSy) < shapeNsigma)) {
-      if (source->type == PS_SOURCE_PSFSTAR) return (true);
-      source->type = PS_SOURCE_BRIGHTSTAR;
-      return (true);
+	if (source->type == PS_SOURCE_PSFSTAR) return (true);
+	source->type = PS_SOURCE_BRIGHTSTAR;
+	return (true);
     }
     
     if (source->type == PS_SOURCE_PSFSTAR) {
-      psLogMsg ("psphot", 3, "PSFSTAR demoted based on dSx, dSy\n");
+	psLogMsg ("psphot", 3, "PSFSTAR demoted based on dSx, dSy\n");
     }
 
     if ((nSx >= shapeNsigma) || (nSy >= shapeNsigma)) {
-      source->type = PS_SOURCE_GALAXY;
-      return (false);
+	source->type = PS_SOURCE_GALAXY;
+	return (false);
     }
     // replace DEFECT with COSMIC?
     if ((nSx <= -shapeNsigma) || (nSy <= -shapeNsigma)) {
-      source->type = PS_SOURCE_DEFECT;
-      return (false);
+	source->type = PS_SOURCE_DEFECT;
+	return (false);
     }
     psTrace (".psphot.mark_psf_source", 2, "unexpected result: unmarked object\n");
