IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6520


Ignore:
Timestamp:
Mar 3, 2006, 5:25:00 PM (20 years ago)
Author:
Paul Price
Message:

In the process of writing pmCellRead, pmChipRead, pmFPARead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmFPARead.c

    r6448 r6520  
    102102// Portion out an image into the cell
    103103static bool generateReadouts(pmCell *cell, // The cell that gets its bits
    104                              p_pmHDU *hdu // Pixel data, containing image, mask, weights
     104                             pmHDU *hdu // Pixel data, containing image, mask, weights
    105105                            )
    106106{
     
    139139// Public functions
    140140//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     141
     142
     143bool pmReadoutRead(pmReadout *readout,  // Readout to read into
     144                   psFits *fits         // FITS file from which to read
     145                  )
     146{
     147    //
     148
     149}
     150
     151// Carve a readout from the image pixels
     152static pmReadout *readoutCarve(pmCell *cell, // Cell into which the new readout will be placed
     153                               psImage *image, // Image that will be carved
     154                               const psRegion *trimsec, // Trim section
     155                               const psList *biassecs // Bias sections
     156                              )
     157{
     158    pmReadout *readout = pmReadoutAlloc(cell);
     159
     160    // The image corresponding to the trim region
     161    readout->image = psMemIncrRefCounter(psImageSubset(image, *trimsec));
     162
     163    // Get the list of overscans
     164    psListIterator *iter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator
     165    psRegion *biassec = NULL;       // A BIASSEC region from the list
     166    while ((biassec = psListGetAndIncrement(iter))) {
     167        psImage *overscan = psMemIncrRefCounter(psImageSubset(image, *biassec));
     168        psListAdd(readout->bias, PS_LIST_TAIL, overscan);
     169        psFree(overscan);
     170    }
     171    psFree(iter);
     172
     173    return readout;
     174}
     175
     176
     177bool pmCellRead(pmCell *cell,           // Cell to read into
     178                psFits *fits,           // FITS file from which to read
     179                psDB *db                // Database handle, for "concepts" ingest
     180               )
     181{
     182    pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
     183    if (!hdu->images && !pmHDURead(hdu, fits)) {
     184        psError(PS_ERR_IO, false, "Unable to read HDU for cell.\n");
     185        return false;
     186    }
     187
     188    // Read the "concepts"
     189    pmConceptsReadCell(cell, db);
     190
     191    // Having read the cell, we now have to cut it up
     192    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     193    psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
     194
     195    // Iterate over each of the image planes
     196    for (int i = 0; i < hdu->images->n; i++) {
     197        psImage *image = hdu->images->data[i]; // The i-th plane
     198        pmReadout *readout = readoutCarve(cell, image, trimsec, biassecs);
     199        readout->mask = NULL;
     200        readout->weight = NULL;
     201        psFree(readout);                // Drop reference
     202    }
     203
     204    return true;
     205}
     206
     207
     208bool pmChipRead(pmChip *chip,           // Chip to read into
     209                psFits *fits,           // FITS file from which to read
     210                psDB *db                // Database handle, for "concepts" ingest
     211               )
     212{
     213    psArray *cells = chip->cells;       // Array of cells
     214    for (int i = 0; i < cells->n; i++) {
     215        pmCell *cell = cells->data[i];  // The cell of interest
     216        if (!pmCellRead(cell, fits, db)) {
     217            psError(PS_ERR_IO, false, "Unable to read cell %d.\n", i);
     218            return false;
     219        }
     220    }
     221
     222    return true;
     223}
     224
     225bool pmFPARead(pmFPA *fpa,              // FPA to read into
     226               psFits *fits,            // FITS file from which to read
     227               psDB *db                 // Database handle, for "concepts" ingest
     228              )
     229{
     230    psArray *chips = fpa->cells;       // Array of cells
     231    for (int i = 0; i < chips->n; i++) {
     232        pmCell *chip = chips->data[i];  // The cell of interest
     233        if (!pmChipRead(chip, fits, db)) {
     234            psError(PS_ERR_IO, false, "Unable to read chip %d.\n", i);
     235            return false;
     236        }
     237    }
     238
     239    return true;
     240}
     241
     242#if 0
    141243
    142244bool pmFPARead(pmFPA *fpa,              // FPA to read into
     
    656758    return true;
    657759}
     760
     761
     762#endif
Note: See TracChangeset for help on using the changeset viewer.