gwcelery.tasks.p_astro_other module

Module containing the computation of p_astro by source category See https://dcc.ligo.org/LIGO-T1800072 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, num_bins)[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
  • num_bins (int) – number of astrophysical categories
Returns:

p_astro – p_astro for all source categories

Return type:

dictionary

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

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

Parameters:url (string) – url pointing at location of counts mean file
Returns:mean_values_dict – mean values read from url file
Return type:dictionary
(task)gwcelery.tasks.p_astro_other.compute_p_astro(snr, far, mass1, mass2)[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
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}