threeML.io.fits_file module
- class threeML.io.fits_file.FITSExtension(data_tuple, header_tuple)[source]
Bases:
object
- property hdu
- class threeML.io.fits_file.FITSFile(primary_hdu=None, fits_extensions=None)[source]
Bases:
object
- index_of(key)[source]
Get the index of an HDU from the HDUList.
- Parameters
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)
wherever
is anEXTVER
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 theHDUList
.- Returns
index – The index of the HDU in the HDUList.
- Return type
int
- Raises
ValueError – If
key
is an HDU object and it is not found in theHDUList
.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 theHDUList
.
- info(output=None)[source]
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.
- Parameters
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.
- Parameters
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 anOSError
ifFalse
and the output file exists. Default isFalse
.Changed in version 1.3:
overwrite
replaces the deprecatedclobber
argument.checksum (bool) – When True adds both
DATASUM
andCHECKSUM
cards to the headers of all HDU’s written to the file.