OGIPDatasetWriter#

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

Bases: 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:
filenamePath or str

Filename.

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

Which format to use. Default is ‘ogip’.

overwritebool, optional

Overwrite existing files. Default is False.

checksumbool

When True adds both DATASUM and CHECKSUM cards to the headers written to the files. Default is False.

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 file.

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

Dictionary 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. Default is False.

write(dataset)[source]#

Write dataset to file.

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.