Index: branches/eam_branches/ipp-20101205/psphot/src/psphotApResid.c
===================================================================
--- branches/eam_branches/ipp-20101205/psphot/src/psphotApResid.c	(revision 30028)
+++ branches/eam_branches/ipp-20101205/psphot/src/psphotApResid.c	(revision 30030)
@@ -378,5 +378,12 @@
 
     // XXX test for errors here
-    if (!pmTrend2DFit (apTrend, mask, 0xff, xPos, yPos, apResid, dMagSoft)) {
+    bool goodFit = false;
+    if (!pmTrend2DFit (&goodFit, apTrend, mask, 0xff, xPos, yPos, apResid, dMagSoft)) {
+	// XXX this is probably a real error, and I should exit
+        psWarning("Failed to fit trend for %d x %d map", Nx, Ny);
+        psFree (apTrend);
+        return NULL;
+    }
+    if (!goodFit) {
         psWarning("Failed to fit trend for %d x %d map", Nx, Ny);
         psFree (apTrend);
Index: branches/eam_branches/ipp-20101205/psphot/src/psphotMakeFluxScale.c
===================================================================
--- branches/eam_branches/ipp-20101205/psphot/src/psphotMakeFluxScale.c	(revision 30028)
+++ branches/eam_branches/ipp-20101205/psphot/src/psphotMakeFluxScale.c	(revision 30030)
@@ -55,6 +55,13 @@
     fPts->n = Npts;
 
-    if (!pmTrend2DFit (trend, NULL, 0xff, xPts, yPts, fPts, NULL)) {
+    // XXX we should allow the spatial sampling to decrease if the fit fails
+    bool goodFit = false;
+    if (!pmTrend2DFit (&goodFit, trend, NULL, 0xff, xPts, yPts, fPts, NULL)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to fit trend");
+        success = false;
+        goto DONE;
+    }
+    if (!goodFit) {
+        psError(PS_ERR_UNKNOWN, false, "poor fit to flux-scale trend");
         success = false;
         goto DONE;
