threeML.utils.OGIP.response module

class threeML.utils.OGIP.response.EBOUNDS(energy_boundaries)[source]

Bases: threeML.io.fits_file.FITSExtension

exception threeML.utils.OGIP.response.GapInCoverageIntervals[source]

Bases: RuntimeError

class threeML.utils.OGIP.response.InstrumentResponse(matrix: numpy.ndarray, ebounds: numpy.ndarray, monte_carlo_energies: numpy.ndarray, coverage_interval: Optional[threeML.utils.time_interval.TimeInterval] = None)[source]

Bases: object

property arf_filename: None

Returns the name of the ARF file (or None if there is none)

clone() threeML.utils.OGIP.response.InstrumentResponse[source]

return a new response with the contents of this response

Returns

convolve(precalc_fluxes: Optional[numpy.array] = None) numpy.ndarray[source]

Convolve the source flux with the response :param precalc_fluxes: The precalulated flux. If this is None, the flux gets calculated here.

property coverage_interval: threeML.utils.time_interval.TimeInterval

Returns the time interval that this matrix is applicable to. None if it wasn’t defined and the matrix is applicable everywhere

Return time_interval

the time interval

:type time_interval : TimeInterval

classmethod create_dummy_response(ebounds: numpy.ndarray, monte_carlo_energies: numpy.ndarray) threeML.utils.OGIP.response.InstrumentResponse[source]

Creates a dummy identity response of the shape of the ebounds and mc energies

Parameters
  • ebounds – the energy boundaries of the detector channels (size n_channels + 1)

  • monte_carlo_energies – the energy boundaries of the monte carlo channels (size n_mc_energies + 1)

Returns

InstrumentResponse

property ebounds: numpy.ndarray

Returns the ebounds of the RSP.

Returns

energy_to_channel(energy: float) int[source]

Finds the channel containing the provided energy. NOTE: returns the channel index (starting at zero), not the channel number (likely starting from 1).

If you ask for a energy lower than the minimum ebounds, 0 will be returned If you ask for a energy higher than the maximum ebounds, the last channel index will be returned

property first_channel: int
property matrix: numpy.ndarray

Return the matrix representing the response

Return matrix

response matrix

property monte_carlo_energies: numpy.ndarray

Returns the boundaries of the Monte Carlo bins (true energy bins)

Returns

array

plot_matrix() matplotlib.figure.Figure[source]
replace_matrix(new_matrix) None[source]

Replace the read matrix with a new one of the same shape

Returns

none

property rsp_filename: None

Returns the name of the RSP/RMF file from which the response has been loaded

set_function(integral_function=None) None[source]

Set the function to be used for the convolution

Parameters

integral_function (callable) – a function f = f(e1,e2) which returns the integral of the model between e1 and e2

to_fits(filename: str, telescope_name: str, instrument_name: str, overwrite: bool = False) None[source]

Write the current matrix into a OGIP FITS file

:param filename : the name of the FITS file to be created :type filename : str :param telescope_name : a name for the telescope/experiment which this matrix applies to :param instrument_name : a name for the instrument which this matrix applies to :param overwrite: True or False, whether to overwrite or not the output file :return: None

class threeML.utils.OGIP.response.InstrumentResponseSet(matrix_list: List[threeML.utils.OGIP.response.InstrumentResponse], exposure_getter: collections.abc.Callable, counts_getter: collections.abc.Callable, reference_time: float = 0.0)[source]

Bases: object

A set of responses

property ebounds: numpy.ndarray
classmethod from_rsp2_file(rsp2_file: Union[str, pathlib.Path], exposure_getter: collections.abc.Callable, counts_getter: collections.abc.Callable, reference_time: float = 0.0, half_shifted: bool = True) threeML.utils.OGIP.response.InstrumentResponseSet[source]
property monte_carlo_energies: numpy.ndarray
property reference_time: float
weight_by_counts(*intervals) threeML.utils.OGIP.response.InstrumentResponse[source]
weight_by_exposure(*intervals) threeML.utils.OGIP.response.InstrumentResponse[source]
exception threeML.utils.OGIP.response.IntervalOfInterestNotCovered[source]

Bases: RuntimeError

class threeML.utils.OGIP.response.MATRIX(mc_energies, channel_energies, matrix)[source]

Bases: threeML.io.fits_file.FITSExtension

Represents the MATRIX extension of a response FITS file following the OGIP format

Parameters
  • mc_energies_lo – lower bound of MC energies (in keV)

  • mc_energies_hi – hi bound of MC energies (in keV)

  • channel_energies_lo – lower bound of channel energies (in keV)

  • channel_energies_hi – hi bound of channel energies (in keV

  • matrix – the redistribution matrix, representing energy dispersion effects

exception threeML.utils.OGIP.response.NoCoverageIntervals[source]

Bases: RuntimeError

exception threeML.utils.OGIP.response.NoMatrixForInterval[source]

Bases: RuntimeError

exception threeML.utils.OGIP.response.NonContiguousCoverageIntervals[source]

Bases: RuntimeError

class threeML.utils.OGIP.response.OGIPResponse(rsp_file: str, arf_file: Optional[str] = None)[source]

Bases: threeML.utils.OGIP.response.InstrumentResponse

property arf_filename: Optional[pathlib.Path]

Returns the name of the ARF file (or None if there is none)

property first_channel: int

The first channel of the channel array. Corresponds to TLMIN keyword in FITS files

Returns

first channel

property rsp_filename: pathlib.Path

Returns the name of the RSP/RMF file from which the response has been loaded

class threeML.utils.OGIP.response.RMF(mc_energies, ebounds, matrix, telescope_name, instrument_name)[source]

Bases: threeML.io.fits_file.FITSFile

A RMF file, the OGIP format for a matrix representing energy dispersion effects.

class threeML.utils.OGIP.response.RSP(mc_energies, ebounds, matrix, telescope_name, instrument_name)[source]

Bases: threeML.io.fits_file.FITSFile

A response file, the OGIP format for a matrix representing both energy dispersion effects and effective area, in the same matrix.

class threeML.utils.OGIP.response.SPECRESP_MATRIX(mc_energies, channel_energies, matrix)[source]

Bases: threeML.utils.OGIP.response.MATRIX

Represents the SPECRESP_MATRIX extension of a response FITS file following the OGIP format

Parameters
  • mc_energies_lo – lower bound of MC energies (in keV)

  • mc_energies_hi – hi bound of MC energies (in keV)

  • channel_energies_lo – lower bound of channel energies (in keV)

  • channel_energies_hi – hi bound of channel energies (in keV

  • matrix – the redistribution matrix, representing energy dispersion effects and effective area information