Index: trunk/psModules/src/objects/pmPSF.c
===================================================================
--- trunk/psModules/src/objects/pmPSF.c	(revision 19999)
+++ trunk/psModules/src/objects/pmPSF.c	(revision 20000)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-07-15 20:25:00 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-10-08 21:53:29 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -271,8 +271,7 @@
     pol.e2 = fittedPar[PM_PAR_E2];
 
-    psEllipseAxes axes;
-    if (psEllipsePolToAxes (pol, minMinorAxis, &axes) != PS_ERR_NONE) {
-        psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
-                pol.e0, pol.e1, pol.e2);
+    psEllipseAxes axes = psEllipsePolToAxes (pol, minMinorAxis);
+    if (!isfinite(axes.major) || !isfinite(axes.minor) || !isfinite(axes.theta)) {
+        psTrace("psModules.objects", 5, "Failed to convert e[012] (%g,%g,%g) to axes", pol.e0, pol.e1, pol.e2);
         return false;
     }
@@ -420,20 +419,32 @@
     maskVal |= markVal;
 
-    // use the center of the center pixel of the image
-    xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5;
-    yc = 0.5*readout->image->numRows + readout->image->row0 + 0.5;
-    dx = psf->growth->maxRadius + 1;
-    dy = psf->growth->maxRadius + 1;
-
-    // assign the x and y coords to the image center
-    // create an object with center intensity of 1000
-    modelRef->params->data.F32[PM_PAR_SKY] = 0;
-    modelRef->params->data.F32[PM_PAR_I0] = 1000;
-    modelRef->params->data.F32[PM_PAR_XPOS] = xc;
-    modelRef->params->data.F32[PM_PAR_YPOS] = yc;
-
-    // create modelPSF from this model
-    pmModel *model = pmModelFromPSF (modelRef, psf);
-
+    // XXXX A Serious hack: the psf might not be determined in the field center.
+    // for the moment, just try a few locations until it is defined!
+
+    pmModel *model = NULL;
+    for (int ix = -1; ix <= +1; ix ++) {
+	for (int iy = -1; iy <= +1; iy ++) {
+
+	    // use the center of the center pixel of the image
+	    xc = (0.5 + 0.3*ix)*readout->image->numCols + readout->image->col0 + 0.5;
+	    yc = (0.5 + 0.3*ix)*readout->image->numRows + readout->image->row0 + 0.5;
+	    dx = psf->growth->maxRadius + 1;
+	    dy = psf->growth->maxRadius + 1;
+
+	    // assign the x and y coords to the image center
+	    // create an object with center intensity of 1000
+	    modelRef->params->data.F32[PM_PAR_SKY] = 0;
+	    modelRef->params->data.F32[PM_PAR_I0] = 1000;
+	    modelRef->params->data.F32[PM_PAR_XPOS] = xc;
+	    modelRef->params->data.F32[PM_PAR_YPOS] = yc;
+
+	    // create modelPSF from this model
+	    model = pmModelFromPSF (modelRef, psf);
+	    if (model) goto got_model;
+	}
+    }
+    psAssert (model, "cannot build growth curve (psf model is invalid everywhere)");
+
+got_model:
     // measure the fitMag for this model
     pmSourcePhotometryModel (&fitMag, model);
