Commit a7c4dfd1 authored by Min-A Cho's avatar Min-A Cho

add uncertainty ellipse text when they are a good approximation

parent bcf7ca28
Pipeline #26417 passed with stages
in 5 minutes and 54 seconds
......@@ -16,7 +16,7 @@ build:
expire_in: 5 minutes
test:
image: python:slim
image: python:3.6
stage: test
coverage: '/^TOTAL\s+.*\s+(\d+\.?\d*)%/'
variables:
......@@ -35,7 +35,7 @@ test:
# Run code lint
lint:
image: python:slim
image: python:3.6
stage: test
variables:
GIT_STRATEGY: none
......
import os
import shutil
import tempfile
import urllib
import webbrowser
import astropy.coordinates as coord
import astropy.time
from ligo.gracedb import rest
import astropy.units as u
import healpy as hp
import lxml.etree
import numpy as np
from ligo.gracedb import rest
from ligo.skymap.io.fits import read_sky_map
from ligo.skymap.postprocess.ellipse import find_ellipse
from ligo.skymap.postprocess.find_injection import find_injection_moc
from .jinja import env
from .version import __version__ # noqa
......@@ -93,7 +99,24 @@ def compose(gracedb_id, authors=(), mailto=False,
instruments=preferred_event['instruments'].split(','),
skymaps=skymaps,
prob_has_ns=source_classification.get('Prob NS2'),
prob_has_remnant=source_classification.get('Prob EMbright'))
prob_has_remnant=source_classification.get('Prob EMbright'),
include_ellipse=None)
if skymaps:
preferred_skymap = skymaps[-1]['filename']
cl = 90
include_ellipse, ra, dec, a, b, pa, area = uncertainty_ellipse(
gracedb_id, preferred_skymap, client, cl=cl)
kwargs.update(
preferred_skymap=preferred_skymap,
cl=cl,
include_ellipse=include_ellipse,
ra=coord.Longitude(ra*u.deg),
dec=coord.Latitude(dec*u.deg),
a=coord.Angle(a*u.deg),
b=coord.Angle(b*u.deg),
pa=coord.Angle(pa*u.deg),
ellipse_area=area)
subject = env.get_template('subject.txt').render(**kwargs).strip()
body = env.get_template('circular.txt').render(**kwargs).strip()
......@@ -108,25 +131,19 @@ def compose(gracedb_id, authors=(), mailto=False,
return '{0}\n{1}'.format(subject, body)
def read_map_gracedb(graceid, filename, client):
import healpy as hp
with tempfile.NamedTemporaryFile() as localfile:
remotefile = client.files(graceid, filename, raw=True)
try:
shutil.copyfileobj(remotefile, localfile)
finally:
remotefile.close()
def read_map_gracedb(graceid, filename, client, moc_table=False):
with tempfile.NamedTemporaryFile(mode='w+b') as localfile:
remotefile = client.files(graceid, filename, raw=True).read()
localfile.write(remotefile)
localfile.flush()
m = hp.read_map(localfile.name, verbose=False)
return m
return read_sky_map(localfile.name, moc=moc_table)
def read_map_from_path(path, client):
return read_map_gracedb(*path.split('/'), client)
return read_map_gracedb(*path.split('/'), client)[0]
def mask_cl(p, level=90):
import numpy as np
pflat = p.ravel()
i = np.flipud(np.argsort(p))
cs = np.cumsum(pflat[i])
......@@ -140,7 +157,6 @@ def compare_skymaps(paths, service=rest.DEFAULT_SERVICE_URL, client=None):
"""Produce table of sky map overlaps"""
if client is None:
client = rest.GraceDb(service)
import healpy as hp
filenames = [path.split('/')[1] for path in paths]
pipelines = [guess_skyloc_pipeline(filename) for filename in filenames]
probs = [read_map_from_path(path, client) for path in paths]
......@@ -155,3 +171,15 @@ def compare_skymaps(paths, service=rest.DEFAULT_SERVICE_URL, client=None):
kwargs = dict(params=zip(filenames, pipelines, areas, joint_areas))
return env.get_template('compare_skymaps.txt').render(**kwargs)
def uncertainty_ellipse(graceid, filename, client, cl=90):
"""Compute uncertainty ellipses for a given skymap"""
skymap_table = read_map_gracedb(graceid, filename, client, moc_table=True)
result = find_injection_moc(skymap_table, contours=[cl/100])
greedy_area = result.contour_areas[0]
prob = read_map_gracedb(graceid, filename, client)[0]
ra, dec, a, b, pa, ellipse_area = find_ellipse(prob, cl=cl,
projection='ARC',
nest=False)
return ellipse_area <= 1.35*greedy_area, ra, dec, a, b, pa, ellipse_area
......@@ -83,6 +83,21 @@ document: <{{ embright_public_dcc }}>.
distributed via GCN notice about {{ skymap.latency|naturaldelta }} after the event
{%- endfor %}
{% if include_ellipse -%}
For the {{ preferred_skymap }} sky map, the {{ cl }}% credible region is well
fit by an ellipse with an area of {{ ellipse_area|round|int }} deg2 described
by the following DS9 region (right ascension, declination, semi-major axis,
semi-minor axis, position angle of the semi-minor axis):
icrs; ellipse(
{{- ra.to('15 arcsec').round().to_string(unit='hourangle', pad=True,
alwayssign=False) }},
{{- ' ' }}{{ dec.to('arcsec').round().to_string(unit='deg', pad=True,
alwayssign=True) }},
{{- ' ' }}{{ a.round().to_string(fields=1, unit='deg') }},
{{- ' ' }}{{ b.round().to_string(fields=1, unit='deg') }},
{{- ' ' }}{{ pa.round().to_string(fields=1, unit='deg') }})
{% endif -%}
Updates on our analysis of this event will be sent as they become
available.
{%- endfilter -%}
{"coinc.xml": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml", "initial.data": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data", "initial.data,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data,0", "event.log,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log,0", "psd.xml.gz,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz,0", "event.log": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log", "bayestar.fits.gz,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz,0", "psd.xml.gz": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz", "coinc.xml,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml,0", "bayestar.fits.gz": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz"}
{"coinc.xml": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml", "initial.data": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data", "initial.data,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data,0", "event.log,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log,0", "psd.xml.gz,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz,0", "event.log": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log", "bayestar.fits.gz,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz,0", "psd.xml.gz": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz", "coinc.xml,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml,0", "bayestar.fits.gz": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz", "LALInference.fits.gz": "https://gracedb-dev1.ligo.org/api/events/S1234/files/LALInference.fits.gz", "LALInference.fits.gz,0": "https://gracedb-dev1.ligo.org/api/events/S1234/files/LALInference.fits.gz,0", "S1234-1-Initial.xml": "https://gracedb-dev1.ligo.org/api/events/S1234/files/S1234-1-Initial.xml", "S1234-2-Update.xml": "https://gracedb-dev1.ligo.org/api/events/S1234/files/S1234-2-Update.xml"}
......@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v2.0 http://www.ivoa.net/xml/VOEvent/VOEvent-v2.0.xsd"
version="2.0"
role="test"
ivorn="ivo://gwnet/gcn_sender#S1234-1-Preliminary">
ivorn="ivo://gwnet/gcn_sender#S1234-1-Initial">
<Who>
<Date>2018-06-28T13:42:02</Date>
<Author>
......@@ -20,7 +20,7 @@
<Param name="SupereventID" dataType="string" value="S1234" ucd="meta.id">
<Description>Identifier in GraceDB</Description>
</Param>
<Param name="AlertType" dataType="string" value="Preliminary" ucd="meta.version" unit="">
<Param name="AlertType" dataType="string" value="Initial" ucd="meta.version" unit="">
<Description>VOEvent alert type</Description>
</Param>
<Param name="Retraction" dataType="string" value="false" ucd="meta.code" unit="">
......
<?xml version="1.0" ?>
<voe:VOEvent
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:voe="http://www.ivoa.net/xml/VOEvent/v2.0"
xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v2.0 http://www.ivoa.net/xml/VOEvent/VOEvent-v2.0.xsd"
version="2.0"
role="test"
ivorn="ivo://gwnet/gcn_sender#S1234-2-Update">
<Who>
<Date>2018-06-28T14:42:02</Date>
<Author>
<contactName>LIGO Scientific Collaboration and Virgo Collaboration</contactName>
</Author>
</Who>
<What>
<Param name="internal" dataType="int" value="1">
<Description>Indicates whether this event should be distributed to LSC/Virgo members only</Description>
</Param>
<Param name="Pkt_Ser_Num" dataType="string" value="1"/>
<Param name="SupereventID" dataType="string" value="S1234" ucd="meta.id">
<Description>Identifier in GraceDB</Description>
</Param>
<Param name="AlertType" dataType="string" value="Update" ucd="meta.version" unit="">
<Description>VOEvent alert type</Description>
</Param>
<Param name="Retraction" dataType="string" value="false" ucd="meta.code" unit="">
<Description>Set to true if the event is retracted.</Description>
</Param>
<Param name="HardwareInj" dataType="int" value="0" ucd="meta.number" unit="">
<Description>Indicates that this event is a hardware injection if 1, no if 0</Description>
</Param>
<Param name="Vetted" dataType="int" value="1" ucd="meta.number" unit="">
<Description>Indicates whether this candidate has undergone basic vetting by humans</Description>
</Param>
<Param name="OpenAlert" dataType="int" value="0" ucd="meta.number" unit="">
<Description>Indicates that this event is an open alert if 1, no if 0</Description>
</Param>
<Param name="SupereventPage" dataType="string" value="https://gracedb-playground.ligo.org/superevents/S1234/view/" ucd="meta.ref.url">
<Description>Web page for evolving status of this GW candidate</Description>
</Param>
<Param name="Instruments" dataType="string" value="H1,L1" ucd="meta.code">
<Description>List of instruments used in analysis to identify this event</Description>
</Param>
<Param name="FAR" dataType="float" value="9.11069936486e-14" ucd="arith.rate;stat.falsealarm" unit="Hz">
<Description>False alarm rate for GW candidates with this strength or greater</Description>
</Param>
<Param name="Group" dataType="string" value="CBC" ucd="meta.code" unit="">
<Description>Data analysis working group</Description>
</Param>
<Param name="Pipeline" dataType="string" value="gstlal" ucd="meta.code" unit="">
<Description>Low-latency data analysis pipeline</Description>
</Param>
<Param name="Search" dataType="string" value="MDC" ucd="meta.code" unit="">
<Description>Specific low-latency search</Description>
</Param>
<Group type="GW_SKYMAP" name="LALInference">
<Param name="skymap_fits_shib" dataType="string" value="https://gracedb-playground.ligo.org/apiweb/superevents/S1234/files/LALInference.fits.gz" ucd="meta.ref.url" unit="">
<Description>Sky Map FITS Shibboleth protected</Description>
</Param>
<Param name="skymap_fits_x509" dataType="string" value="https://gracedb-playground.ligo.org/api/superevents/S1234/files/LALInference.fits.gz" ucd="meta.ref.url" unit="">
<Description>Sky Map FITS X509 protected</Description>
</Param>
<Param name="skymap_fits_basic" dataType="string" value="https://gracedb-playground.ligo.org/apibasic/superevents/S1234/files/LALInference.fits.gz" ucd="meta.ref.url" unit=""> <Description>Sky Map FITS basic auth protected</Description>
</Param>
<Param name="skymap_png_shib" dataType="string" value="https://gracedb-playground.ligo.org/apiweb/superevents/S1234/files/LALInference.png" ucd="meta.ref.url" unit="">
<Description>Sky Map image Shibboleth protected</Description>
</Param>
<Param name="skymap_png_x509" dataType="string" value="https://gracedb-playground.ligo.org/api/superevents/S1234/files/LALInference.png" ucd="meta.ref.url" unit="">
<Description>Sky Map image X509 protected</Description>
</Param>
<Param name="skymap_png_basic" dataType="string" value="https://gracedb-playground.ligo.org/apibasic/superevents/S1234/files/LALInference.png" ucd="meta.ref.url" unit="">
<Description>Sky Map image basic auth protected</Description>
</Param>
</Group>
</What>
<WhereWhen>
<ObsDataLocation>
<ObservatoryLocation id="LIGO Virgo"/>
<ObservationLocation>
<AstroCoordSystem id="UTC-FK5-GEO"/>
<AstroCoords coord_system_id="UTC-FK5-GEO">
<Time>
<TimeInstant>
<ISOTime>2018-06-28T14:35:16.911085</ISOTime>
</TimeInstant>
</Time>
</AstroCoords>
</ObservationLocation>
</ObsDataLocation>
</WhereWhen>
<How>
<Description>Candidate gravitational wave event identified by low-latency analysis</Description>
<Description>H1: LIGO Hanford 4 km gravitational wave detector</Description>
<Description>L1: LIGO Livingston 4 km gravitational wave detector</Description>
</How>
<Description>Report of a candidate gravitational wave event</Description>
</voe:VOEvent>
{"numRows": 9, "start": 0, "log": [{"comment": "Original Data", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/1", "issuer": "leo.singer@LIGO.ORG", "filename": "initial.data", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/1/tag/", "N": 1}, {"comment": "Log File Created", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/2", "issuer": "leo.singer@LIGO.ORG", "filename": "event.log", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/2/tag/", "N": 2}, {"comment": "Coinc Table Created", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/3", "issuer": "leo.singer@LIGO.ORG", "filename": "coinc.xml", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/3/tag/", "N": 3}, {"comment": "Set as preferred event for superevent: S180628g", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/4", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/4/tag/", "N": 4}, {"comment": "Noise PSD", "file_version": 0, "tag_names": ["psd"], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz,0", "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/5", "issuer": "leo.singer@LIGO.ORG", "filename": "psd.xml.gz", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/5/tag/", "N": 5}, {"comment": "Tagged message 5: psd ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/6", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/6/tag/", "N": 6}, {"comment": "sky localization complete", "file_version": 0, "tag_names": ["sky_loc", "lvem"], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz,0", "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/7", "issuer": "leo.singer@LIGO.ORG", "filename": "bayestar.fits.gz", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/7/tag/", "N": 7}, {"comment": "Tagged message 7: sky_loc ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/8", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/8/tag/", "N": 8}, {"comment": "Tagged message 7: lvem ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/9", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/9/tag/", "N": 9}], "links": {"self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/", "last": "https://gracedb-dev1.ligo.org/api/events/S1234/log/", "first": "https://gracedb-dev1.ligo.org/api/events/S1234/log/"}}
{"numRows": 9, "start": 0, "log": [{"comment": "Original Data", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/initial.data,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/1", "issuer": "leo.singer@LIGO.ORG", "filename": "initial.data", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/1/tag/", "N": 1}, {"comment": "Log File Created", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/event.log,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/2", "issuer": "leo.singer@LIGO.ORG", "filename": "event.log", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/2/tag/", "N": 2}, {"comment": "Coinc Table Created", "file_version": 0, "tag_names": [], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/coinc.xml,0", "created": "2018-06-28 03:08:36 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/3", "issuer": "leo.singer@LIGO.ORG", "filename": "coinc.xml", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/3/tag/", "N": 3}, {"comment": "Set as preferred event for superevent: S180628g", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/4", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/4/tag/", "N": 4}, {"comment": "Noise PSD", "file_version": 0, "tag_names": ["psd"], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/psd.xml.gz,0", "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/5", "issuer": "leo.singer@LIGO.ORG", "filename": "psd.xml.gz", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/5/tag/", "N": 5}, {"comment": "Tagged message 5: psd ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:39 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/6", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/6/tag/", "N": 6}, {"comment": "bayestar sky localization complete", "file_version": 0, "tag_names": ["sky_loc", "lvem"], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/bayestar.fits.gz,0", "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/7", "issuer": "leo.singer@LIGO.ORG", "filename": "bayestar.fits.gz", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/7/tag/", "N": 7}, {"comment": "Tagged message 7: sky_loc ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/8", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/8/tag/", "N": 8}, {"comment": "Tagged message 7: lvem ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 03:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/9", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/9/tag/", "N": 9}, {"comment": "lalinference sky localization complete", "file_version": 0, "tag_names": ["sky_loc", "lvem"], "file": "https://gracedb-dev1.ligo.org/api/events/S1234/files/LALInference.fits.gz,0", "created": "2018-06-28 04:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/10", "issuer": "leo.singer@LIGO.ORG", "filename": "LALInference.fits.gz", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/10/tag/", "N": 10},{"comment": "Tagged message 10: sky_loc ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 04:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/11", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/11/tag/", "N": 11}, {"comment": "Tagged message 10: lvem ", "file_version": null, "tag_names": [], "file": null, "created": "2018-06-28 04:08:44 UTC", "self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/12", "issuer": "leo.singer@LIGO.ORG", "filename": "", "tags": "https://gracedb-dev1.ligo.org/api/events/S1234/log/12/tag/", "N": 12}], "links": {"self": "https://gracedb-dev1.ligo.org/api/events/S1234/log/", "last": "https://gracedb-dev1.ligo.org/api/events/S1234/log/", "first": "https://gracedb-dev1.ligo.org/api/events/S1234/log/"}}
{
"start": 0,
"numRows": 1,
"voevents": [{
"voevent_type": "PR",
"numRows": 2,
"voevents": [
{"voevent_type": "PR",
"file_version": 0,
"ivorn": "ivo://gwnet/gcn_sender#S1234-1-Preliminary",
"ivorn": "ivo://gwnet/gcn_sender#S1234-1-Initial",
"created": "2018-06-28 13:42:02 UTC",
"issuer": "emfollow",
"filename": "S1234-1-Preliminary.xml",
"filename": "S1234-1-Initial.xml",
"N": 1,
"links": {
"self": "https://gracedb-playground.ligo.org/api/superevents/S1234/voevents/1/",
"file": ["https://gracedb-playground.ligo.org/api/superevents/S1234/files/S1234-1-Preliminary.xml,0"]
},
"text": "voevent text"}],
"file": ["https://gracedb-playground.ligo.org/api/superevents/S1234/files/S1234-1-Initial.xml,0"]},
"text": "voevent text"},
{"voevent_type": "IN",
"file_version": 0,
"ivorn": "ivo://gwnet/gcn_sender#S1234-2-Update",
"created": "2018-06-28 14:42:02 UTC",
"issuer": "emfollow",
"filename": "S1234-2-Update.xml",
"N": 2,
"links": {
"self": "https://gracedb-playground.ligo.org/api/superevents/S1234/voevents/2/",
"file": ["https://gracedb-playground.ligo.org/api/superevents/S1234/files/S1234-2-Update.xml,0"]},
"text": "voevent text"}],
"links": {
"self": "https://gracedb-playground.ligo.org/api/superevents/S1234/voevents/",
"first": "https://gracedb-playground.ligo.org/api/superevents/S1234/voevents/",
......
......@@ -17,13 +17,20 @@ class MockGraceDb(object):
def _open(self, graceid, filename):
filename = os.path.join('data', graceid, filename)
f = io.open(pkg_resources.resource_filename(__name__, filename))
if filename.endswith('.fits.gz'):
from astropy.utils.data import download_file
url = ('https://dcc.ligo.org/public/0145/T1700453/001/'
'LALInference_v1.fits.gz')
f = io.open(download_file(url, cache=False), 'rb')
return f
else:
f = io.open(pkg_resources.resource_filename(__name__, filename))
def get_json():
return json.load(f)
def get_json():
return json.load(f)
f.json = get_json
return f
f.json = get_json
return f
def superevent(self, graceid):
return self._open(graceid, 'superevent.json')
......@@ -37,7 +44,7 @@ class MockGraceDb(object):
def voevents(self, graceid):
return self._open(graceid, 'voevents.json')
def files(self, graceid, filename=None):
def files(self, graceid, filename=None, raw=True):
if filename is None:
return self._open(graceid, 'files.json')
else:
......
......@@ -30,6 +30,7 @@ install_requires =
humanize
jinja2
ligo-gracedb >= 1.29.dev1
ligo.skymap
lxml
numpy
namespace_packages = ligo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment