OGIPDatasetWriter#

class gammapy.datasets.OGIPDatasetWriter(filename, format='ogip', overwrite=False)[source]#

Bases: gammapy.datasets.io.DatasetWriter

Write OGIP files.

If you want to use the written files with Sherpa you have to use the ogip-sherpa format. Then all files will be written in units of ‘keV’ and ‘cm2’.

The naming scheme is fixed as following:

  • PHA file is named filename.fits

  • BKG file is named filename_bkg.fits

  • ARF file is named filename_arf.fits

  • RMF file is named filename_rmf.fits

Parameters
filenamepathlib.Path or str

Filename.

format{“ogip”, “ogip-sherpa”}

Which format to use.

overwritebool

Overwrite existing files?

Attributes Summary

tag

Methods Summary

get_filenames(filename)

Get filenames

get_ogip_meta(dataset[, is_bkg])

Meta info for the OGIP data format

to_counts_hdulist(dataset[, is_bkg])

Convert counts region map to hdulist

write(dataset)

Write dataset to files

write_arf(dataset, filename)

Write effective area

write_bkg(dataset, filename)

Write off counts file

write_pha(dataset, filename)

Write counts file

write_rmf(dataset, filename)

Write energy dispersion.

Attributes Documentation

tag = ['ogip', 'ogip-sherpa']#

Methods Documentation

static get_filenames(filename)[source]#

Get filenames

Parameters
filenamePath

Filename

Returns
filenamesdict

Dict of filenames.

get_ogip_meta(dataset, is_bkg=False)[source]#

Meta info for the OGIP data format

to_counts_hdulist(dataset, is_bkg=False)[source]#

Convert counts region map to hdulist

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

is_bkgbool

Whether to use counts off.

write(dataset)[source]#

Write dataset to files

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

write_arf(dataset, filename)[source]#

Write effective area

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

filenamestr or Path

Filename to use.

write_bkg(dataset, filename)[source]#

Write off counts file

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

filenamestr or Path

Filename to use.

write_pha(dataset, filename)[source]#

Write counts file

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

filenamestr or Path

Filename to use.

write_rmf(dataset, filename)[source]#

Write energy dispersion.

Parameters
datasetSpectrumDatasetOnOff

Dataset to write

filenamestr or Path

Filename to use.