IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 16, 2006, 5:35:58 PM (20 years ago)
Author:
Paul Price
Message:

Documenting pmHDU.[ch]

File:
1 edited

Legend:

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

    r9067 r9604  
    4242    psFree(hdu->header);
    4343    psFree(hdu->images);
    44     psFree(hdu->table);
    4544    psFree(hdu->weights);
    4645    psFree(hdu->masks);
     
    5251//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    5352
    54 pmHDU *pmHDUAlloc(const char *extname   // Extension name
    55                  )
     53pmHDU *pmHDUAlloc(const char *extname)
    5654{
    5755    pmHDU *hdu = psAlloc(sizeof(pmHDU));
     
    6866    hdu->header  = NULL;
    6967    hdu->images  = NULL;
    70     hdu->table   = NULL;
    7168    hdu->weights = NULL;
    7269    hdu->masks   = NULL;
     
    7572}
    7673
    77 bool pmHDUReadHeader(pmHDU *hdu,        // HDU for which to read header
    78                      psFits *fits       // FITS file from which to read
    79                     )
     74bool pmHDUReadHeader(pmHDU *hdu, psFits *fits)
    8075{
    8176    PS_ASSERT_PTR_NON_NULL(hdu, false);
     
    10095}
    10196
    102 // Read the HDU
    10397// XXX: Add a region specifier?
    104 bool pmHDURead(pmHDU *hdu,              // HDU to read
    105                psFits *fits             // FITS file to read from
    106               )
     98bool pmHDURead(pmHDU *hdu, psFits *fits)
    10799{
    108100    PS_ASSERT_PTR_NON_NULL(hdu, false);
     
    119111    }
    120112
    121     #ifdef FITS_TABLES
    122     // What type is it?
    123     if (psFitsIsImage(hdu->header)) {
    124         #endif
    125         if (hdu->images) {
    126             psLogMsg(__func__, PS_LOG_WARN, "HDU %s has already been read --- overwriting.\n", hdu->extname);
    127             psFree(hdu->images);        // Blow away anything existing
    128         }
    129         psTrace("psModules.camera", 5, "Reading the pixels...\n");
    130         hdu->images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
    131         if (! hdu->images) {
    132             psError(PS_ERR_IO, false, "Unable to read pixels for extension %s\n", hdu->extname);
    133             return false;
    134         }
    135         return true;
    136         #ifdef FITS_TABLES
    137 
     113    if (hdu->images) {
     114        psLogMsg(__func__, PS_LOG_WARN, "HDU %s has already been read --- overwriting.\n", hdu->extname);
     115        psFree(hdu->images);        // Blow away anything existing
    138116    }
    139     if (psFitsIsTable(hdu->table)) {
    140         // Read the table
    141         if (hdu->table) {
    142             psFree(hdu->table);         // Blow away anything existing
    143         }
    144         hdu->table = psFitsReadTable(fits);
    145         return true;
     117    psTrace("psModules.camera", 5, "Reading the pixels...\n");
     118    hdu->images = psFitsReadImageCube(fits, psRegionSet(0,0,0,0));
     119    if (! hdu->images) {
     120        psError(PS_ERR_IO, false, "Unable to read pixels for extension %s\n", hdu->extname);
     121        return false;
    146122    }
    147 
    148     psError(PS_ERR_UNKNOWN, true, "No idea what this HDU consists of!\n");
    149     return false;
    150     #endif
     123    return true;
    151124}
    152125
    153 // Write the HDU
    154126// XXX: Add a region specifier?
    155 bool pmHDUWrite(pmHDU *hdu,             // HDU to write
    156                 psFits *fits            // FITS file to write to
    157                )
     127bool pmHDUWrite(pmHDU *hdu, psFits *fits)
    158128{
    159129    PS_ASSERT_PTR_NON_NULL(hdu, false);
     
    188158    }
    189159
    190     #ifdef FITS_TABLES
    191     if (hdu->images && (!hdu->table || psFitsIsImage(hdu->header))) {
    192         psFitsWriteImageCube(fits, hdu->header, hdu->images, extname);
    193         return true;
    194     }
    195 
    196     if (hdu->table && (!hdu->images || psFitsIsTable(hdu->header))) {
    197         bool psFitsWriteTable(psFits* fits, const psMetadata *header, const psArray* table);
    198         return true;
    199     }
    200 
    201     psError(PS_ERR_IO, true, "No idea what this HDU consists of!\n");
    202     return false;
    203     #else
    204 
    205160    if (hdu->images) {
    206161        psTrace("psModules.camera", 9, "Writing pixels for %s\n", hdu->extname);
     
    211166    }
    212167    return true;
    213     #endif
    214168}
    215169
Note: See TracChangeset for help on using the changeset viewer.