Index: trunk/psphot/src/psphotEvalPSF.c
===================================================================
--- trunk/psphot/src/psphotEvalPSF.c	(revision 9270)
+++ trunk/psphot/src/psphotEvalPSF.c	(revision 9771)
@@ -6,15 +6,12 @@
 
 // identify objects consistent with PSF shape/magnitude distribution
-// we expect dparams[4],dparams[5] to have a scatter of:
-// sigma_x / (S/N) * sqrt(2)
-// 1 / (params[4],params[5])*(S/N)
-
-// sigma_x : 1 / SX
-// dsx : 1 / (SX * SN)
-// dsx_o = hypot (1/(SX*SN), MIN_DSX)
+// we expect dparams[PM_PAR_SXX],dparams[PM_PAR_SXX] to have a scatter of:
+// sigma_x / (S/N)
 
 // any objects which is consistent with the PSF should have 
-// abs(dparams[5]) < N * dsxLine(mag) & abs(dparams[6]) < N * dsyLine(mag)
+// abs(dparams[PM_PAR_SXX]) < N * dsxLine(mag) & abs(dparams[PM_PAR_SYY]) < N * dsyLine(mag)
 // this includes a minimum buffer (DS) for the brighter objects
+
+// EAM : 2006.10.20 : I have re-defined params[PM_PAR_SXX] : it is now sqrt(2)*sigma_x, not 1/sigma_x
 
 // saturated stars should fall outside (larger), but have peaks above SATURATION
@@ -51,4 +48,105 @@
     float dSX, dSY, SX, SY, SN;
     float nSx, nSy, Chi;
+
+    // do we actually have a valid PSF model?
+    if (model == NULL) {
+	source->mode &= ~PM_SOURCE_MODE_FITTED;
+	return false;
+    }
+
+    // did the model fit fail for one or another reason?
+    switch (model->status) {
+      case PM_MODEL_SUCCESS:
+	break;
+      case PM_MODEL_UNTRIED:
+	source->mode &= ~PM_SOURCE_MODE_FITTED; 
+	return false;
+      case PM_MODEL_BADARGS:
+      case PM_MODEL_NONCONVERGE:
+      case PM_MODEL_OFFIMAGE:
+      default:
+	source->mode |= PM_SOURCE_MODE_FAIL;
+	return false;
+    }
+
+    // unless we prove otherwise, this object is a star.
+    source->type = PM_SOURCE_TYPE_STAR;
+
+    // the following source->mode information pertains to modelPSF:
+    source->mode |= PM_SOURCE_MODE_PSFMODEL;
+
+    // if the object has fitted peak above saturation, label as SATSTAR
+    // this is a valid PSF object, but ignore the other quality tests
+    // remember: fit does not use saturated pixels (masked)
+    // XXX no extended object can saturate and stay extended...
+    if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
+	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
+	    psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
+	}
+	source->mode |=  PM_SOURCE_MODE_SATSTAR;
+	return true;
+    } 
+
+    // if the object has a fitted peak below 0, the fit did not converge cleanly
+    if (model->params->data.F32[PM_PAR_I0] <= 0) {
+	source->mode |= PM_SOURCE_MODE_FAIL;
+	return false;
+    } 
+
+    // if the source was predicted to be a SATSTAR, but it fitted below saturation, 
+    // make a note to the user
+    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
+	psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
+	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
+    }
+
+    SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[1];
+    SX  = model->params->data.F32[PM_PAR_SXX]/M_SQRT2;
+    SY  = model->params->data.F32[PM_PAR_SYY]/M_SQRT2;
+    dSX = model->dparams->data.F32[PM_PAR_SXX];
+    dSY = model->dparams->data.F32[PM_PAR_SYY];
+    Chi = model->chisqNorm / model->nDOF;
+
+    // swing of sigma_x,y in sigmas
+    nSx = dSX / hypot (MIN_DS, (SX / SN));
+    nSy = dSY / hypot (MIN_DS, (SY / SN));
+
+    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
+    keep = TRUE;
+    keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);
+    keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);
+    keep &= (SN > PSF_MIN_SN);
+    keep &= (Chi < PSF_MAX_CHI);
+    if (keep) return true;
+
+    // this source is not a star, warn if it was a PSFSTAR
+    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
+	psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  %f %f %f %f)\n", 
+		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi);
+    } else {
+	psLogMsg ("psphot", 5, "fails PSF fit (%f, %f  :  %f %f %f %f)\n", 
+		  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi);
+    }
+
+    // object appears to be small, suspected defect
+    if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {
+	source->type = PM_SOURCE_TYPE_DEFECT;
+	return false;
+    }
+
+    // object appears to be large, suspected extended source
+    if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {
+	source->type = PM_SOURCE_TYPE_EXTENDED;
+	return false;
+    }
+
+    // poor-quality fit; only keep if nothing else works...
+    source->mode |= PM_SOURCE_MODE_POOR;
+    return false;
+}	
+
+// examine the model->status, fit parameters, etc and decide if the model succeeded
+// set the source->type and source->mode appropriately
+bool psphotEvalDBL (pmSource *source, pmModel *model) { 
 
     // do we actually have a valid PSF model?
@@ -103,105 +201,4 @@
 	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
     }
-
-    SN  = model->params->data.F32[1]/model->dparams->data.F32[1];
-    SX  = model->params->data.F32[4];
-    SY  = model->params->data.F32[5];
-    dSX = model->dparams->data.F32[4];
-    dSY = model->dparams->data.F32[5];
-    Chi = model->chisqNorm / model->nDOF;
-
-    // swing of sigma_x,y in sigmas
-    nSx = dSX / hypot (MIN_DS, 1 / (SX * SN));
-    nSy = dSY / hypot (MIN_DS, 1 / (SY * SN));
-
-    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
-    keep = TRUE;
-    keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);
-    keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);
-    keep &= (SN > PSF_MIN_SN);
-    keep &= (Chi < PSF_MAX_CHI);
-    if (keep) return true;
-
-    // this source is not a star, warn if it was a PSFSTAR
-    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  %f %f %f %f)\n", 
-		  model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);
-    } else {
-	psLogMsg ("psphot", 5, "fails PSF fit (%f, %f  :  %f %f %f %f)\n", 
-		  model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);
-    }
-
-    // object appears to be small, suspected defect
-    if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {
-	source->type = PM_SOURCE_TYPE_DEFECT;
-	return false;
-    }
-
-    // object appears to be large, suspected extended source
-    if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {
-	source->type = PM_SOURCE_TYPE_EXTENDED;
-	return false;
-    }
-
-    // poor-quality fit; only keep if nothing else works...
-    source->mode |= PM_SOURCE_MODE_POOR;
-    return false;
-}	
-
-// examine the model->status, fit parameters, etc and decide if the model succeeded
-// set the source->type and source->mode appropriately
-bool psphotEvalDBL (pmSource *source, pmModel *model) { 
-
-    // do we actually have a valid PSF model?
-    if (model == NULL) {
-	source->mode &= ~PM_SOURCE_MODE_FITTED;
-	return false;
-    }
-
-    // did the model fit fail for one or another reason?
-    switch (model->status) {
-      case PM_MODEL_SUCCESS:
-	break;
-      case PM_MODEL_UNTRIED:
-	source->mode &= ~PM_SOURCE_MODE_FITTED; 
-	return false;
-      case PM_MODEL_BADARGS:
-      case PM_MODEL_NONCONVERGE:
-      case PM_MODEL_OFFIMAGE:
-      default:
-	source->mode |= PM_SOURCE_MODE_FAIL;
-	return false;
-    }
-
-    // unless we prove otherwise, this object is a star.
-    source->type = PM_SOURCE_TYPE_STAR;
-
-    // the following source->mode information pertains to modelPSF:
-    source->mode |= PM_SOURCE_MODE_PSFMODEL;
-
-    // if the object has fitted peak above saturation, label as SATSTAR
-    // this is a valid PSF object, but ignore the other quality tests
-    // remember: fit does not use saturated pixels (masked)
-    // XXX no extended object can saturate and stay extended...
-    if (model->params->data.F32[1] >= SATURATION) {
-	if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	    psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
-	}
-	source->mode |=  PM_SOURCE_MODE_SATSTAR;
-	return true;
-    } 
-
-    // if the object has a fitted peak below 0, the fit did not converge cleanly
-    if (model->params->data.F32[1] <= 0) {
-	source->mode |= PM_SOURCE_MODE_FAIL;
-	return false;
-    } 
-
-    // if the source was predicted to be a SATSTAR, but it fitted below saturation, 
-    // make a note to the user
-    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
-	psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
-	source->mode &= ~PM_SOURCE_MODE_SATSTAR;
-    }
     return true;
 }	
