GNU Astronomy Utilities

Next: , Previous: , Up: FITS files (fits.h)   [Contents][Index] FITS Macros, errors and filenames

Some general constructs provided by Gnuastro’s FITS handling functions are discussed here. In particular there are several useful functions about FITS file names.


The maximum number of dimensions a dataset can have in FITS format, according to the FITS standard this is 999.

gal_fits_io_error (int status, char *message)

If status is non-zero, this function will print the CFITSIO error message corresponding to status, print message (optional) in the next line and abort the program. If message==NULL, it will print a default string after the CFITSIO error.

gal_fits_name_is_fits (char *name)

If the name is an acceptable CFITSIO FITS filename return 1 (one), otherwise return 0 (zero). The currently acceptable FITS suffixes are .fits, .fit, .fits.gz, .fits.Z, .imh, .fits.fz. IMH is the IRAF format which is acceptable to CFITSIO.

gal_fits_suffix_is_fits (char *suffix)

Similar to gal_fits_name_is_fits, but only for the suffix. The suffix does not have to start with ‘.’: this function will return 1 (one) for both fits and .fits.

gal_fits_file_recognized (char *name)

Return 1 if the given file name (possibly including its contents) is a FITS file. This is necessary in when the contents of a FITS file do follow the FITS standard, but it the file does not have a Gnuastro-recognized FITS suffix. Therefore, it will first call gal_fits_name_is_fits, if the result is negative, then this function will attempt to open the file with CFITSIO and if it works, it will close it again and return 1. In the process of opening the file, CFITSIO will just to open the file, no reading will take place, so it should have minimal CPU footprint.

char *
gal_fits_name_save_as_string (char *filename, char *hdu)

If the name is a FITS name, then put a (hdu: ...) after it and return the string. If it is not a FITS file, just print the name, if filename==NULL, then return the string stdin. Note that the output string’s space is allocated.

This function is useful when you want to report a random file to the user which may be FITS or not (for a FITS file, simply the filename is not enough, the HDU is also necessary).

Next: CFITSIO and Gnuastro types, Previous: FITS files (fits.h), Up: FITS files (fits.h)   [Contents][Index]