p_astro_gstlal module¶
- p_astro_gstlal.compute_p_astro(event_ln_likelihood_ratio, event_mass1, event_mass2, snr, far, rankingstatpdf, livetime=14394240.0, mean_values_dict={'counts_BBH': 9.26042350393, 'counts_BNS': 2.11050326523, 'counts_MassGap': 2.40800240248, 'counts_NSBH': 1.56679410666, 'counts_Terrestrial': 3923}, activation_counts=None)[source]¶
Task to compute p_astro by source category.
Parameters¶
- event_ln_likelihood_ratiofloat
Event’s log likelihood ratio value
- event_mass1float
Event’s heavier component mass value
- event_mass2float
Event’s lighter component mass value
- snr: float
Event’s snr value
- far: float
Event’s far value
- livetime: float
Livetime consistent with estimate of Poisson counts. Eg. If counts are from O1 and O2, livetime is O1-O2 livetime in seconds.
- mean_values_dictdictionary
dictionary of source specific FGMC Poisson counts
- activation_countsdictionary
(optional) dictionary of activation counts keyed on bin number and source category
Returns¶
- p_astrosstr
JSON dump of the p_astro by source category
Example¶
>>> import json >>> p_astros = json.loads(compute_p_astro(files)) >>> p_astros {'BNS': 0.999, 'BBH': 0.0, 'NSBH': 0.0, 'Terrestrial': 0.001}
- p_astro_gstlal.compute_p_astro_approx(snr, far, mass1, mass2, livetime, mean_values_dict)[source]¶
Task to compute p_astro by source category.
Parameters¶
- snrfloat
event’s SNR
- farfloat
event’s cfar
- mass1float
event’s mass1
- mass2float
event’s mass2
- livetime: float
Livetime consistent with estimate of Poisson counts. Eg. If counts are from O1 and O2, livetime is O1-O2 livetime in seconds.
- mean_values_dictdictionary
dictionary of source specific FGMC Poisson counts
Returns¶
- p_astrosstr
JSON dump of the p_astro by source category
Example¶
>>> import json >>> p_astros = json.loads(compute_p_astro(files)) >>> p_astros {'BNS': 0.999, 'BBH': 0.0, 'NSBH': 0.0, 'Terrestrial': 0.001}
- p_astro_gstlal.evaluate_p_astro_from_bayesfac(astro_bayesfac, mean_values_dict, mass1, mass2, activation_counts=None)[source]¶
Evaluates p_astro for a new event using Bayes factor, masses, and number of astrophysical categories. Invoked with every new GraceDB entry.
Parameters¶
- astro_bayesfacfloat
astrophysical Bayes factor
- mean_values_dict: dictionary
mean values of Poisson counts
- mass1float
event mass1
- mass2float
event mass2
- activation_counts: dictionary
array of activation counts keyed on source type and bin number
Returns¶
- p_astrodictionary
p_astro for all source categories
- p_astro_gstlal.make_weights_from_hardcuts(mass1, mass2)[source]¶
Construct binary weights from component masses based on cuts in component mass space that define astrophysical source categories. To be used for MBTA, PyCBC and SPIIR.
Parameters¶
- mass1float
heavier component mass of the event
- mass2float
lighter component mass of the event
Returns¶
- a_bns, a_bbh, a_nshb, a_mgfloats
binary weights (i.e, 1 or 0)
- p_astro_gstlal.make_weights_from_histograms(mass1, mass2, activation_counts=None)[source]¶
Construct binary weights from bin number provided by GstLAL, and a weights matrix pre-constructed and stored in a file, to be read from ???. The weights are keyed on template parameters of Gstlal’s template bank. If that doesn’t work, construct binary weights.
Parameters¶
- mass1float
heavier component mass of the event
- mass2float
lighter component mass of the event
- spin1zfloat
z component spin of heavier mass
- spin2zfloat
z component spin of lighter mass
- activation_countshdf5 object/ dictionary
dictionary of activation counts keyed on bin number and source category
Returns¶
- a_hat_bns, a_hat_bbh, a_hat_nsbh, a_hat_mgfloats
mass-based template weights
- p_astro_gstlal.p_astro_update(category, event_bayesfac_dict, mean_values_dict)[source]¶
Compute p_astro for a new event using mean values of Poisson expected counts constructed from all the previous events. Invoked with every new GraceDB entry.
Parameters¶
- categorystring
source category
- event_bayesfac_dictdictionary
event Bayes factors
- mean_values_dictdictionary
mean values of Poisson counts
Returns¶
- p_astrofloat
p_astro by source category