gbm_drm_gen package¶
Subpackages¶
Submodules¶
gbm_drm_gen.basersp module¶
gbm_drm_gen.basersp_numba module¶
- class gbm_drm_gen.basersp_numba.DetDatabase_numba(detector_group)[source]¶
Bases:
object
- property rsps¶
gbm_drm_gen.create_rsp2 module¶
- gbm_drm_gen.create_rsp2.create_rsp2(file_name: str, response_generator: gbm_drm_gen.drmgen.DRMGen, ra: float, dec: float, tstart: float, tstop: float, delta_time: float = 3, overwrite: bool = False) None [source]¶
gbm_drm_gen.detdatabase module¶
gbm_drm_gen.drmgen module¶
- class gbm_drm_gen.drmgen.DRMGen(position_interpolator: gbmgeometry.position_interpolator.PositionInterpolator, det_number: str, ebin_edge_in, mat_type: int = 0, ebin_edge_out=None, occult: bool = True, time: float = 0)[source]¶
Bases:
object
- __init__(position_interpolator: gbmgeometry.position_interpolator.PositionInterpolator, det_number: str, ebin_edge_in, mat_type: int = 0, ebin_edge_out=None, occult: bool = True, time: float = 0)[source]¶
A generic GBM DRM generator. This can be inherited for specific purposes. It takes as input various spacecraft files to figure out geometry. The user can either supply custom output energy edges or they can be read from a cspec file.
The great benefit here is the ability to make custom input edges if desired. The user needs to have the GBM database pointed at by the environment variable: BALROG_DB
Additionally, matrix folding routines are supplied for spectral fitting. One can also simulate Poisson rates from supplied spectral models.
- Parameters
trigdat – the path to a trigdat file
det_number – the number (0-13) of the detector to be used
ebin_edge_in – an array of energy edges lenght 1 longer than the num of bins
mat_type – 0=direct 1=scattered 2=direct+scattered
time – time relative to trigger to pull spacecraft position
cspecfile – the cspecfile to pull energy output edges from
ebin_edge_out – an array of output edges
- classmethod from_128_bin_data(det_name, time: float = 0.0, cspecfile: Optional[str] = None, trigdat: Optional[str] = None, poshist: Optional[str] = None, T0: Optional[float] = None, mat_type: int = 0, custom_input_edges: Optional[gbm_drm_gen.input_edges.InputEdges] = None, occult: bool = False)[source]¶
A TTE/CSPEC specific drmgen already incorporating the standard input edges. Output edges are obtained from lib import funs the input cspec file. Spacecraft position is read from the TTE file. For further details see the generic reader (DRMGen).
- Parameters
det_name – either NAI_{**} or BGO_{**} or n* b*
trigdat – the path to a trigdat file
mat_type – 0=direct 1=scattered 2=direct+scattered
time – time relative to trigger to pull spacecraft position or MET if using a poshist file
cspecfile – the cspecfile to pull energy output edges from
poshist – read a poshist file
- classmethod from_trigdat(trigdat_file: str, det, mat_type=0, tstart=0, tstop=0.0, time=0.0, occult=False)[source]¶
TODO describe function
- Parameters
cls –
trigdat_file (str) –
det –
mat_type –
tstart –
tstop –
time –
occult –
- Returns
- property postion_interpolator: gbmgeometry.position_interpolator.PositionInterpolator¶
- property current_met: float¶
- met_at(t: float) float [source]¶
returns the MET at a given relative time
- Parameters
t (float) –
- Returns
- property ebounds¶
- property monte_carlo_energies¶
- property matrix¶
- to_3ML_response(ra, dec, coverage_interval=None)[source]¶
create an instrument reponse object for 3ML
- Parameters
ra –
dec –
- Returns
- set_location(ra, dec) None [source]¶
Set the Ra and Dec of the DRM to be built. This invokes DRM generation as well.
- Parameters
ra – ra in degrees
dec – dec in degrees
gbm_drm_gen.drmgen_trig module¶
- class gbm_drm_gen.drmgen_trig.DRMGenTrig(trigdat_file: str, det, mat_type=0, tstart=0, tstop=0.0, time=0.0, occult=False)[source]¶
Bases:
gbm_drm_gen.drmgen.DRMGen
- __init__(trigdat_file: str, det, mat_type=0, tstart=0, tstop=0.0, time=0.0, occult=False)[source]¶
Inherited drmgen from the TTE version. Builds 8-channel RSPs for trigdat data using 140 input edges :param trigdat: a TrigReader object with the background and source selection already exists :param det: a number corresponding to the GBM detector to be used :param mat_type: the type of matrix to produce: 0=direct 1=scattered 2=direct+scattered :param time: the time of the spacecraft position to use :param occult: (bool) occult points blocked by the Earth
gbm_drm_gen.drmgen_tte module¶
- class gbm_drm_gen.drmgen_tte.DRMGenTTE(tte_file: Optional[str] = None, det_name: Optional[str] = None, time: float = 0.0, cspecfile: Optional[str] = None, trigdat: Optional[str] = None, poshist: Optional[str] = None, T0: Optional[float] = None, mat_type: int = 0, custom_input_edges: Optional[gbm_drm_gen.input_edges.InputEdges] = None, occult: bool = False)[source]¶
Bases:
gbm_drm_gen.drmgen.DRMGen
- __init__(tte_file: Optional[str] = None, det_name: Optional[str] = None, time: float = 0.0, cspecfile: Optional[str] = None, trigdat: Optional[str] = None, poshist: Optional[str] = None, T0: Optional[float] = None, mat_type: int = 0, custom_input_edges: Optional[gbm_drm_gen.input_edges.InputEdges] = None, occult: bool = False)[source]¶
A TTE/CSPEC specific drmgen already incorporating the standard input edges. Output edges are obtained from lib import funs the input cspec file. Spacecraft position is read from the TTE file. For further details see the generic reader (DRMGen).
- Parameters
tte_file – the TTE file the data are associated to (used if det name NOT given)
det_name – either NAI_{**} or BGO_{**} or n* b*
trigdat – the path to a trigdat file
mat_type – 0=direct 1=scattered 2=direct+scattered
time – time relative to trigger to pull spacecraft position or MET if using a poshist file
cspecfile – the cspecfile to pull energy output edges from
poshist – read a poshist file
gbm_drm_gen.input_edges module¶
gbm_drm_gen.matrix_functions module¶
- gbm_drm_gen.matrix_functions.calc_weights_numba(p1, p2, p3, p_find)[source]¶
###################### Weights from https://codeplea.com/triangular-interpolation ############ p1_lat = np.arcsin(p1[2]) p1_lon = np.arctan2(p1[1],p1[0])
p2_lat = np.arcsin(p2[2]) p2_lon = np.arctan2(p2[1],p2[0])
p3_lat = np.arcsin(p3[2]) p3_lon = np.arctan2(p3[1],p3[0])
pf_lat = np.arcsin(p_find[2]) pf_lon = np.arctan2(p_find[1],p_find[0])
W1 = ((p2_lat-p3_lat)*(pf_lon-p3_lon)+(p3_lon-p2_lon)*(pf_lat-p3_lat))/((p2_lat-p3_lat)*(p1_lon-p3_lon)+(p3_lon-p2_lon)*(p1_lat-p3_lat)) W2 = ((p3_lat-p1_lat)*(pf_lon-p3_lon)+(p1_lon-p3_lon)*(pf_lat-p3_lat))/((p2_lat-p3_lat)*(p1_lon-p3_lon)+(p3_lon-p2_lon)*(p1_lat-p3_lat)) W3 = 1-W1-W2
- gbm_drm_gen.matrix_functions.highres_ephoton_interpolator(ebin_edge_in, ein, matrix, edif_edge_lo, edif_edge_hi, nhbins)[source]¶
Module contents¶
- class gbm_drm_gen.DRMGenTTE(tte_file: Optional[str] = None, det_name: Optional[str] = None, time: float = 0.0, cspecfile: Optional[str] = None, trigdat: Optional[str] = None, poshist: Optional[str] = None, T0: Optional[float] = None, mat_type: int = 0, custom_input_edges: Optional[gbm_drm_gen.input_edges.InputEdges] = None, occult: bool = False)[source]¶
Bases:
gbm_drm_gen.drmgen.DRMGen
- __init__(tte_file: Optional[str] = None, det_name: Optional[str] = None, time: float = 0.0, cspecfile: Optional[str] = None, trigdat: Optional[str] = None, poshist: Optional[str] = None, T0: Optional[float] = None, mat_type: int = 0, custom_input_edges: Optional[gbm_drm_gen.input_edges.InputEdges] = None, occult: bool = False)[source]¶
A TTE/CSPEC specific drmgen already incorporating the standard input edges. Output edges are obtained from lib import funs the input cspec file. Spacecraft position is read from the TTE file. For further details see the generic reader (DRMGen).
- Parameters
tte_file – the TTE file the data are associated to (used if det name NOT given)
det_name – either NAI_{**} or BGO_{**} or n* b*
trigdat – the path to a trigdat file
mat_type – 0=direct 1=scattered 2=direct+scattered
time – time relative to trigger to pull spacecraft position or MET if using a poshist file
cspecfile – the cspecfile to pull energy output edges from
poshist – read a poshist file
- class gbm_drm_gen.DRMGenTrig(trigdat_file: str, det, mat_type=0, tstart=0, tstop=0.0, time=0.0, occult=False)[source]¶
Bases:
gbm_drm_gen.drmgen.DRMGen
- __init__(trigdat_file: str, det, mat_type=0, tstart=0, tstop=0.0, time=0.0, occult=False)[source]¶
Inherited drmgen from the TTE version. Builds 8-channel RSPs for trigdat data using 140 input edges :param trigdat: a TrigReader object with the background and source selection already exists :param det: a number corresponding to the GBM detector to be used :param mat_type: the type of matrix to produce: 0=direct 1=scattered 2=direct+scattered :param time: the time of the spacecraft position to use :param occult: (bool) occult points blocked by the Earth
- class gbm_drm_gen.BALROG_DRM(drm_generator, ra, dec)[source]¶
Bases:
threeML.utils.OGIP.response.InstrumentResponse
- class gbm_drm_gen.BALROGLike(name, observation, drm_generator=None, background=None, time=0, free_position=True, verbose=True, use_cache=False, **kwargs)[source]¶
Bases:
threeML.plugins.DispersionSpectrumLike.DispersionSpectrumLike
- __init__(name, observation, drm_generator=None, background=None, time=0, free_position=True, verbose=True, use_cache=False, **kwargs)[source]¶
BALROGLike is a general plugin for fitting GBM spectra and locations at the same time
- Parameters
name – plugin name
observation – observed spectrum
drm_generator – the drm generator for this
background – background spectrum
time – time of the observation
free_position – keep the position free
verbose – the verbosity level of the plugin
- set_model(likelihoodModel)[source]¶
Set the model and free the location parameters
- Parameters
likelihoodModel –
- Returns
None
- get_model(precalc_fluxes=None)[source]¶
The model integrated over the energy bins. Note that it only returns the model for the currently active channels/measurements
- Returns
array of folded model
- classmethod from_spectrumlike(spectrum_like, time, drm_generator=None, free_position=True)[source]¶
Generate a BALROGlike from an existing SpectrumLike child
- Parameters
spectrum_like – the existing spectrumlike
time – the time to generate the RSPs at
drm_generator – optional BALROG DRM generator
free_position – if the position should be free
- Returns
- class gbm_drm_gen.BALROGHealpixMap(analysis_results, nside=32)[source]¶
Bases:
object
- property map¶
- property ra¶
- property ra_healpix¶
- property dec¶
- class gbm_drm_gen.Palantir(result, nside=64, trigdat=None, poshist=None, time=0.0)[source]¶
Bases:
object
- __init__(result, nside=64, trigdat=None, poshist=None, time=0.0)[source]¶
View the 3ML BALROG results
- Parameters
result – 3ML BALROG result
nside – power of 2
trigdat – optional trigdat files
time – time of observation
- skymap(*dets, **kwargs)[source]¶
- Parameters
dets – optional detectors
cmap – colormap for location
show_earth – show the earth points
width – no idea
fov – FOV of GBM detectors
- Returns
figure
- property healpix_map¶
- property balrog_map¶