IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10081


Ignore:
Timestamp:
Nov 18, 2006, 1:43:28 PM (20 years ago)
Author:
Paul Price
Message:

Extensive changes to FPA reading/writing functions to support mask and weight map reading/writing. Actually, not so much changes as generalisations to the reading/writing functions. Moved the reading/writing functionality into file-static functions, which the higher level functions for reading/writing particular elements (image, mask, weight) call. Added additional pmFPAfile types for mask and weight, with supporting functionality to call the reading/writing functions.

Location:
trunk/psModules/src/camera
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPARead.c

    r9998 r10081  
    1616
    1717#include "pmFPARead.h"
     18
     19//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     20// Definitions
     21//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     22
     23// Specify what to read
     24typedef enum {
     25    FPA_READ_TYPE_IMAGE,                // Read image
     26    FPA_READ_TYPE_MASK,                 // Read mask
     27    FPA_READ_TYPE_WEIGHT                // Read weight map
     28} fpaReadType;
    1829
    1930//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    155166}
    156167
     168
     169// Read into an cell; this is the engine for pmCellRead, pmCellReadMask, pmCellReadWeight
     170// Does most of the work for the reading --- reads the HDU, and portions the HDU into readouts.
     171static bool cellRead(pmCell *cell,      // Cell into which to read
     172                     psFits *fits,      // FITS file from which to read
     173                     psDB *db,          // Database handle, for concepts ingest
     174                     fpaReadType type   // Type to read
     175                    )
     176{
     177    assert(cell);
     178    assert(fits);
     179
     180    pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
     181    if (!hdu) {
     182        return true;                    // We read everything we could
     183    }
     184
     185    bool (*hduReadFunc)(pmHDU*, psFits*); // Function to use to read the HDU
     186    psArray **imageArray;               // Array of images in the HDU
     187    psElemType imageType;               // Expected type for image
     188    switch (type) {
     189    case FPA_READ_TYPE_IMAGE:
     190        hduReadFunc = pmHDURead;
     191        imageArray = &hdu->images;
     192        imageType = PS_TYPE_F32;
     193        break;
     194    case FPA_READ_TYPE_MASK:
     195        hduReadFunc = pmHDUReadMask;
     196        imageArray = &hdu->masks;
     197        imageType = PS_TYPE_MASK;
     198        break;
     199    case FPA_READ_TYPE_WEIGHT:
     200        hduReadFunc = pmHDUReadWeight;
     201        imageArray = &hdu->weights;
     202        imageType = PS_TYPE_F32;
     203        break;
     204    default:
     205        psAbort(__func__, "Unknown read type: %x\n", type);
     206    }
     207
     208    if (!(*imageArray) && !hduReadFunc(hdu, fits)) {
     209        psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n");
     210        return false;
     211    }
     212
     213    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
     214        //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
     215        //return false;
     216        psWarning("Difficulty reading concepts for cell; attempting to proceed.");
     217    }
     218
     219    // Having read the cell, we now have to cut it up
     220    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     221    psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
     222    if (psRegionIsNaN(*trimsec)) {
     223        psError(PS_ERR_IO, false, "CELL.TRIMSEC is not set --- can't read cell.\n");
     224        return false;
     225    }
     226
     227    // Iterate over each of the image planes, converting type if necessary, and extracting the bits that
     228    // matter (CELL.TRIMSEC, CELL.BIASSEC) into readouts with readoutCarve.
     229    for (int i = 0; i < (*imageArray)->n; i++) {
     230        psImage *source = (*imageArray)->data[i]; // Source image, from the i-th plane
     231
     232        // Type conversion here to support the modules, which don't have multiple type support yet
     233        if (source->type.type != imageType) {
     234            psImage *temp = psImageCopy(NULL, source, imageType); // Temporary image
     235            psFree((*imageArray)->data[i]);
     236            (*imageArray)->data[i] = temp;
     237            source = temp;
     238        }
     239
     240        pmReadout *readout;             // Readout into which to read
     241        if (cell->readouts->n > i && cell->readouts->data[i]) {
     242            readout = psMemIncrRefCounter(cell->readouts->data[i]);
     243        } else {
     244            readout = pmReadoutAlloc(cell);
     245        }
     246
     247        psImage **target;               // Place in readout to put carved image
     248        switch (type) {
     249        case FPA_READ_TYPE_IMAGE:
     250            target = &readout->image;
     251            break;
     252        case FPA_READ_TYPE_MASK:
     253            target = &readout->mask;
     254            break;
     255        case FPA_READ_TYPE_WEIGHT:
     256            target = &readout->weight;
     257            break;
     258        default:
     259            psAbort(__func__, "Unknown read type: %x\n", type);
     260        }
     261
     262        if (!readoutCarve(readout, target, source, trimsec, biassecs)) {
     263            psError(PS_ERR_UNEXPECTED_NULL, false,
     264                    "Unable to carve readout into image and bias sections for %d the plane.", i);
     265            return NULL;
     266        }
     267        psFree(readout);                // Drop reference
     268    }
     269
     270    pmCellSetDataStatus(cell, true);
     271    return true;
     272}
     273
     274
     275// Read into an chip; this is the engine for pmChipRead, pmChipReadMask, pmChipReadWeight
     276// Iterates over component cells, reading each
     277static bool chipRead(pmChip *chip,      // Chip into which to read
     278                     psFits *fits,      // FITS file from which to read
     279                     psDB *db,          // Database handle, for concepts ingest
     280                     fpaReadType type   // Type to read
     281                    )
     282{
     283    assert(chip);
     284    assert(fits);
     285
     286    bool success = false;               // Were we able to read at least one HDU?
     287    psArray *cells = chip->cells;       // Array of cells
     288    for (int i = 0; i < cells->n; i++) {
     289        pmCell *cell = cells->data[i];  // The cell of interest
     290        success |= cellRead(cell, fits, db, type);
     291    }
     292    if (success) {
     293        if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
     294            psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
     295            return false;
     296        }
     297        // XXX probably could just use chip->data_exists
     298        pmChipSetDataStatus(chip, true);
     299    }
     300
     301    return success;
     302}
     303
     304
     305// Read into an FPA; this is the engine for pmFPARead, pmFPAReadMask, pmFPAReadWeight
     306// Iterates over component chips, reading each
     307static bool fpaRead(pmFPA *fpa,         // FPA into which to read
     308                    psFits *fits,       // FITS file from which to read
     309                    psDB *db,           // Database handle, for concepts ingest
     310                    fpaReadType type    // Type to read
     311                   )
     312{
     313    assert(fpa);
     314    assert(fits);
     315
     316    bool success = false;               // Were we able to read at least one HDU?
     317    psArray *chips = fpa->chips;        // Array of chips
     318    for (int i = 0; i < chips->n; i++) {
     319        pmChip *chip = chips->data[i];  // The cell of interest
     320        success |= chipRead(chip, fits, db, type);
     321    }
     322    if (success) {
     323        if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
     324            psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
     325            return false;
     326        }
     327    } else {
     328        psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA");
     329    }
     330
     331    return success;
     332}
     333
    157334//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    158335// Public functions
     336//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     337
     338
     339//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     340// Reading images
    159341//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    160342
     
    325507    PS_ASSERT_PTR_NON_NULL(fits, false);
    326508
    327     pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
    328     if (!hdu) {
    329         return true;                    // We read everything we could
    330     }
    331     if (!hdu->images && !pmHDURead(hdu, fits)) {
    332         psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n");
    333         return false;
    334     }
    335 
    336     if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    337         //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    338         //return false;
    339         psWarning("Difficulty reading concepts for cell; attempting to proceed.");
    340     }
    341 
    342     // Having read the cell, we now have to cut it up
    343     psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    344     psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
    345     if (psRegionIsNaN(*trimsec)) {
    346         psError(PS_ERR_IO, false, "CELL.TRIMSEC is not set --- can't read cell.\n");
    347         return false;
    348     }
    349 
    350     // Iterate over each of the image planes
    351     for (int i = 0; i < hdu->images->n; i++) {
    352         psImage *image = hdu->images->data[i]; // The i-th plane
    353 
    354         // XXX: Type conversion here to support the modules, which don't have multiple type support yet
    355         if (image->type.type != PS_TYPE_F32) {
    356             psImage *temp = psImageCopy(NULL, image, PS_TYPE_F32); // Temporary image
    357             psFree(hdu->images->data[i]);
    358             hdu->images->data[i] = temp;
    359             image = temp;
    360         }
    361 
    362         pmReadout *readout;             // Readout into which to read
    363         if (cell->readouts->n > i && cell->readouts->data[i]) {
    364             readout = psMemIncrRefCounter(cell->readouts->data[i]);
    365         } else {
    366             readout = pmReadoutAlloc(cell);
    367         }
    368         if (!readoutCarve(readout, &readout->image, image, trimsec, biassecs)) {
    369             psError(PS_ERR_UNEXPECTED_NULL, false,
    370                     "Unable to carve readout into image and bias sections for %d the plane.", i);
    371             return NULL;
    372         }
    373         psFree(readout);                // Drop reference
    374     }
    375 
    376     pmCellSetDataStatus(cell, true);
    377     return true;
     509    return cellRead(cell, fits, db, FPA_READ_TYPE_IMAGE);
    378510}
    379511
     
    383515    PS_ASSERT_PTR_NON_NULL(fits, false);
    384516
    385     bool success = false;               // Were we able to read at least one HDU?
    386     psArray *cells = chip->cells;       // Array of cells
    387     for (int i = 0; i < cells->n; i++) {
    388         pmCell *cell = cells->data[i];  // The cell of interest
    389         success |= pmCellRead(cell, fits, db);
    390     }
    391     if (success) {
    392         if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
    393             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    394             return false;
    395         }
    396         // XXX probably could just use chip->data_exists
    397         pmChipSetDataStatus(chip, true);
    398     }
    399 
    400     return success;
     517    return chipRead(chip, fits, db, FPA_READ_TYPE_IMAGE);
    401518}
    402519
     
    406523    PS_ASSERT_PTR_NON_NULL(fits, false);
    407524
    408     bool success = false;               // Were we able to read at least one HDU?
    409     psArray *chips = fpa->chips;        // Array of chips
    410     for (int i = 0; i < chips->n; i++) {
    411         pmChip *chip = chips->data[i];  // The cell of interest
    412         success |= pmChipRead(chip, fits, db);
    413     }
    414     if (success) {
    415         if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    416             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    417             return false;
    418         }
    419     } else {
    420         psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA");
    421     }
    422 
    423     return success;
     525    return fpaRead(fpa, fits, db, FPA_READ_TYPE_IMAGE);
    424526}
    425527
     
    434536    PS_ASSERT_PTR_NON_NULL(fits, false);
    435537
    436     pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
    437     if (!hdu) {
    438         return false;                    // Nothing to see here; move along
    439     }
    440     if (!hdu->images && !pmHDURead(hdu, fits)) {
    441         psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n");
    442         return false;
    443     }
    444 
    445     if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    446         psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    447         return false;
    448     }
    449 
    450     // Having read the cell, we now have to cut it up
    451     psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    452 
    453     // Iterate over each of the image planes
    454     for (int i = 0; i < hdu->images->n; i++) {
    455         psImage *image = hdu->images->data[i]; // The i-th plane
    456 
    457         if (image->type.type != PS_TYPE_U8) {
    458             psImage *temp = psImageCopy(NULL, image, PS_TYPE_U8); // Temporary image
    459             psFree(hdu->images->data[i]);
    460             hdu->images->data[i] = temp;
    461             image = temp;
    462         }
    463 
    464         pmReadout *readout;             // Readout into which to read
    465         if (cell->readouts->n > i && cell->readouts->data[i]) {
    466             readout = psMemIncrRefCounter(cell->readouts->data[i]);
    467         } else {
    468             readout = pmReadoutAlloc(cell);
    469         }
    470         if (!readoutCarve(readout, &readout->mask, image, trimsec, NULL)) {
    471             psError(PS_ERR_UNEXPECTED_NULL, false,
    472                     "Unable to carve readout into image and bias sections for %d the plane.", i);
    473             return NULL;
    474         }
    475         psFree(readout);                // Drop reference
    476     }
    477 
    478     pmCellSetDataStatus(cell, true);
    479     return true;
     538    return cellRead(cell, fits, db, FPA_READ_TYPE_MASK);
    480539}
    481540
     
    485544    PS_ASSERT_PTR_NON_NULL(fits, false);
    486545
    487     bool success = false;               // Were we able to read at least one HDU?
    488     psArray *cells = chip->cells;       // Array of cells
    489     for (int i = 0; i < cells->n; i++) {
    490         pmCell *cell = cells->data[i];  // The cell of interest
    491         success |= pmCellReadMask(cell, fits, db);
    492     }
    493     if (success) {
    494         if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
    495             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    496             return false;
    497         }
    498         // XXX probably could just use chip->data_exists
    499         pmChipSetDataStatus(chip, true);
    500     }
    501 
    502     return success;
     546    return chipRead(chip, fits, db, FPA_READ_TYPE_MASK);
    503547}
    504548
     
    508552    PS_ASSERT_PTR_NON_NULL(fits, false);
    509553
    510     bool success = false;               // Were we able to read at least one HDU?
    511     psArray *chips = fpa->chips;        // Array of chips
    512     for (int i = 0; i < chips->n; i++) {
    513         pmChip *chip = chips->data[i];  // The cell of interest
    514         success |= pmChipReadMask(chip, fits, db);
    515     }
    516     if (success) {
    517         if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    518             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    519             return false;
    520         }
    521     } else {
    522         psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA");
    523     }
    524 
    525     return success;
     554    return fpaRead(fpa, fits, db, FPA_READ_TYPE_MASK);
    526555}
    527556
     
    535564    PS_ASSERT_PTR_NON_NULL(fits, false);
    536565
    537     pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
    538     if (!hdu) {
    539         return false;                    // Nothing to see here; move along
    540     }
    541     if (!hdu->images && !pmHDURead(hdu, fits)) {
    542         psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n");
    543         return false;
    544     }
    545 
    546     if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    547         psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
    548         return false;
    549     }
    550 
    551     // Having read the cell, we now have to cut it up
    552     psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    553 
    554     // Iterate over each of the image planes
    555     for (int i = 0; i < hdu->images->n; i++) {
    556         psImage *image = hdu->images->data[i]; // The i-th plane
    557 
    558         if (image->type.type != PS_TYPE_F32) {
    559             psImage *temp = psImageCopy(NULL, image, PS_TYPE_F32); // Temporary image
    560             psFree(hdu->images->data[i]);
    561             hdu->images->data[i] = temp;
    562             image = temp;
    563         }
    564 
    565         pmReadout *readout;             // Readout into which to read
    566         if (cell->readouts->n > i && cell->readouts->data[i]) {
    567             readout = psMemIncrRefCounter(cell->readouts->data[i]);
    568         } else {
    569             readout = pmReadoutAlloc(cell);
    570         }
    571         if (!readoutCarve(readout, &readout->weight, image, trimsec, NULL)) {
    572             psError(PS_ERR_UNEXPECTED_NULL, false,
    573                     "Unable to carve readout into image and bias sections for %d the plane.", i);
    574             return NULL;
    575         }
    576         psFree(readout);                // Drop reference
    577     }
    578 
    579     pmCellSetDataStatus(cell, true);
    580     return true;
     566    return cellRead(cell, fits, db, FPA_READ_TYPE_WEIGHT);
    581567}
    582568
     
    586572    PS_ASSERT_PTR_NON_NULL(fits, false);
    587573
    588     bool success = false;               // Were we able to read at least one HDU?
    589     psArray *cells = chip->cells;       // Array of cells
    590     for (int i = 0; i < cells->n; i++) {
    591         pmCell *cell = cells->data[i];  // The cell of interest
    592         success |= pmCellReadWeight(cell, fits, db);
    593     }
    594     if (success) {
    595         if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) {
    596             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    597             return false;
    598         }
    599         // XXX probably could just use chip->data_exists
    600         pmChipSetDataStatus(chip, true);
    601     }
    602 
    603     return success;
     574    return chipRead(chip, fits, db, FPA_READ_TYPE_WEIGHT);
    604575}
    605576
     
    609580    PS_ASSERT_PTR_NON_NULL(fits, false);
    610581
    611     bool success = false;               // Were we able to read at least one HDU?
    612     psArray *chips = fpa->chips;        // Array of chips
    613     for (int i = 0; i < chips->n; i++) {
    614         pmChip *chip = chips->data[i];  // The cell of interest
    615         success |= pmChipReadWeight(chip, fits, db);
    616     }
    617     if (success) {
    618         if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) {
    619             psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n");
    620             return false;
    621         }
    622     } else {
    623         psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA");
    624     }
    625 
    626     return success;
    627 }
    628 
     582    return fpaRead(fpa, fits, db, FPA_READ_TYPE_WEIGHT);
     583}
     584
     585//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     586// Reading FITS tables
     587//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    629588
    630589int pmCellReadTable(pmCell *cell, psFits *fits, const char *name)
  • trunk/psModules/src/camera/pmFPAWrite.c

    r9983 r10081  
    1414
    1515#include "pmFPAWrite.h"
     16
     17//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     18// Definitions
     19//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     20
     21// Specify what to read
     22typedef enum {
     23    FPA_WRITE_TYPE_IMAGE,               // Write image
     24    FPA_WRITE_TYPE_MASK,                // Write mask
     25    FPA_WRITE_TYPE_WEIGHT               // Write weight map
     26} fpaWriteType;
     27
     28//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     29// File-static (private) functions
     30//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     31
     32// Return the appropriate image array for the given type
     33static psArray **appropriateImageArray(pmHDU *hdu, // HDU containing the image arrays
     34                                       fpaWriteType type // Type to write
     35                                      )
     36{
     37    switch (type) {
     38    case FPA_WRITE_TYPE_IMAGE:
     39        return &hdu->images;
     40    case FPA_WRITE_TYPE_MASK:
     41        return &hdu->masks;
     42    case FPA_WRITE_TYPE_WEIGHT:
     43        return &hdu->weights;
     44    default:
     45        psAbort(__func__, "Unknown write type: %x\n", type);
     46    }
     47    return NULL;
     48}
     49
     50// Run the appropriate HDU write function
     51static bool appropriateWriteFunc(pmHDU *hdu, // HDU to write
     52                                 psFits *fits, // FITS file to which to write
     53                                 fpaWriteType type // Type to write
     54                                )
     55{
     56    switch (type) {
     57    case FPA_WRITE_TYPE_IMAGE:
     58        return pmHDUWrite(hdu, fits);
     59    case FPA_WRITE_TYPE_MASK:
     60        return pmHDUWriteMask(hdu, fits);
     61    case FPA_WRITE_TYPE_WEIGHT:
     62        return pmHDUWriteWeight(hdu, fits);
     63    default:
     64        psAbort(__func__, "Unknown write type: %x\n", type);
     65    }
     66    return false;
     67}
     68
     69// Write a cell image/mask/weight
     70static bool cellWrite(pmCell *cell,     // Cell to write
     71                      psFits *fits,     // FITS file to which to write
     72                      psDB *db,         // Database handle for "concepts" update
     73                      bool blank,       // Write a blank PHU?
     74                      fpaWriteType type // Type to write
     75                     )
     76{
     77    assert(cell);
     78    assert(fits);
     79
     80    psTrace ("pmFPAWrite", 5, "writing to Cell (%d)\n", blank);
     81
     82    pmHDU *hdu = cell->hdu;             // The HDU
     83    if (!hdu) {
     84        return true;                    // We wrote every HDU that exists
     85    }
     86
     87    psArray **imageArray = appropriateImageArray(hdu, type); // Array of images in the HDU
     88
     89    // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     90    // generate the HDU, but only copies the structure.
     91    if (!hdu->blankPHU && !*imageArray && (!pmHDUGenerateForCell(cell) || !*imageArray)) {
     92        psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.\n");
     93        return false;
     94    }
     95
     96    // We only write out a blank PHU if it's specifically requested.
     97    bool writeBlank = blank && hdu->blankPHU && !*imageArray; // Write a blank PHU?
     98    bool writeImage = !blank && !hdu->blankPHU && *imageArray; // Write an image?
     99
     100    if (writeBlank || writeImage) {
     101        pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
     102                                 PM_CONCEPT_SOURCE_DEFAULTS;
     103        if (!pmConceptsWriteCell(cell, source, false, NULL)) {
     104            psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n");
     105            return false;
     106        }
     107        if (!appropriateWriteFunc(hdu, fits, type)) {
     108            psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n");
     109            return false;
     110        }
     111    }
     112    // No lower levels to which to recurse
     113
     114    return true;
     115}
     116
     117// Write a chip image/mask/weight
     118static bool chipWrite(pmChip *chip,     // Chip to write
     119                      psFits *fits,     // FITS file to which to write
     120                      psDB *db,         // Database handle for "concepts" update
     121                      bool blank,       // Write a blank PHU?
     122                      bool recurse,     // Recurse to lower levels?
     123                      fpaWriteType type // Type to write
     124                     )
     125{
     126    assert(chip);
     127    assert(fits);
     128
     129    pmHDU *hdu = chip->hdu;             // The HDU
     130
     131    psTrace ("pmFPAWrite", 5, "writing to Chip (%d, %d)\n", blank, recurse);
     132
     133    // If we have data at this level, try to write it out
     134    if (hdu) {
     135        psArray **imageArray = appropriateImageArray(hdu, type); // Array of images in HDU
     136
     137        // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     138        // generate the HDU, but only copies the structure.
     139        if (!blank && !hdu->blankPHU && !*imageArray && (!pmHDUGenerateForChip(chip) || !*imageArray)) {
     140            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for chip --- likely programming error.\n");
     141            return false;
     142        }
     143
     144        // We only write out a blank PHU if it's specifically requested.
     145        bool writeBlank = blank && hdu->blankPHU && !*imageArray; // Write a blank HDU?
     146        bool writeImage = !blank && !hdu->blankPHU && *imageArray; // Write an image?
     147
     148        if (writeBlank || writeImage) {
     149            pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
     150                                     PM_CONCEPT_SOURCE_DEFAULTS;
     151            if (!pmConceptsWriteChip(chip, source, false, true, NULL)) {
     152                psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n");
     153                return false;
     154            }
     155            if (!appropriateWriteFunc(hdu, fits, type)) {
     156                psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n");
     157                return false;
     158            }
     159        }
     160    }
     161
     162    // Recurse to lower level if specifically requested.
     163    // XXX recursion implies blank == false (must be called on correct level?)
     164    if (recurse) {
     165        psArray *cells = chip->cells;       // Array of cells
     166        for (int i = 0; i < cells->n; i++) {
     167            pmCell *cell = cells->data[i];  // The cell of interest
     168            if (!cellWrite(cell, fits, db, false, type)) {
     169                psError(PS_ERR_IO, false, "Unable to write Chip.\n");
     170                return false;
     171            }
     172        }
     173    }
     174
     175    return true;
     176}
     177
     178// Write an FPA image/mask/weight
     179static bool fpaWrite(pmFPA *fpa,        // FPA to write
     180                     psFits *fits,      // FITS file to which to write
     181                     psDB *db,          // Database handle for "concepts" update
     182                     bool blank,        // Write a blank PHU?
     183                     bool recurse,      // Recurse to lower levels?
     184                     fpaWriteType type  // Type to write
     185                    )
     186{
     187    assert(fpa);
     188    assert(fits);
     189
     190    pmHDU *hdu = fpa->hdu;              // The HDU
     191
     192    psTrace ("pmFPAWrite", 5, "writing to FPA (%d, %d)\n", blank, recurse);
     193
     194    // If we have data at this level, try to write it out
     195    if (hdu) {
     196        psArray **imageArray = appropriateImageArray(hdu, type); // Array of images in HDU
     197
     198        // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     199        // generate the HDU, but only copies the structure.
     200        if (!blank && !hdu->blankPHU && !*imageArray && (!pmHDUGenerateForFPA(fpa) || !*imageArray)) {
     201            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for FPA --- likely programming error.\n");
     202            return false;
     203        }
     204
     205        // We only write out a blank PHU if it's specifically requested.
     206        bool writeBlank = blank && hdu->blankPHU && !*imageArray; // Write a blank PHU?
     207        bool writeImage = !blank && !hdu->blankPHU && *imageArray; // Write an image?
     208
     209        if (writeBlank || writeImage) {
     210            pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
     211                                     PM_CONCEPT_SOURCE_DEFAULTS;
     212            if (!pmConceptsWriteFPA(fpa, source, true, NULL)) {
     213                psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n");
     214                return false;
     215            }
     216            if (!appropriateWriteFunc(hdu, fits, type))  {
     217                psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
     218                return false;
     219            }
     220        }
     221    }
     222
     223    // Recurse to lower levels if requested
     224    if (recurse) {
     225        psArray *chips = fpa->chips;        // Array of chips
     226        for (int i = 0; i < chips->n; i++) {
     227            pmChip *chip = chips->data[i];  // The chip of interest
     228            if (!chipWrite(chip, fits, db, false, true, type)) {
     229                psError(PS_ERR_IO, false, "Unable to write FPA.\n");
     230                return false;
     231            }
     232        }
     233    }
     234
     235    return true;
     236}
     237
     238//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     239// Public functions
     240//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    16241
    17242bool pmReadoutWriteNext(pmReadout *readout, psFits *fits, int z)
     
    82307
    83308
    84 
    85 
    86 bool pmCellWrite(pmCell *cell,          // Cell to write
    87                  psFits *fits,          // FITS file to which to write
    88                  psDB *db,              // Database handle for "concepts" update
    89                  bool blank             // Write a blank PHU?
    90                 )
     309bool pmCellWrite(pmCell *cell, psFits *fits, psDB *db, bool blank)
    91310{
    92311    PS_ASSERT_PTR_NON_NULL(cell, false);
    93312    PS_ASSERT_PTR_NON_NULL(fits, false);
    94 
    95     psTrace ("pmFPAWrite", 5, "writing to Cell (%d)\n", blank);
    96 
    97     pmHDU *hdu = cell->hdu;             // The HDU
    98     if (!hdu) {
    99         return true;                    // We wrote every HDU that exists
    100     }
    101 
    102     // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    103     // generate the HDU, but only copies the structure.
    104     if (!hdu->blankPHU && !hdu->images) {
    105         if (!pmHDUGenerateForCell(cell) || !hdu->images) {
    106             psAbort(__func__, "Unable to generate HDU for cell --- likely programming error.\n");
    107         }
    108     }
    109 
    110     // We only write out a blank PHU if it's specifically requested.
    111     bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank PHU?
    112     bool writeImage = !blank && !hdu->blankPHU && hdu->images; // Write an image?
    113 
    114     if (writeBlank || writeImage) {
    115         pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    116                                  PM_CONCEPT_SOURCE_DEFAULTS;
    117         if (!pmConceptsWriteCell(cell, source, false, NULL)) {
    118             psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n");
    119             return false;
    120         }
    121         if (!pmHDUWrite(hdu, fits)) {
    122             psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n");
    123             return false;
    124         }
    125     }
    126     // No lower levels to which to recurse
    127 
    128     return true;
    129 }
    130 
     313    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_IMAGE);
     314}
    131315
    132316bool pmChipWrite(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     
    134318    PS_ASSERT_PTR_NON_NULL(chip, false);
    135319    PS_ASSERT_PTR_NON_NULL(fits, false);
    136 
    137     pmHDU *hdu = chip->hdu;             // The HDU
    138 
    139     psTrace ("pmFPAWrite", 5, "writing to Chip (%d, %d)\n", blank, recurse);
    140 
    141     // If we have data at this level, try to write it out
    142     if (hdu) {
    143         // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    144         // generate the HDU, but only copies the structure.
    145         if (!blank && !hdu->blankPHU && !hdu->images) {
    146             if (!pmHDUGenerateForChip(chip) || !hdu->images) {
    147                 psAbort (__func__, "Unable to generate HDU for chip --- likely programming error.\n");
    148             }
    149         }
    150 
    151         // We only write out a blank PHU if it's specifically requested.
    152         bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank HDU?
    153         bool writeImage = !blank && !hdu->blankPHU && hdu->images; // Write an image?
    154 
    155         if (writeBlank || writeImage) {
    156             pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    157                                      PM_CONCEPT_SOURCE_DEFAULTS;
    158             if (!pmConceptsWriteChip(chip, source, false, true, NULL)) {
    159                 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n");
    160                 return false;
    161             }
    162             if (!pmHDUWrite(hdu, fits)) {
    163                 psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n");
    164                 return false;
    165             }
    166         }
    167     }
    168 
    169     // Recurse to lower level if specifically requested.
    170     // XXX recursion implies blank == false (must be called on correct level?)
    171     if (recurse) {
    172         psArray *cells = chip->cells;       // Array of cells
    173         for (int i = 0; i < cells->n; i++) {
    174             pmCell *cell = cells->data[i];  // The cell of interest
    175             if (!pmCellWrite(cell, fits, db, false)) {
    176                 psError(PS_ERR_IO, false, "Unable to write Chip.\n");
    177                 return false;
    178             }
    179         }
    180     }
    181 
    182     return true;
    183 }
    184 
    185 
     320    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
     321}
    186322
    187323bool pmFPAWrite(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     
    189325    PS_ASSERT_PTR_NON_NULL(fpa, false);
    190326    PS_ASSERT_PTR_NON_NULL(fits, false);
    191 
    192     pmHDU *hdu = fpa->hdu;              // The HDU
    193 
    194     psTrace ("pmFPAWrite", 5, "writing to FPA (%d, %d)\n", blank, recurse);
    195 
    196     // If we have data at this level, try to write it out
    197     if (hdu) {
    198         // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    199         // generate the HDU, but only copies the structure.
    200         if (!blank && !hdu->blankPHU && !hdu->images) {
    201             if (!pmHDUGenerateForFPA(fpa)) {
    202                 psAbort("pmFPAWrite", "error generating HDU");
    203             }
    204             if (!hdu->images) {
    205                 psAbort("pmFPAWrite", "programming error: failure generating HDU");
    206             }
    207         }
    208 
    209         // We only write out a blank PHU if it's specifically requested.
    210         bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank PHU?
    211         bool writeImage = !blank && !hdu->blankPHU && hdu->images; // Write an image?
    212 
    213         if (writeBlank || writeImage) {
    214             pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |
    215                                      PM_CONCEPT_SOURCE_DEFAULTS;
    216             if (!pmConceptsWriteFPA(fpa, source, true, NULL)) {
    217                 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n");
    218                 return false;
    219             }
    220             if (!pmHDUWrite(hdu, fits))  {
    221                 psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
    222                 return false;
    223             }
    224         }
    225     }
    226 
    227     // Recurse to lower levels if requested
    228     if (recurse) {
    229         psArray *chips = fpa->chips;        // Array of chips
    230         for (int i = 0; i < chips->n; i++) {
    231             pmChip *chip = chips->data[i];  // The chip of interest
    232             if (!pmChipWrite(chip, fits, db, false, true)) {
    233                 psError(PS_ERR_IO, false, "Unable to write FPA.\n");
    234                 return false;
    235             }
    236         }
    237     }
    238 
    239     return true;
    240 }
    241 
    242 
    243 
    244 bool pmCellWriteMask(pmCell *cell,          // Cell to write
    245                      psFits *fits,          // FITS file to which to write
    246                      psDB *db           // Database handle for "concepts" update
    247                     )
     327    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
     328}
     329
     330
     331bool pmCellWriteMask(pmCell *cell, psFits *fits, psDB *db, bool blank)
    248332{
    249333    PS_ASSERT_PTR_NON_NULL(cell, false);
    250334    PS_ASSERT_PTR_NON_NULL(fits, false);
    251 
    252     pmHDU *hdu = cell->hdu;             // The HDU
    253     if (!hdu) {
    254         return true;                    // We wrote every HDU that exists
    255     }
    256 
    257     psTrace ("pmFPAWrite", 5, "writing mask to Cell\n");
    258 
    259     // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    260     // generate the HDU, but only copies the structure.
    261     if (!hdu->blankPHU && !hdu->masks) {
    262         if (!pmHDUGenerateForCell(cell) || !hdu->masks) {
    263             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.\n");
    264             return false;
    265         }
    266     }
    267 
    268     pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
    269     if (!pmConceptsWriteCell(cell, source, false, NULL)) {
    270         psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n");
    271         return false;
    272     }
    273     if (!pmHDUWriteMask(hdu, fits)) {
    274         psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n");
    275         return false;
    276     }
    277 
    278     return true;
    279 }
    280 
    281 
    282 bool pmChipWriteMask(pmChip *chip, psFits *fits, psDB *db)
     335    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_IMAGE);
     336}
     337
     338bool pmChipWriteMask(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
    283339{
    284340    PS_ASSERT_PTR_NON_NULL(chip, false);
    285341    PS_ASSERT_PTR_NON_NULL(fits, false);
    286 
    287     pmHDU *hdu = chip->hdu;             // The HDU
    288     if (!hdu) {
    289         return true;                    // We wrote every HDU that exists
    290     }
    291 
    292     psTrace ("pmFPAWrite", 5, "writing mask to Chip\n");
    293 
    294     // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    295     // generate the HDU, but only copies the structure.
    296     if (!hdu->blankPHU && !hdu->masks) {
    297         if (!pmHDUGenerateForChip(chip) || !hdu->masks) {
    298             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for chip --- likely programming error.\n");
    299             return false;
    300         }
    301     }
    302 
    303     pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
    304     if (!pmConceptsWriteChip(chip, source, false, true, NULL)) {
    305         psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n");
    306         return false;
    307     }
    308     if (!pmHDUWriteMask(hdu, fits)) {
    309         psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n");
    310         return false;
    311     }
    312 
    313     return true;
    314 }
    315 
    316 
    317 
    318 bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, psDB *db)
     342    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
     343}
     344
     345bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
    319346{
    320347    PS_ASSERT_PTR_NON_NULL(fpa, false);
    321348    PS_ASSERT_PTR_NON_NULL(fits, false);
    322 
    323     pmHDU *hdu = fpa->hdu;              // The HDU
    324     if (!hdu) {
    325         return true;                    // We wrote every HDU that exists
    326     }
    327 
    328     psTrace ("pmFPAWrite", 5, "writing mask to FPA\n");
    329 
    330     // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
    331     // generate the HDU, but only copies the structure.
    332     if (!hdu->blankPHU && !hdu->masks) {
    333         if (!pmHDUGenerateForFPA(fpa) || !hdu->masks) {
    334             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for chip --- likely programming error.\n");
    335             return false;
    336         }
    337     }
    338 
    339     pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
    340     if (!pmConceptsWriteFPA(fpa, source, true, NULL)) {
    341         psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n");
    342         return false;
    343     }
    344     if (!pmHDUWriteMask(hdu, fits))  {
    345         psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
    346         return false;
    347     }
    348 
    349     return true;
    350 }
    351 
     349    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
     350}
     351
     352
     353bool pmCellWriteWeight(pmCell *cell, psFits *fits, psDB *db, bool blank)
     354{
     355    PS_ASSERT_PTR_NON_NULL(cell, false);
     356    PS_ASSERT_PTR_NON_NULL(fits, false);
     357    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_WEIGHT);
     358}
     359
     360bool pmChipWriteWeight(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
     361{
     362    PS_ASSERT_PTR_NON_NULL(chip, false);
     363    PS_ASSERT_PTR_NON_NULL(fits, false);
     364    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
     365}
     366
     367bool pmFPAWriteWeight(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
     368{
     369    PS_ASSERT_PTR_NON_NULL(fpa, false);
     370    PS_ASSERT_PTR_NON_NULL(fits, false);
     371    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
     372}
    352373
    353374
  • trunk/psModules/src/camera/pmFPAWrite.h

    r9983 r10081  
    77/// @author Paul Price, IfA
    88///
    9 /// @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2006-11-15 00:40:02 $
     9/// @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2006-11-18 23:43:28 $
    1111///
    1212/// Copyright 2005-2006 Institute for Astronomy, University of Hawaii
     
    6969/// Write a cell mask to a FITS file
    7070///
    71 /// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU pixels if required.  Writes the concepts to the various
    72 /// locations, and then the HDU mask to the FITS file.
     71/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU mask pixels if required.  A blank (i.e., image-less
     72/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     73/// the HDU mask to the FITS file.  This function should be called at the beginning of the output cell loop
     74/// with blank=true in order to produce the correct file structure.
    7375bool pmCellWriteMask(pmCell *cell,      ///<  Cell to write
    7476                     psFits *fits,      ///<  FITS file to which to write
    75                      psDB *db           ///<  Database handle for "concepts" update
     77                     psDB *db,          ///<  Database handle for "concepts" update
     78                     bool blank         ///<  Write a blank PHU?
    7679                    );
    7780
    7881/// Write a chip mask to a FITS file
    7982///
    80 /// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU pixels if required.  Writes the concepts to the various
    81 /// locations, and then the HDU mask to the FITS file.
     83/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU mask pixels if required.  A blank (i.e., image-less
     84/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     85/// the HDU mask to the FITS file, optionally recursing to lower levels.  This function should be called at
     86/// the beginning of the output chip loop with blank=true and recurse=false in order to produce the correct
     87/// file structure.
    8288bool pmChipWriteMask(pmChip *chip,      ///<  Chip to write
    8389                     psFits *fits,      ///<  FITS file to which to write
    84                      psDB *db           ///<  Database handle for "concepts" update
     90                     psDB *db,          ///<  Database handle for "concepts" update
     91                     bool blank,        ///<  Write a blank PHU?
     92                     bool recurse       ///<  Recurse to lower levels?
    8593                    );
    8694
    8795/// Write an FPA mask to a FITS file
    8896///
    89 /// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU pixels if required.  Writes the concepts to the various
    90 /// locations, and then the HDU mask to the FITS file.
     97/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU mask pixels if required.  A blank (i.e., image-less
     98/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     99/// the HDU mask to the FITS file, optionally recursing to lower levels.  This function should be called at
     100/// the beginning of the output FPA loop with blank=true and recurse=false in order to produce the correct
     101/// file structure.
    91102bool pmFPAWriteMask(pmFPA *fpa,         ///<  FPA to write
    92103                    psFits *fits,       ///<  FITS file to which to write
    93                     psDB *db            ///<  Database handle for "concepts" update
     104                    psDB *db,           ///<  Database handle for "concepts" update
     105                    bool blank,         ///<  Write a blank PHU?
     106                    bool recurse        ///<  Recurse to lower levels?
    94107                   );
     108
     109/// Write a cell weight to a FITS file
     110///
     111/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU weight pixels if required.  A blank (i.e., image-less
     112/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     113/// the HDU weight to the FITS file.  This function should be called at the beginning of the output cell loop
     114/// with blank=true in order to produce the correct file structure.
     115bool pmCellWriteWeight(pmCell *cell,    ///<  Cell to write
     116                       psFits *fits,    ///<  FITS file to which to write
     117                       psDB *db,        ///<  Database handle for "concepts" update
     118                       bool blank       ///<  Write a blank PHU?
     119                      );
     120
     121/// Write a chip weight to a FITS file
     122///
     123/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU weight pixels if required.  A blank (i.e., image-less
     124/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     125/// the HDU weight to the FITS file, optionally recursing to lower levels.  This function should be called at
     126/// the beginning of the output chip loop with blank=true and recurse=false in order to produce the correct
     127/// file structure.
     128bool pmChipWriteWeight(pmChip *chip,    ///<  Chip to write
     129                       psFits *fits,    ///<  FITS file to which to write
     130                       psDB *db,        ///<  Database handle for "concepts" update
     131                       bool blank,      ///<  Write a blank PHU?
     132                       bool recurse     ///<  Recurse to lower levels?
     133                      );
     134
     135/// Write an FPA weight to a FITS file
     136///
     137/// Generates CELL.TRIMSEC, CELL.BIASSEC and the HDU weight pixels if required.  A blank (i.e., image-less
     138/// header) is written only if specifically requested.  Writes the concepts to the various locations, and then
     139/// the HDU weight to the FITS file, optionally recursing to lower levels.  This function should be called at
     140/// the beginning of the output FPA loop with blank=true and recurse=false in order to produce the correct
     141/// file structure.
     142bool pmFPAWriteWeight(pmFPA *fpa,       ///<  FPA to write
     143                      psFits *fits,     ///<  FITS file to which to write
     144                      psDB *db,         ///<  Database handle for "concepts" update
     145                      bool blank,       ///<  Write a blank PHU?
     146                      bool recurse      ///<  Recurse to lower levels?
     147                     );
     148
    95149
    96150/// Write a FITS table from the cell's analysis metadata.
  • trunk/psModules/src/camera/pmFPAfile.c

    r9950 r10081  
    374374        return PM_FPA_FILE_JPEG;
    375375    }
     376    if (!strcasecmp (type, "MASK"))     {
     377        return PM_FPA_FILE_MASK;
     378    }
     379    if (!strcasecmp (type, "WEIGHT"))     {
     380        return PM_FPA_FILE_WEIGHT;
     381    }
    376382    if (!strcasecmp (type, "FRINGE")) {
    377383        return PM_FPA_FILE_FRINGE;
  • trunk/psModules/src/camera/pmFPAfile.h

    r9950 r10081  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-11-13 22:15:55 $
     9*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-11-18 23:43:28 $
    1111*
    1212*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    3737    PM_FPA_FILE_JPEG,
    3838    PM_FPA_FILE_MANAPLOT,
     39    PM_FPA_FILE_MASK,
     40    PM_FPA_FILE_WEIGHT,
    3941    PM_FPA_FILE_FRINGE,
    4042} pmFPAfileType;
  • trunk/psModules/src/camera/pmFPAfileFitsIO.c

    r9950 r10081  
    6161}
    6262
    63 // given an already-opened fits file, read the components corresponding
    64 // to the specified view
    65 bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file)
    66 {
    67     PS_ASSERT_PTR_NON_NULL(view, false);
    68     PS_ASSERT_PTR_NON_NULL(file, false);
    69 
    70     bool status;
    71     pmFPA *fpa = file->fpa;
    72     psFits *fits = file->fits;
    73 
    74     if (view->chip == -1) {
    75         status = pmFPARead (fpa, fits, NULL);
    76         return status;
     63
     64// given an already-opened fits file, read the components corresponding to the specified view
     65static bool fpaViewReadFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
     66                                 pmFPAfile *file, // FPA file of interest
     67                                 bool (*fpaReadFunc)(pmFPA*, psFits*, psDB*), // Function to read FPA
     68                                 bool (*chipReadFunc)(pmChip*, psFits*, psDB*), // Function to read chip
     69                                 bool (*cellReadFunc)(pmCell*, psFits*, psDB*) // Function to read cell
     70                                )
     71{
     72    assert(view);
     73    assert(file);
     74
     75    pmFPA *fpa = file->fpa;             // FPA of interest
     76    psFits *fits = file->fits;          // FITS file from which to read
     77
     78    if (view->chip == -1) {
     79        return fpaReadFunc(fpa, fits, NULL);
    7780    }
    7881
     
    8184        return false;
    8285    }
    83     pmChip *chip = fpa->chips->data[view->chip];
    84 
    85     if (view->cell == -1) {
    86         status = pmChipRead (chip, fits, NULL);
    87         return status;
     86    pmChip *chip = fpa->chips->data[view->chip]; // Chip of interest
     87
     88    if (view->cell == -1) {
     89        return chipReadFunc(chip, fits, NULL);
    8890    }
    8991
     
    9294        return false;
    9395    }
    94     pmCell *cell = chip->cells->data[view->cell];
     96    pmCell *cell = chip->cells->data[view->cell]; // Cell of interest
    9597
    9698    if (view->readout == -1) {
    97         status = pmCellRead (cell, fits, NULL);
    98         return status;
    99     }
    100     psError(PS_ERR_UNKNOWN, true, "Returning false");
     99        return cellReadFunc(cell, fits, NULL);
     100    }
     101    psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell);
    101102    return false;
    102103
     
    118119    return true;
    119120    #endif
     121}
     122
     123
     124bool pmFPAviewReadFitsImage(const pmFPAview *view, pmFPAfile *file)
     125{
     126    PS_ASSERT_PTR_NON_NULL(view, false);
     127    PS_ASSERT_PTR_NON_NULL(file, false);
     128    return fpaViewReadFitsImage(view, file, pmFPARead, pmChipRead, pmCellRead);
     129}
     130
     131bool pmFPAviewReadFitsMask(const pmFPAview *view, pmFPAfile *file)
     132{
     133    PS_ASSERT_PTR_NON_NULL(view, false);
     134    PS_ASSERT_PTR_NON_NULL(file, false);
     135    return fpaViewReadFitsImage(view, file, pmFPAReadMask, pmChipReadMask, pmCellReadMask);
     136}
     137
     138bool pmFPAviewReadFitsWeight(const pmFPAview *view, pmFPAfile *file)
     139{
     140    PS_ASSERT_PTR_NON_NULL(view, false);
     141    PS_ASSERT_PTR_NON_NULL(file, false);
     142    return fpaViewReadFitsImage(view, file, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight);
    120143}
    121144
     
    126149// out data in an inconsistent fashion
    127150// the calls below should recurse down the element to write out all components.
    128 bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file)
    129 {
    130     PS_ASSERT_PTR_NON_NULL(view, false);
    131     PS_ASSERT_PTR_NON_NULL(file, false);
    132 
    133     pmFPA *fpa = file->fpa;
    134     psFits *fits = file->fits;
     151static bool fpaViewWriteFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
     152                                  pmFPAfile *file, // FPA file of interest
     153                                  bool (*fpaWriteFunc)(pmFPA*, psFits*, psDB*, bool, bool), // Func for FPA
     154                                  bool (*chipWriteFunc)(pmChip*, psFits*, psDB*, bool, bool), // Func for chip
     155                                  bool (*cellWriteFunc)(pmCell*, psFits*, psDB*, bool) // Func for cell
     156                                 )
     157{
     158    assert(view);
     159    assert(file);
     160
     161    pmFPA *fpa = file->fpa;             // FPA of interest
     162    psFits *fits = file->fits;          // FITS file
    135163
    136164    // pmFPAWrite takes care of all PHUs as needed
    137165    if (view->chip == -1) {
    138         pmFPAWrite(fpa, fits, NULL, false, true);
    139         return true;
     166        return fpaWriteFunc(fpa, fits, NULL, false, true);
    140167    }
    141168
     
    144171        return false;
    145172    }
    146     pmChip *chip = fpa->chips->data[view->chip];
    147 
    148     if (view->cell == -1) {
    149         pmChipWrite (chip, fits, NULL, false, true);
    150         return true;
     173    pmChip *chip = fpa->chips->data[view->chip]; // Chip of interest
     174
     175    if (view->cell == -1) {
     176        return chipWriteFunc(chip, fits, NULL, false, true);
    151177    }
    152178
     
    155181        return false;
    156182    }
    157     pmCell *cell = chip->cells->data[view->cell];
     183    pmCell *cell = chip->cells->data[view->cell]; // Cell of interest
    158184
    159185    if (view->readout == -1) {
    160         return pmCellWrite (cell, fits, NULL, false);
    161     }
    162     psError(PS_ERR_UNKNOWN, true, "Returning false");
     186        return cellWriteFunc(cell, fits, NULL, false);
     187    }
     188    psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell);
    163189    return false;
    164190
     
    182208}
    183209
    184 // this old code was used to write the blank by hand.
    185 // pmFPAWrite now takes care of this choice.
    186 # if 0
    187 // do we need to write out a PHU for this entry?
    188 if (file->phu == NULL)
    189     {
    190         pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
    191         pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
    192         // if this hdu is the phu, the write function below will create the phu
    193         if (hdu != phu) {
    194             // we assume that the PHU is just a header
    195             // header may not be defined for constructed images; make a dummy one
    196             psMetadata *outhead = NULL;
    197             if (phu->header) {
    198                 outhead = psMetadataCopy (NULL, phu->header);
    199             } else {
    200                 outhead = psMetadataAlloc ();
    201             }
    202             psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
    203             psFitsWriteBlank (file->fits, outhead, "");
    204             file->phu = phu->header;
    205             psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
    206             psFree (outhead);
    207         }
    208     }
    209 # endif
     210bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file)
     211{
     212    PS_ASSERT_PTR_NON_NULL(view, false);
     213    PS_ASSERT_PTR_NON_NULL(file, false);
     214    return fpaViewWriteFitsImage(view, file, pmFPAWrite, pmChipWrite, pmCellWrite);
     215}
     216
     217bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file)
     218{
     219    PS_ASSERT_PTR_NON_NULL(view, false);
     220    PS_ASSERT_PTR_NON_NULL(file, false);
     221    return fpaViewWriteFitsImage(view, file, pmFPAWriteMask, pmChipWriteMask, pmCellWriteMask);
     222}
     223
     224bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file)
     225{
     226    PS_ASSERT_PTR_NON_NULL(view, false);
     227    PS_ASSERT_PTR_NON_NULL(file, false);
     228    return fpaViewWriteFitsImage(view, file, pmFPAWriteWeight, pmChipWriteWeight, pmCellWriteWeight);
     229}
    210230
    211231// given an already-opened fits file, read the components corresponding
    212232// to the specified view
    213 bool pmFPAviewFreeFitsImage (const pmFPAview *view, pmFPAfile *file)
     233bool pmFPAviewFreeData(const pmFPAview *view, pmFPAfile *file)
    214234{
    215235    PS_ASSERT_PTR_NON_NULL(view, false);
     
    270290}
    271291
     292#if 0
     293// Shouldn't need this --- when we want to free fringe data, we want to free the whole level, not just the
     294// table.
    272295
    273296// Free the table within a cell
     
    329352}
    330353
     354#endif
  • trunk/psModules/src/camera/pmFPAfileFitsIO.h

    r9950 r10081  
    66*
    77*  @author EAM, IfA
     8*  @author PAP, IfA
    89*
    9 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-11-13 22:15:55 $
     10*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-11-18 23:43:28 $
    1112*
    1213*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
     
    1617#define PM_FPA_FILE_FITS_IO_H
    1718
    18 // read an image into the current view
    19 bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file);
     19/// Read an image into the current view
     20bool pmFPAviewReadFitsImage(const pmFPAview *view, ///< View specifying level of interest
     21                            pmFPAfile *file ///< FPA file into which to read
     22                           );
    2023
    21 // write the components for the specified view
    22 bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file);
     24/// Read a mask into the current view
     25bool pmFPAviewReadFitsMask(const pmFPAview *view, ///< View specifying level of interest
     26                           pmFPAfile *file ///< FPA file into which to read
     27                          );
     28/// Read a weight map into the current view
     29bool pmFPAviewReadFitsWeight(const pmFPAview *view,  ///< View specifying level of interest
     30                             pmFPAfile *file ///< FPA file into which to read
     31                            );
    2332
    24 // free the appropriate image containers
    25 bool pmFPAviewFreeFitsImage (const pmFPAview *view, pmFPAfile *file);
     33/// Write the image for the specified view
     34bool pmFPAviewWriteFitsImage(const pmFPAview *view, ///< View specifying level of interest
     35                             pmFPAfile *file ///< FPA file to write
     36                            );
    2637
     38/// Write the mask for the specified view
     39bool pmFPAviewWriteFitsMask(const pmFPAview *view, ///< View specifying level of interest
     40                            pmFPAfile *file ///< FPA file to write
     41                           );
    2742
    28 // read a table into the current view
    29 bool pmFPAviewReadFitsTable(const pmFPAview *view, pmFPAfile *file, const char *name);
     43/// Write the weight map for the specified view
     44bool pmFPAviewWriteFitsWeight(const pmFPAview *view, ///< View specifying level of interest
     45                              pmFPAfile *file ///< FPA file to write
     46                             );
    3047
    31 // write the table for the specified view
    32 bool pmFPAviewWriteFitsTable(const pmFPAview *view, pmFPAfile *file, const char *name);
     48/// Free the data for the specified view
     49bool pmFPAviewFreeData(const pmFPAview *view, ///< View specifying level of interest
     50                       pmFPAfile *file  ///< FPA file to free data
     51                      );
    3352
    34 // free the appropriate table containers
    35 bool pmFPAviewFreeFitsTable(const pmFPAview *view, pmFPAfile *file, const char *name);
     53/// Read a table into the current view
     54bool pmFPAviewReadFitsTable(const pmFPAview *view, ///<  View specifying level of interest
     55                            pmFPAfile *file, ///< FPA file into which to read
     56                            const char *name ///< Name of table
     57                           );
     58
     59/// Write the table for the specified view
     60bool pmFPAviewWriteFitsTable(const pmFPAview *view, ///<  View specifying level of interest
     61                             pmFPAfile *file, ///< FPA file to write
     62                             const char *name ///< Name of table
     63                            );
    3664
    3765# endif
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r9950 r10081  
    225225        // open the FITS types:
    226226    case PM_FPA_FILE_IMAGE:
     227    case PM_FPA_FILE_MASK:
     228    case PM_FPA_FILE_WEIGHT:
    227229    case PM_FPA_FILE_FRINGE:
    228230        psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type);
     
    311313    switch (file->type) {
    312314    case PM_FPA_FILE_IMAGE:
    313         if (!pmFPAviewReadFitsImage (view, file)) {
     315        if (!pmFPAviewReadFitsImage(view, file)) {
     316            psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type);
     317            return false;
     318        }
     319        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
     320        break;
     321    case PM_FPA_FILE_MASK:
     322        if (!pmFPAviewReadFitsMask(view, file)) {
     323            psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type);
     324            return false;
     325        }
     326        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
     327        break;
     328    case PM_FPA_FILE_WEIGHT:
     329        if (!pmFPAviewReadFitsWeight(view, file)) {
    314330            psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type);
    315331            return false;
     
    384400    switch (file->type) {
    385401    case PM_FPA_FILE_IMAGE:
    386         if (pmFPAviewFreeFitsImage (view, file)) {
     402    case PM_FPA_FILE_MASK:
     403    case PM_FPA_FILE_WEIGHT:
     404    case PM_FPA_FILE_FRINGE:
     405        if (pmFPAviewFreeData(view, file)) {
    387406            psTrace ("pmFPAfile", 5, "freed %s for %s (type: %d)\n", file->filename, file->name, file->type);
    388407            if (file->filename == NULL) {
     
    394413        }
    395414        break;
    396     case PM_FPA_FILE_FRINGE:
    397         if (!pmFPAviewFreeFitsTable(view, file, "FRINGE")) {
    398             psError(PS_ERR_UNKNOWN, false, "Unable to free fringe data.\n");
    399             return false;
    400         }
    401         break;
    402 
    403415    case PM_FPA_FILE_SX:
    404416    case PM_FPA_FILE_RAW:
     
    469481    switch (file->type) {
    470482    case PM_FPA_FILE_IMAGE:
     483        pmFPAviewWriteFitsImage(view, file);
     484        psTrace ("pmFPAfile", 5, "wrote image %s (fpa: %p)\n", file->filename, file->fpa);
     485        break;
     486    case PM_FPA_FILE_MASK:
     487        pmFPAviewWriteFitsMask(view, file);
     488        psTrace ("pmFPAfile", 5, "wrote mask %s (fpa: %p)\n", file->filename, file->fpa);
     489        break;
     490    case PM_FPA_FILE_WEIGHT:
     491        pmFPAviewWriteFitsWeight(view, file);
     492        psTrace ("pmFPAfile", 5, "wrote weight %s (fpa: %p)\n", file->filename, file->fpa);
     493        break;
     494    case PM_FPA_FILE_FRINGE:
    471495        pmFPAviewWriteFitsImage (view, file);
    472496        psTrace ("pmFPAfile", 5, "wrote image %s (fpa: %p)\n", file->filename, file->fpa);
    473         break;
    474     case PM_FPA_FILE_FRINGE:
    475         pmFPAviewWriteFitsImage (view, file);
    476         psTrace ("pmFPAfile", 5, "wrote table %s (fpa: %p)\n", file->filename, file->fpa);
    477497        pmFPAviewWriteFitsTable(view, file, "FRINGE");
    478498        psTrace ("pmFPAfile", 5, "wrote fringe table %s (fpa: %p)\n", file->filename, file->fpa);
     
    554574    switch (file->type) {
    555575    case PM_FPA_FILE_IMAGE:
     576    case PM_FPA_FILE_MASK:
     577    case PM_FPA_FILE_WEIGHT:
    556578    case PM_FPA_FILE_FRINGE:
    557579        // create FPA structure component based on view
     
    608630        // check the FITS types
    609631    case PM_FPA_FILE_IMAGE:
     632    case PM_FPA_FILE_MASK:
     633    case PM_FPA_FILE_WEIGHT:
    610634    case PM_FPA_FILE_FRINGE:
    611635    case PM_FPA_FILE_CMF:
  • trunk/psModules/src/camera/pmHDU.c

    r9983 r10081  
    8585    if (!hdu->header) {
    8686        psTrace("psModules.camera", 5, "Reading the header...\n");
    87         hdu->header = psFitsReadHeader(NULL, fits);
     87        hdu->header = psFitsReadHeader(hdu->header, fits);
    8888        if (! hdu->header) {
    8989            psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname);
     
    9595}
    9696
     97// Read an HDU from a FITS file
    9798// XXX: Add a region specifier?
    98 bool pmHDURead(pmHDU *hdu, psFits *fits)
    99 {
    100     PS_ASSERT_PTR_NON_NULL(hdu, false);
    101     PS_ASSERT_PTR_NON_NULL(fits, false);
     99bool hduRead(pmHDU *hdu,                // HDU to write
     100             psArray **images,          // Images into which to read
     101             psFits *fits               // FITS file to read
     102            )
     103{
     104    assert(hdu);
     105    assert(images);
     106    assert(fits);
    102107
    103108    // Read the header; includes the move
     
    111116    }
    112117
    113     if (hdu->images) {
     118    if (*images) {
    114119        psLogMsg(__func__, PS_LOG_WARN, "HDU %s has already been read --- overwriting.\n", hdu->extname);
    115         psFree(hdu->images);        // Blow away anything existing
     120        psFree(*images);                // Blow away anything existing
    116121    }
    117122    psTrace("psModules.camera", 5, "Reading the pixels...\n");
    118     hdu->images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
    119     if (! hdu->images) {
     123    *images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
     124    if (!*images) {
    120125        psError(PS_ERR_IO, false, "Unable to read pixels for extension %s\n", hdu->extname);
    121126        return false;
     
    124129}
    125130
     131bool pmHDURead(pmHDU *hdu, psFits *fits)
     132{
     133    PS_ASSERT_PTR_NON_NULL(hdu, false);
     134    PS_ASSERT_PTR_NON_NULL(fits, false);
     135
     136    return hduRead(hdu, &hdu->images, fits);
     137}
     138
     139bool pmHDUReadMask(pmHDU *hdu, psFits *fits)
     140{
     141    PS_ASSERT_PTR_NON_NULL(hdu, false);
     142    PS_ASSERT_PTR_NON_NULL(fits, false);
     143
     144    return hduRead(hdu, &hdu->masks, fits);
     145}
     146
     147bool pmHDUReadWeight(pmHDU *hdu, psFits *fits)
     148{
     149    PS_ASSERT_PTR_NON_NULL(hdu, false);
     150    PS_ASSERT_PTR_NON_NULL(fits, false);
     151
     152    return hduRead(hdu, &hdu->weights, fits);
     153}
     154
    126155// Write an HDU to a FITS file
    127 bool hduWrite(pmHDU *hdu,               // HDU to write
    128               psArray *images,          // Images to write
    129               psFits *fits              // FITS file to which to write
    130              )
     156static bool hduWrite(pmHDU *hdu,        // HDU to write
     157                     psArray *images,   // Images to write
     158                     psFits *fits       // FITS file to which to write
     159                    )
    131160{
    132161    assert(hdu);
     
    182211}
    183212
     213bool pmHDUWriteWeight(pmHDU *hdu, psFits *fits)
     214{
     215    PS_ASSERT_PTR_NON_NULL(hdu, false);
     216    PS_ASSERT_PTR_NON_NULL(fits, false);
     217
     218    return hduWrite(hdu, hdu->weights, fits);
     219}
  • trunk/psModules/src/camera/pmHDU.h

    r9983 r10081  
    77/// @author Paul Price, IfA
    88///
    9 /// @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2006-11-15 00:40:02 $
     9/// @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2006-11-18 23:43:28 $
    1111///
    1212/// Copyright 2005-2006 Institute for Astronomy, University of Hawaii
     
    5151              );
    5252
     53/// Read the HDU header and mask
     54///
     55/// Moves to the appropriate extension
     56bool pmHDUReadMask(pmHDU *hdu,          ///< HDU to read
     57                   psFits *fits         ///< FITS file to read from
     58                  );
     59
     60/// Read the HDU header and weight map
     61///
     62/// Moves to the appropriate extension
     63bool pmHDUReadWeight(pmHDU *hdu,        ///< HDU to read
     64                     psFits *fits       ///< FITS file to read from
     65                    );
     66
    5367/// Write the HDU header and pixels
    5468bool pmHDUWrite(pmHDU *hdu,             ///< HDU to write
     
    5771
    5872/// Write the HDU header and mask
    59 bool pmHDUWriteMask(pmHDU *hdu,         ///< HDU to write mask
     73bool pmHDUWriteMask(pmHDU *hdu,         ///< HDU to write
    6074                    psFits *fits        ///< FITS file to write to
    6175                   );
    6276
     77/// Write the HDU header and weight map
     78bool pmHDUWriteWeight(pmHDU *hdu,       ///< HDU to write
     79                      psFits *fits      ///< FITS file to write to
     80                     );
     81
    6382#endif
Note: See TracChangeset for help on using the changeset viewer.