Commit f6f33b4c authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

Match bayestar_{aggregate_found_injections,plot_allsky} command line options

Original: 2f060a556503abdae7b1432181afba81533252fb
parent 0eb80bef
......@@ -50,8 +50,8 @@ if __name__ == '__main__':
help="Name of output file [default: %default]"),
Option("-j", "--jobs", default=1, type=int,
help="Number of threads [default: %default]"),
Option("-p", "--prob-contour", default=[], action="append",
type=float, metavar="0.DD",
Option("-p", "--contour", default=[], action="append",
type=float, metavar="PERCENT",
help="Report the area of the smallest contour containing this "
+ "much probability. Can be repeated mulitple times")
......@@ -75,10 +75,10 @@ from lalinference.bayestar import fits
from lalinference.bayestar import postprocess
def startup(dbfilename, opts_prob_contour):
global db, prob_contours
def startup(dbfilename, opts_contour):
global db, contours
db = sqlite3.connect(dbfilename)
prob_contours = opts_prob_contour
contours = opts_contour
def process(fitsfilename):
......@@ -100,10 +100,10 @@ def process(fitsfilename):
WHERE cem1.table_name = 'sim_inspiral'
AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?""",
searched_area, searched_prob, offset, prob_areas = postprocess.find_injection(
sky_map, true_ra, true_dec, prob_contours=prob_contours)
searched_area, searched_prob, offset, contour_areas = postprocess.find_injection(
sky_map, true_ra, true_dec, contours=[0.01 * p for p in contours])
return [coinc_event_id, simulation_id, far, searched_area, searched_prob, offset, runtime] + prob_areas
return [coinc_event_id, simulation_id, far, searched_area, searched_prob, offset, runtime] + contour_areas
if __name__ == '__main__':
......@@ -117,8 +117,8 @@ if __name__ == '__main__':
from itertools import imap
import multiprocessing
imap = multiprocessing.Pool(, startup, (dbfilename, opts.prob_contour)).imap_unordered
startup(dbfilename, opts.prob_contour)
imap = multiprocessing.Pool(, startup, (dbfilename, opts.contour)).imap_unordered
startup(dbfilename, opts.contour)
progress.update(-1, 'obtaining filenames of sky maps')
fitsfilenames = tuple(itertools.chain.from_iterable(glob.iglob(fitsfileglob)
......@@ -126,7 +126,7 @@ if __name__ == '__main__':
colnames = ['coinc_event_id', 'simulation_id', 'far', 'searched_area',
'searched_prob', 'offset', 'runtime'] + ["area({0:g})".format(p)
for p in prob_contours]
for p in contours]
print(*colnames, sep="\t", file=outfile)
count_records = 0
......@@ -38,7 +38,7 @@ def angle_distance(theta0, phi0, theta1, phi1):
return np.arccos(cos_angle_distance)
def find_injection(sky_map, true_ra, true_dec, prob_contours=()):
def find_injection(sky_map, true_ra, true_dec, contours=()):
Given a sky map and the true right ascension and declination (in radians),
find the smallest area in deg^2 that would have to be searched to find the
......@@ -89,13 +89,13 @@ def find_injection(sky_map, true_ra, true_dec, prob_contours=()):
# For each of the given confidence levels, compute the area of the
# smallest region containing that probability.
prob_areas = [(np.searchsorted(cum_sky_map, p, side='right') + 1)
* deg2perpix for p in prob_contours]
contour_areas = [(np.searchsorted(cum_sky_map, p, side='right') + 1)
* deg2perpix for p in contours]
# Find the angular offset between the mode and true locations.
offset = np.rad2deg(angle_distance(true_theta, true_phi,
mode_theta, mode_phi))
# Done.
return searched_area, searched_prob, offset, prob_areas
return searched_area, searched_prob, offset, contour_areas
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