Tools for listening to LVAlerts, LIGO/Virgo’s internal GW trigger alert system.
A JSON alert dictionary from LVAlert. Parses the alert and reads various properties.
Check whether the alert describes an ADVOK label being applied.
Check whether the alert has received the advocate requested label (ADVREQ) and is therefore a promising trigger.
Return the preferred event GraceID if this is a superevent or else return this event’s GraceID if it is just a normal event.
Return the GraceID associated with this trigger; works for both events and superevents.
Check whether the alert describes a superevent.
Get the JSON value. If this was originally constructed as JSON, return that; otherwise, try to serialize it. Raises a
Alertcannot be represented as a JSON string.
Check whether the alert describes the availability of a new skymap.
Return whether this LVAlert object is marked as “production”.
Return the superevent GraceID if this is a superevent. Raises a
KeyErrorif not available.
Client(processor: function, server: str = 'lvalert.cgca.uwm.edu', nodes: Tuple[str] = ('cbc_lowmass', 'stc-testnode', 'cbc_gstlal', 'burst_cwb', 'cbc_pycbc', 'cbc_mbtaonline', 'superevent', 'test_superevent', 'cbc_spiir'), heartbeat_interval: float = 180)¶
A wrapper around
LVAlertClientthat provides an interface for subscribing to LVAlert nodes and starting a listener. Specify the new alert processor as
processorand the URL of the LVAlert server to use as
Publish a test message to
self.HEARTBEAT_NODEand wait for a that same message to be parotted back by this instance’s
self.heartbeat_queue. If, after waiting for
timeoutseconds, nothing has been received, or if the received message does not match the random string sent out, return
False; otherwise, return
True. You should probably restart your subscriptions if
This heartbeat check creates a new
LVAlertClientand reconnects each time it is called. It is therefore fairly slow and should only be called at most every few minutes or so.
Get a random message with which to run a heartbeat check.
self.server, subscribe to desired
self.nodes, and start listening for new LVAlerts, reacting with
self.processor. Sleep for
sleepseconds between checks for
SystemExit. Will keep checking to make sure all original subscriptions are still active. Will only quit on keyboard interrupt or system exit call.
process_alert_json(node, alert_json, rundir)¶
Process an LVAlert JSON string as read from stdin when called by