You are here: GW-Astronomy wiki>LV_EM Web>TechInfo>EMailGCN (2018-05-29, adminuser)Edit Attach

Processing GCN Notices via Full-Format E-Mail [public]

This example script demonstrates how to process LIGO/Virgo alerts delivered via 'full-format' GCN/TAN e-mail messages, as an alternative to the VOEvent method described in our tutorial. To deploy, configure your computer's mail transfer agent (for example, using procmail) to filter and pipe messages to this script.

Attached to this Wiki page, there are three example messages that you can pipe in to this script like this:
Here are the example e-mails:

Note that you will need to obtain a robot password from GraceDb in order to download sky maps. See the main tutorial for further information about how to work with sky maps or determine visibility of an event.

Example script:

#!/usr/bin/env python
# - Parse and process LIGO/Virgo GCN notices via full-format e-mail
# Leo Singer 
# Bare-bones script to process GCN/TAN notices resulting from LIGO/Virgo
# detection candidates. This script will handle GCN 'full-format' e-mails
# (see for description).
# Test this script by passing it at test e-mail message on stdin:
#     ./ &lt; 2-GCN_LVC_INITIAL_SKYMAP.eml
# To deploy, configure your system's mail transfer agent to filter and pipe
# messages to this script. Details depend on your system; see
# &lt;; for procmail.
# Note that you need to get a GraceDb robot password to download sky maps
# from GraceDb. Add a line like this to your ~/.netrc file:
#    machine login albert.einstein@LIGO.ORG password JKJKJKJkjkjkjkj1223
# You can get the password from:

# Imports
import email
import sys
import os

# Parse e-mail message from stdin.
message = email.message_from_file(sys.stdin)

# By a pleasant coincidence, Python can parse the colon-separated
# 'Key: Value' format of GCN notices just like an e-mail header.
gcn = email.message_from_string(message.get_payload())

# Filter based on notice type:
#  * keep initial and update events, both of which come with sky maps,
#  * and keep only compact binary coalescence (CBC) events.
if gcn['NOTICE_TYPE'] in ('TEST LVC Initial Skymap', 'TEST LVC Update Skymap') and gcn['GROUP_TYPE'] == '1 = CBC':
    # Assemble, echo, and execute curl command to download sky map.
    command = "curl --netrc -O '{0}'".format(gcn['SKYMAP_BASIC_URL'])
    print('Ignoring alert, not for us')

Topic attachments
I Attachment Action Size Date Who Comment
1-GCN_LVC_TEST_PRELIMINARY.emleml 1-GCN_LVC_TEST_PRELIMINARY.eml manage 1 K 2015-06-03 - 23:57 UnknownUser Example 'preliminary' GCN notice e-mail
2-GCN_LVC_TEST_INITIAL.emleml 2-GCN_LVC_TEST_INITIAL.eml manage 1 K 2015-06-03 - 23:58 UnknownUser Example 'initial' GCN notice e-mail
3-GCN_LVC_TEST_UPDATE.emleml 3-GCN_LVC_TEST_UPDATE.eml manage 384 K 2015-06-03 - 23:59 UnknownUser Example 'update' GCN notice e-mail
Topic revision: r7 - 2018-05-29, adminuser
Warning: Can't find topic LV_EM.WebLeftBarExample

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GW-Astronomy wiki? Send feedback