35matplotlib.rcParams.update({
37 "axes.titlesize": 10.0,
38 "axes.labelsize": 10.0,
39 "xtick.labelsize": 8.0,
40 "ytick.labelsize": 8.0,
41 "legend.fontsize": 8.0,
46from matplotlib.backends.backend_agg
import FigureCanvasAgg
as FigureCanvas
47from matplotlib.figure
import Figure
50from optparse
import OptionParser
52from lalburst
import git_version
54__author__ =
"Daichi Tsuna <>"
55__version__ =
"git id %s" % git_version.id
56__date__ = git_version.date
60 parser = OptionParser(
61 version =
"Name: %%prog\n%s" % git_version.verbose_msg
63 parser.add_option(
"-v",
"--verbose", action =
"store_true",
65 parser.add_option(
"-t",
"--live-time", dest=
"livetime",
67 help =
"The total amount of live time in the run")
69 options, filenames = parser.parse_args()
70 if options.livetime
is None:
71 raise ValueError(
"No live time specified. Use -t or --live-time.")
73 raise ValueError(
"No data file specified.")
74 return options, filenames
80 fig.set_size_inches(4.5, 4.5)
81 axes = fig.add_axes((.12, .15, .98 - .12, .90 - .15))
83 axes.contour(x, y, avg, [neventsUL], linestyles=
'solid', colors=
'r')
84 axes.contour(x, y, min, [neventsUL], linestyles=
'dashed', colors=
'r')
85 axes.contour(x, y, max, [neventsUL], linestyles=
'dashed', colors=
'r')
86 axes.set_xlim([x.min(),x.max()])
87 axes.set_ylim([y.min(),y.max()])
88 axes.set_title(
r"95\% upper limit")
89 axes.set_xlabel(
r"$G\mu$")
90 axes.set_ylabel(
r"$p$")
99prob, gmu, avg, min, max = [], [], [], [], []
100for line
in open(filenames[0],
'r'):
104 for arr, val
in zip((prob, gmu, avg, min, max), line.split()):
105 arr.append(float(val))
107gmuindex = dict((b, a)
for a, b
in enumerate(sorted(set(gmu))))
108pindex = dict((b, a)
for a, b
in enumerate(sorted(set(prob))))
111assert len(pindex) * len(gmuindex) == len(gmu)
113avgarr = numpy.zeros([len(pindex), len(gmuindex)], dtype =
"double")
114minarr = numpy.zeros([len(pindex), len(gmuindex)], dtype =
"double")
115maxarr = numpy.zeros([len(pindex), len(gmuindex)], dtype =
"double")
117for p, g, val
in zip(prob, gmu, avg):
118 avgarr[pindex[p], gmuindex[g]] = val
119for p, g, val
in zip(prob, gmu, min):
120 minarr[pindex[p], gmuindex[g]] = val
121for p, g, val
in zip(prob, gmu, max):
122 maxarr[pindex[p], gmuindex[g]] = val
124avgarr *= options.livetime
125minarr *= options.livetime
126maxarr *= options.livetime
128numberofeventsUL = -numpy.log(1-0.95)
130x = numpy.array(sorted(gmuindex.keys()))
131y = numpy.array(sorted(pindex.keys()))
133cosmo_contour(x, y, avgarr, minarr, maxarr, numberofeventsUL,
"constraint")
def cosmo_contour(x, y, avg, min, max, neventsUL, filename)