gwcelery.tasks.p_astro_other module

Computation of p_astro by source category. See Kapadia et al (2019), arXiv:1903.06881, for details.

gwcelery.tasks.p_astro_other.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:
  • category (string) – source category
  • event_bayesfac_dict (dictionary) – event Bayes factors
  • mean_values_dict (dictionary) – mean values of Poisson counts
Returns:

p_astro – p_astro by source category

Return type:

float

gwcelery.tasks.p_astro_other.evaluate_p_astro_from_bayesfac(astro_bayesfac, mean_values_dict, mass1, mass2, spin1z=None, spin2z=None, url_weights_key=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_bayesfac (float) – astrophysical Bayes factor
  • mean_values_dict (dictionary) – mean values of Poisson counts
  • mass1 (float) – event mass1
  • mass2 (float) – event mass2
  • spin1z (float) – event spin1z
  • spin2z (float) – event spin2z
  • url_weights_key (str) – url config key pointing to weights file
Returns:

p_astro – p_astro for all source categories

Return type:

dictionary

gwcelery.tasks.p_astro_other.read_mean_values()[source]

Reads the mean values in the file pointed to by a url.

Returns:mean_values_dict – mean values read from url file
Return type:dictionary
gwcelery.tasks.p_astro_other.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:
  • mass1 (float) – heavier component mass of the event
  • mass2 (float) – lighter component mass of the event
Returns:

a_bns, a_bbh, a_nshb, a_mg – binary weights (i.e, 1 or 0)

Return type:

floats

gwcelery.tasks.p_astro_other.closest_template(params, params_list)[source]

Associate event’s template to a template in the template bank. The assumed bank is the one used by Gstlal. Hence, for Gstlal events, the association should be exact, up to rounding errors.

Parameters:
  • params (tuple of floats) – intrinsic params of event template
  • params_list (list of strings) – list of template bank’s template params
Returns:

key – params of template in template bank matching event’s template

Return type:

string

gwcelery.tasks.p_astro_other.make_weights_from_histograms(url_weights_key, mass1, mass2, spin1z, spin2z)[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 a url. The weights are keyed on template parameters of Gstlal’s template bank. If that doesn’t work, construct binary weights.

Parameters:
  • url_weights_key (string) – url config key pointing at location of weights file
  • mass1 (float) – heavier component mass of the event
  • mass2 (float) – lighter component mass of the event
  • spin1z (float) – z component spin of heavier mass
  • spin2z (float) – z component spin of lighter mass
Returns:

a_bns, a_bbh, a_nsbh, a_mg – mass-based template weights

Return type:

floats

gwcelery.tasks.p_astro_other.choose_snr(far, snr, pipeline, instruments)[source]

Given a pipeline and combination of instruments, return an SNR that does not exceed the SNR threshold for FARs below a FAR threshold. The SNR and FAR thresholds are read from a file containing these values keyed on pipelines and instrument combinations.

Parameters:
  • far (float) – false alarm rate of the event
  • snr (float) – SNR of the event
  • pipeline (string) – pipeline that posted the event
  • instruments (set) – set of instruments that detected the event
Returns:

snr – limiting SNR value

Return type:

float

(task)gwcelery.tasks.p_astro_other.compute_p_astro(snr, far, mass1, mass2, pipeline, instruments)[source]

Task to compute p_astro by source category.

Parameters:
  • snr (float) – event’s SNR
  • far (float) – event’s cfar
  • mass1 (float) – event’s mass1
  • mass2 (float) – event’s mass2
  • instruments (set) – set of instruments that detected the event
Returns:

p_astros – JSON dump of the p_astro by source category

Return type:

str

Example

>>> p_astros = json.loads(compute_p_astro(files))
>>> p_astros
{'BNS': 0.999, 'BBH': 0.0, 'NSBH': 0.0, 'Terrestrial': 0.001}