IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2006, 10:59:57 AM (20 years ago)
Author:
Paul Price
Message:

SIMPLE may not be at the start of the header (for some reason), so
check for it explicitly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsHeader.c

    r7295 r7297  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-06-02 19:50:48 $
     9 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-06-02 20:59:57 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3636
    3737// List of FITS header keys not to write (handled by cfitsio); NULL-terminated
    38 static char *noWriteFitsKeys[] = {"XTENSION", "BITPIX", "NAXIS", "EXTNAME", "BSCALE", "BZERO",
     38static char *noWriteFitsKeys[] = {"SIMPLE", "XTENSION", "BITPIX", "NAXIS", "EXTNAME", "BSCALE", "BZERO",
    3939                                  "TFIELDS", NULL};
    4040// List of the start of FITS header keys not to write (handled by cfitsio); NULL-terminated
     
    250250                           )
    251251{
     252    int status = 0;                     // Status of cfitsio calls
     253    bool simple = true;                 // If SIMPLE is T, then the file should conform to the FITS standard
     254    psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header
     255    if (simpleItem) {
     256        // We allow the user to write SIMPLE, but it must be boolean
     257        if (simpleItem->type != PS_DATA_BOOL) {
     258            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
     259                    "not %x --- assuming TRUE.\n", simpleItem->type);
     260            int value = false;          // Temporary holder for boolean
     261            fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
     262                            "File does not conform to FITS standard", &status);
     263            simple = false;
     264        } else if (!simpleItem->data.B) {
     265            simple = false;
     266            int value = false;          // Temporary holder for boolean
     267            fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
     268                            "File does not conform to FITS standard", &status);
     269        }
     270        // SIMPLE = T is taken care of by cfitsio.
     271    }
     272
    252273    // Traverse the metadata list and add each key.
    253274    psListIterator* iter = psListIteratorAlloc(output->list, PS_LIST_HEAD, true); // Iterator
    254275    psMetadataItem* item;               // Item from iteration
    255     int status = 0;                     // Status of cfitsio calls
    256     bool simple = true;                 // If SIMPLE is T, then the file should conform to the FITS standard
    257276    while ((item = psListGetAndIncrement(iter))) {
    258         // We allow the user to write SIMPLE, but it must be boolean
    259         if (strcmp(item->name, "SIMPLE") == 0) {
    260             if (item->type != PS_DATA_BOOL) {
    261                 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
    262                         "not %x --- assuming FALSE.\n", item->type);
    263                 int value = false;      // Temporary
    264                 fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
    265                                 "File does not conform to FITS standard", &status);
    266                 simple = false;
    267                 continue;
    268             } else if (! item->data.B) {
    269                 simple = false;
    270             }
    271         }
    272 
    273277        // Check to see if the item should be ignored
    274278        if (simple) {
Note: See TracChangeset for help on using the changeset viewer.