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__ =
"Andrew Mergl <>"
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 / ((1 + math.sqrt(5)) / 2))
81 axes = fig.add_axes((.12, .15, .98 - .12, .90 - .15))
86 axes.contour(x, y, avg/p, [neventsUL], linestyles=
'solid', colors=
'r')
87 axes.contour(x, y, min/p, [neventsUL], linestyles=
'dashed', colors=
'r')
88 axes.contour(x, y, max/p, [neventsUL], linestyles=
'dashed', colors=
'r')
89 axes.set_xlim([x.min(),x.max()])
90 axes.set_ylim([y.min(),y.max()])
91 axes.set_title(
r"$P = %g$" % p)
92 axes.set_xlabel(
r"$G\mu$")
93 axes.set_ylabel(
r"$\epsilon$")
102p, n, eps, gmu, avg, min, max = [], [], [], [], [], [], []
103for line
in open(filenames[0],
'r'):
107 for arr, val
in zip((p, n, eps, gmu, avg, min, max), line.split()):
108 arr.append(float(val))
110epsindex = dict((b, a)
for a, b
in enumerate(sorted(set(eps))))
111gmuindex = dict((b, a)
for a, b
in enumerate(sorted(set(gmu))))
114assert len(epsindex) * len(gmuindex) == len(gmu)
116assert set(p) == set([1])
118avgarr = numpy.zeros([len(epsindex), len(gmuindex)], dtype =
"double")
119minarr = numpy.zeros([len(epsindex), len(gmuindex)], dtype =
"double")
120maxarr = numpy.zeros([len(epsindex), len(gmuindex)], dtype =
"double")
122for e, g, val
in zip(eps, gmu, avg):
123 avgarr[epsindex[e], gmuindex[g]] = val
124for e, g, val
in zip(eps, gmu, min):
125 minarr[epsindex[e], gmuindex[g]] = val
126for e, g, val
in zip(eps, gmu, max):
127 maxarr[epsindex[e], gmuindex[g]] = val
129avgarr *= options.livetime
130minarr *= options.livetime
131maxarr *= options.livetime
133numberofeventsUL = -numpy.log(1-0.90)
135x = numpy.array(sorted(gmuindex.keys()))
136y = numpy.array(sorted(epsindex.keys()))
138cosmo_contour(x, y, avgarr, minarr, maxarr, 1.000, numberofeventsUL,
"gmu-eps-p1e+0")
139cosmo_contour(x, y, avgarr, minarr, maxarr, 0.100, numberofeventsUL,
"gmu-eps-p1e-1")
140cosmo_contour(x, y, avgarr, minarr, maxarr, 0.010, numberofeventsUL,
"gmu-eps-p1e-2")
141cosmo_contour(x, y, avgarr, minarr, maxarr, 0.001, numberofeventsUL,
"gmu-eps-p1e-3")
def cosmo_contour(x, y, avg, min, max, p, neventsUL, filename)