IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9604


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

Documenting pmHDU.[ch]

Location:
trunk/psModules/src/camera
Files:
2 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
  • trunk/psModules/src/camera/pmHDU.h

    r7717 r9604  
     1/// @file pmHDU.h
     2///
     3/// @brief Define a header data unit (from a FITS file), with functions to read and write
     4///
     5/// @ingroup Camera
     6///
     7/// @author Paul Price, IfA
     8///
     9/// @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2006-10-17 03:35:58 $
     11///
     12/// Copyright 2005-2006 Institute for Astronomy, University of Hawaii
     13///
     14
    115#ifndef PM_HDU_H
    216#define PM_HDU_H
    317
    4 // An instance of the FITS Header Data Unit
     18/// An instance of the FITS Header Data Unit
     19///
     20/// Of course, it is not an exact replica of a FITS HDU --- they have no mask and weight data, but these are
     21/// stored here for convenience --- it keeps all the relevant data about the image in one place.
    522typedef struct
    623{
    7     psString extname;                   // The extension name
    8     bool blankPHU;                      // Is this a blank FITS Primary Header Unit, i.e., no data?
    9     psMetadata *format;                 // The camera format
    10     psMetadata *header;                 // The FITS header, or NULL if primary for FITS; or section info
    11     psArray *images;                    // The pixel data
    12     psArray *weights;                   // The pixel data
    13     psArray *masks;                     // The pixel data
    14     psArray *table;                     // The table data
     24    psString extname;                   ///< The extension name
     25    bool blankPHU;                      ///< Is this a blank FITS Primary Header Unit, i.e., no data?
     26    psMetadata *format;                 ///< The camera format
     27    psMetadata *header;                 ///< The FITS header, or NULL if primary for FITS; or section info
     28    psArray *images;                    ///< The pixel data
     29    psArray *weights;                   ///< The pixel data
     30    psArray *masks;                     ///< The pixel data
    1531}
    1632pmHDU;
    1733
    1834
    19 // Allocators
     35/// Allocator for pmHDU
    2036pmHDU *pmHDUAlloc(const char *extname);
    2137
    22 // Read the header
    23 bool pmHDUReadHeader(pmHDU *hdu,        // HDU for which to read header
    24                      psFits *fits       // FITS file from which to read
     38/// Read the HDU header only
     39bool pmHDUReadHeader(pmHDU *hdu,        ///< HDU for which to read header
     40                     psFits *fits       ///< FITS file from which to read
    2541                    );
    2642
    27 // Read the HDU
    28 bool pmHDURead(pmHDU *hdu,              // HDU to read
    29                psFits *fits             // FITS file to read from
     43/// Read the HDU header and pixels
     44bool pmHDURead(pmHDU *hdu,              ///< HDU to read
     45               psFits *fits             ///< FITS file to read from
    3046              );
    3147
    32 // Write the HDU
    33 bool pmHDUWrite(pmHDU *hdu,             // HDU to write
    34                 psFits *fits            // FITS file to write to
     48/// Write the HDU header and pixels
     49bool pmHDUWrite(pmHDU *hdu,             ///< HDU to write
     50                psFits *fits            ///< FITS file to write to
    3551               );
    3652
Note: See TracChangeset for help on using the changeset viewer.