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

#ifndef PS_FITSIMAGE_H
#define PS_FITSIMAGE_H

#include "psFits.h"

#include "psType.h"
#include "psArray.h"
#include "psVector.h"
#include "psMetadata.h"
#include "psImage.h"

/// @addtogroup FileIO
/// @{

/** Reads an image, given the desired region and z-plane.
 *
 *  @return psImage*     the read image or NULL if there was an error.
 */
psImage* psFitsReadImage(
    const psFits* fits,                ///< the psFits object
    psRegion region,                   ///< the region in the FITS image to read
    int z                              ///< the z-plane in the FITS image cube to read
);

/** Writes an image, given the desired region and z-plane.
 *
 *  @return bool        TRUE is the write was successful, otherwise FALSE.
 */
bool psFitsWriteImage(
    psFits* fits,                      ///< the psFits object
    psMetadata* header,                ///< header items for the new HDU.  Can be NULL.
    const psImage* input,              ///< the image to output
    int depth,                         ///< the number of z-planes of the FITS image data cube
    const char *extname                ///< the extension name
);

/** Updates the FITS file image, given the desired region and z-plane.
 *
 *  @return bool        TRUE is the write was successful, otherwise FALSE.
 */
bool psFitsUpdateImage(
    psFits* fits,                      ///< the psFits object
    const psImage* input,              ///< the image to output
    int x0,                            ///< the x offset on the FITS image to write
    int y0,                            ///< the y offset on the FITS image to write
    int z                              ///< the z-planes of the FITS image data cube to write
);

/** Reads an image cube into an array of images
 *
 * @return psArray*     Array of images, or NULL if an error.
 */
psArray *psFitsReadImageCube(
    const psFits *fits,                 ///< The FITS file pointer
    psRegion region                     ///< Region in the image to read
);

/** Writes an image cube from an array of images
 *
 * @return bool          TRUE if the operation was successful; otherwise FALSE.
 */
bool psFitsWriteImageCube(
    psFits *fits,                       ///< The FITS file pointer
    psMetadata *header,                 ///< The FITS header, or NULL
    const psArray *input,               ///< The input array of images
    const char *extname                 ///< The extension name
);

/** Updates an image cube from an array of images
 *
 * @return bool          TRUE if the operation was successful; otherwise FALSE.
 */
bool psFitsUpdateImageCube(
    psFits *fits,                       ///< The FITS file pointer
    const psArray *input,               ///< The input array of images
    int x0,                             ///< The x offset on the FITS image
    int y0                              ///< The y offset on the FITS image
);

/// @}

#endif // #ifndef PS_FITS_H
