GNU Astronomy Utilities


Next: , Previous: , Up: FITS files   [Contents][Index]


10.3.8.3 FITS HDUs

A FITS file can contain multiple HDUs/extensions. The functions in this section can be used to get basic information about the extensions or open them. Note that fitsfile is defined in CFITSIO’s fitsio.h which is automatically included by Gnuastro’s gnuastro/fits.h.

Function:
fitsfile *
gal_fits_open_to_write (char *filename)

If filename exists, open it and return the fitsfile pointer that corresponds to it. If filename doesn’t exist, the file will be created which contains a blank first extension and the pointer to its next extension will be returned.

Function:
size_t
gal_fits_hdu_num (char *filename)

Return the number of HDUs/extensions in filename.

Function:
int
gal_fits_hdu_format (char *filename, char *hdu)

Return the format of the HDU as one of CFITSIO’s recognized macros: IMAGE_HDU, ASCII_TBL, or BINARY_TBL.

Function:
fitsfile *
gal_fits_hdu_open (char *filename, char *hdu, int iomode)

Open the HDU/extension hdu from filename and return a pointer to CFITSIO’s fitsfile. iomode determines how the FITS file will be opened using CFITSIO’s macros: READONLY or READWRITE.

The string in hdu will be appended to filename in square brackets so CFITSIO only opens this extension. You can use any formatting for the hdu that is acceptable to CFITSIO. See the description under --hdu in Input/Output options for more.

Function:
fitsfile *
gal_fits_hdu_open_format (char *filename, char *hdu, int img0_tab1)

Open (in read-only format) the hdu HDU/extension of filename as an image or table. When img0_tab1 is 0(zero) but the HDU is a table, this function will abort with an error. It will also abort with an error when img0_tab1 is 1 (one), but the HDU is an image.

A FITS HDU may contain both tables or images. When your program needs one of these formats, you can call this function so if the user provided the wrong HDU/file, it will abort and inform the user that the file/HDU is has the wrong format.


Next: , Previous: , Up: FITS files   [Contents][Index]