pyspi.utils.response.spi_response module

class pyspi.utils.response.spi_response.ResponseGenerator(pointing_id=None, ebounds=None, response_irf_read_object=None, det=None)[source]

Bases: object

__init__(pointing_id=None, ebounds=None, response_irf_read_object=None, det=None)[source]

Base Response Class - Here we have everything that stays the same for GRB and Constant Pointsource Reponses

Parameters
  • ebounds – User defined ebins for binned effective area

  • response_irf_read_object – Object that holds the read in irf values

  • sc_matrix – Matrix to convert SPI coordinate system <-> ICRS

  • det – Which detector

property det

detector number

Type

returns

property ebounds

Ebounds of the analysis

Type

returns

property ene_max

End of Ebounds

Type

returns

property ene_min

Start of ebounds

Type

returns

get_xy_pos(azimuth, zenith)[source]

Get xy position (in SPI simulation) for given azimuth and zenith

Parameters
  • azimuth – Azimuth in Sat. coordinates [rad]

  • zenith – Zenith in Sat. coordinates [rad]

Returns

grid position in (x,y) coordinates

property irf_ob

the irf_read object with the information from the response simulation

Type

returns

property rod

Ensure that you know what you are doing.

Returns

Roland

set_binned_data_energy_bounds(ebounds)[source]

Change the energy bins for the binned effective_area

Parameters

ebounds – New ebinedges: ebounds[:-1] start of ebins,

ebounds[1:] end of ebins

Returns

set_location(ra, dec)[source]

Calculate the weighted irfs for the three event types for a given position

Parameters
  • azimuth – Azimuth position in sat frame

  • zenith – Zenith position in sat frame

Returns

set_location_direct_sat_coord(azimuth, zenith)[source]

Calculate the weighted irfs for the three event types for a given position

Parameters
  • azimuth – Azimuth position in sat frame

  • zenith – Zenith position in sat frame

Returns

ra and dec value

class pyspi.utils.response.spi_response.ResponsePhotopeakGenerator(pointing_id=None, ebounds=None, response_irf_read_object=None, det=None)[source]

Bases: pyspi.utils.response.spi_response.ResponseGenerator

__init__(pointing_id=None, ebounds=None, response_irf_read_object=None, det=None)[source]

Init Response object with photopeak only

Parameters

pointing_id – The pointing ID for which the

response should be valid :param ebound: Ebounds of Ebins :param response_irf_read_object: Object that holds the read in irf values :param det: Detector ID

property effective_area

vector with photopeak effective area

Type

returns

classmethod from_time(time, det, ebounds, rsp_read_obj)[source]

Init Response object with photopeak only

Parameters
  • time – The time for which the response should be valid

  • ebound – Ebounds of Ebins

  • response_irf_read_object – Object that holds the read in irf values

  • det – Detector ID

Returns

Object

class pyspi.utils.response.spi_response.ResponseRMFGenerator(pointing_id=None, monte_carlo_energies=None, ebounds=None, response_irf_read_object=None, det=None, fixed_rsp_matrix=None)[source]

Bases: pyspi.utils.response.spi_response.ResponseGenerator

__init__(pointing_id=None, monte_carlo_energies=None, ebounds=None, response_irf_read_object=None, det=None, fixed_rsp_matrix=None)[source]

Init Response object with total RMF used

Parameters
  • pointing_id – The pointing ID for which the response should be valid

  • ebound – Ebounds of Ebins

  • monte_carlo_energies – Input energy bin edges

  • response_irf_read_object – Object that holds the read in irf values

  • det – Detector ID

  • fixed_rsp_matrix – A fixed response matrix to overload the normal matrix

Returns

Object

clone()[source]

Clone this response object

Returns

cloned response

classmethod from_time(time, det, ebounds, monte_carlo_energies, rsp_read_obj, fixed_rsp_matrix=None)[source]

Init Response object with total RMF used from a time

Parameters
  • time – Time for which to construct the response object

  • ebound – Ebounds of Ebins

  • monte_carlo_energies – Input energy bin edges

  • response_irf_read_object – Object that holds

the read in irf values :param det: Detector ID :param fixed_rsp_matrix: A fixed response matrix to overload the normal matrix

Returns

Object

property matrix

response matrix

Type

returns

property monte_carlo_energies

Input energies for response

Type

returns

property transpose_matrix

transposed response matrix

Type

returns

pyspi.utils.response.spi_response.add_frac(ph_matrix, i, idx, ebounds, einlow, einhigh)[source]

Recursive Funktion to get the fraction of einlow…

pyspi.utils.response.spi_response.log_interp1d(x_new, x_old, y_old)[source]

Linear interpolation in log space for base value pairs (x_old, y_old) for new x_values x_new

Parameters
  • x_old – Old x values used for interpolation

  • y_old – Old y values used for interpolation

  • x_new – New x values

Returns

y_new from liner interpolation in log space

pyspi.utils.response.spi_response.multi_response_irf_read_objects(times, detector, drm='Photopeak')[source]

TODO: This is very ugly. Come up with a better way. Function to initalize the needed responses for the given times. Only initalize every needed response version once! Because of memory. One response object needs about 1 GB of RAM… TODO: Not needed at the moment. We need this when we want to analyse many pointings together.

Parameters

times – Times of the different sw used

Returns

list with correct response version object of the times

pyspi.utils.response.spi_response.trapz(y, x)[source]

Fast trapz integration with numba

Parameters
  • x – x values

  • y – y values

Returns

Trapz integrated