IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7245


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

Removed psMetadataReadHeader --- this function is no longer in the SDRS, and its functionality has been replaced by psFitsReadHeader.

Location:
trunk/psLib/src/types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r7148 r7245  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-05-19 03:25:26 $
     12*  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-05-30 22:18:39 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    511511
    512512    return success;
    513 }
    514 
    515 
    516 psMetadata* psMetadataReadHeader(psMetadata* output,
    517                                  char *extName,
    518                                  psS32 extNum,
    519                                  char *fileName)
    520 {
    521     psBool tempBool;
    522     psBool success;
    523     char keyType;
    524     char keyName[FITS_LINE_SIZE];
    525     char keyValue[FITS_LINE_SIZE];
    526     char keyComment[FITS_LINE_SIZE];
    527     char fitsErr[MAX_STRING_LENGTH];
    528     psS32 i;
    529     psS32 hduType = 0;
    530     psS32 status = 0;
    531     psS32 numKeys = 0;
    532     psS32 keyNum = 0;
    533     fitsfile *fd = NULL;
    534 
    535     PS_ASSERT_PTR_NON_NULL(fileName,NULL);
    536 
    537     fits_open_file(&fd, fileName, READONLY, &status);
    538     if(fd == NULL || status != 0) {
    539         FITS_ERROR("FITS error while opening file: %s %s", fileName);
    540         return NULL;
    541     }
    542 
    543     if (extName == NULL && extNum < 1) {
    544         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    545                 PS_ERRORTEXT_psMetadataIO_EXTNUM_NOTPOSITIVE,
    546                 extNum);
    547         return NULL;
    548     }
    549 
    550     // Allocate metadata if user didn't
    551     if (output == NULL) {
    552         output = psMetadataAlloc();
    553     }
    554 
    555     // Move to user designated HDU number or HDU name in FITS file. HDU numbers starts at one.
    556     if (extName != NULL) {
    557         if (fits_movnam_hdu(fd, ANY_HDU, extName, 0, &status) != 0) {
    558             FITS_ERROR("FITS error while locating header %s: %s", extName);
    559         }
    560     } else {
    561         if (fits_movabs_hdu(fd, extNum, &hduType, &status) != 0) {
    562             FITS_ERROR("FITS error while locating header %d: %s", extNum);
    563         }
    564     }
    565 
    566     // Get number of key names
    567     if (fits_get_hdrpos(fd, &numKeys, &keyNum, &status) != 0) {
    568         FITS_ERROR("FITS error while reading key %d: %s", keyNum);
    569     }
    570 
    571     // Get each key name. Keywords start at one.
    572     for (i = 1; i <= numKeys; i++) {
    573         if (fits_read_keyn(fd, i, keyName, keyValue, keyComment, &status) != 0) {
    574             FITS_ERROR("FITS error while reading key %d: %s", keyNum);
    575         }
    576         if (fits_get_keytype(keyValue, &keyType, &status) != 0) {
    577             fits_get_errstatus(status, fitsErr);
    578             if (status != VALUE_UNDEFINED) {
    579                 FITS_ERROR("FITS error while determining key %d type: %s", keyNum);
    580             } else {
    581                 // Some keywords are still valid if they don't have a type (like COMMENTS and HISTORY)
    582                 keyType = 'C';
    583                 status = 0;
    584             }
    585         }
    586 
    587         switch (keyType) {
    588         case 'I':
    589             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    590                                     PS_DATA_S32 | PS_META_DUPLICATE_OK,
    591                                     keyComment, atoi(keyValue));
    592             break;
    593         case 'F':
    594             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    595                                     PS_DATA_F64 | PS_META_DUPLICATE_OK,
    596                                     keyComment, atof(keyValue));
    597             break;
    598         case 'C':
    599             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    600                                     PS_DATA_STRING | PS_META_DUPLICATE_OK,
    601                                     keyComment, keyValue);
    602             break;
    603         case 'L':
    604             tempBool = (keyValue[0] == 'T') ? 1 : 0;
    605             success = psMetadataAdd(output, PS_LIST_TAIL, keyName,
    606                                     PS_DATA_BOOL | PS_META_DUPLICATE_OK,
    607                                     keyComment, tempBool);
    608             break;
    609         case 'U':
    610         case 'X':
    611         default:
    612             psError(PS_ERR_IO, true, PS_ERRORTEXT_psMetadataIO_FITS_METATYPE_INVALID, keyType);
    613             return output;
    614         }
    615 
    616         if (!success) {
    617             psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psMetadataIO_ADD_FAILED, keyName);
    618             return output;
    619         }
    620     }
    621 
    622     return output;
    623513}
    624514
  • trunk/psLib/src/types/psMetadataConfig.h

    r4870 r7245  
    1010 *  @author Robert DeSonia, MHPCC
    1111 *
    12  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-08-24 22:00:53 $
     12 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-05-30 22:18:39 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5959);
    6060
    61 /** Read metadata header.
    62  *
    63  *  Read a metadata header from file. If the file is not found, an error is
    64  *  reported.
    65  *
    66  *  @return psMetadata* : Pointer to resulting metadata.
    67  */
    68 psMetadata* psMetadataReadHeader(
    69     psMetadata* output,                ///< Resulting metadata from read.
    70     char *extName,                     ///< File name extension string.
    71     psS32 extNum,                      ///< File name extension number. Starts at 1.
    72     char *fileName                     ///< Name of file to read.
    73 );
    74 
    7561/** Read metadata configuration file.
    7662 *
Note: See TracChangeset for help on using the changeset viewer.