OGIPDatasetReader#

class gammapy.datasets.OGIPDatasetReader(filename, checksum=False)[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.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

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[, checksum])

Read ARF file.

read_bkg(filename[, checksum])

Read PHA background file.

read_pha(filename[, checksum])

Read PHA file.

read_rmf(filename, exposure[, checksum])

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, checksum=False)[source]#

Read ARF file.

Parameters
filenamestr or Path

PHA file name.

livetimeQuantity

Livetime.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

Returns
dataRegionNDMap

Exposure map.

static read_bkg(filename, checksum=False)[source]#

Read PHA background file.

Parameters
filenamestr or Path

PHA file name.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

Returns
datadict

Dictionary with counts_off and acceptance_off.

static read_pha(filename, checksum=False)[source]#

Read PHA file.

Parameters
filenamestr or Path

PHA file name.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

Returns
datadict

Dictionary with counts, acceptance and mask_safe.

static read_rmf(filename, exposure, checksum=False)[source]#

Read RMF file.

Parameters
filenamestr or Path

PHA file name.

exposureRegionNDMap

Exposure map.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

Returns
dataEDispKernelMap

Dictionary with edisp.