From c10522658322feab97d9a7c7352ca486dff7d0c2 Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Mon, 25 Feb 2019 10:30:22 -0600
Subject: [PATCH] Final touches on VOEvent descriptions

As shown here: https://git.ligo.org/emfollow/userguide/merge_requests/23
---
 gracedb/events/buildVOEvent.py      | 49 +++++++++++++++--------------
 gracedb/superevents/buildVOEvent.py | 49 +++++++++++++++--------------
 2 files changed, 52 insertions(+), 46 deletions(-)

diff --git a/gracedb/events/buildVOEvent.py b/gracedb/events/buildVOEvent.py
index b160262c1..ef1177b82 100644
--- a/gracedb/events/buildVOEvent.py
+++ b/gracedb/events/buildVOEvent.py
@@ -259,8 +259,9 @@ def buildVOEvent(event, serial_number, voevent_type, request=None, skymap_filena
     # Analysis specific attributes
     if voevent_type != 'retraction':
         classification_group = Group('Classification', Description=["Source "
-            "classification: binary neutron star (BNS), neutron star-black"
-            "hole (NSBH), binary black hole (BBH), or terrestrial (noise)"])
+            "classification: binary neutron star (BNS), neutron star-black "
+            "hole (NSBH), binary black hole (BBH), MassGap, or terrestrial "
+            "(noise)"])
         properties_group = Group('Properties', Description=["Qualitative "
             "properties of the source, conditioned on the assumption that the "
             "signal is an astrophysical compact binary merger"])
@@ -272,39 +273,33 @@ def buildVOEvent(event, serial_number, voevent_type, request=None, skymap_filena
             eta = pow((mchirp/mass),5.0/3.0)
 
             # EM-Bright mass classifier information for CBC event candidates
-            if ProbHasNS is not None:
-                properties_group.add_Param(Param(name="HasNS",
-                    dataType="float", ucd="stat.probability", value=ProbHasNS,
-                    Description=["Probability that at least one object in the "
-                    "binary has a mass that is less than 2.83 solar masses"]))
-
-            if ProbHasRemnant is not None:
-                properties_group.add_Param(Param(name="HasRemnant",
-                    dataType="float", ucd="stat.probability",
-                    value=ProbHasRemnant, Description=["Probability that a "
-                    "nonzero mass was ejected outside the central remnant "
-                    "object"]))
-
             if BNS is not None:
                 classification_group.add_Param(Param(name="BNS",
                     dataType="float", ucd="stat.probability",
                     value=BNS, Description=["Probability that the "
                     "source is a binary neutron star merger (both objects "
-                    "below 3 solar masses)"]))
+                    "lighter than 3 solar masses)"]))
 
             if NSBH is not None:
                 classification_group.add_Param(Param(name="NSBH",
                     dataType="float", ucd="stat.probability",
                     value=NSBH, Description=["Probability that the "
-                    "source is a neutron star - black hole merger (heavier "
-                    "above 5, lighter below 3 solar masses)"]))
+                    "source is a neutron star-black hole merger (primary "
+                    "heavier than 5 solar masses, secondary lighter than 3 "
+                    "solar masses)"]))
 
             if BBH is not None:
                 classification_group.add_Param(Param(name="BBH",
                     dataType="float", ucd="stat.probability",
                     value=BBH, Description=["Probability that the "
                     "source is a binary black hole merger (both objects "
-                    "above 5 solar masses)"]))
+                    "heavier than 5 solar masses)"]))
+
+            if MassGap is not None:
+                classification_group.add_Param(Param(name="MassGap",
+                    dataType="float", ucd="stat.probability",
+                    value=MassGap, Description=["Probability that the source "
+                    "has at least one object between 3 and 5 solar masses"]))
 
             if Terrestrial is not None:
                 classification_group.add_Param(Param(name="Terrestrial",
@@ -313,11 +308,19 @@ def buildVOEvent(event, serial_number, voevent_type, request=None, skymap_filena
                     "that the source is terrestrial (i.e., a background noise "
                     "fluctuation or a glitch)"]))
 
-            if MassGap is not None:
-                classification_group.add_Param(Param(name="MassGap",
+            # Add to source properties group
+            if ProbHasNS is not None:
+                properties_group.add_Param(Param(name="HasNS",
+                    dataType="float", ucd="stat.probability", value=ProbHasNS,
+                    Description=["Probability that at least one object in the "
+                    "binary has a mass that is less than 2.83 solar masses"]))
+
+            if ProbHasRemnant is not None:
+                properties_group.add_Param(Param(name="HasRemnant",
                     dataType="float", ucd="stat.probability",
-                    value=MassGap, Description=["Probability that the source "
-                    "has at least one object between 3 and 5 solar masses"]))
+                    value=ProbHasRemnant, Description=["Probability that a "
+                    "nonzero mass was ejected outside the central remnant "
+                    "object"]))
 
             # build up MaxDistance. event.singleinspiral_set.all()?
             # Each detector calculates an effective distance assuming the inspiral is 
diff --git a/gracedb/superevents/buildVOEvent.py b/gracedb/superevents/buildVOEvent.py
index dfce6dc66..7348d9230 100644
--- a/gracedb/superevents/buildVOEvent.py
+++ b/gracedb/superevents/buildVOEvent.py
@@ -249,8 +249,9 @@ def construct_voevent_file(superevent, voevent, request=None,
     # Analysis specific attributes
     if voevent_type != 'retraction':
         classification_group = Group('Classification', Description=["Source "
-            "classification: binary neutron star (BNS), neutron star-black"
-            "hole (NSBH), binary black hole (BBH), or terrestrial (noise)"])
+            "classification: binary neutron star (BNS), neutron star-black "
+            "hole (NSBH), binary black hole (BBH), MassGap, or terrestrial "
+            "(noise)"])
         properties_group = Group('Properties', Description=["Qualitative "
             "properties of the source, conditioned on the assumption that the "
             "signal is an astrophysical compact binary merger"])
@@ -262,39 +263,33 @@ def construct_voevent_file(superevent, voevent, request=None,
             eta = pow((mchirp/mass),5.0/3.0)
 
             # EM-Bright mass classifier information for CBC event candidates
-            if ProbHasNS is not None:
-                properties_group.add_Param(Param(name="HasNS",
-                    dataType="float", ucd="stat.probability", value=ProbHasNS,
-                    Description=["Probability that at least one object in the "
-                    "binary has a mass that is less than 2.83 solar masses"]))
-
-            if ProbHasRemnant is not None:
-                properties_group.add_Param(Param(name="HasRemnant",
-                    dataType="float", ucd="stat.probability",
-                    value=ProbHasRemnant, Description=["Probability that a "
-                    "nonzero mass was ejected outside the central remnant "
-                    "object"]))
-
             if BNS is not None:
                 classification_group.add_Param(Param(name="BNS",
                     dataType="float", ucd="stat.probability",
                     value=BNS, Description=["Probability that the "
                     "source is a binary neutron star merger (both objects "
-                    "below 3 solar masses)"]))
+                    "lighter than 3 solar masses)"]))
 
             if NSBH is not None:
                 classification_group.add_Param(Param(name="NSBH",
                     dataType="float", ucd="stat.probability",
                     value=NSBH, Description=["Probability that the "
-                    "source is a neutron star - black hole merger (heavier "
-                    "above 5, lighter below 3 solar masses)"]))
+                    "source is a neutron star-black hole merger (primary "
+                    "heavier than 5 solar masses, secondary lighter than 3 "
+                    "solar masses)"]))
 
             if BBH is not None:
                 classification_group.add_Param(Param(name="BBH",
                     dataType="float", ucd="stat.probability",
                     value=BBH, Description=["Probability that the "
                     "source is a binary black hole merger (both objects "
-                    "above 5 solar masses)"]))
+                    "heavier than 5 solar masses)"]))
+
+            if MassGap is not None:
+                classification_group.add_Param(Param(name="MassGap",
+                    dataType="float", ucd="stat.probability",
+                    value=MassGap, Description=["Probability that the source "
+                    "has at least one object between 3 and 5 solar masses"]))
 
             if Terrestrial is not None:
                 classification_group.add_Param(Param(name="Terrestrial",
@@ -303,11 +298,19 @@ def construct_voevent_file(superevent, voevent, request=None,
                     "that the source is terrestrial (i.e., a background noise "
                     "fluctuation or a glitch)"]))
 
-            if MassGap is not None:
-                classification_group.add_Param(Param(name="MassGap",
+            # Add to source properties group
+            if ProbHasNS is not None:
+                properties_group.add_Param(Param(name="HasNS",
+                    dataType="float", ucd="stat.probability", value=ProbHasNS,
+                    Description=["Probability that at least one object in the "
+                    "binary has a mass that is less than 2.83 solar masses"]))
+
+            if ProbHasRemnant is not None:
+                properties_group.add_Param(Param(name="HasRemnant",
                     dataType="float", ucd="stat.probability",
-                    value=MassGap, Description=["Probability that the source "
-                    "has at least one object between 3 and 5 solar masses"]))
+                    value=ProbHasRemnant, Description=["Probability that a "
+                    "nonzero mass was ejected outside the central remnant "
+                    "object"]))
 
             # build up MaxDistance. event.singleinspiral_set.all()?
             # Each detector calculates an effective distance assuming the inspiral is 
-- 
GitLab