3 # Copyright (C) 2018 Chad Hanna
4 # Copyright (C) 2019 Patrick Godwin
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the
8 # Free Software Foundation; either version 2 of the License, or (at your
9 # option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 # Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import sys, os, glob, shutil, time
25 from optparse
import OptionParser
26 from ligo.scald
import report
28 ABOUT_URL =
'https://docs.google.com/document/d/12wJjCz8L1UczqRm86q3-EFnpnIZ2FHPSwKR_kym2L5g/pub?embedded=true'
29 SCHEDULE_URL =
'https://docs.google.com/spreadsheets/d/e/2PACX-1vR1XwazhZYoVbMXFZCq_s2rlzyNwcF0xC4kyhnKrCeXFSWte-2jRodL590RU3PsoX4OVypYyAZ7Nl_8/pubhtml?widget=true&headers=false'
30 IMAGE_URL =
'https://results.ligo.uwm.edu/~gstlalcbc/share/vis/gstlal.png'
34 with open(path,
'r') as f:
35 return json.loads(f.read())
38 def parse_command_line():
39 parser = OptionParser(usage =
"%prog [options] [file ...]", description =
"%prog summary web page")
40 parser.add_option(
"--webserver-dir", help =
"Set the directory for the webserver. Required. Example /archive/home/channa/public_html/highmass_months_23-24_summary_page")
41 parser.add_option(
"--open-box", action =
"store_true", help =
"Produce open box page")
42 parser.add_option(
"--output-user-tag", action =
"append", metavar =
"name", help =
"Set the basename for image search")
43 parser.add_option(
"--title", default=
"gstlal_inspiral offline analysis")
44 parser.add_option(
"--glob-path", help =
"This is the path to search for images")
46 opts, filenames = parser.parse_args()
47 return opts, filenames
54 opts, files = parse_command_line()
55 reportdir = opts.webserver_dir+
'_lite'
57 thisreport = report.Report(
'gstlal analysis', image=IMAGE_URL)
60 os.makedirs(reportdir)
68 summary = report.Tab(
'Summary')
69 about_doc = report.Tab(
'About', url=ABOUT_URL)
70 sched_doc = report.Tab(
'Schedule', url=SCHEDULE_URL)
77 summary += report.Header(
'Summary')
78 summary += report.Description(
"This page was generated on %s by %s in the working directory: %s" % (time.strftime(
"%Y-%m-%d %H:%M"), os.environ[
"USER"], os.environ[
"PWD"]))
82 # IFAR, ln L plots and table
85 summary += report.Header(
'Rate vs. Threshold')
86 summary += report.Description(
"This section provides the detection statistic plots and a summary of the loudest event.")
88 summary += report.Header(
'Closed Box Results')
89 imgfooter =
"Comparison of single time slide event rate to event rate expected from background as a function of threshold."
90 summary += report.ImageGrid(
"Rate vs. Threshold", grid_size=3, footer=imgfooter).glob(os.path.join(opts.glob_path,
'*5_count_vs_*_closedbox*.png'))
92 tabledata = load_json(os.path.join(opts.glob_path,
'%sbgsummary_table.json' % opts.output_user_tag[0]))
93 summary += report.Table(
'Closed Box Summary Table').save(tabledata, reportdir)
96 summary += report.Header(
'Open Box Results')
97 imgfooter =
"Comparison of single time slide event rate to event rate expected from background as a function of threshold."
98 summary += report.ImageGrid(
"Rate vs. Threshold", grid_size=3, footer=imgfooter).glob(os.path.join(opts.glob_path,
'*5_count_vs_*_openbox*.png'))
100 tabledata = load_json(os.path.join(opts.glob_path,
'%ssummary_table.json' % opts.output_user_tag[0]))
101 summary += report.Table(
'Open Box Summary Table').save(tabledata, reportdir)
103 ## Include found/missed as function of decisive characteristic SNR
104 summary += report.Header(
"Found / Missed Expected SNR")
105 summary += report.Description(
"""Measuring the found and missed injections as a function of various parameters aids in diagnosing the pipeline as well as providing the expected sensitivity of the pipeline to real signals. The plots in this section show the missed and found injections for the various IFO times for coincident triggers.""")
107 tabledata = load_json(os.path.join(opts.glob_path,
'%s_injection_summary.json' % opts.output_user_tag[0]))
108 footer =
"Summary of missed and found injections broken up by detector time for %s" % opts.output_user_tag[0]
109 summary += report.Table(
'Injection Summary Table', footer=footer).save(tabledata, reportdir)
111 plots = os.path.join(opts.glob_path,
'*%s*1_dec_expsnr_vs_mchirp_*.png' % opts.output_user_tag[0])
112 imgfooter =
"Expected SNR of found and missed injections as a function of chirp mass: %s" % opts.output_user_tag[0]
113 summary += report.ImageGrid(
"Expected SNR vs. chirp mass", grid_size=4, footer=imgfooter).glob(plots)
115 ## Include missed injection table
116 summary += report.Header(
"Missed Table")
117 tabledata = load_json(os.path.join(opts.glob_path,
'%s_missed_summary.json' % opts.output_user_tag[0]))
118 summary += report.Table(
'Missed Injection Table for %s' % opts.output_user_tag[0]).save(tabledata, reportdir)
121 ## Include search sensitivity binned by source type
122 summary += report.Header(
'Search Sensitivity')
123 summary += report.Description(
"""These plots characterize the overall sensitivity of the search. The detection rate is directly proportional to the observed sensitive volume, which is a function of the significance threshold used to identify candidates. These plots are useful for determining how sensitive the search was to the input injection population. Here we show the sensitivity as a function of source type: BNS mchirp between 0.8 and 2, NSBH between 2 and 4.5, BBH between 4.5 and 45.0, IMBH between 45.0 and 450.0""")
125 plots = os.path.join(opts.glob_path,
'*%s*_BINNED_BY_SOURCE_TYPE*.png' % opts.output_user_tag[0])
126 imgfooter =
"Binned by source type"
127 summary += report.ImageGrid(
"Sensitive volume (V*T) and mean sensitive distance: %s" % opts.output_user_tag[0], grid_size=4, footer=imgfooter, visible=False).glob(plots)
129 ## Include horizon distance plots
130 imgfooter =
"This is the distance at which you should see a 1.4 1.4 Msun binary at SNR 8. The first panel shows the time evolution of the horizon distance and the second panel shows the same information in histogram form."
131 summary += report.ImageGrid(
"Horizon distance", grid_size=1, footer=imgfooter).glob(os.path.join(opts.glob_path,
'*HORIZON*.png'))
134 tabledata = load_json(os.path.join(opts.glob_path,
'%s_plot_summary.json' % opts.output_user_tag[0]))
135 summary += report.Table(
'Search Summary').save(tabledata, reportdir)
137 ## Include Chi-square distribution plots
138 summary += report.Header(
"Chi-squared Distributions")
139 summary += report.Description(
"The chi-squared test checks that the snr accumulated matches expectation.")
141 imgfooter =
"Chi-squared vs snr for single detectors after coincidence. Blue points are full data zero lag, red are software injections and black are time slides."
142 summary += report.ImageGrid(
"Chi-squared Distributions", grid_size=3, footer=imgfooter).glob(os.path.join(opts.glob_path,
'*3_chi2_vs_rho_*closedbox*.png'))
144 summary += report.ImageGrid(
"Chi-squared Distributions: Zero lag", grid_size=3, footer=imgfooter).glob(os.path.join(opts.glob_path,
'*3_chi2_vs_rho_*openbox*.png'))
146 thisreport += summary
147 thisreport += about_doc
148 thisreport += sched_doc
154 thisreport.save(reportdir, config_name=
'report_lite')