Index: /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c	(revision 6621)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c	(revision 6622)
@@ -12,129 +12,4 @@
 // File-static functions
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if 0
-// Read a FITS extension into a chip
-static bool readExtension(p_pmHDU *hdu, // Pixel data into which to read
-                          psFits *fits  // The FITS file from which to read
-                         )
-{
-    const char *extName = hdu->extname; // Extension name
-
-    psTrace(__func__, 7, "Moving to extension %s...\n", extName);
-    if (strncmp(extName, "PHU", 3) == 0) {
-        if (!psFitsMoveExtNum(fits, 0, false)) {
-            psError(PS_ERR_IO, false, "Unable to find PHU in FITS file!\n");
-            return false;
-        }
-    } else if (! psFitsMoveExtName(fits, extName)) {
-        psError(PS_ERR_IO, false, "Unable to find extension %s in FITS file!\n", extName);
-        return false;
-    }
-    psTrace(__func__, 7, "Reading header....\n");
-    psMetadata *header = psFitsReadHeader(NULL, fits); // Header
-    if (! header) {
-        psError(PS_ERR_IO, false, "Unable to read FITS header!\n");
-        return false;
-    }
-
-    psTrace(__func__, 7, "Checking NAXIS....\n");
-    bool mdStatus = false;
-    int nAxis = psMetadataLookupS32(&mdStatus, header, "NAXIS");
-    if (!mdStatus) {
-        psLogMsg(__func__, PS_LOG_WARN, "There is no NAXIS keyword in the FITS header of extension %s!\n",
-                 extName);
-    }
-    if (nAxis != 2 && nAxis != 3) {
-        psLogMsg(__func__, PS_LOG_WARN, "Image is not 2- or 3-dimensional --- reading into a single image "
-                 "anyway.\n");
-    }
-    psTrace(__func__, 9, "NAXIS = %d\n", nAxis);
-
-    int numPlanes = 1;                  // Number of planes
-    if (nAxis == 3) {
-        numPlanes = psMetadataLookupS32(&mdStatus, header, "NAXIS3");
-        if (!mdStatus) {
-            psError(PS_ERR_IO, false, "Unable to read NAXIS3 for 3-dimensional image!\n");
-            return false;
-        }
-    }
-    psRegion region = {0, 0, 0, 0};     // Region to read is everything
-
-    // Read each plane into the array
-    psTrace(__func__, 7, "Reading %d planes into array....\n", numPlanes);
-    psArray *pixels = psArrayAlloc(numPlanes); // Array of images
-    for (int i = 0; i < numPlanes; i++) {
-        psTrace(__func__, 9, "Reading plane %d\n", i);
-        psMemCheckCorruption(true);
-        psImage *image = psFitsReadImage(NULL, fits, region, i);
-
-        // XXX: Type conversion here to support the modules, which don't have multiple type support yet
-        if (image->type.type != PS_TYPE_F32) {
-            pixels->data[i] = psImageCopy(NULL, image, PS_TYPE_F32);
-
-            // XXX: Temporary fix for writing images, until psFits gets cleaned up
-            psMetadataItem *bitpixItem = psMetadataLookup(header, "BITPIX");
-            bitpixItem->data.S32 = -32;
-            psMetadataRemove(header, 0, "BZERO");
-            psMetadataRemove(header, 0, "BSCALE");
-
-            psFree(image);
-        } else {
-            pixels->data[i] = image;
-        }
-        psTrace(__func__, 10, "Done\n");
-        if (! pixels->data[i]) {
-            psError(PS_ERR_IO, false, "Unable to read image for extension %s, plane %d\n", extName, i);
-            return false;
-        }
-    }
-
-    // Update the HDU with the new data
-    hdu->images = pixels;
-    hdu->header = header;
-
-    // Mask and weight not set yet
-    hdu->weights = NULL;
-    hdu->masks = NULL;
-
-    return true;
-}
-
-// Portion out an image into the cell
-static bool generateReadouts(pmCell *cell, // The cell that gets its bits
-                             pmHDU *hdu // Pixel data, containing image, mask, weights
-                            )
-{
-    psArray *images = hdu->images;      // Array of images (each of which is a readout)
-
-    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
-    psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
-
-    // Iterate over each of the image planes
-    for (int i = 0; i < images->n; i++) {
-        psImage *image = images->data[i]; // The i-th plane
-        pmReadout *readout = pmReadoutAlloc(cell);
-
-        readout->image = psMemIncrRefCounter(psImageSubset(image, *trimsec)); // The image corresponding to the trim region
-
-        // Get the list of overscans
-        psListIterator *iter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator
-        psRegion *biassec = NULL;       // A BIASSEC region from the list
-        while ((biassec = psListGetAndIncrement(iter))) {
-            psImage *overscan = psMemIncrRefCounter(psImageSubset(image, *biassec));
-            psListAdd(readout->bias, PS_LIST_TAIL, overscan);
-            psFree(overscan);
-        }
-        psFree(iter);
-
-        readout->mask = NULL;
-        readout->weight = NULL;
-
-        psFree(readout);                // Drop reference
-    }
-
-    return true;
-}
-#endif
 
 // Carve a readout from the image pixels
@@ -309,102 +184,4 @@
 {
     return readPHU(fpa->hdu, fits);
-}
-#endif
-
-
-
-#if 0
-
-bool pmFPARead(pmFPA *fpa,              // FPA to read into
-               psFits *fits,            // FITS file from which to read
-               psMetadata *phu,         // Primary header
-               psDB *db                 // Database handle, for concept ingest
-              )
-{
-    p_pmHDU *hdu = NULL;        // Pixel data from FITS file
-
-    // Read the PHU, if required
-    if (! phu) {
-        if (! psFitsMoveExtNum(fits, 0, false)) {
-            psError(PS_ERR_IO, false, "Unable to find PHU in FITS file!\n");
-            return false;
-        }
-        psTrace(__func__, 7, "Reading PHU....\n");
-        fpa->phu = psFitsReadHeader(NULL, fits); // Primary header
-    } else if (! fpa->phu) {
-        fpa->phu = psMemIncrRefCounter(phu);
-    }
-
-    // Read in....
-    psTrace(__func__, 1, "Reading FPA...\n");
-    if (fpa->hdu) {
-        hdu = fpa->hdu;
-        psTrace(__func__, 3, "Reading pixels from extension %s into FPA.\n", hdu->extname);
-        if (! readExtension(hdu, fits)) {
-            psError(PS_ERR_IO, false, "Unable to read pixels from extension %s\n", hdu->extname);
-            return false;
-        }
-    }
-    pmConceptsReadFPA(fpa, db);
-
-    psArray *chips = fpa->chips;        // Array of chips
-    // Iterate over the FPA
-    for (int i = 0; i < chips->n; i++) {
-        pmChip *chip = chips->data[i]; // The chip
-
-        // Only read chips marked to "read"
-        if (! chip || ! chip->process || chip->exists) {
-            psTrace(__func__, 2, "Ignoring chip %d...\n", i);
-            continue;
-        }
-        psTrace(__func__, 2, "Reading in chip %d...\n", i);
-
-        if (chip->hdu) {
-            hdu = chip->hdu;
-            psTrace(__func__, 3, "Reading pixels from extension %s into chip %d.\n", hdu->extname, i);
-            if (! readExtension(hdu, fits)) {
-                psError(PS_ERR_IO, false, "Unable to read pixels from extension %s\n", hdu->extname);
-                return false;
-            }
-        }
-
-        pmConceptsReadChip(chip, db);
-
-        // Iterate over the chip
-        psArray *cells = chip->cells;   // Array of cells
-        for (int j = 0; j < cells->n; j++) {
-            pmCell *cell = cells->data[j]; // The cell
-
-            // Only read cells marked to "read"
-            if (!cell || ! cell->process || cell->exists) {
-                psTrace(__func__, 3, "Ignoring chip %d...\n", i);
-                continue;
-            }
-            psTrace(__func__, 3, "Reading in cell %d...\n", j);
-
-            if (cell->hdu) {
-                hdu = cell->hdu;
-                psTrace(__func__, 5, "Reading pixels from extension %s into cell %d.\n", hdu->extname,
-                        j);
-                if (! readExtension(hdu, fits)) {
-                    psError(PS_ERR_IO, false, "Unable to read pixels from extension %s\n",
-                            hdu->extname);
-                    return false;
-                }
-            }
-            psTrace(__func__, 5, "Reading concepts for cell %d...\n", j);
-            pmConceptsReadCell(cell, db);
-
-            psTrace(__func__, 5, "Allocating readouts for chip %d cell %d...\n", i, j);
-            generateReadouts(cell, hdu);
-
-            cell->exists = true;
-        }
-        chip->exists = true;
-    }
-
-    psTrace(__func__, 1, "Done reading FPA...\n");
-
-    return true;
 }
 
