# unpack_pha¶

sherpa.astro.ui.unpack_pha(arg, use_errors=False)

Create a PHA data structure.

Any instrument or background data sets referenced in the header of the PHA file - e.g. with the ANCRFILE, RESPFILE, and BACKFILE keywords - will also be loaded.

Parameters: arg – Identify the PHA file: a file name, or a data structure representing the data to use, as used by the I/O backend in use by Sherpa: a TABLECrate for crates, as used by CIAO, or a list of AstroPy HDU objects. use_errors (bool, optional) – If True then the statistical errors are taken from the input data, rather than calculated by Sherpa from the count values. The default is False. pha a sherpa.astro.data.DataPHA instance

load_pha()
Load a file as a PHA data set.
pack_pha()
Convert a PHA data set into a file structure.
set_data()
Set a data set.

Examples

>>> pha1 = unpack_arf("src1.pi")
>>> pha2 = unpack_arf("field.pi")
>>> set_data(1, pha1)
>>> set_bkg(1, pha2)


Read in a PHA file using Crates:

>>> cr = pycrates.read_file("src.fits")
>>> pha = unpack_pha(cr)


Read in a PHA file using AstroPy:

>>> hdus = astropy.io.fits.open("src.fits")
>>> pha = unpack_pha(hdus)