threeML.utils.OGIP.response module

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

Bases: FITSExtension

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

Bases: RuntimeError

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

Bases: object

property arf_filename: None

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

clone() InstrumentResponse[source]

return a new response with the contents of this response

Returns:

convolve(precalc_fluxes: array | None = None) 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: 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: ndarray, monte_carlo_energies: ndarray) 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: 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: ndarray

Return the matrix representing the response

Return matrix:

response matrix

property monte_carlo_energies: ndarray

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

Returns:

array

plot_matrix() 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[InstrumentResponse], exposure_getter: Callable, counts_getter: Callable, reference_time: float = 0.0)[source]

Bases: object

A set of responses

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

Bases: RuntimeError

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

Bases: 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: str | None = None)[source]

Bases: InstrumentResponse

property arf: ndarray | None

The area response function

property arf_filename: Path | None

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 rmf: ndarray | None

The redistribution matrix function

property rsp_filename: 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: 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: 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: 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