Changeset 25002 for trunk/psLib/src/fits/psFitsHeader.c
- Timestamp:
- Aug 5, 2009, 3:13:53 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsHeader.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsHeader.c
r23376 r25002 147 147 return keyword; 148 148 } 149 150 149 151 150 bool psFitsCheckCompressedImagePHU(const psFits *fits, psMetadata *header) … … 497 496 static bool fitsWriteHeader(psFits *fits, // The FITS file handle 498 497 const psMetadata *output, // Metadata that is to be output into the FITS file 499 bool keyStarts // Write out the key starts? 498 bool keyStarts, // Write out the key starts? 499 bool phuImage // Are we writing a PHU image? 500 500 ) 501 501 { 502 502 int status = 0; // Status of cfitsio calls 503 int extnum = psFitsGetExtNum(fits); // Number of extension 503 504 bool simple = true; // If SIMPLE is T, then the file should conform to the FITS standard 504 505 psFitsCompressionType compress = psFitsCompressionGetType(fits); // Compression type 505 if (psFitsGetExtNum(fits) == 0) { 506 if (extnum == 0) { 507 506 508 // We allow the user to write SIMPLE, but it must be boolean 507 509 psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header … … 526 528 bool compressing = ((!fits->options || fits->options->conventions.compression) && 527 529 compress != PS_FITS_COMPRESS_NONE) ? true : false; // Are we compressing? 528 529 530 if (compressing) { 530 531 psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header … … 538 539 } 539 540 } 540 // int value = simple; // Temporary holder for boolean 541 // fits_update_key(fits->fd, TLOGICAL, "ZSIMPLE", &value, 542 // "Uncompressed file's conformance to FITS standard", &status); 541 if (simple && phuImage && extnum == 1) { 542 // ZSIMPLE is required for decompression with funpack, etc. For funpack to work, ZSIMPLE needs to 543 // go early in the FITS header (otherwise we get "Extension doesn't start with SIMPLE or XTENSION 544 // keyword."). We put it after ZIMAGE by reading ZIMAGE (which sets the insertion pointer) and 545 // then inserting ZSIMPLE. 546 char comment[FLEN_CARD]; // Comment for ZIMAGE; unused 547 int value; // Value for ZIMAGE; unused 548 fits_read_key(fits->fd, TLOGICAL, "ZIMAGE", &value, comment, &status); 549 fits_insert_key_log(fits->fd, "ZSIMPLE", simple, "Uncompressed file's conforms to FITS", &status); 550 } 543 551 } 544 552 … … 699 707 PS_ASSERT_METADATA_NON_NULL(output, false); 700 708 701 return fitsWriteHeader(fits, output, true); 709 return fitsWriteHeader(fits, output, true, false); 710 } 711 712 bool psFitsWriteHeaderImage(psFits *fits, 713 const psMetadata *output, 714 bool phuImage 715 ) 716 { 717 PS_ASSERT_FITS_NON_NULL(fits, false); 718 PS_ASSERT_FITS_WRITABLE(fits, false); 719 PS_ASSERT_METADATA_NON_NULL(output, false); 720 721 return fitsWriteHeader(fits, output, true, phuImage); 702 722 } 703 723 … … 733 753 } 734 754 735 if (output && !fitsWriteHeader(fits, output, false )) {755 if (output && !fitsWriteHeader(fits, output, false, false)) { 736 756 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 737 757 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
