From aa10fba100b9971219eed74bb911cfe66b879f1d Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Fri, 20 Apr 2018 15:38:39 +0900
Subject: [PATCH] gstlal_inspiral_marginalize_likelihood

- add --density-estimate-zero-lag
---
 .../bin/gstlal_inspiral_marginalize_likelihood       | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gstlal-inspiral/bin/gstlal_inspiral_marginalize_likelihood b/gstlal-inspiral/bin/gstlal_inspiral_marginalize_likelihood
index 0fdf053504..b9fea9eee4 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_marginalize_likelihood
+++ b/gstlal-inspiral/bin/gstlal_inspiral_marginalize_likelihood
@@ -23,6 +23,7 @@
 #
 #	+ `--ignore-missing`: Ignore and skip missing input documents.
 #	+ `--marginalize` {ranking-stat|ranking-stat-pdf}: Set which set of PDFs to marginalize, the ranking statistics themselves, or the distributions of ranking statistic values (default: ranking-stat).
+#	+ `--density-estimate-zero-lag`: Apply density estimation algorithm to zero-lag PDFs (default: do not).  Requires --marginalize=ranking-stat-pdf.  In the online analysis, the ingested zero-lag histograms contain raw bin counts, but the consumer of this program's output requires the PDFs to be properly density-estimated, so we provide the option of performing that operation here as a courtesy.  This will probably work differently one day.
 #	+ `--output` [filename]: Set the output file name (default = write to stdout).
 #	+ `--likelihood-cache` [filename]: Set the cache file name from which to read likelihood files
 #	+ `--verbose`: Be verbose.
@@ -70,6 +71,7 @@ def parse_command_line():
 	)
 	parser.add_option("--ignore-missing", action = "store_true", help = "Ignore and skip missing input documents.")
 	parser.add_option("--marginalize", metavar = "{ranking-stat|ranking-stat-pdf}", default = "ranking-stat", help = "Set which set of PDFs to marginalize, the ranking statistics themselves, or the distributions of ranking statistic values (default: ranking-stat).")
+	parser.add_option("--density-estimate-zero-lag", action = "store_true", help = "Apply density estimation algorithm to zero-lag PDFs (default: do not).  Requires --marginalize=ranking-stat-pdf.  In the online analysis, the ingested zero-lag histograms contain raw bin counts, but the consumer of this program's output requires the PDFs to be properly density-estimated, so we provide the option of performing that operation here as a courtesy.  This will probably work differently one day.")
 	parser.add_option("-o", "--output", metavar = "filename", help = "Set the output file name (default = write to stdout).")
 	parser.add_option("--likelihood-cache", metavar = "filename", help = "Set the cache file name from which to read likelihood files.")
 	parser.add_option("--verbose", action = "store_true", help = "Be verbose.")
@@ -78,6 +80,8 @@ def parse_command_line():
 
 	if options.marginalize not in ("ranking-stat", "ranking-stat-pdf"):
 		raise ValueError("--marginalize must be one of 'ranking-stat' or 'ranking-stat-pdf'")
+	if options.density_estimate_zero_land and options.marginalize != "ranking-stat-pdf":
+		raise ValueError("--density-estimate-zero-lag cannot be set unless --marginalize=ranking-stat-pdf")
 
 	if options.likelihood_cache:
 		urls += [CacheEntry(line).url for line in open(options.likelihood_cache)]
@@ -131,6 +135,14 @@ marginalized = far.marginalize_pdf_urls(
 )
 
 
+#
+# Apply density estimation to zero-lag rates
+#
+
+
+rankingstatpdf.density_estimate_zero_lag_rates()
+
+
 #
 # write output document
 #
-- 
GitLab