Index: trunk/archive/scripts/src/pmFPAConstruct.c
===================================================================
--- trunk/archive/scripts/src/pmFPAConstruct.c	(revision 4594)
+++ trunk/archive/scripts/src/pmFPAConstruct.c	(revision 4694)
@@ -81,6 +81,6 @@
 	    // Extensions are chips; Content contains a list of cells
 	    while (contentItem = psMetadataGetAndIncrement(contentsIter)) {
-		const char *extName = contentItem->name; // The name of the extension
-		papChip *chip = papChipAlloc(fpa); // The chip
+		psString extName = contentItem->name; // The name of the extension
+		papChip *chip = papChipAlloc(fpa, extName); // The chip
 		chip->extname = extName;// Mark chip to receive FITS data
 		if (contentItem->type != PS_META_STR) {
@@ -97,5 +97,5 @@
 		while (cellName = psListGetAndIncrement(cellNamesIter)) {
 		    // Get the cell data
-		    papCell *cell = papCellAlloc(chip); // The cell
+		    papCell *cell = papCellAlloc(chip, cellName); // The cell
 		    psMetadata *cellData = getCellData(camera, cellName);
 		    metadataCopy(cell->values, cellData);
@@ -109,5 +109,5 @@
 	    psMetadata *chips = psMetadataAlloc(); // Given a chip name, holds the chip number
 	    while (contentItem = psMetadataGetAndIncrement(contentsIter)) {
-		const char *extName = contentItem->name; // The name of the extension
+		psString extName = contentItem->name; // The name of the extension
 		psTrace(__func__, 1, "Getting %s....\n", extName);
 
@@ -122,6 +122,6 @@
 		    psLogMsg(__func__, PS_LOG_WARN, "Unable to read contents of %s: ignored.\n", extName);
 		} else {
-		    const char *chipName = psListGet(contents, 0); // The name of the chip
-		    const char *cellType = psListGet(contents, 1); // The type of cell
+		    psString chipName = psListGet(contents, 0); // The name of the chip
+		    psString cellType = psListGet(contents, 1); // The type of cell
 		    psTrace(__func__, 7, "Extension is cell of type %s, from chip %s\n", cellType,
 			    chipName);
@@ -129,5 +129,5 @@
 		    papChip *chip = psMetadataLookupChip(&mdStatus, chips, chipName); // The chip
 		    if (! mdStatus && ! chip) {
-			chip = papChipAlloc(fpa);
+			chip = papChipAlloc(fpa, chipName);
 			psMetadataAdd(chips, PS_LIST_TAIL, chipName, PS_META_CHIP, "", chip);
 		    }
@@ -135,5 +135,5 @@
 		    psArray *images = NULL;
 		    psMetadata *header = NULL;
-		    papCell *cell = papCellAlloc(chip); // The cell
+		    papCell *cell = papCellAlloc(chip, extName); // The cell
 		    cell->extname = extName; // Mark cell to receive FITS data
 		    psMetadata *cellData = getCellData(camera, cellType);
@@ -147,5 +147,5 @@
 	    fpa->extname = "PHU";
 	    while (contentItem = psMetadataGetAndIncrement(contentsIter)) {
-		const char *chipName = contentItem->name; // The name of the chip
+		psString chipName = contentItem->name; // The name of the chip
 
 		if (contentItem->type != PS_META_STR) {
@@ -154,7 +154,7 @@
 		    continue;
 		}
-		const char *content = contentItem->data.V; // The content of the extension
+		psString content = contentItem->data.V; // The content of the extension
 		psTrace(__func__, 5, "Component cells are: %s\n", content);
-		papChip *chip = papChipAlloc(fpa); // The chip
+		papChip *chip = papChipAlloc(fpa, chipName); // The chip
 		psList *cellNames = papSplit(content, ", "); // Split the list of cells
 		psListIterator *cellNamesIter = psListIteratorAlloc(cellNames, PS_LIST_HEAD, false);
@@ -162,5 +162,5 @@
 		while (cellName = psListGetAndIncrement(cellNamesIter)) {
 		    psTrace(__func__, 7, "Processing cell %s....\n", cellName);
-		    papCell *cell = papCellAlloc(chip); // The cell
+		    papCell *cell = papCellAlloc(chip, cellName); // The cell
 		    psMetadata *cellData = getCellData(camera, cellName);
 		    metadataCopy(cell->values, cellData);
@@ -179,5 +179,6 @@
     } else if (strncmp(phuType, "CHIP", 4) == 0) {
 	// The FITS file contains a single chip only
-	papChip *chip = papChipAlloc(fpa); // The chip
+	psString chipName = psStringCopy("CHIP"); // Name for chip
+	papChip *chip = papChipAlloc(fpa, chipName); // The chip
 
 	if (strncmp(extType, "NONE", 4) == 0) {
@@ -193,7 +194,7 @@
 	    psList *cellNames = papSplit(contents, " ,"); // Names of cells
 	    psListIterator *cellIter = psListIteratorAlloc(cellNames, PS_LIST_HEAD, false); // Iterator
-	    const char *cellName = NULL;
+	    psString cellName = NULL;
 	    while (cellName = psListGetAndIncrement(cellIter)) {
-		papCell *cell = papCellAlloc(chip); // The cell
+		papCell *cell = papCellAlloc(chip, cellName); // The cell
 		psMetadata *cellData = getCellData(camera, cellName);
 		metadataCopy(cell->values, cellData);
@@ -219,10 +220,5 @@
 	    psMetadataItem *contentItem = NULL; // Item from metadata
 	    while (contentItem = psMetadataGetAndIncrement(contentsIter)) {
-		const char *extName = contentItem->name; // The name of the extension
-
-		psMemCheckCorruption(true);
-		
-		psTrace(__func__, 1, "Getting %s....\n", extName);
-
+		psString extName = contentItem->name; // The name of the extension
 		// Content is a cell type
 		if (contentItem->type != PS_META_STR) {
@@ -233,8 +229,8 @@
 		}
 		const char *cellType = contentItem->data.V; // The type of cell
-		psTrace(__func__, 2, "Cell type is %s\n", cellType);
+		psTrace(__func__, 5, "Cell type is %s\n", cellType);
 		psArray *images = NULL;
 		psMetadata *header = NULL;
-		papCell *cell = papCellAlloc(chip); // The cell
+		papCell *cell = papCellAlloc(chip, extName); // The cell
 		cell->extname = extName; // Mark cell to receive FITS data
 		psMetadata *cellData = getCellData(camera, cellType);
@@ -266,6 +262,9 @@
 {
     psTrace(__func__, 0, "FPA:\n");
-    if (fpa->pixels) {
-	psTrace(__func__, 1, "---> FPA contains pixels.\n");
+    if (fpa->extname) {
+	psTrace(__func__, 1, "---> FPA is extension %s.\n", fpa->extname);
+	if (! fpa->pixels) {
+	    psTrace(__func__, 1, "---> NO PIXELS for extension %s\n", fpa->extname);
+	}
     }
 
@@ -275,6 +274,9 @@
 	psTrace(__func__, 1, "Chip: %d\n", i);
 	papChip *chip = chips->data[i]; // The chip
-	if (chip->pixels) {
-	    psTrace(__func__, 2, "---> Chip contains pixels.\n");
+	if (chip->extname) {
+	    psTrace(__func__, 2, "---> Chip is extension %s.\n", chip->extname);
+	    if (! chip->pixels) {
+		psTrace(__func__, 2, "---> NO PIXELS for extension %s\n", chip->extname);
+	    }
 	}
 	// Iterate over the chip
@@ -283,6 +285,9 @@
 	    psTrace(__func__, 2, "Cell: %d\n", j);
 	    papCell *cell = cells->data[j]; // The cell
-	    if (cell->pixels) {
-		psTrace(__func__, 3, "---> Cell contains pixels.\n");
+	    if (cell->extname) {
+		psTrace(__func__, 3, "---> Cell is extension %s.\n", cell->extname);
+		if (! cell->pixels) {
+		    psTrace(__func__, 3, "---> NO PIXELS for extension %s\n", cell->extname);
+		}
 	    }
 	    psMetadataPrint(cell->values, 3);
@@ -292,11 +297,13 @@
 		papReadout *readout = readouts->data[k]; // The readout
 		psImage *image = readout->image; // The image
-		psTrace(__func__, 4, "Image: [%d:%d,%d:%d]\n", image->col0, image->col0 + 
-			image->numCols, image->row0, image->row0 + image->numRows);
+		psTrace(__func__, 4, "Image: [%d:%d,%d:%d] (%dx%d)\n", image->col0, image->col0 + 
+			image->numCols, image->row0, image->row0 + image->numRows, image->numCols,
+			image->numRows);
 		psList *overscans = readout->overscans;	// The list of overscans
 		psListIterator *overscansIter = psListIteratorAlloc(overscans, PS_LIST_HEAD, false);
 		while (image = psListGetAndIncrement(overscansIter)) {
-		    psTrace(__func__, 4, "Overscan: [%d:%d,%d:%d]\n", image->col0, image->col0 + 
-			    image->numCols, image->row0, image->row0 + image->numRows);
+		    psTrace(__func__, 4, "Overscan: [%d:%d,%d:%d] (%dx%d)\n", image->col0, image->col0 + 
+			    image->numCols, image->row0, image->row0 + image->numRows, image->numCols,
+			    image->numRows);
 		}
 		psFree(overscansIter);
