Index: /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c
===================================================================
--- /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c	(revision 34453)
+++ /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c	(revision 34454)
@@ -200,9 +200,4 @@
         psImageInit(image1,NAN);
         psImageInit(image2,NAN);
-	for (int y = 0; y < numRows1; y++) {
-	  for (int x = 0; x < numCols1; x++) {
-	    image1->data.F32[y][x] = NAN;
-	  }
-	}
 	
         psImage *mask1 = NULL, *mask2 = NULL; // Binned masks
@@ -220,5 +215,4 @@
                 continue;
             }
-	    fprintf(stderr,"ISITNAN? %g\n",image1->data.F32[0][0]);
             pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.IMAGE", j);
             if (data->masksName) {
@@ -240,16 +234,4 @@
             psFree(view);
 
-            // Flip images; no idea why this has to be done, but apparently it does
-/*             { */
-/*                 psImage *rot = psImageRotate(NULL, inRO->image, M_PI, NAN, PS_INTERPOLATE_BILINEAR); */
-/*                 psFree(inRO->image); */
-/*                 inRO->image = rot; */
-/*             } */
-/*             if (inRO->mask) { */
-/*                 psImage *rot = psImageRotate(NULL, inRO->mask, M_PI, 0, PS_INTERPOLATE_FLAT); */
-/*                 psFree(inRO->mask); */
-/*                 inRO->mask = rot; */
-/*             } */
-
             pmReadout *bin1RO = pmReadoutAlloc(NULL), *bin2RO = pmReadoutAlloc(NULL); // Binned readouts
             if (!pmReadoutRebin(bin1RO, inRO, data->maskVal, data->bin1, data->bin1)) {
@@ -272,6 +254,6 @@
             // XXX Completely neglecting rotations
             // The skycells are divided up neatly with them all having the same orientation
-	    psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "=");
-	    psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "=");
+	    psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E");
+	    psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E");
             if (data->masksName) {
                 psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, "=");
@@ -331,17 +313,20 @@
 
 	  // Change wcs here
+#define WCS_DEBUG 0
 	  if (modify_wcs1) {
 	    pmAstromWCS *WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header);
 	    double cd1f = 1.0 * data->bin1;
 	    double cd2f = 1.0 * data->bin1;
+#if WCS_DEBUG
 	    fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2,
 		    cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
 		    WCS->crpix1,WCS->crpix2
 		    );
-
+#endif
 	    WCS->cdelt1 *= cd1f;
 	    WCS->cdelt2 *= cd2f;
 	    WCS->crpix1 = WCS->crpix1 / cd1f;
 	    WCS->crpix2 = WCS->crpix2 / cd2f;
+#if WCS_DEBUG
 	    fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g) %d %d %d %d\n",data->bin1,data->bin2,
 		    cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
@@ -350,11 +335,13 @@
 		    WCS->trans->y->nX,		    WCS->trans->y->nY
 		    );
-	    
+#endif
 	    for (int q = 0; q <= WCS->trans->x->nX; q++) {
 	      for (int r = 0; r <= WCS->trans->x->nY; r++) {
 		WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
+#if WCS_DEBUG
 		fprintf(stderr,"PC: %d %d %g %g\n",
 			q,r,pow(cd1f,q) * pow(cd2f,r),
 			WCS->trans->x->coeff[q][r]);
+#endif
 	      }
 	    }
@@ -362,17 +349,19 @@
 	      for (int r = 0; r <= WCS->trans->y->nY; r++) {
 		WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r);
+#if WCS_DEBUG
 		fprintf(stderr,"PC: %d %d %g %g\n",
 			 q,r,pow(cd1f,q) * pow(cd2f,r),
 			 WCS->trans->y->coeff[q][r]);
-
+#endif
 	      }
 	    }
 	    pmAstromWCStoHeader (fits1->fpa->hdu->header,WCS);
 	    WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header);
+#if WCS_DEBUG
 	    fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2,
 		    cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,
 		    WCS->crpix1,WCS->crpix2
 		    );
-	    
+#endif
 	    modify_wcs1 = 0;
 	  }
@@ -426,6 +415,4 @@
 	    modify_wcs2 = 0;
 	  }
-
-
 	  
 	  pmChip *Fchip2 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN2");
