sherpa.astro.ui.unpack_image(arg, coord='logical', dstype=<class 'sherpa.astro.data.DataIMG'>)

Create an image data structure.

Changed in version 4.16.0: Setting coord to a value other than ‘logical’ will now correctly change the coordinate setting for DataIMG datasets.

  • arg – Identify the data: a file name, or a data structure representing the data to use, as used by the I/O backend in use by Sherpa: an IMAGECrate for crates, as used by CIAO, or a list of AstroPy HDU objects.

  • coord ({ 'logical', 'image', 'physical', 'world', 'wcs' }, optional) – Ensure that the image contains the given coordinate system.

  • dstype (optional) – The image class to use. The default is DataIMG.


The class of the returned object is controlled by the dstype parameter.

Return type:



sherpa.utils.err.DataErr – If the image does not contain the requested coordinate system.

See also


Load an image as a data set.


Set a data set.


>>> img1 = unpack_img("img.fits")
>>> set_data(img1)
>>> img = unpack_img('img.fits', 'physical')

Read in an image using Crates:

>>> cr = pycrates.read_file('broad.img')
>>> idata = unpack_img(cr)

Read in an image using AstroPy:

>>> hdus = astropy.io.fits.open('broad.img')
>>> idata = unpack_img(hdus)