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.10 $ $Name: rel5_0 $ 00010 * @date $Date: 2005/03/24 23:52:25 $ 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 "psHash.h" 00025 #include "psImage.h" 00026 00027 /// @addtogroup FileIO 00028 /// @{ 00029 00030 typedef enum { 00031 PS_FITS_TYPE_NONE = -1, 00032 PS_FITS_TYPE_IMAGE = IMAGE_HDU, 00033 PS_FITS_TYPE_BINARY_TABLE = BINARY_TBL, 00034 PS_FITS_TYPE_ASCII_TABLE = ASCII_TBL, 00035 PS_FITS_TYPE_ANY = ANY_HDU 00036 } psFitsType; 00037 00038 /** FITS file object. 00039 * 00040 * This object should be considered opaque to the user; no item in this 00041 * struct should be accessed directly. 00042 * 00043 */ 00044 typedef struct 00045 { 00046 fitsfile* p_fd; ///< the CFITSIO fits files handle. 00047 const char* filename; ///< the filename of the fits file 00048 } 00049 psFits; 00050 00051 /** Opens a FITS file and allocates the associated psFits object. 00052 * 00053 * @return psFits* new psFits object for the FITS files specified or 00054 * NULL if the open of the FITS file failed 00055 */ 00056 psFits* psFitsAlloc( 00057 const char* name ///< the FITS file name 00058 ); 00059 00060 /** Moves the FITS HDU to the specified extension name. 00061 * 00062 * @return psFitsType The HDU type, or PS_FITS_TYPE_NONE if move failed. 00063 */ 00064 bool psFitsMoveExtName( 00065 const psFits* fits, ///< the psFits object to move 00066 const char* extname ///< the extension name 00067 ); 00068 00069 /** Moves the FITS HDU to the specified extension number 00070 * 00071 * @return psFitsType The HDU type, or PS_FITS_TYPE_NONE if move failed. 00072 */ 00073 bool psFitsMoveExtNum( 00074 const psFits* fits, ///< the psFits object to move 00075 int extnum, ///< the extension number to move to (zero is primary HDU) 00076 bool relative ///< if true, extnum is a relative number to the current position 00077 ); 00078 00079 /** Get the current extension number, where 0 is the primary HDU. 00080 * 00081 * @return int Current HDU number of the psFits file or < 0 if an error 00082 * occurred. 00083 */ 00084 int psFitsGetExtNum( 00085 const psFits* fits ///< the psFits object 00086 ); 00087 00088 /** Get the current extension name. 00089 * 00090 * @return int Current HDU name of the psFits file or NULL if an 00091 * error occurred. 00092 */ 00093 char* psFitsGetExtName( 00094 const psFits* fits ///< the psFits object 00095 ); 00096 00097 /** Set the current extension's name 00098 * 00099 * @return bool TRUE if the extension was successfully set, otherwise FALSE. 00100 */ 00101 bool psFitsSetExtName( 00102 const psFits* fits, ///< the psFits object 00103 const char* name ///< the extension name 00104 ); 00105 00106 /** Get the total number of HDUs in the FITS file. 00107 * 00108 * @return int The total number of HDUs in the FITS file or < 0 if an 00109 * error occurred. 00110 */ 00111 int psFitsGetSize( 00112 const psFits* fits ///< the psFits object 00113 ); 00114 00115 /** Get the extension type of the current HDU. 00116 * 00117 * @return psFitsType The type of the current HDU. If PS_FITS_TYPE_UNKNOWN, 00118 * the type could not be determined. 00119 */ 00120 psFitsType psFitsGetExtType( 00121 const psFits* fits ///< the psFits object 00122 ); 00123 00124 /** Reads the header of the current HDU. 00125 * 00126 * @return psMetadata* the header data 00127 */ 00128 psMetadata* psFitsReadHeader( 00129 psMetadata* out, 00130 ///< The psMetadata to add the header data. If null, a new psMetadata is created. 00131 00132 const psFits* fits ///< the psFits object 00133 ); 00134 00135 /** Reads the header of all HDUs. The current HDU is not changed. 00136 * 00137 * @return psHash* the header data 00138 */ 00139 psHash* psFitsReadHeaderSet( 00140 psHash* out, 00141 ///< The psHash to add the header data via psMetadata items. If null, a 00142 ///< new psHash is created. The keys of the psHash are the extension names 00143 ///< of the cooresponding HDUs. 00144 00145 const psFits* fits ///< the psFits object 00146 ); 00147 00148 /** Writes the values of the metadata to the current HDU header. 00149 * 00150 * @return bool if TRUE, the write was successful, otherwise FALSE. 00151 */ 00152 bool psFitsWriteHeader( 00153 const psMetadata* header, ///< the psMetadata data in which to write 00154 const psFits* fits ///< the psFits object 00155 ); 00156 00157 /** Reads an image, given the desired region and z-plane. 00158 * 00159 * @return psImage* the read image or NULL if there was an error. 00160 */ 00161 psImage* psFitsReadImage( 00162 psImage* out, ///< a psImage to recycle. 00163 const psFits* fits, ///< the psFits object 00164 psRegion region, ///< the region in the FITS image to read 00165 int z ///< the z-plane in the FITS image cube to read 00166 ); 00167 00168 /** Writes an image, given the desired region and z-plane. 00169 * 00170 * @return bool TRUE is the write was successful, otherwise FALSE. 00171 */ 00172 bool psFitsWriteImage( 00173 const psFits* fits, ///< the psFits object 00174 const psMetadata* header, ///< header items for the new HDU. Can be NULL. 00175 const psImage* input, ///< the image to output 00176 int depth, ///< the number of z-planes of the FITS image data cube 00177 char* extname ///< extension name 00178 ); 00179 00180 /** Updates the FITS file image, given the desired region and z-plane. 00181 * 00182 * @return bool TRUE is the write was successful, otherwise FALSE. 00183 */ 00184 bool psFitsUpdateImage( 00185 const psFits* fits, ///< the psFits object 00186 const psImage* input, ///< the image to output 00187 psRegion region, ///< the region in the FITS image to write 00188 int z ///< the z-planes of the FITS image data cube to write 00189 ); 00190 00191 /** Reads a table row. The current HDU type must be either 00192 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00193 * 00194 * @return psMetadata* The table row's data. The keys are the column names. 00195 */ 00196 psMetadata* psFitsReadTableRow( 00197 const psFits* fits, ///< the psFits object 00198 int row ///< row number to read 00199 ); 00200 00201 /** Reads a table column. The current HDU type must be either 00202 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00203 * 00204 * @return psArray* Array of data items for the specified column or NULL 00205 * if an error occurred. 00206 */ 00207 psArray* psFitsReadTableColumn( 00208 const psFits* fits, ///< the psFits object 00209 const char* colname ///< the column name 00210 ); 00211 00212 /** Reads a table column of numbers. The current HDU type must be either 00213 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00214 * 00215 * @return psVector* Vector of data for the specified column or NULL 00216 * if an error occurred. 00217 */ 00218 psVector* psFitsReadTableColumnNum( 00219 const psFits* fits, ///< the psFits object 00220 const char* colname ///< the column name 00221 ); 00222 00223 00224 /** Reads a whole FITS table. The current HDU type must be either 00225 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00226 * 00227 * @return psArray* Array of psMetadata items, which contains the output 00228 * data items of each row. 00229 * 00230 * @see psFitsReadTableRow 00231 */ 00232 psArray* psFitsReadTable( 00233 const psFits* fits ///< the psFits object 00234 ); 00235 00236 /** Writes a whole FITS table. The current HDU type must be either 00237 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00238 * 00239 * @return bool TRUE if the write was successful, otherwise FALSE 00240 * 00241 * @see psFitsReadTableRow 00242 */ 00243 bool psFitsWriteTable( 00244 const psFits* fits, ///< the psFits object 00245 psMetadata* header, ///< header items for the new HDU. Can be NULL. 00246 psArray* table, 00247 ///< Array of psMetadata items, which contains the output data items of each row. 00248 char* extname ///< extension name 00249 ); 00250 00251 00252 /** Updates a FITS table. The current HDU type must be either 00253 * PS_FITS_TYPE_BINARY_TABLE or PS_FITS_TYPE_ASCII_TABLE. 00254 * 00255 * @return bool TRUE if the write was successful, otherwise FALSE 00256 * 00257 * @see psFitsWriteTable 00258 */ 00259 bool psFitsUpdateTable( 00260 const psFits* fits, ///< the psFits object 00261 psMetadata* data, 00262 ///< Array of psMetadata items, which contains the output data items of each row. 00263 int row ///< the row number to update. 00264 ); 00265 00266 /// @} 00267 00268 #endif
1.3.9.1