00001 /* @file psFits.h 00002 * @brief Contains Fits I/O routines 00003 * 00004 * @author Robert DeSonia, MHPCC 00005 * 00006 * @version $Revision: 1.26 $ $Name: $ 00007 * @date $Date: 2007/01/23 22:47:23 $ 00008 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00009 */ 00010 00011 #ifndef PS_FITS_H 00012 #define PS_FITS_H 00013 00014 /// @addtogroup FileIO Input/Output 00015 /// @{ 00016 00017 #include <fitsio.h> 00018 #include "psType.h" 00019 #include "psArray.h" 00020 #include "psVector.h" 00021 #include "psMetadata.h" 00022 #include "psImage.h" 00023 00024 /** FITS HDU type. 00025 * 00026 * Enumeration for FITS HDU type. 00027 * 00028 */ 00029 typedef enum { 00030 PS_FITS_TYPE_NONE = -1, ///< Unknown HDU type 00031 PS_FITS_TYPE_IMAGE = IMAGE_HDU, ///< Image HDU type 00032 PS_FITS_TYPE_BINARY_TABLE = BINARY_TBL, ///< Binary table HDU type 00033 PS_FITS_TYPE_ASCII_TABLE = ASCII_TBL, ///< ASCII table HDU type 00034 PS_FITS_TYPE_ANY = ANY_HDU ///< Any HDU type 00035 } psFitsType; 00036 00037 /** FITS file object. 00038 * 00039 * This object should be considered opaque to the user; no item in this 00040 * struct should be accessed directly. 00041 * 00042 */ 00043 typedef struct 00044 { 00045 fitsfile* fd; ///< the CFITSIO fits files handle. 00046 bool writable; ///< Is the file writable? 00047 } 00048 psFits; 00049 00050 /** Opens a FITS file and allocates the associated psFits object. 00051 * 00052 * @return psFits* new psFits object for the FITS files specified or 00053 * NULL if the open of the FITS file failed 00054 */ 00055 psFits* psFitsOpen( 00056 const char* filename, ///< the FITS file name 00057 const char* mode 00058 /**< File open mode. Could be one of the following: 00059 * 'r' (read only), 00060 * 'r+' (read & write), 00061 * 'rw' (same as 'r+'), or 00062 * 'w' (create new file for writing) 00063 */ 00064 ); 00065 00066 /** Closes a FITS file. 00067 * 00068 * @return bool TRUE if FITS file was successfully closed, otherwise FALSE 00069 */ 00070 bool psFitsClose( 00071 psFits* fits ///< psFits object to close 00072 ); 00073 00074 /** Checks the type of a particular pointer. 00075 * 00076 * Uses the appropriate deallocation function in psMemBlock to check the ptr 00077 * datatype. 00078 * 00079 * @return bool: True if the pointer matches a psFits structure, false 00080 * otherwise. 00081 */ 00082 bool psMemCheckFits( 00083 psPtr ptr ///< the pointer whose type to check 00084 ); 00085 00086 00087 /** Moves the FITS HDU to the specified extension name. 00088 * 00089 * @return bool TRUE if the extension name was found and move was 00090 * successful, otherwise FALSE 00091 */ 00092 bool psFitsMoveExtName( 00093 const psFits* fits, ///< the psFits object to move 00094 const char* extname ///< the extension name 00095 ); 00096 00097 /** Moves the FITS HDU to the specified extension number 00098 * 00099 * @return bool TRUE if the extension number was found and move was 00100 * successful, otherwise FALSE 00101 */ 00102 bool psFitsMoveExtNum( 00103 const psFits* fits, ///< the psFits object to move 00104 int extnum, ///< the extension number to move to (zero is primary HDU) 00105 bool relative ///< if true, extnum is a relative number to the current position 00106 ); 00107 00108 /** Moves the FITS HDU to the end of the file 00109 * 00110 * @return bool TRUE if the move was successful, otherwise FALSE 00111 */ 00112 bool psFitsMoveLast( 00113 psFits* fits ///< the psFits object to move 00114 ); 00115 00116 /** Get the current extension number, where 0 is the primary HDU. 00117 * 00118 * @return int Current HDU number of the psFits file or < 0 if an error 00119 * occurred. 00120 */ 00121 int psFitsGetExtNum( 00122 const psFits* fits ///< the psFits object 00123 ); 00124 00125 /** Get the current extension name. 00126 * 00127 * @return int Current HDU name of the psFits file or NULL if an 00128 * error occurred. 00129 */ 00130 psString psFitsGetExtName( 00131 const psFits* fits ///< the psFits object 00132 ); 00133 00134 /** Set the current extension's name 00135 * 00136 * @return bool TRUE if the extension was successfully set, otherwise FALSE. 00137 */ 00138 bool psFitsSetExtName( 00139 psFits* fits, ///< the psFits object 00140 const char* name ///< the extension name 00141 ); 00142 00143 /** Get the total number of HDUs in the FITS file. 00144 * 00145 * @return int The total number of HDUs in the FITS file or < 0 if an 00146 * error occurred. 00147 */ 00148 int psFitsGetSize( 00149 const psFits* fits ///< the psFits object 00150 ); 00151 00152 /** Remove the an HDU as specified by number 00153 * 00154 * @return bool TRUE if the specified HDU was removed, otherwise FALSE 00155 */ 00156 bool psFitsDeleteExtNum( 00157 psFits* fits, ///< the psFits object 00158 int extnum, ///< the extension number to delete (zero is primary HDU) 00159 bool relative ///< if true, extnum is a relative number to the current position 00160 ); 00161 00162 /** Remove the an HDU as specified by extension name 00163 * 00164 * @return bool TRUE if the specified HDU was removed, otherwise FALSE 00165 */ 00166 bool psFitsDeleteExtName( 00167 psFits* fits, ///< the psFits object 00168 const char* extname ///< the extension name to delete 00169 ); 00170 00171 /** Get the extension type of the current HDU. 00172 * 00173 * @return psFitsType The type of the current HDU. If PS_FITS_TYPE_UNKNOWN, 00174 * the type could not be determined. 00175 */ 00176 psFitsType psFitsGetExtType( 00177 const psFits* fits ///< the psFits object 00178 ); 00179 00180 /** Delete all extensions after the current position 00181 * 00182 * @return bool TRUE if the operation was successful, otherwise FALSE 00183 */ 00184 bool psFitsTruncate( 00185 psFits* fits ///< the psFits object 00186 ); 00187 00188 // Return the psLib type, given a cfitsio data type 00189 psDataType p_psFitsTypeFromCfitsio(int datatype // cfitsio data type 00190 ); 00191 00192 // Return the cfitsio data type, given a psLib type 00193 bool p_psFitsTypeToCfitsio(psDataType type, // psLib data type 00194 int* bitPix, // The corresponding BITPIX (returned) 00195 double* bZero, // The corresponding BZERO (returned) 00196 int* dataType// The corresponding cfitsio data type (returned) 00197 ); 00198 00199 /// @} 00200 #endif // #ifndef PS_FITS_H
1.5.1