IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 25, 2004, 10:21:41 AM (22 years ago)
Author:
harman
Message:

Removed FReadHeader function and added ReadHeader function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psMetadata.c

    r1546 r1621  
    1212*  @author Ross Harman, MHPCC
    1313*
    14 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2004-08-14 02:55:46 $
     14*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2004-08-25 20:21:25 $
    1616*
    1717*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3939/******************************************************************************/
    4040
    41 #define FITS_ERROR(STRING,PS_ERROR)                  \
    42 fits_get_errstatus(status, fitsErr);             \
    43 psError( __func__, STRING, PS_ERROR, fitsErr);   \
    44 status = 0;                                      \
     41#define FITS_ERROR(STRING,PS_ERROR)                                                                          \
     42fits_get_errstatus(status, fitsErr);                                                                     \
     43psError(__func__, STRING, PS_ERROR, fitsErr);                                                            \
     44status = 0;                                                                                              \
     45fits_close_file(fd, &status);                                                                            \
     46if(status){                                                                                              \
     47    fits_get_errstatus(status, fitsErr);                                                                  \
     48    psError(__func__, "Couldn't close FITS file. FITS error: %s", fitsErr);                               \
     49}                                                                                                        \
     50status = 0;                                                                                              \
    4551return output;
    4652
     
    657663}
    658664
    659 psMetadata* psMetadataFReadHeader(psMetadata* output, char *extName, int extNum, fitsfile * fd)
     665psMetadata* psMetadataReadHeader(psMetadata* output, char *extName, int extNum, char *fileName)
    660666{
    661667    bool tempBool;
     
    672678    int keyNum = 0;
    673679    psMetadataType metadataItemType;
    674 
    675     if (fd == NULL) {
    676         psError(__func__, "Null FITS file descriptor not allowed");
     680    fitsfile *fd = NULL;
     681
     682    if(fileName == NULL) {
     683        psError(__func__, "Null fileName not allowed");
     684        return NULL;
     685    }
     686
     687    fits_open_file(&fd, fileName, READONLY, &status);
     688    if(fd == NULL || status != 0) {
     689        FITS_ERROR("FITS error while opening file: %s %s", fileName);
    677690        return NULL;
    678691    }
     
    685698        return NULL;
    686699    }
     700
    687701    // Allocate metadata if user didn't
    688702    if (output == NULL) {
    689703        output = psMetadataAlloc();
    690704    }
     705
    691706    // Move to user designated HDU number or HDU name in FITS file. HDU numbers starts at one.
    692707    if (extName != NULL) {
     
    704719        FITS_ERROR("FITS error while reading key %d: %s", keyNum);
    705720    }
     721
    706722    // Get each key name. Keywords start at one.
    707723    for (i = 1; i <= numKeys; i++) {
     
    714730                FITS_ERROR("FITS error while determining key %d type: %s", keyNum);
    715731            } else {
    716                 // Some keywords are still valid even though they don't have a type, like COMMENTS and
    717                 // HISTORY
     732                // Some keywords are still valid if they don't have a type (like COMMENTS and HISTORY)
    718733                keyType = 'C';
    719734                status = 0;
Note: See TracChangeset for help on using the changeset viewer.