Fits (pygnuastro.fits)

The FITS format is the most common format to store data (images and tables) in astronomy. The CFITSIO library already provides a very good low-level collection of functions for manipulating FITS data. pyGnuastro’s FITS module provides access to the Gnuastro FITS library functions which provide wrappers for CFITSIO functions. With these, it is much easier to read, write, or modify FITS file data, header keywords and extensions.

Note

This module is currently under development and more functions will be added in the future.

pygnuastro.fits.img_read()

Reads the contents of the ‘hdu’ extension/HDU of ‘filename’ into a NumPy array and returns it. Note that this function only reads the main data within the requested FITS extension, the WCS will not be read into the returned dataset.

Args: filename (str): Name of the FITS file(with the ‘.fits’ ext) hdu (str): The HDU number of the FITS file to read

Returns: np.array: The Numpy array with the data read from the hdu of the given FITS image

pygnuastro.fits.img_write()

Write the input ‘data’ into the FITS file named ‘filename’. Also, add the program’s name(‘program string’) to the newly created HDU/extension.

Args: data (np.array/list): The data array to be written filename (str): Name of the output file with extension program_string (str): Program’s name. Written out to the newly created extension

Returns: bool: True if the image write was successful