OGIPDatasetReader#

class gammapy.datasets.OGIPDatasetReader(filename)[source]#

Bases: gammapy.datasets.io.DatasetReader

Read SpectrumDatasetOnOff from OGIP files.

BKG file, ARF, and RMF must be set in the PHA header and be present in the same folder.

The naming scheme is fixed to the following scheme:

  • PHA file is named pha_obs{name}.fits

  • BKG file is named bkg_obs{name}.fits

  • ARF file is named arf_obs{name}.fits

  • RMF file is named rmf_obs{name}.fits with {name} the dataset name.

Parameters
filenamestr or Path

OGIP PHA file to read.

Attributes Summary

tag

Methods Summary

get_filenames(pha_meta)

Get filenames.

get_valid_path(filename)

Get absolute or relative path.

read()

Read dataset.

read_arf(filename, livetime)

Read ARF file.

read_bkg(filename)

Read PHA background file.

read_pha(filename)

Read PHA file.

read_rmf(filename, exposure)

Read RMF file.

Attributes Documentation

tag = 'ogip'#

Methods Documentation

get_filenames(pha_meta)[source]#

Get filenames.

Parameters
pha_metadict

Metadata from the PHA file.

Returns
filenamesdict

Dictionary with filenames of “arffile”, “rmffile” (optional) and “bkgfile” (optional).

get_valid_path(filename)[source]#

Get absolute or relative path.

The relative path is with respect to the name of the reference file.

Parameters
filenamestr or Path

Filename.

Returns
filenamePath

Valid path.

read()[source]#

Read dataset.

Returns
datasetSpectrumDatasetOnOff

Spectrum dataset.

static read_arf(filename, livetime)[source]#

Read ARF file.

Parameters
filenamestr or Path

PHA file name.

livetimeQuantity

Livetime.

Returns
dataRegionNDMap

Exposure map.

static read_bkg(filename)[source]#

Read PHA background file.

Parameters
filenamestr or Path

PHA file name.

Returns
datadict

Dictionary with counts_off and acceptance_off.

static read_pha(filename)[source]#

Read PHA file.

Parameters
filenamestr or Path

PHA file name.

Returns
datadict

Dictionary with counts, acceptance and mask_safe.

static read_rmf(filename, exposure)[source]#

Read RMF file.

Parameters
filenamestr or Path

PHA file name.

exposureRegionNDMap

Exposure map.

Returns
dataEDispKernelMap

Dictionary with edisp.