Commit bcf7ca28 authored by Leo Pound Singer's avatar Leo Pound Singer

Refactor reading sky maps from GraceDb

parent 3df29bad
Pipeline #25452 failed with stages
in 30 seconds
......@@ -108,10 +108,10 @@ def compose(gracedb_id, authors=(), mailto=False,
return '{0}\n{1}'.format(subject, body)
def read_map_gracedb(path, client):
def read_map_gracedb(graceid, filename, client):
import healpy as hp
with tempfile.NamedTemporaryFile() as localfile:
remotefile = client.files(*path.split('/'), raw=True)
remotefile = client.files(graceid, filename, raw=True)
try:
shutil.copyfileobj(remotefile, localfile)
finally:
......@@ -121,6 +121,10 @@ def read_map_gracedb(path, client):
return m
def read_map_from_path(path, client):
return read_map_gracedb(*path.split('/'), client)
def mask_cl(p, level=90):
import numpy as np
pflat = p.ravel()
......@@ -139,7 +143,7 @@ def compare_skymaps(paths, service=rest.DEFAULT_SERVICE_URL, client=None):
import healpy as hp
filenames = [path.split('/')[1] for path in paths]
pipelines = [guess_skyloc_pipeline(filename) for filename in filenames]
probs = [read_map_gracedb(path, client) for path in paths]
probs = [read_map_from_path(path, client) for path in paths]
npix = max(len(prob) for prob in probs)
nside = hp.npix2nside(npix)
deg2perpix = hp.nside2pixarea(nside, degrees=True)
......
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