GNU Astronomy Utilities


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


10.3.8.5 FITS arrays (images)

Images (or multi-dimensional arrays in general) are one of the common data formats that is stored in FITS files. Only one image may be stored in each FITS HDU/extension. The functions described here can be used to get the information of, read, or write images in FITS files.

Function:
void
gal_fits_img_info (fitsfile *fptr, int *type, size_t *ndim, size_t **dsize, char **name, char **unit)

Read the type (see Library data types (type.h)), number of dimensions, and size along each dimension of the CFITSIO fitsfile into the type, ndim, and dsize pointers respectively. If name and unit are not NULL (point to a char *), then if the image has a name and units, the respective string will be put in these pointers.

Function:
gal_data_t *
gal_fits_img_read (char *filename, char *hdu, size_t minmapsize)

Read the contents of the hdu extension/HDU of filename into a Gnuastro generic data container (see Generic data container (gal_data_t)) and return it. If the necessary space is larger than minmapsize, then don’t keep the data in RAM, but in a file on the HDD/SSD. For more on minmapsize see the description under the same name in Generic data container (gal_data_t).

Function:
gal_data_t *
gal_fits_img_read_to_type (char *inputname, char *inhdu, uint8_t type, size_t minmapsize)

Read the contents of the hdu extension/HDU of filename into a Gnuastro generic data container (see Generic data container (gal_data_t)) of type type and return it.

This is just a wrapper around gal_fits_img_read (to read the image/array of any type) and gal_data_copy_to_new_type_free (to convert it to type and free the initially read dataset).

Function:
gal_data_t *
gal_fits_img_read_kernel (char *filename, char *hdu, size_t minmapsize)

Read the hdu of filename as a convolution kernel. A convolution kernel must have an odd size along all dimensions, it must not have blank (NaN in floating point types) values and must be flipped around the center to make the proper convolution (see Convolution process). If there are blank values, this function will change the blank values to 0.0. If the input image doesn’t have the other two requirements, this function will abort with an error describing the condition to the user. The finally returned dataset will have a float32 type.

Function:
fitsfile *
gal_fits_img_write_to_ptr (gal_data_t *input, char *filename)

Write the input dataset into a FITS file named filename and return the corresponding CFITSIO fitsfile pointer. This function won’t close fitsfile, so you can still add other extensions to it after this function or make other modifications.

Function:
void
gal_fits_img_write (gal_data_t *data, char *filename, gal_fits_list_key_t *headers, char *program_string)

Write the input dataset into the FITS file named filename. Also add the headers keywords to the newly created HDU/extension it along with your program’s name (program_string).

Function:
void
gal_fits_img_write_to_type (gal_data_t *data, char *filename, gal_fits_list_key_t *headers, char *program_string, int type)

Convert the input dataset into type, then write it into the FITS file named filename. Also add the headers keywords to the newly created HDU/extension along with your program’s name (program_string). After the FITS file is written, this function will free the copied dataset (with type type) from memory.

This is just a wrapper for the gal_data_copy_to_new_type and gal_fits_img_write functions.

Function:
void
gal_fits_img_write_corr_wcs_str (gal_data_t *data, char *filename, char *wcsstr, int nkeyrec, double *crpix, gal_fits_list_key_t *headers, char *program_string)

Write the input dataset into filename using the wcsstr while correcting the CRPIX values.

This function is mainly useful when you want to make FITS files in parallel (from one main WCS structure, with just differing CRPIX). This can happen in the following cases for example:


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