IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 30, 2006, 7:18:05 PM (20 years ago)
Author:
Paul Price
Message:

Adding recurse option to pmFPAWrite, pmChipWrite. pixels option now only outputs an HDU if there's data there to output.

File:
1 edited

Legend:

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

    r7168 r7249  
    8484                 psFits *fits,          // FITS file to which to write
    8585                 psDB *db,              // Database handle for "concepts" update
    86                  bool pixels            // Write the pixels?
     86                 bool pixels            // Write the pixels, or only the PHU header?
    8787                )
    8888{
    8989    pmHDU *hdu = cell->hdu;             // The HDU
    90     if (hdu && ((!pixels && hdu->phu) || pixels)) {
    91         if (pixels && !hdu->images && !pmHDUGenerateForCell(cell)) {
    92             psError(PS_ERR_IO, false, "Unable to generate HDU for cell.\n");
    93             return false;
    94         }
    95         bool status = pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
    96                                           PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
    97         status &= pmHDUWrite(hdu, fits);
    98         if (!status) {
    99             psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n");
    100             return false;
    101         }
     90    if (!hdu) {
     91        return true;                    // We wrote every HDU that exists
    10292    }
    10393
    104     return true;
     94    bool success = true;                // Success of writing
     95    if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU
     96            (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForCell(cell) && hdu->images)))) { // Data
     97        success &= pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
     98                                       PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
     99        success &= pmHDUWrite(hdu, fits);
     100    }
     101
     102    if (!success) {
     103        psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n");
     104        return false;
     105    }
     106
     107    // No lower levels to which to recurse
     108
     109    return success;
    105110}
    106111
     
    109114                 psFits *fits,          // FITS file to which to write
    110115                 psDB *db,              // Database handle for "concepts" update
    111                  bool pixels            // Write the pixels?
     116                 bool pixels,           // Write the pixels, or only the PHU header?
     117                 bool recurse           // Recurse to lower levels?
    112118                )
    113119{
    114120    pmHDU *hdu = chip->hdu;             // The HDU
    115     if (hdu && ((!pixels && hdu->phu) || pixels)) {
    116         if (pixels && !hdu->images && !pmHDUGenerateForChip(chip)) {
    117             psError(PS_ERR_IO, false, "Unable to generate HDU for chip.\n");
    118             return false;
    119         }
    120         bool status = pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
    121                                           PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
    122         status &= pmHDUWrite(hdu, fits);
    123         if (!status) {
    124             psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n");
    125             return false;
    126         }
     121    if (!hdu) {
     122        return true;                    // We wrote every HDU that exists
    127123    }
    128124
    129125    bool success = true;                // Success of writing
    130     if (pixels) {
     126    if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU
     127            (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForChip(chip) && hdu->images)))) { // Data
     128        success &= pmConceptsWriteChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
     129                                       PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
     130        success &= pmHDUWrite(hdu, fits);
     131    }
     132
     133    if (!success) {
     134        psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n");
     135        return false;
     136    }
     137
     138    if (recurse) {
    131139        psArray *cells = chip->cells;       // Array of cells
    132140        for (int i = 0; i < cells->n; i++) {
    133141            pmCell *cell = cells->data[i];  // The cell of interest
    134             success |= pmCellWrite(cell, fits, db, true);
     142            success &= pmCellWrite(cell, fits, db, pixels);
    135143        }
    136144    }
     
    144152                psFits *fits,           // FITS file to which to write
    145153                psDB *db,               // Database handle for "concepts" update
    146                 bool pixels             // Write the pixels?
     154                bool pixels,            // Write the pixels, or only the PHU header?
     155                bool recurse            // Recurse to lower levels?
    147156               )
    148157{
    149158    pmHDU *hdu = fpa->hdu;              // The HDU
    150     if (hdu && ((!pixels && hdu->phu) || pixels)) {
    151         if (pixels && !hdu->images && !pmHDUGenerateForFPA(fpa)) {
    152             psError(PS_ERR_IO, false, "Unable to generate HDU for FPA.\n");
    153             return false;
    154         }
    155         bool status = pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
    156                                          PM_CONCEPT_SOURCE_DEFAULTS, NULL);
    157         status &= pmHDUWrite(hdu, fits);
    158         if (!status) {
    159             psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
    160             return false;
    161         }
     159    if (!hdu) {
     160        return true;                    // We wrote every HDU that exists
    162161    }
    163162
    164163    bool success = true;                // Success of writing
    165     if (pixels) {
     164    if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU
     165            (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForFPA(fpa) && hdu->images)))) { // Data
     166        success &= pmConceptsWriteFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA |
     167                                      PM_CONCEPT_SOURCE_DEFAULTS, NULL);
     168        success &= pmHDUWrite(hdu, fits);
     169    }
     170
     171    if (!success) {
     172        psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
     173        return false;
     174    }
     175
     176    if (recurse) {
    166177        psArray *chips = fpa->chips;        // Array of chips
    167178        for (int i = 0; i < chips->n; i++) {
    168179            pmChip *chip = chips->data[i];  // The chip of interest
    169             success |= pmChipWrite(chip, fits, db, true);
     180            success &= pmChipWrite(chip, fits, db, pixels, true);
    170181        }
    171182    }
Note: See TracChangeset for help on using the changeset viewer.