Index: /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c
===================================================================
--- /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c	(revision 34455)
+++ /branches/czw_branch/20120906/ppSkycell/src/ppSkycellLoop.c	(revision 34456)
@@ -133,4 +133,5 @@
     psArray *imageRegions = psArrayAlloc(data->numInputs); // Region for image
     psArray *regionHDUs = psArrayAlloc(data->numInputs);
+    // Determine which projection cells we have to deal with.
     for (int i = 0; i < data->numInputs; i++) {
         pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", i); // File to examine
@@ -184,5 +185,5 @@
 
     pmFPAfileActivate(data->config->files, false, NULL);
-
+    // Loop over projections
     for (int i = 0; i < numProj; i++) {
         psRegion *projRegion = projRegions->data[i]; // Region for skycell projection
@@ -211,4 +212,5 @@
 	int modify_wcs1 = 1;
 	int modify_wcs2 = 1;
+	// Loop over inputs to this projection.
         for (int j = 0; j < data->numInputs; j++) {
             if (target->data.S32[j] != i) {
@@ -249,7 +251,11 @@
             // Offsets for image on skycell
             int xOffset1 = (-imageRegion->x0 + projRegion->x0) / (float)data->bin1;
-            int yOffset1 = (imageRegion->y0 - projRegion->y0) / (float)data->bin1;
+            int yOffset1 = (-imageRegion->y1 + projRegion->y1) / (float)data->bin1;
             int xOffset2 = xOffset1 / (float)data->bin2, yOffset2 = yOffset1 / (float)data->bin2;
-
+	    fprintf(stderr,"OFF: %d %d %d %g %g %g %g %g %g %g %g\n",j,xOffset1,yOffset1,
+		    imageRegion->x0,imageRegion->y0,
+		    imageRegion->x1,imageRegion->y1,
+		    projRegion->x0,projRegion->y0,
+		    projRegion->x1,projRegion->y1);
             // XXX Completely neglecting rotations
             // The skycells are divided up neatly with them all having the same orientation
