3 # Copyright (C) 2017 Kipp Cannon
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # =============================================================================
25 # =============================================================================
31 matplotlib.rcParams.update({
33 "axes.titlesize": 10.0,
34 "axes.labelsize": 10.0,
35 "xtick.labelsize": 8.0,
36 "ytick.labelsize": 8.0,
37 "legend.fontsize": 8.0,
43 from optparse
import OptionParser
47 from ligo
import segments
48 from gstlal
import far
49 from gstlal.plots
import far as plotfar
53 # =============================================================================
57 # =============================================================================
61 def parse_command_line():
62 parser = OptionParser()
63 parser.add_option("--max-snr", metavar = "snr", type = "
float", default = 200.0, help = "Set the maximum SNR for (chi^2, snr) plots (default = 200.0).")
64 parser.add_option("--output-format", metavar = "extension", default = ".png", help = "Select output format by choosen the filename extension (default = \".png\").")
65 parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose.")
66 options, filenames = parser.parse_args()
68 if options.output_format not in (".png", ".pdf", ".svg"):
69 raise ValueError("invalid --output-format \"%s\"" % options.output_format)
71 return options, filenames
75 # =============================================================================
79 # =============================================================================
88 options, filenames = parse_command_line()
96 rankingstat = far.RankingStat(instruments = frozenset((
"H1",)), min_instruments = 1)
100 # place a grid of impulses into the arrays and smooth
104 for x in 1.5**numpy.arange(4, 13):
105 for y in 3.**numpy.arange(-8, 0):
106 rankingstat.background_rates[
"H1_snr_chi"][x, y] = 1e8
115 if rankingstat is not None:
116 fig = plotfar.plot_snr_chi_pdf(rankingstat,
"H1",
"background_pdf", options.max_snr)
117 plotname =
"coinc_params_binning%s" % options.output_format
119 print >>sys.stderr,
"writing %s" % plotname
120 fig.savefig(plotname)
123 # ranking statistic PDFs and CCDFs
124 #fig = plotfar.plot_likelihood_ratio_pdf(rankingstatpdf, (options.min_log_lambda, options.max_log_lambda), "Noise", which = "noise")
125 #plotname = "coinc_params_binning%s" % options.output_format
127 # print >>sys.stderr, "writing %s" % plotname
128 #fig.savefig(plotname)