Index: trunk/ppSim/src/ppSimUtils.c
===================================================================
--- trunk/ppSim/src/ppSimUtils.c	(revision 14531)
+++ trunk/ppSim/src/ppSimUtils.c	(revision 14798)
@@ -4,7 +4,7 @@
 // this function is called with only one of fpa, chip, cell not NULL
 bool ppSimInitHeader(pmConfig *config,
-		     pmFPA *fpa,
-		     pmChip *chip,
-		     pmCell *cell)
+                     pmFPA *fpa,
+                     pmChip *chip,
+                     pmCell *cell)
 {
 
@@ -17,41 +17,42 @@
     int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
 
-    float x0, y0;
-    int xParity, yParity;
+    float x0 = 0.0, y0 = 0.0;
+    int xParity = 0, yParity = 0;
     if (cell) {
-	int x0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.X0");
-	int y0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.Y0");
-	int xParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.XPARITY");
-	int yParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.YPARITY");
+        int x0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.X0");
+        int y0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.Y0");
+        int xParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.XPARITY");
+        int yParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.YPARITY");
 
-	int x0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
-	int y0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
-	int xParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
-	int yParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
+        int x0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
+        int y0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
+        int xParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
+        int yParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
 
-	x0 = PPSIM_FPA_TO_CELL(0.0, x0Cell, xParityCell, binning, x0Chip, xParityChip);
-	y0 = PPSIM_FPA_TO_CELL(0.0, y0Cell, yParityCell, binning, y0Chip, yParityChip);
-	xParity = xParityCell * xParityChip;
-	yParity = yParityCell * yParityChip;
+        x0 = PPSIM_FPA_TO_CELL(0.0, x0Cell, xParityCell, binning, x0Chip, xParityChip);
+        y0 = PPSIM_FPA_TO_CELL(0.0, y0Cell, yParityCell, binning, y0Chip, yParityChip);
+        xParity = xParityCell * xParityChip;
+        yParity = yParityCell * yParityChip;
     }
     if (chip) {
-	int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
-	int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
-	int xParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY");
-	int yParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY");
+        int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
+        int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
+        int xParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY");
+        int yParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY");
 
-	x0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, x0Chip, xParityChip);
-	y0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, y0Chip, yParityChip);
-	xParity = xParityChip;
-	yParity = yParityChip;
+        x0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, x0Chip, xParityChip);
+        y0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, y0Chip, yParityChip);
+        xParity = xParityChip;
+        yParity = yParityChip;
     }
     if (fpa) {
-	psRegion *bounds = ppSimFPABounds (fpa);
-	x0 = 0.5 * (bounds->x1 - bounds->x0);
-	y0 = 0.5 * (bounds->y1 - bounds->y0);
-	xParity = 1;
-	yParity = 1;
-	psFree (bounds);
+        psRegion *bounds = ppSimFPABounds (fpa);
+        x0 = 0.5 * (bounds->x1 - bounds->x0);
+        y0 = 0.5 * (bounds->y1 - bounds->y0);
+        xParity = 1;
+        yParity = 1;
+        psFree (bounds);
     }
+    assert(xParity != 0 && yParity != 0);
 
     psMetadata *header = psMetadataAlloc(); // Header, to return
@@ -77,13 +78,13 @@
 
     if (cell) {
-	cell->hdu->header = header;
-	cell->data_exists = true;
+        cell->hdu->header = header;
+        cell->data_exists = true;
     }
     if (chip) {
-	chip->hdu->header = header;
+        chip->hdu->header = header;
         chip->data_exists = true;
     }
     if (fpa) {
-	fpa->hdu->header = header;
+        fpa->hdu->header = header;
     }
 
@@ -131,11 +132,11 @@
 
     psMetadataAddF32(cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE,
-		     "Exposure time (sec)", expTime);
+                     "Exposure time (sec)", expTime);
     psMetadataAddF32(cell->concepts, PS_LIST_TAIL, "CELL.DARKTIME", PS_META_REPLACE,
-		     "Dark time (sec)", expTime);
+                     "Dark time (sec)", expTime);
     psMetadataAddS32(cell->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE,
-		     "Binning in x", binning);
+                     "Binning in x", binning);
     psMetadataAddS32(cell->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE,
-		     "Binning in y", binning);
+                     "Binning in y", binning);
 
     return true;
