next up previous contents FITSIO Home
Next: 4.4 Image I/O Routines Up: 4 CFITSIO Routines Previous: 4.2 File Open/Close Routines   Contents

4.3 HDU-level Routines

The routines listed in this section operate on Header-Data Units (HDUs) in a file.

_______________________________________________________________
int fits_get_num_hdus(fitsfile *fptr, int *hdunum, int *status)
int fits_get_hdu_num(fitsfile *fptr,  int *hdunum)

The first routines returns the total number of HDUs in the FITS file, and the second routine returns the position of the currently opened HDU in the FITS file (starting with 1, not 0).

__________________________________________________________________________
int fits_movabs_hdu(fitsfile *fptr, int hdunum, int *hdutype, int *status)
int fits_movrel_hdu(fitsfile *fptr, int nmove,  int *hdutype, int *status)
int fits_movnam_hdu(fitsfile *fptr, int hdutype, char *extname,
                    int extver, int *status)

These routines enable you to move to a different HDU in the file. Most of the CFITSIO functions which read or write keywords or data operate only on the currently opened HDU in the file. The first routine moves to the specified absolute HDU number in the FITS file (the first HDU = 1), whereas the second routine moves a relative number of HDUs forward or backward from the currently open HDU. The hdutype parameter returns the type of the newly opened HDU, and will be equal to one of these symbolic constant values: IMAGE_HDU, ASCII_TBL, or BINARY_TBL. hdutype may be set to NULL if it is not needed. The third routine moves to the (first) HDU that matches the input extension type, name, and version number, as given by the XTENSION, EXTNAME (or HDUNAME) and EXTVER keywords. If the input value of extver = 0, then the version number will be ignored when looking for a matching HDU.

_________________________________________________________________
int fits_get_hdu_type(fitsfile *fptr,  int *hdutype, int *status)

Get the type of the current HDU in the FITS file: IMAGE_HDU, ASCII_TBL, or BINARY_TBL.

____________________________________________________________________
int fits_copy_hdu(fitsfile *infptr, fitsfile *outfptr, int morekeys,
                  int *status)
int fits_copy_file(fitsfile *infptr, fitsfile *outfptr, int previous,
                  int current, int following, > int *status)

The first routine copies the current HDU from the FITS file associated with infptr and appends it to the end of the FITS file associated with outfptr. Space may be reserved for morekeys additional keywords in the output header. The second routine copies any HDUs previous to the current HDU, and/or the current HDU, and/or any HDUs following the current HDU, depending on the value (True or False) of previous, current, and following, respectively. For example,

  fits_copy_file(infptr, outfptr, 0, 1, 1, &status);
will copy the current HDU and any HDUs that follow it from the input to the output file, but it will not copy any HDUs preceding the current HDU.


next up previous contents FITSIO Home
Next: 4.4 Image I/O Routines Up: 4 CFITSIO Routines Previous: 4.2 File Open/Close Routines   Contents