Changeset 9604 for trunk/psModules/src/camera/pmHDU.c
- Timestamp:
- Oct 16, 2006, 5:35:58 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmHDU.c (modified) (8 diffs)
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
Note:
See TracChangeset
for help on using the changeset viewer.
