Changeset 19385 for trunk/psModules/src/camera/pmFPAWrite.c
- Timestamp:
- Sep 4, 2008, 10:21:35 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAWrite.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAWrite.c
r18177 r19385 36 36 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37 37 38 39 // Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required40 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell)41 {42 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU43 if (!hdu) {44 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU.\n");45 return false;46 }47 if (!hdu->header) {48 hdu->header = psMetadataAlloc();49 }50 bool mdok; // Status of MD lookup51 psMetadata *fileData = psMetadataLookupMetadata(&mdok, hdu->format, "FILE"); // File information52 if (!mdok || !fileData) {53 psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n");54 return false;55 }56 if (fpa) {57 const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS");58 if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) {59 const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");60 psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,61 "Observation identifier", fpaObs);62 }63 }64 65 if (fpa && !fpa->hdu && (chip || cell)) {66 const char *rule = psMetadataLookupStr(NULL, fileData, "CONTENT.RULE"); // How to define the CONTENT67 if (!rule) {68 psError(PS_ERR_UNKNOWN, false, "Unable to find CONTENT.RULE in FILE in camera format.");69 return false;70 }71 72 pmFPAview *view = pmFPAviewGenerate(fpa, chip, cell, NULL); // View for fpa, chip, cell73 psString content = pmFPANameFromRule(rule, fpa, view); // Content of this file, specified by the rule74 psFree(view);75 76 const char *contentKey = psMetadataLookupStr(NULL, fileData, "CONTENT"); // The CONTENT header keyword77 if (!contentKey) {78 psError(PS_ERR_UNKNOWN, false, "Unable to find CONTENT in FILE in the camera format.");79 psFree(content);80 return false;81 }82 83 psMetadataAddStr(hdu->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE, "Content of file", content);84 psFree(content); // Drop reference85 }86 87 return true;88 }89 90 38 // Return the appropriate image array for the given type 91 39 static psArray **appropriateImageArray(pmHDU *hdu, // HDU containing the image arrays … … 109 57 static bool appropriateWriteFunc(pmHDU *hdu, // HDU to write 110 58 psFits *fits, // FITS file to which to write 59 const pmConfig *config, // Configuration 111 60 fpaWriteType type // Type to write 112 61 ) … … 114 63 switch (type) { 115 64 case FPA_WRITE_TYPE_IMAGE: 116 return pmHDUWrite(hdu, fits );65 return pmHDUWrite(hdu, fits, config); 117 66 case FPA_WRITE_TYPE_MASK: 118 return pmHDUWriteMask(hdu, fits );67 return pmHDUWriteMask(hdu, fits, config); 119 68 case FPA_WRITE_TYPE_WEIGHT: 120 return pmHDUWriteWeight(hdu, fits );69 return pmHDUWriteWeight(hdu, fits, config); 121 70 default: 122 71 psAbort("Unknown write type: %x\n", type); … … 165 114 return false; 166 115 } 167 if (!appropriateWriteFunc(hdu, fits, type)) {116 if (!appropriateWriteFunc(hdu, fits, config, type)) { 168 117 psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n"); 169 118 return false; … … 215 164 return false; 216 165 } 217 if (!appropriateWriteFunc(hdu, fits, type)) {166 if (!appropriateWriteFunc(hdu, fits, config, type)) { 218 167 psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n"); 219 168 return false; … … 279 228 return false; 280 229 } 281 if (!appropriateWriteFunc(hdu, fits, type)) {230 if (!appropriateWriteFunc(hdu, fits, config, type)) { 282 231 psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n"); 283 232 return false; … … 305 254 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 306 255 256 // Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required 257 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell) 258 { 259 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU 260 if (!hdu) { 261 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU.\n"); 262 return false; 263 } 264 if (!hdu->header) { 265 hdu->header = psMetadataAlloc(); 266 } 267 bool mdok; // Status of MD lookup 268 psMetadata *fileData = psMetadataLookupMetadata(&mdok, hdu->format, "FILE"); // File information 269 if (!mdok || !fileData) { 270 psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n"); 271 return false; 272 } 273 if (fpa) { 274 const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS"); 275 if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) { 276 const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS"); 277 psMetadataAddStr(hdu->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE, 278 "Observation identifier", fpaObs); 279 } 280 } 281 282 if (fpa && !fpa->hdu && (chip || cell)) { 283 const char *rule = psMetadataLookupStr(NULL, fileData, "CONTENT.RULE"); // How to define the CONTENT 284 if (!rule) { 285 psError(PS_ERR_UNKNOWN, false, "Unable to find CONTENT.RULE in FILE in camera format."); 286 return false; 287 } 288 289 pmFPAview *view = pmFPAviewGenerate(fpa, chip, cell, NULL); // View for fpa, chip, cell 290 psString content = pmFPANameFromRule(rule, fpa, view); // Content of this file, specified by the rule 291 psFree(view); 292 293 const char *contentKey = psMetadataLookupStr(NULL, fileData, "CONTENT"); // The CONTENT header keyword 294 if (!contentKey) { 295 psError(PS_ERR_UNKNOWN, false, "Unable to find CONTENT in FILE in the camera format."); 296 psFree(content); 297 return false; 298 } 299 300 psMetadataAddStr(hdu->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE, "Content of file", content); 301 psFree(content); // Drop reference 302 } 303 304 return true; 305 } 306 307 307 bool pmReadoutWriteNext(pmReadout *readout, psFits *fits, int z) 308 308 { … … 347 347 return false; 348 348 } 349 psImage *image = readout->image; // The image from the HDU to write 349 psImage *image = readout->image; // The image from the HDU to write 350 // psImage *mask = readout->mask; // Corresponding mask image 350 351 if (readout->row0 == 0 && readout->col0 == 0 && z == 0) { 351 352 // Then we can assume that nothing has been written to the FITS file for now
Note:
See TracChangeset
for help on using the changeset viewer.
