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