Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psFits.h

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

Generated on Thu Oct 13 14:32:52 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2