From 447bb27df72b4516dc7556e0c5aec842791c3af4 Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Sun, 15 Apr 2018 09:05:20 -0500
Subject: [PATCH] gstlal_inspiral: rename --marginalized-likelihood-file

- to --ranking-stat-pdf to more correctly describe what this command line option does.
- also switch to using the load_url() function, instead of load_filename(), to anticipate getting this data from a non-disk location in O3.
---
 gstlal-inspiral/bin/gstlal_inspiral           | 10 +++----
 ...inspiral_recompute_online_far_from_gracedb |  2 +-
 gstlal-inspiral/bin/gstlal_ll_inspiral_pipe   |  4 +--
 gstlal-inspiral/python/inspiral.py            | 26 +++++++++----------
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gstlal-inspiral/bin/gstlal_inspiral b/gstlal-inspiral/bin/gstlal_inspiral
index 7647b9f789..0652f05ade 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral
+++ b/gstlal-inspiral/bin/gstlal_inspiral
@@ -151,7 +151,7 @@
 #	+ `--reference-likelihood-file` [filename]: Set the name of the likelihood ratio data file to use for ranking events.  Can only use with --data-source lvshm or framexmit, must also set --likelihood-snapshot-interval.
 #	+ `--zerolag-rankingstatpdf-filename` [filename]: Record a histogram of the likelihood ratio ranking statistic values assigned to zero-lag candidates in this XML file, which must exist at start up and contain a RankingStatPDF object.  The counts will be added to the file.  Optional.  Can be given multiple times.
 #	+ `--likelihood-snapshot-interval` [seconds] (float): How often to reread the marginalized likelihoood data. If --likelihood-file is provided, the likelihood file will be overwritten by a snapshot of the trigger files and a duplicate snapshot will be generated to keep a record of past ranking statistics.
-#	+ `--marginalized-likelihood-file` [filename]: Set the name of the file from which to load initial marginalized likelihood ratio data.  This is required for online operation (when --data-source is framexmit or lvshm) and is forbidden for offline operation (all other data sources).
+#	+ `--ranking-stat-pdf` [url]: Set the URL from which to load the ranking statistic PDF.  This is used to compute false-alarm probabilities and false-alarm rates and is required for online operation (when --data-source is framexmit or lvshm).  It is forbidden for offline operation (all other data sources).
 #	+ `--gracedb-far-threshold` (float): False-alarm rate threshold for gracedb uploads in Hertz (default = do not upload to gracedb).
 #	+ `--gracedb-search`: Name of search to provide in GracedB uploads (default is LowMass).
 #	+ `--gracedb-pipeline`: Name of pipeline to provide in GracedB uploads (default is gstlal).
@@ -300,7 +300,7 @@ def parse_command_line():
 	group.add_option("--likelihood-file", metavar = "filename", action = "append", default = [], help = "Set the name of the file to which to write ranking statistic data collected from triggers (optional).  Can be given more than once.  If given, exactly as many must be provided as there are --svd-bank options and they will be writen to in order.")
 	group.add_option("--likelihood-file-cache", metavar = "filename", help = "Provide a cache of likelihood files.  This can be used instead of giving multiple --likelihood-file options.  Cannot be combined with --likelihood-file.")
 	group.add_option("--likelihood-snapshot-interval", type = "float", metavar = "seconds", help = "How often to reread the marginalized likelihoood data. If --likelihood-file is provided, the likelihood file will be overwritten by a snapshot of the trigger files and a duplicate snapshot will be generated to keep a record of past ranking statistics.")
-	group.add_option("--marginalized-likelihood-file", metavar = "filename", help = "Set the name of the file from which to load initial marginalized likelihood ratio data.  This is required for online operation (when --data-source is framexmit or lvshm) and is forbidden for offline operation (all other data sources).")
+	group.add_option("--ranking-stat-pdf", metavar = "url", help = "Set the URL from which to load the ranking statistic PDF.  This is used to compute false-alarm probabilities and false-alarm rates and is required for online operation (when --data-source is framexmit or lvshm).  It is forbidden for offline operation (all other data sources)")
 	group.add_option("--reference-likelihood-file", metavar = "filename", help = "Set the name of the likelihood ratio data file to use for ranking events.  Can only use with --data-source lvshm or framexmit, must also set --likelihood-snapshot-interval.")
 	group.add_option("--time-slide-file", metavar = "filename", help = "Set the name of the xml file to get time slide offsets (required).")
 	group.add_option("--zerolag-rankingstatpdf-filename", metavar = "filename", action = "append", help = "Record a histogram of the likelihood ratio ranking statistic values assigned to zero-lag candidates in this XML file, which must exist at start up and contain a RankingStatPDF object.  The counts will be added to the file.  Optional.  Can be given multiple times.")
@@ -429,7 +429,7 @@ def parse_command_line():
 
 	if options.data_source in ("lvshm", "framexmit"):
 		missing_options = []
-		for option in ["job_tag", "marginalized_likelihood_file"]:
+		for option in ["job_tag", "ranking_stat_pdf"]:
 			if getattr(options, option) is None:
 				missing_options.append("--%s" %option.replace("_","-"))
 
@@ -446,7 +446,7 @@ def parse_command_line():
 		os.environ['GSTLAL_LL_JOB'] = options.job_tag
 	else:
 		bad_options = []
-		for option in ["job_tag", "marginalized_likelihood_file", "likelihood_snapshot_interval"]:
+		for option in ["job_tag", "ranking_stat_pdf", "likelihood_snapshot_interval"]:
 			if getattr(options, option) is not None:
 				bad_options.append("--%s" % option.replace("_","-"))
 		if bad_options:
@@ -809,7 +809,7 @@ for output_file_number, (svd_bank_url_dict, output_url, likelihood_url, zerolag_
 		pipeline = pipeline,
 		rankingstat = rankingstat,
 		zerolag_rankingstatpdf_filename = zerolag_rankingstatpdf_filename,
-		rankingstatpdf_filename = options.marginalized_likelihood_file,
+		rankingstatpdf_url = options.ranking_stat_pdf,
 		likelihood_url = likelihood_url,
 		reference_likelihood_url = options.reference_likelihood_file,
 		likelihood_snapshot_interval = options.likelihood_snapshot_interval,
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_recompute_online_far_from_gracedb b/gstlal-inspiral/bin/gstlal_inspiral_recompute_online_far_from_gracedb
index 99c70b00a2..fdc60be53f 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_recompute_online_far_from_gracedb
+++ b/gstlal-inspiral/bin/gstlal_inspiral_recompute_online_far_from_gracedb
@@ -75,7 +75,7 @@ def get_likelihood_files(gid_list, gracedb):
 	for gid in gid_list:
 		coinc_xmldoc = lvalert_helper.get_coinc_xmldoc(gracedb, gid)
 		likelihood_files_dict.setdefault(ligolw_process.get_process_params(coinc_xmldoc, "gstlal_inspiral", "--likelihood-file")[0], []).append([gid, coinc_xmldoc])
-		marg_files_dict.setdefault(ligolw_process.get_process_params(coinc_xmldoc, "gstlal_inspiral", "--marginalized-likelihood-file")[0], []).append(gid)
+		marg_files_dict.setdefault(ligolw_process.get_process_params(coinc_xmldoc, "gstlal_inspiral", "--ranking-stat-pdf")[0], []).append(gid)
 
 	if len(marg_files_dict.keys()) > 1:
 		raise ValueError("the gracedb events specified have different marginalized likelihood files, all specified events need to come from the same analysis and thus share the same marginalized likelihood file")
diff --git a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
index 1feb2461e1..82424be971 100755
--- a/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
+++ b/gstlal-inspiral/bin/gstlal_ll_inspiral_pipe
@@ -422,7 +422,7 @@ for num_insp_nodes, (svd_banks, likefile, zerolikefile) in enumerate(zip(bank_gr
 			"min-log-L":options.min_log_L,
 			"time-slide-file":options.time_slide_file
 			},
-		input_files = {"marginalized-likelihood-file":options.marginalized_likelihood_file},
+		input_files = {"ranking-stat-pdf":options.marginalized_likelihood_file},
 		output_files = {"output":"not_used.xml.gz",
 				"likelihood-file":likefile,
 				"zerolag-rankingstatpdf-filename":zerolikefile,
@@ -468,7 +468,7 @@ for num_insp_nodes, (svd_banks, likefile, zerolikefile) in enumerate(zip(bank_gr
 				"min-log-L":options.min_log_L,
 				"time-slide-file":options.time_slide_file
 				},
-			input_files = {"marginalized-likelihood-file":options.marginalized_likelihood_file,
+			input_files = {"ranking-stat-pdf":options.marginalized_likelihood_file,
 			"reference-likelihood-file":[likefile]},
 			output_files = {"output":"not_used.xml.gz",
 				}
diff --git a/gstlal-inspiral/python/inspiral.py b/gstlal-inspiral/python/inspiral.py
index 3291b511b4..15e80e7a21 100644
--- a/gstlal-inspiral/python/inspiral.py
+++ b/gstlal-inspiral/python/inspiral.py
@@ -470,7 +470,7 @@ class CoincsDocument(object):
 
 
 class Data(object):
-	def __init__(self, coincs_document, pipeline, rankingstat, zerolag_rankingstatpdf_filename = None, rankingstatpdf_filename = None, likelihood_url = None, reference_likelihood_url = None, likelihood_snapshot_interval = None, thinca_interval = 50.0, min_log_L = None, sngls_snr_threshold = None, gracedb_far_threshold = None, gracedb_min_instruments = None, gracedb_group = "Test", gracedb_search = "LowMass", gracedb_pipeline = "gstlal", gracedb_service_url = "https://gracedb.ligo.org/api/", upload_auxiliary_data_to_gracedb = True, verbose = False):
+	def __init__(self, coincs_document, pipeline, rankingstat, zerolag_rankingstatpdf_filename = None, rankingstatpdf_url = None, likelihood_url = None, reference_likelihood_url = None, likelihood_snapshot_interval = None, thinca_interval = 50.0, min_log_L = None, sngls_snr_threshold = None, gracedb_far_threshold = None, gracedb_min_instruments = None, gracedb_group = "Test", gracedb_search = "LowMass", gracedb_pipeline = "gstlal", gracedb_service_url = "https://gracedb.ligo.org/api/", upload_auxiliary_data_to_gracedb = True, verbose = False):
 		#
 		# initialize
 		#
@@ -584,18 +584,18 @@ class Data(object):
 
 		#
 		# rankingstatpdf contains the RankingStatPDF object (loaded
-		# from rankingstatpdf_filename) used to initialize the
-		# FAPFAR object for on-the-fly FAP and FAR assignment.
-		# except to initialize the FAPFAR object it is not used for
-		# anything, but is retained so that it can be exposed
-		# through the web interface for diagnostic purposes and
-		# uploaded to gracedb with candidates.  the extinction
-		# model is applied to initialize the FAPFAR object but the
-		# original is retained for upload to gracedb, etc.
+		# from rankingstatpdf_url) used to initialize the FAPFAR
+		# object for on-the-fly FAP and FAR assignment.  except to
+		# initialize the FAPFAR object it is not used for anything,
+		# but is retained so that it can be exposed through the web
+		# interface for diagnostic purposes and uploaded to gracedb
+		# with candidates.  the extinction model is applied to
+		# initialize the FAPFAR object but the original is retained
+		# for upload to gracedb, etc.
 		#
 
 		# None to disable
-		self.rankingstatpdf_filename = rankingstatpdf_filename
+		self.rankingstatpdf_url = rankingstatpdf_url
 		self.rankingstatpdf = None
 		self.fapfar = None
 
@@ -730,7 +730,7 @@ class Data(object):
 				# overwritten.
 				self.pipeline.get_bus().post(message_new_checkpoint(self.pipeline, timestamp = buf_timestamp.ns()))
 
-				if self.rankingstatpdf_filename is not None:
+				if self.rankingstatpdf_url is not None:
 					# enable streamthinca's likelihood
 					# ratio assignment using our own,
 					# local, parameter distribution
@@ -757,9 +757,9 @@ class Data(object):
 					# been updated asynchronously and
 					# initialize a FAP/FAR assignment
 					# machine from it.
-					_, self.rankingstatpdf = far.parse_likelihood_control_doc(ligolw_utils.load_filename(self.rankingstatpdf_filename, verbose = self.verbose, contenthandler = far.RankingStat.LIGOLWContentHandler))
+					_, self.rankingstatpdf = far.parse_likelihood_control_doc(ligolw_utils.load_url(self.rankingstatpdf_url, verbose = self.verbose, contenthandler = far.RankingStat.LIGOLWContentHandler))
 					if self.rankingstatpdf is None:
-						raise ValueError("\"%s\" does not contain ranking statistic PDFs" % self.rankingstatpdf_filename)
+						raise ValueError("\"%s\" does not contain ranking statistic PDFs" % self.rankingstatpdf_url)
 					if not self.rankingstat.template_ids <= self.rankingstatpdf.template_ids:
 						raise ValueError("\"%s\" is for the wrong templates")
 					self.fapfar = far.FAPFAR(self.rankingstatpdf.new_with_extinction())
-- 
GitLab