class, header_tuple)[source]

Bases: object

classmethod from_fits_file_extension(fits_extension)[source]
property hdu
class, fits_extensions=None)[source]

Bases: object


Get the index of an HDU from the HDUList.


key (int, str, tuple of (string, int) or BaseHDU) – The key identifying the HDU. If key is a tuple, it is of the form (name, ver) where ver is an EXTVER value that must match the HDU being searched for.

If the key is ambiguous (e.g. there are multiple ‘SCI’ extensions) the first match is returned. For a more precise match use the (name, ver) pair.

If even the (name, ver) pair is ambiguous (it shouldn’t be but it’s not impossible) the numeric index must be used to index the duplicate HDU.

When key is an HDU object, this function returns the index of that HDU object in the HDUList.


index – The index of the HDU in the HDUList.

Return type


  • ValueError – If key is an HDU object and it is not found in the HDUList.

  • KeyError – If an HDU specified by the key that is an extension number, extension name, or a tuple of extension name and version is not found in the HDUList.


Summarize the info of the HDUs in this HDUList.

Note that this function prints its results to the console—it does not return a value.


output (file-like or bool, optional) – A file-like object to write the output to. If False, does not output to a file and instead returns a list of tuples representing the HDU info. Writes to sys.stdout by default.

writeto(*args, **kwargs)[source]

Write the HDUList to a new file.

  • fileobj (str, file-like or pathlib.Path) – File to write to. If a file object, must be opened in a writeable mode.

  • output_verify (str) – Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". May also be any combination of "fix" or "silentfix" with "+ignore", +warn, or +exception" (e.g. ``"fix+warn"). See verify for more info.

  • overwrite (bool, optional) – If True, overwrite the output file if it exists. Raises an OSError if False and the output file exists. Default is False.

    Changed in version 1.3: overwrite replaces the deprecated clobber argument.

  • checksum (bool) – When True adds both DATASUM and CHECKSUM cards to the headers of all HDU’s written to the file.