Index: trunk/ppSim/src/ppSimArguments.c
===================================================================
--- trunk/ppSim/src/ppSimArguments.c	(revision 12971)
+++ trunk/ppSim/src/ppSimArguments.c	(revision 12973)
@@ -171,5 +171,5 @@
         usage(arguments, config);
     }
-    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", bin);
+    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BINNING", 0, "Binning in x and y", bin);
 
     psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image",
Index: trunk/ppSim/src/ppSimLoop.c
===================================================================
--- trunk/ppSim/src/ppSimLoop.c	(revision 12971)
+++ trunk/ppSim/src/ppSimLoop.c	(revision 12973)
@@ -19,9 +19,10 @@
                              int cell0, // Cell offset
                              int cellParity, // Cell parity
+                             int binning, // Binning factor
                              int chip0, // Chip offset
                              int chipParity // Chip parity
     )
 {
-    return (chip0 + chipParity * (cell0 + cellParity * pos));
+    return (chip0 + binning * chipParity * (cell0 + cellParity * pos));
 }
 
@@ -30,9 +31,10 @@
                              int cell0, // Cell offset
                              int cellParity, // Cell parity
+                             int binning, // Binning factor
                              int chip0, // Chip offset
                              int chipParity // Chip parity
     )
 {
-    return ((pos - chip0) * chipParity - cell0) * cellParity;
+    return ((pos - chip0) * chipParity - cell0) * cellParity / binning;
 }
 
@@ -95,8 +97,8 @@
 
         // "Left", "Right", "Bottom" and "Top" don't take into account the parity
-        int cellLeft = cell2fpa(0, x0Cell, xParityCell, x0Chip, xParityChip);
-        int cellRight = cell2fpa(xSize, x0Cell, xParityCell, x0Chip, xParityChip);
-        int cellBottom = cell2fpa(0, y0Cell, yParityCell, y0Chip, yParityChip);
-        int cellTop = cell2fpa(ySize, y0Cell, yParityCell, y0Chip, yParityChip);
+        int cellLeft = cell2fpa(0, x0Cell, xParityCell, 1, x0Chip, xParityChip);
+        int cellRight = cell2fpa(xSize, x0Cell, xParityCell, 1, x0Chip, xParityChip);
+        int cellBottom = cell2fpa(0, y0Cell, yParityCell, 1, y0Chip, yParityChip);
+        int cellTop = cell2fpa(ySize, y0Cell, yParityCell, 1, y0Chip, yParityChip);
 
         COMPARE(cellLeft, xMin, xMax);
@@ -262,4 +264,5 @@
     float starsMag = psMetadataLookupF32(NULL, config->arguments, "STARS.MAG"); // Star brightest magnitude
     float starsDensity = psMetadataLookupF32(NULL, config->arguments, "STARS.DENSITY"); // Density of fakes
+    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
 
     float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time
@@ -439,6 +442,6 @@
 
             // Size, position and orientation of cell
-            int numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE");
-            int numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE");
+            int numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE") / binning;
+            int numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE") / binning;
             int x0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
             int y0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
@@ -547,9 +550,9 @@
                     rowBias->data.F32[y] = psPolynomial1DEval(biasPoly, (float)(y + biasOffset) /
                                                               (float)numRows - 0.5) + biasLevel;
-                    float yFPA = cell2fpa(y, y0Cell, yParityCell, y0Chip, yParityChip) * 2.0 /
+                    float yFPA = cell2fpa(y, y0Cell, yParityCell, binning, y0Chip, yParityChip) * 2.0 /
                         (bounds->y1 - bounds->y0); // Relative y position in FPA
 
                     for (int x = 0; x < numCols; x++) {
-                        float xFPA = cell2fpa(x, x0Cell, xParityCell, x0Chip, xParityChip) * 2.0 /
+                        float xFPA = cell2fpa(x, x0Cell, xParityCell, binning, x0Chip, xParityChip) * 2.0 /
                             (bounds->x1 - bounds->x0); // Relative x position in FPA
 
@@ -602,6 +605,8 @@
                     for (long j = 0; j < ra->n; j++) {
                         // Position on the cell and peak flux
-                        float x = fpa2cell(ra->data.F32[j], x0Cell, xParityCell, x0Chip, xParityChip);
-                        float y = fpa2cell(dec->data.F32[j], y0Cell, yParityCell, y0Chip, yParityChip);
+                        float x = fpa2cell(ra->data.F32[j], x0Cell, xParityCell, binning,
+                                           x0Chip, xParityChip);
+                        float y = fpa2cell(dec->data.F32[j], y0Cell, yParityCell, binning,
+                                           y0Chip, yParityChip);
                         float flux = mag->data.F32[j];
                         star(signal, variance, x, y, flux, roughNoise, seeing, expCorr);
@@ -641,4 +646,8 @@
             psMetadataAddF32(cell->concepts, PS_LIST_TAIL, "CELL.DARKTIME", PS_META_REPLACE,
                              "Dark time (sec)", expTime);
+            psMetadataAddS32(cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE,
+                             "Binning in x", binning);
+            psMetadataAddS32(cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE,
+                             "Binning in y", binning);
 
             if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
