gwcelery.tasks.p_astro module

Computation of p_astro by source category and utilities related to p_astro.json source classification files. See Kapadia et al (2019), doi:10.1088/1361-6382/ab5f2d, for details.

(task)gwcelery.tasks.p_astro.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}
(task)gwcelery.tasks.p_astro.plot(contents)[source]

Make a visualization of the source classification.

Parameters:

contents (str, bytes) – The contents of the p_astro.json file.

Returns:

png – The contents of a PNG file.

Return type:

bytes

Notes

The unusually small size of the plot (2.5 x 2 inches) is optimized for viewing in GraceDB’s image display widget.

Examples

>>> from gwcelery.tasks import p_astro
>>> contents = '''
... {"Terrestrial": 0.001, "BNS": 0.65, "NSBH": 0.20,
... "BBH": 0.059}
... '''
>>> p_astro.plot(contents)

(Source code)

(task)gwcelery.tasks.p_astro.handle(alert)[source]

LVAlert handler to plot and upload a visualization of every *.p_astro.json file that is added to a superevent.