Changeset 6663 for branches/rel10_ifa/psModules/src/astrom/pmHDU.c
- Timestamp:
- Mar 21, 2006, 1:52:54 PM (20 years ago)
- File:
-
- 1 edited
-
branches/rel10_ifa/psModules/src/astrom/pmHDU.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmHDU.c
r6590 r6663 114 114 assert(fits); 115 115 116 psTrace(__func__, 7, "Writing HDU %s\n", hdu->extname); 117 116 118 if (hdu->images && hdu->table && !hdu->header) { 117 119 psError(PS_ERR_IO, true, "Both image and table data provided in HDU, but no header --- " … … 120 122 } 121 123 124 // Preserve the extension name, if it's the PHU 125 char *extname = hdu->extname; // The name of the extension 126 if (strcasecmp(extname, "PHU") == 0) { 127 bool mdok = true; // Status of MD lookup 128 extname = psMetadataLookupStr(&mdok, hdu->header, "EXTNAME"); 129 if (!mdok || strlen(extname) == 0) { 130 extname = ""; 131 } 132 } 133 134 if (!hdu->images && !psFitsWriteHeader(hdu->header, fits)) { 135 psError(PS_ERR_IO, false, "Unable to write header for extension %s\n", extname); 136 } 137 122 138 #ifdef FITS_TABLES 123 139 if (hdu->images && (!hdu->table || psFitsIsImage(hdu->header))) { 124 #endif 125 psFitsWriteImageCube(fits, hdu->header, hdu->images, hdu->extname); 140 psFitsWriteImageCube(fits, hdu->header, hdu->images, extname); 126 141 return true; 127 #ifdef FITS_TABLES128 129 142 } 130 143 … … 136 149 psError(PS_ERR_IO, true, "No idea what this HDU consists of!\n"); 137 150 return false; 151 #else 152 153 if (hdu->images) { 154 psTrace(__func__, 9, "Writing pixels for %s\n", hdu->extname); 155 if (!psFitsWriteImageCube(fits, hdu->header, hdu->images, extname)) { 156 psError(PS_ERR_IO, false, "Unable to write image to extension %s\n", hdu->extname); 157 return false; 158 } 159 } 160 return true; 138 161 #endif 139 162 } 140 163 141 142 143 #if 0144 145 146 147 148 // Read the PHU of a file149 static bool readPHU(pmCameraFile *file // File for which to read the PHU150 )151 {152 if (! file->phu) {153 if (! file->fits) {154 file->fits = psFitsOpen(file->name, "r");155 }156 (void)psFitsMoveExtNum(file->fits, 0, false);157 file->phu = psFitsReadHeader(NULL, file->fits);158 159 return true;160 }161 162 return false;163 }164 165 bool pmCameraFileFormat(pmCameraFile *file, // File to inspect166 psMetadata *camera // Camera description167 )168 {169 if (! camera) {170 return false;171 }172 173 readPHU(file);174 175 bool mdok = true; // Result of MD lookup176 psMetadata *formats = psMetadataLookupMD(&mdok, camera, "FORMATS"); // List of known formats177 if (! mdok || ! formats) {178 psLogMsg(__func__, PS_LOG_WARN, "Unable to find list of FORMATS in camera configuration!\n");179 return false;180 }181 182 bool result = false; // Result of search183 psMetadataIterator *formatsIter = psMetadataIteratorAlloc(formats, NULL); // Iterator for formats184 psMetadataItem *formatsItem = NULL; // Item from formats185 while ((formatsItem = psMetadataGetAndIncrement(formatsIter))) {186 if (formatsItem->type != PS_DATA_STRING) {187 psLogMsg(__func__, PS_LOG_WARN, "Entry not of type STR found in camera FORMATS list.\n");188 continue;189 }190 psTrace(__func__, 7, "Trying format file: %s\n", formatsItem->name);191 int numBadLines = 0; // Number of bad lines in file192 psMetadata *format = psMetadataConfigParse(NULL, &numBadLines, formatsItem->data.V, true);193 if (numBadLines > 0) {194 psLogMsg(__func__, PS_LOG_WARN, "%d bad lines found in %s.\n", formatsItem->name);195 }196 if (pmConfigValidateCamera(format, file->phu)) {197 file->format = format;198 result = true;199 psLogMsg(__func__, PS_LOG_INFO + 2, "File %s matches camera format file %s\n", file->name,200 formatsItem->data.V);201 break;202 }203 psFree(format);204 }205 psFree(formatsIter);206 207 return result;208 }209 210 211 bool pmConfigValidateCamera(const psMetadata *camera, const psMetadata *header);212 213 pmFPA *pmFPASourceFile(pmFPA *fpa, // FPA to which to add214 pmFile *file, // File to add215 const char *name, // Symbolic name for file, e.g., "INPUT", "OUTPUT", "TESTFILE"216 pmConfig *config // Configuration set217 )218 {219 assert(file);220 assert(name);221 222 if (! file->fits) {223 file->fits = psFitsOpen(file->name, "r");224 }225 if (! file->phu) {226 (void)psFitsMoveExtNum(file->fits, 0, false);227 file->phu = psFitsReadHeader(NULL, file->fits);228 }229 230 psMetadata *fileConfig = NULL; // The file configuration231 if (fpa && fpa->camera) {232 fpa233 234 bool pmConfigValidateCamera(const psMetadata *camera, const psMetadata *header);235 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
