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
keyis a tuple, it is of the form(name, ver)whereveris anEXTVERvalue 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
keyis 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
keyis an HDU object and it is not found in theHDUList.KeyError – If an HDU specified by the
keythat 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.stdoutby 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 astropy:verify for more info.overwrite (bool, optional) – If
True, overwrite the output file if it exists. Raises anOSErrorifFalseand the output file exists. Default isFalse.checksum (bool) – When True adds both
DATASUMandCHECKSUMcards to the headers of all HDU’s written to the file.
Notes
gzip, zip, bzip2 and lzma compression algorithms are natively supported. Compression mode is determined from the filename extension (‘.gz’, ‘.zip’, ‘.bz2’ or ‘.xz’ respectively). It is also possible to pass a compressed file object, e.g. gzip.GzipFile.