Changeset 9604
- Timestamp:
- Oct 16, 2006, 5:35:58 PM (20 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmHDU.c
r9067 r9604 42 42 psFree(hdu->header); 43 43 psFree(hdu->images); 44 psFree(hdu->table);45 44 psFree(hdu->weights); 46 45 psFree(hdu->masks); … … 52 51 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 53 52 54 pmHDU *pmHDUAlloc(const char *extname // Extension name 55 ) 53 pmHDU *pmHDUAlloc(const char *extname) 56 54 { 57 55 pmHDU *hdu = psAlloc(sizeof(pmHDU)); … … 68 66 hdu->header = NULL; 69 67 hdu->images = NULL; 70 hdu->table = NULL;71 68 hdu->weights = NULL; 72 69 hdu->masks = NULL; … … 75 72 } 76 73 77 bool pmHDUReadHeader(pmHDU *hdu, // HDU for which to read header 78 psFits *fits // FITS file from which to read 79 ) 74 bool pmHDUReadHeader(pmHDU *hdu, psFits *fits) 80 75 { 81 76 PS_ASSERT_PTR_NON_NULL(hdu, false); … … 100 95 } 101 96 102 // Read the HDU103 97 // XXX: Add a region specifier? 104 bool pmHDURead(pmHDU *hdu, // HDU to read 105 psFits *fits // FITS file to read from 106 ) 98 bool pmHDURead(pmHDU *hdu, psFits *fits) 107 99 { 108 100 PS_ASSERT_PTR_NON_NULL(hdu, false); … … 119 111 } 120 112 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 138 116 } 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; 146 122 } 147 148 psError(PS_ERR_UNKNOWN, true, "No idea what this HDU consists of!\n"); 149 return false; 150 #endif 123 return true; 151 124 } 152 125 153 // Write the HDU154 126 // XXX: Add a region specifier? 155 bool pmHDUWrite(pmHDU *hdu, // HDU to write 156 psFits *fits // FITS file to write to 157 ) 127 bool pmHDUWrite(pmHDU *hdu, psFits *fits) 158 128 { 159 129 PS_ASSERT_PTR_NON_NULL(hdu, false); … … 188 158 } 189 159 190 #ifdef FITS_TABLES191 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 #else204 205 160 if (hdu->images) { 206 161 psTrace("psModules.camera", 9, "Writing pixels for %s\n", hdu->extname); … … 211 166 } 212 167 return true; 213 #endif214 168 } 215 169 -
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 1 15 #ifndef PM_HDU_H 2 16 #define PM_HDU_H 3 17 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. 5 22 typedef struct 6 23 { 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 15 31 } 16 32 pmHDU; 17 33 18 34 19 // Allocators35 /// Allocator for pmHDU 20 36 pmHDU *pmHDUAlloc(const char *extname); 21 37 22 // Read the header23 bool pmHDUReadHeader(pmHDU *hdu, // HDU for which to read header24 psFits *fits // FITS file from which to read38 /// Read the HDU header only 39 bool pmHDUReadHeader(pmHDU *hdu, ///< HDU for which to read header 40 psFits *fits ///< FITS file from which to read 25 41 ); 26 42 27 // Read the HDU28 bool pmHDURead(pmHDU *hdu, // HDU to read29 psFits *fits // FITS file to read from43 /// Read the HDU header and pixels 44 bool pmHDURead(pmHDU *hdu, ///< HDU to read 45 psFits *fits ///< FITS file to read from 30 46 ); 31 47 32 // Write the HDU33 bool pmHDUWrite(pmHDU *hdu, // HDU to write34 psFits *fits // FITS file to write to48 /// Write the HDU header and pixels 49 bool pmHDUWrite(pmHDU *hdu, ///< HDU to write 50 psFits *fits ///< FITS file to write to 35 51 ); 36 52
Note:
See TracChangeset
for help on using the changeset viewer.
