The module

Classes for storing, inspecting, and manipulating astronomical data sets.

The two types of Astronomical data supported in this module are two-dimensional images (DataIMG) and X-ray spectra (DataPHA), along with associated response information (DataARF and DataRMF). These objects can be constructed directly or read from FITS files using the routines.

Both types of data extend the capabilities of the class:

  • using geometric shapes (regions) to filter images;

  • support different units for filtering images (logical, physical, and WCS), depending on the available metadata;

  • support different analysis units for filtering and display for PHA files (channels, energy, and wavelengths);

  • dynamically re-bin PHA data to improve the signal to noise (grouping and quality);

  • and automatically support one or more spectra that define the background for the observation (for PHA files) that can then be subtracted from the data or a background model fit to them.


The DataPHA class adds support for grouping data - effectively reducing the number of values in a data set - and adds an extra way to filter the data with the quality array. The class extends Data1D, since the primary data is channels and counts, but it also has to act like an integrated data set (Data1DInt) in some cases. In an extension to OGIP support, there is limited support for the BIN_LO and BIN_HI fields provided with Chandra grating data.

The DataIMG class extends 2D support for “gridded” data, with multiple possible coordinate systems (e.g. logical, physical, and world). Along with this, spatial filters can be applied, using the CIAO region syntax [REGION].


Some functionality depends on the presence of the region and grouping Sherpa modules, which are optional components of Sherpa.

Notebook support

The Data objects support the rich display protocol of IPython, with HTML display of a table of information highlighting the relevant data and, for some classes, SVG images. Examples can be found at [AstroNoteBook].



“The OGIP Spectral File Format Addendum: Changes log “,


“The Calibration Requirements for Spectral Analysis (Definition of RMF and ARF file formats)”,


“The Calibration Requirements for Spectral Analysis Addendum: Changes log”,


Private communication with Keith Arnaud


Read in a 2D dataset from the file ‘image2.fits’ and then filter it to only use those pixels that lie within 45 units from the physical coordinate 3150,4515:

>>> from import read_image
>>> img = read_image(data_dir + 'image2.fits')
>>> img.set_coord('physical')
>>> img.notice2d('circle(3150,4515,45)')

Read in a PHA dataset from the file ‘3c273.pi’, subtract the background, filter to only use the data 0.5 to 7 keV, and re-group the data within this range to have at least 20 counts per group:

>>> from import read_pha
>>> pha = read_pha(data_3c273 + '3c273.pi')
>>> pha.subtract()
>>> pha.set_analysis('energy')
>>> pha.notice(0.5, 7)
>>> pha.group_counts(20)


DataOgipResponse(name, xlo, xhi, y[, ...])

Parent class for OGIP responses, in particular ARF and RMF.

DataARF(name, energ_lo, energ_hi, specresp)

ARF data set.

DataRMF(name, detchans, energ_lo, energ_hi, ...)

RMF data set.

DataRosatRMF(name, detchans, energ_lo, ...)

DataPHA(name, channel, counts[, staterror, ...])

PHA data set, including any associated instrument and background data.

DataIMG(name, x0, x1, y[, shape, staterror, ...])

Image data set

DataIMGInt(name, x0lo, x1lo, x0hi, x1hi, y)

Binned image data set

Class Inheritance Diagram

Inheritance diagram of DataOgipResponse, DataARF, DataRMF, DataRosatRMF, DataPHA, DataIMG, DataIMGInt