Index: /branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c
===================================================================
--- /branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c	(revision 34470)
+++ /branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c	(revision 34471)
@@ -951,18 +951,13 @@
   if (xl < 0) { xl = 0; }
   if (xl >= image->numCols) {xl = image->numCols - 1; }
-    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
   xh = xl + 1;
   if (xh >= image->numCols) {xh = image->numCols - 1; }
-    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
-    //
+
   yl = floor(y);
   if (yl < 0) { yl = 0; }
   if (yl >= image->numRows) {yl = image->numRows - 1; }
-    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
-  //
   yh = yl + 1;
   if (yh >= image->numRows) {yh = image->numRows - 1; }
-    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
-  //
+
   if (imageValue && image) {
     if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) {
@@ -989,4 +984,5 @@
     }
   }
+#if (0)
   if (*imageValue == 0.0) {
     fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n",
@@ -995,4 +991,5 @@
 	    );
   }
+#endif
   return PS_INTERPOLATE_STATUS_GOOD;
 }
Index: /branches/czw_branch/20120906/pswarp/src/pswarp.h
===================================================================
--- /branches/czw_branch/20120906/pswarp/src/pswarp.h	(revision 34470)
+++ /branches/czw_branch/20120906/pswarp/src/pswarp.h	(revision 34471)
@@ -94,5 +94,4 @@
 
 pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix);
-pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix);
 bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY);
 bool pswarpMapGridCoordRange (pswarpMapGrid *grid, int gridX, int gridY, psPlane *min, psPlane *max);
Index: /branches/czw_branch/20120906/pswarp/src/pswarpLoop.c
===================================================================
--- /branches/czw_branch/20120906/pswarp/src/pswarpLoop.c	(revision 34470)
+++ /branches/czw_branch/20120906/pswarp/src/pswarpLoop.c	(revision 34471)
@@ -159,16 +159,5 @@
         }
     }
-    pmAstromWCS *WCSF = pmAstromWCSfromHeader(phu->header);
-    
-    fprintf(stderr,"WCSFI: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
-	    WCSF->crval1,WCSF->crval2,
-	    WCSF->crpix1,WCSF->crpix2,
-	    WCSF->cdelt1,WCSF->cdelt2,
-	    WCSF->trans->x->coeff[1][0],
-	    WCSF->trans->x->coeff[0][1],
-	    WCSF->trans->y->coeff[1][0],
-	    WCSF->trans->y->coeff[0][1],
-	    -1.0,-1.0);
-    psFree(WCSF);
+
     psList *cells = psListAlloc(NULL);  // List of cells, for concepts averaging
 
@@ -208,17 +197,4 @@
             }
         }
-    pmAstromWCS *WCSF = pmAstromWCSfromHeader(hdu->header);
-    
-    fprintf(stderr,"WCSFIB: %g %g : %g %g : %g %g : %g %g %g %g : %g %g\n",
-	    WCSF->crval1,WCSF->crval2,
-	    WCSF->crpix1,WCSF->crpix2,
-	    WCSF->cdelt1,WCSF->cdelt2,
-	    WCSF->trans->x->coeff[1][0],
-	    WCSF->trans->x->coeff[0][1],
-	    WCSF->trans->y->coeff[1][0],
-	    WCSF->trans->y->coeff[0][1],
-	    -1.0,-1.0);
-    psFree(WCSF);
-
 	
         pmCell *cell;
Index: /branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c
===================================================================
--- /branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c	(revision 34470)
+++ /branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c	(revision 34471)
@@ -52,45 +52,4 @@
     return grid;
 }
-/**
- * pswarpMapGridFromImageForBackground builds a set (a grid) of locally-linear maps which convert the source
- * coordinates (src) to destination coordinates (dest).  we construct a grid with superpixel
- * spacing of nXpix, nYpix.  The transformation for each grid cell is valid for the superpixel.
- * The grid over-fills the source image so every source image pixel is guaranteed to have a map.
- */
-pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) {
-
-    int i, ni;
-    int j, nj;
-
-    // start counting from the center of the superpixels
-    double xMin = 0.5*nXpix;
-    double yMin = 0.5*nYpix;
-
-    // the map is defined for coordinates in the image parent frame.
-    int Nx = src->image->numCols + src->image->col0;
-    int Ny = src->image->numRows + src->image->row0;
-
-    // always allocate an extra superpixel to handle spillover
-    int nXpts = (int)(Nx / nXpix) + 1;
-    int nYpts = (int)(Ny / nYpix) + 1;
-
-    // create the grid of maps
-    pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);
-
-    // measure the map for the center of each superpixel
-    for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) {
-        for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {
-            pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j);
-/* 	    grid->maps[ni][nj]->Xo += (13.0 * 400.0 - 4846.0) / 2.0; */
-/* 	    grid->maps[ni][nj]->Yo += (13.0 * 400.0 - 4868.0) / 2.0; */
-        }
-    }
-
-    grid->nXpix = nXpix;
-    grid->nYpix = nYpix;
-    grid->xMin = xMin;
-    grid->yMin = yMin;
-    return grid;
-}
 
 /**
Index: /branches/czw_branch/20120906/pswarp/src/pswarpTransformReadout.c
===================================================================
--- /branches/czw_branch/20120906/pswarp/src/pswarpTransformReadout.c	(revision 34470)
+++ /branches/czw_branch/20120906/pswarp/src/pswarpTransformReadout.c	(revision 34471)
@@ -60,11 +60,7 @@
     // pswarpMapGridFromImage builds a set of locally-linear maps which convert the
     // output coordinates to input coordinates
-    pswarpMapGrid *grid;
-    if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) {
-      grid = pswarpMapGridFromImageForBackground(input, output, nGridX, nGridY);
-    }
-    else {
-      grid = pswarpMapGridFromImage(input, output, nGridX, nGridY);
-    }
+    pswarpMapGrid *grid = pswarpMapGridFromImage(input, output, nGridX, nGridY);
+    //    if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) {
+    
     // XXX optionally modify the grid based on this result and force the maxError < XXX
     double maxError = pswarpMapGridMaxError(grid); // Maximum (positional) error from using grid
@@ -177,6 +173,4 @@
         } else {
             pswarpTransformTileArgs *args = job->args->data[0];
-	    //	    fprintf (stderr, "finished job %d,%d, Nargs: %ld (%d %d %d %d) (%d %d %d %d)\n", args->gridX, args->gridY, job->args->n,
-	    //		     xMin,xMax,yMin,yMax,args->xMin,args->xMax,args->yMin,args->yMax);
             goodPixels += args->goodPixels;
             xMin = PS_MIN(args->xMin, xMin);
Index: /branches/czw_branch/20120906/pswarp/src/pswarpTransformTile.c
===================================================================
--- /branches/czw_branch/20120906/pswarp/src/pswarpTransformTile.c	(revision 34470)
+++ /branches/czw_branch/20120906/pswarp/src/pswarpTransformTile.c	(revision 34471)
@@ -83,5 +83,5 @@
     // Iterate over the output image pixels (parent frame)
     long goodPixels = 0;                ///< Number of input pixels landing on the output image
-    psTrace("pswarp",3,"Size: %d %d\n",xMax,yMax);
+
     for (int y = yMin; y < yMax; y++) {
         for (int x = xMin; x < xMax; x++) {
@@ -95,15 +95,15 @@
             pswarpMapApply(&xIn, &yIn, map, x + 0.5, y + 0.5);
 
+	    // This needs to use a more reliable method to do this offset and limiting
 	    if (args->interp->mode == 8) {
-	      xIn += 177.0 / 400.0;
-	      yIn += 166.0 / 400.0;
+	      double xOffset = 177.0 / 400.0; // (modelsize * modelbinning - xsize) / 2.0
+	      double yOffset = 166.0 / 400.0; // (modelsize * modelbinning - ysize) / 2.0
+	      xIn += xOffset;
+	      yIn += yOffset;
 
-	      if ((xIn > inNumCols - 177.0/ 400.0)||
-		  (yIn > inNumRows - 166.0/ 400.0)||
-		  (xIn < 177.0/ 400.0)||
-		  (yIn < 166.0/ 400.0)
-		  
-		  ) {
-		fprintf(stderr,"\n");
+	      if ((xIn > inNumCols - xOffset)||
+		  (yIn > inNumRows - yOffset)||
+		  (xIn < xOffset)||
+		  (yIn < yOffset)) {
 		continue;
 	      }
@@ -124,17 +124,4 @@
             int xOut = x - outCol0, yOut = y - outRow0; ///< Position on output image
 
-	    if (((xOut % 500) == 0)&&((yOut % 500) == 0)) {
-	      fprintf(stderr,"%d %d %g %g %d %d (%d %d %d %d) %g %g %g\n",
-		      x,y,xIn,yIn,xOut,yOut,xMin,xMax,yMin,yMax,imageValue,
-		      (4846 - 400 * (12)) / 2.0,
-		      (4868 - 400 * (12)) / 2.0
-		      
-		      );
-	    }
-	    
-/* 	    if ((xIn >= args->interp->image->numCols - 1)|| */
-/* 		(yIn >= args->interp->image->numRows - 1)) { */
-/* 	      imageValue = NAN; */
-/* 	    } */
             if (outImageData) {
                 outImageData[yOut][xOut] = imageValue * jacobian;
