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.1.1.1 $ $Name: $ 00010 * @date $Date: 2005/09/14 20:42:48 $ 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* p_fd; ///< the CFITSIO fits files handle. 00051 const char* filename; ///< the filename of the fits file 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* psFitsAlloc( 00061 const char* name ///< the FITS file name 00062 ); 00063 00064 /** Checks the type of a particular pointer. 00065 * 00066 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 00067 * 00068 * @return bool: True if the pointer matches a psFits structure, false otherwise. 00069 */ 00070 bool psMemCheckFits( 00071 psPtr ptr ///< the pointer whose type to check 00072 ); 00073 00074 00075 /** Moves the FITS HDU to the specified extension name. 00076 * 00077 * @return psFitsType The HDU type, or PS_FITS_TYPE_NONE if move failed. 00078 */ 00079 bool psFitsMoveExtName( 00080 const psFits* fits, ///< the psFits object to move 00081 const char* extname ///< the extension name 00082 ); 00083 00084 /** Moves the FITS HDU to the specified extension number 00085 * 00086 * @return psFitsType The HDU type, or PS_FITS_TYPE_NONE if move failed. 00087 */ 00088 bool psFitsMoveExtNum( 00089 const psFits* fits, ///< the psFits object to move 00090 int extnum, ///< the extension number to move to (zero is primary HDU) 00091 bool relative ///< if true, extnum is a relative number to the current position 00092 ); 00093 00094 /** Get the current extension number, where 0 is the primary HDU. 00095 * 00096 * @return int Current HDU number of the psFits file or < 0 if an error 00097 * occurred. 00098 */ 00099 int psFitsGetExtNum( 00100 const psFits* fits ///< the psFits object 00101 ); 00102 00103 /** Get the current extension name. 00104 * 00105 * @return int Current HDU name of the psFits file or NULL if an 00106 * error occurred. 00107 */ 00108 psString psFitsGetExtName( 00109 const psFits* fits ///< the psFits object 00110 ); 00111 00112 /** Set the current extension's name 00113 * 00114 * @return bool TRUE if the extension was successfully set, otherwise FALSE. 00115 */ 00116 bool psFitsSetExtName( 00117 psFits* fits, ///< the psFits object 00118 const char* name ///< the extension name 00119 ); 00120 00121 /** Get the total number of HDUs in the FITS file. 00122 * 00123 * @return int The total number of HDUs in the FITS file or < 0 if an 00124 * error occurred. 00125 */ 00126 int psFitsGetSize( 00127 const psFits* fits ///< the psFits object 00128 ); 00129 00130 /** Get the extension type of the current HDU. 00131 * 00132 * @return psFitsType The type of the current HDU. If PS_FITS_TYPE_UNKNOWN, 00133 * the type could not be determined. 00134 */ 00135 psFitsType psFitsGetExtType( 00136 const psFits* fits ///< the psFits object 00137 ); 00138 00139 /** Reads the header of the current HDU. 00140 * 00141 * @return psMetadata* the header data 00142 */ 00143 psMetadata* psFitsReadHeader( 00144 psMetadata* out, 00145 ///< The psMetadata to add the header data. If null, a new psMetadata is created. 00146 00147 const psFits* fits ///< the psFits object 00148 ); 00149 00150 /** Reads the header of all HDUs. The current HDU is not changed. 00151 * 00152 * @return psMetadata* the header data set as a number of metadata entries 00153 */ 00154 psMetadata* psFitsReadHeaderSet( 00155 psMetadata* out, 00156 ///< The psMetadata to add the header data via psMetadata items. If null, a 00157 ///< new psMetadata is created. The keys of the psMetadata are the extension names 00158 ///< of the cooresponding HDUs. 00159 00160 const psFits* fits ///< the psFits object 00161 ); 00162 00163 /** Writes the values of the metadata to the current HDU header. 00164 * 00165 * @return bool if TRUE, the write was successful, otherwise FALSE. 00166 */ 00167 bool psFitsWriteHeader( 00168 const psMetadata* output, ///< the psMetadata data in which to write 00169 psFits* fits ///< the psFits object 00170 ); 00171 00172 /** Reads an image, given the desired region and z-plane. 00173 * 00174 * @return psImage* the read image or NULL if there was an error. 00175 */ 00176 psImage* psFitsReadImage( 00177 psImage* out, ///< a psImage to recycle. 00178 const psFits* fits, ///< the psFits object 00179 psRegion region, ///< the region in the FITS image to read 00180 int z ///< the z-plane in the FITS image cube to read 00181 ); 00182 00183 /** Writes an image, given the desired region and z-plane. 00184 * 00185 * @return bool TRUE is the write was successful, otherwise FALSE. 00186 */ 00187 bool psFitsWriteImage( 00188 psFits* fits, ///< the psFits object 00189 psMetadata* header, ///< header items for the new HDU. Can be NULL. 00190 const psImage* input, ///< the image to output 00191 int depth ///< the number of z-planes of the FITS image data cube 00192 ); 00193 00194 /** Updates the FITS file image, given the desired region and z-plane. 00195 * 00196 * @return bool TRUE is the write was successful, otherwise FALSE. 00197 */ 00198 bool psFitsUpdateImage( 00199 psFits* fits, ///< the psFits object 00200 const psImage* input, ///< the image to output 00201 psRegion region, ///< the region in the FITS image to write 00202 int z ///< the z-planes of the FITS image data cube to write 00203 ); 00204 00205 /** Reads a table row. The current HDU type must be either 00206 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00207 * 00208 * @return psMetadata* The table row's data. The keys are the column names. 00209 */ 00210 psMetadata* psFitsReadTableRow( 00211 const psFits* fits, ///< the psFits object 00212 int row ///< row number to read 00213 ); 00214 00215 /** Reads a table column. The current HDU type must be either 00216 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00217 * 00218 * @return psArray* Array of data items for the specified column or NULL 00219 * if an error occurred. 00220 */ 00221 psArray* psFitsReadTableColumn( 00222 const psFits* fits, ///< the psFits object 00223 const char* colname ///< the column name 00224 ); 00225 00226 /** Reads a table column of numbers. The current HDU type must be either 00227 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00228 * 00229 * @return psVector* Vector of data for the specified column or NULL 00230 * if an error occurred. 00231 */ 00232 psVector* psFitsReadTableColumnNum( 00233 const psFits* fits, ///< the psFits object 00234 const char* colname ///< the column name 00235 ); 00236 00237 00238 /** Reads a whole FITS table. The current HDU type must be either 00239 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00240 * 00241 * @return psArray* Array of psMetadata items, which contains the output 00242 * data items of each row. 00243 * 00244 * @see psFitsReadTableRow 00245 */ 00246 psArray* psFitsReadTable( 00247 psFits* fits ///< the psFits object 00248 ); 00249 00250 /** Writes a whole FITS table. The current HDU type must be either 00251 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00252 * 00253 * @return bool TRUE if the write was successful, otherwise FALSE 00254 * 00255 * @see psFitsReadTableRow 00256 */ 00257 bool psFitsWriteTable( 00258 psFits* fits, ///< the psFits object 00259 const psMetadata* header, ///< header items for the new HDU. Can be NULL. 00260 const psArray* table 00261 ///< Array of psMetadata items, which contains the output data items of each row. 00262 ); 00263 00264 /** Updates a FITS table. The current HDU type must be either 00265 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00266 * 00267 * @return bool TRUE if the write was successful, otherwise FALSE 00268 * 00269 * @see psFitsWriteTable 00270 */ 00271 bool psFitsUpdateTable( 00272 psFits* fits, ///< the psFits object 00273 const psMetadata* data, 00274 ///< Array of psMetadata items, which contains the output data items of each row. 00275 int row ///< the row number to update. 00276 ); 00277 00278 /// @} 00279 00280 #endif // #ifndef PS_FITS_H
1.4.2