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