IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7244


Ignore:
Timestamp:
May 30, 2006, 12:11:51 PM (20 years ago)
Author:
Paul Price
Message:

Fix for bug 759: Adding a filter to catch NaN, Inf and -Inf in FITS
headers. Due to a deficiency in cfitsio, fits_get_keytype reports
these as short int, which is its default, "I've no idea what this is"
type. We filter them out explicitly, and add them into the metadata
as F32 types.

File:
1 edited

Legend:

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

    r7236 r7244  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-05-27 02:09:47 $
     9 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-05-30 22:11:51 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1717#include "psFits.h"
    1818#include "string.h"
     19#include "strings.h"
    1920#include "psError.h"
    2021#include "psErrorText.h"
     
    109110            break;
    110111        case 'I': // short int.
    111             success = psMetadataAdd(out, PS_LIST_TAIL, keyName, PS_DATA_S16 | dupFlag, keyComment,
    112                                     (psS16)atoi(keyValue));
     112            // This is the default type that cfitsio reports whenever it doesn't know what it is.
     113            // Trap NAN, INF and -INF, which cfitsio doesn't handle.
     114            if (strncasecmp(keyValue, "nan", 3) == 0) {
     115                success = psMetadataAdd(out, PS_LIST_TAIL, keyName, PS_DATA_F32 | dupFlag, keyComment,
     116                                        (psF32)NAN);
     117            } else if (strncasecmp(keyValue, "inf", 3) == 0) {
     118                success = psMetadataAdd(out, PS_LIST_TAIL, keyName, PS_DATA_F32 | dupFlag, keyComment,
     119                                        (psF32)INFINITY);
     120            } else if (strncasecmp(keyValue, "-inf", 4) == 0) {
     121                success = psMetadataAdd(out, PS_LIST_TAIL, keyName, PS_DATA_F32 | dupFlag, keyComment,
     122                                        (psF32)-INFINITY);
     123            } else {
     124                success = psMetadataAdd(out, PS_LIST_TAIL, keyName, PS_DATA_S16 | dupFlag, keyComment,
     125                                        (psS16)atoi(keyValue));
     126            }
    113127            break;
    114128        case 'J': // int.
Note: See TracChangeset for help on using the changeset viewer.