/** @file  psFitsHeader.h
 *
 *  @brief Contains Fits header I/O routines
 *
 *  @ingroup FileIO
 *
 *  @author Robert DeSonia, MHPCC
 *
 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-02-08 01:03:34 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifndef PS_FITSHEADER_H
#define PS_FITSHEADER_H

#include "psFits.h"
#include "psMetadata.h"

/// @addtogroup FileIO
/// @{

/** Reads the header of the current HDU.
 *
 *  @return psMetadata*   the header data
 */
psMetadata* psFitsReadHeader(
    psMetadata* out,
    ///< The psMetadata to add the header data.  If null, a new psMetadata is created.
    const psFits* fits                 ///< the psFits object
);

/** Reads the header of all HDUs.  The current HDU is not changed.
 *
 *  @return psMetadata*      the header data set as a number of metadata entries
 */
psMetadata* psFitsReadHeaderSet(
    const psFits* fits                       ///< the psFits object
);

/** Writes the values of the metadata to the current HDU header.
 *
 *  @return bool        if TRUE, the write was successful, otherwise FALSE.
 */
bool psFitsWriteHeader(
    const psMetadata* output,          ///< the psMetadata data in which to write
    psFits* fits                       ///< the psFits object
);

/** Updates the given header to be compatible with the supplied image, updating
 *  BITPIX, NAXIS1, and NAXIS2.  The extension name is (re)set to the given
 *  extname.
 *
 *  @return psMetadata*     updated header.
 */
psMetadata* psFitsHeaderFromImage(
    psMetadata* header,                ///< the header to update
    psImage* image,                    ///< the image to use to determine update values
    const char* extname                ///< the extension name
);

/** Updates the given header to be compatible with the given table, i.e. psArray
 *  of psMetadata. The extension name is (re)set to the given extname.
 */
psMetadata* psFitsHeaderFromTable(
    psMetadata* header,                ///< the header to update
    psArray* table,                    ///< the table to use to update header
    const char* extname                ///< the extension name
);

/// @}

#endif // #ifndef PS_FITS_H
