From 157fa96dc59e4bc9e893368a478a773592849e54 Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Mon, 27 Mar 2017 17:53:07 +0900
Subject: [PATCH] gstlal-inspiral: replace deprecated functions

- glue.ligolw.lsctables.instrument_set_from_ifos() --> instrumentsproperty.get()
- glue.ligolw.lsctables.ifos_from_instrument_set() --> instrumentsproperty.set()
---
 gstlal-inspiral/bin/gstlal_inspiral                  |  2 +-
 gstlal-inspiral/bin/gstlal_inspiral_calc_likelihood  |  2 +-
 gstlal-inspiral/bin/gstlal_inspiral_pipe             |  2 +-
 gstlal-inspiral/bin/gstlal_inspiral_plot_sensitivity |  2 +-
 gstlal-inspiral/bin/gstlal_inspiral_plotsummary      | 12 ++++++------
 gstlal-inspiral/python/far.py                        | 10 +++++-----
 gstlal-inspiral/python/stats/inspiral_extrinsics.py  |  5 +++--
 .../gstlal_inspiral_recalc_rank_pdfs                 |  4 ++--
 gstlal-ugly/bin/gstlal_glitch_population             |  2 +-
 9 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/gstlal-inspiral/bin/gstlal_inspiral b/gstlal-inspiral/bin/gstlal_inspiral
index 11a5cb1090..0d5c8b0216 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral
+++ b/gstlal-inspiral/bin/gstlal_inspiral
@@ -749,7 +749,7 @@ for output_file_number, (svd_bank_url_dict, output_url, likelihood_url_namedtupl
 	if options.verbose:
 		print >>sys.stderr, "initializing output document ..."
 	output = inspiral.Data(
-		url = output_url or "%s-%s_LLOID-%d-%d.xml.gz" % (lsctables.ifos_from_instrument_set(detectors.channel_dict.keys()).replace(",", ""), options.job_tag, int(detectors.seg[0]), int(abs(detectors.seg))),
+		url = output_url or "%s-%s_LLOID-%d-%d.xml.gz" % (lsctables.instrumentsproperty.set(detectors.channel_dict.keys()).replace(",", ""), options.job_tag, int(detectors.seg[0]), int(abs(detectors.seg))),
 		process_params = process_params,
 		pipeline = pipeline,
 		seg = detectors.seg or segments.segment(LIGOTimeGPS(0), LIGOTimeGPS(2000000000)), # online data doesn't have a segment so make it all possible time
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_calc_likelihood b/gstlal-inspiral/bin/gstlal_inspiral_calc_likelihood
index 1d6e6d46df..647d56c4f7 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_calc_likelihood
+++ b/gstlal-inspiral/bin/gstlal_inspiral_calc_likelihood
@@ -261,7 +261,7 @@ for n, url in enumerate(urls, 1):
 		for row in lsctables.CoincTable.get_table(xmldoc):
 			if row.coinc_def_id != coinc_def_id:
 				continue
-			instruments = lsctables.instrument_set_from_ifos(coinc_inspiral_index[row.coinc_event_id].ifos)
+			instruments = lsctables.instrumentsproperty.get(coinc_inspiral_index[row.coinc_event_id].ifos)
 			ln_likelihood_ratio = row.likelihood
 			if any(offset_vectors[row.time_slide_id].values()):
 				ranking_data.background_likelihood_rates[frozenset(instruments)][ln_likelihood_ratio,] += 1.
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_pipe b/gstlal-inspiral/bin/gstlal_inspiral_pipe
index a92eb6cbe9..0d9eabf129 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_pipe
+++ b/gstlal-inspiral/bin/gstlal_inspiral_pipe
@@ -200,7 +200,7 @@ def inj_psd_node_gen(segsdict, options):
 	psd_cache_files = {}
 	for line in open(options.psd_cache):
 		ce = CacheEntry(line)
-		psd_cache_files.setdefault(frozenset(lsctables.instrument_set_from_ifos(ce.observatory)), []).append((ce.segment, ce.path))
+		psd_cache_files.setdefault(frozenset(lsctables.instrumentsproperty.get(ce.observatory)), []).append((ce.segment, ce.path))
 	for ifos in segsdict:
 		reference_psd_files = sorted(psd_cache_files[ifos], key = lambda (s, p): s)
 		ref_psd_file_num = 0
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_plot_sensitivity b/gstlal-inspiral/bin/gstlal_inspiral_plot_sensitivity
index b1b2663e1f..eaefd888ea 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_plot_sensitivity
+++ b/gstlal-inspiral/bin/gstlal_inspiral_plot_sensitivity
@@ -156,7 +156,7 @@ class upper_limit(object):
         Retrieve the sets of instruments which were on during the search.
         '''
 	for inst in connection.cursor().execute("""SELECT DISTINCT(ifos) FROM search_summary"""):
-        	inst =  frozenset(lsctables.instrument_set_from_ifos(inst[0]))
+        	inst =  frozenset(lsctables.instrumentsproperty.get(inst[0]))
         	if not inst in self.instruments:
          		self.instruments.append(inst)
 
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_plotsummary b/gstlal-inspiral/bin/gstlal_inspiral_plotsummary
index 57f8596f38..c4d6ff425f 100755
--- a/gstlal-inspiral/bin/gstlal_inspiral_plotsummary
+++ b/gstlal-inspiral/bin/gstlal_inspiral_plotsummary
@@ -237,8 +237,8 @@ class CoincDatabase(object):
 			self.sc_definer_id = None
 
 		# retrieve the distinct on and participating instruments
-		self.on_instruments_combos = [frozenset(lsctables.instrument_set_from_ifos(x)) for x, in cursor.execute("SELECT DISTINCT(instruments) FROM coinc_event WHERE coinc_def_id == ?", (self.ii_definer_id,))]
-		self.participating_instruments_combos = [frozenset(lsctables.instrument_set_from_ifos(x)) for x, in cursor.execute("SELECT DISTINCT(ifos) FROM coinc_inspiral")]
+		self.on_instruments_combos = [frozenset(lsctables.instrumentsproperty.get(x)) for x, in cursor.execute("SELECT DISTINCT(instruments) FROM coinc_event WHERE coinc_def_id == ?", (self.ii_definer_id,))]
+		self.participating_instruments_combos = [frozenset(lsctables.instrumentsproperty.get(x)) for x, in cursor.execute("SELECT DISTINCT(ifos) FROM coinc_inspiral")]
 
 		# get the segment lists
 		self.seglists = ligolw_segments.segmenttable_get_by_name(xmldoc, data_segments_name).coalesce()
@@ -571,7 +571,7 @@ LIMIT 100
 		for instruments, num in contents.connection.cursor().execute("""
 SELECT distinct_ifos.ifos, count(*) FROM coinc_inspiral JOIN distinct_ifos ON (distinct_ifos.ifos==coinc_inspiral.ifos) JOIN coinc_event ON (coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id) WHERE coinc_inspiral.ifos==distinct_ifos.ifos AND NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0) GROUP BY distinct_ifos.ifos;
 """):
-			key = frozenset(lsctables.instrument_set_from_ifos(instruments))
+			key = frozenset(lsctables.instrumentsproperty.get(instruments))
 			self.num_trigs.setdefault(key,0)
 			self.num_trigs[key] += num
 
@@ -737,7 +737,7 @@ FROM
 						continue
 					if self.isolate_precession and not precession_bool:
 						continue
-					participating_instruments = lsctables.instrument_set_from_ifos(values[-1])
+					participating_instruments = lsctables.instrumentsproperty.get(values[-1])
 					if participating_instruments is not None:
 						participating_instruments = frozenset(participating_instruments)
 					self.found_in.setdefault(participating_instruments, []).append(sim)
@@ -800,7 +800,7 @@ FROM
 
 				fig, axes = create_plot(x_label, y_label)
 				legend = []
-				for participating_instruments, sims in sorted(self.found_in.items(), key = (lambda x: lsctables.ifos_from_instrument_set(x[0]))):
+				for participating_instruments, sims in sorted(self.found_in.items(), key = (lambda x: lsctables.instrumentsproperty.set(x[0]))):
 					if cnt == 0:
 						self.missed_found_plots.injection_summary_data.append(["Found", "".join(sorted(self.on_instruments)), "".join(sorted(participating_instruments)), len(sims)])
 					legend.append("Found in %s" % ", ".join(sorted(participating_instruments)))
@@ -829,7 +829,7 @@ FROM
 				fig, axes = create_plot(x_label, y_label)
 				legend = []
 				try:
-					for participating_instruments, sims in sorted(self.found_in.items(), key = (lambda x: lsctables.ifos_from_instrument_set(x[0]))):
+					for participating_instruments, sims in sorted(self.found_in.items(), key = (lambda x: lsctables.instrumentsproperty.set(x[0]))):
 						legend.append("Found in %s" % ", ".join(sorted(participating_instruments)))
 						axes.semilogy([x_func(sim) for sim in sims], [found_decisive_charsnr(sim, self.on_instruments, participating_instruments) for sim in sims], ".")
 					if missed:
diff --git a/gstlal-inspiral/python/far.py b/gstlal-inspiral/python/far.py
index 8f6f88de20..25fca8ca82 100644
--- a/gstlal-inspiral/python/far.py
+++ b/gstlal-inspiral/python/far.py
@@ -800,7 +800,7 @@ class ThincaCoincParamsDistributions(object):
 		# create an instance
 		self = cls(
 			process_id = process_id,
-			instruments = lsctables.instrument_set_from_ifos(ligolw_param.get_pyvalue(xml, u"instruments")),
+			instruments = lsctables.instrumentsproperty.get(ligolw_param.get_pyvalue(xml, u"instruments")),
 			min_instruments = ligolw_param.get_pyvalue(xml, u"min_instruments"),
 			signal_rate = ligolw_param.get_pyvalue(xml, u"signal_rate"),
 			delta_t = ligolw_param.get_pyvalue(xml, u"delta_t")
@@ -852,7 +852,7 @@ class ThincaCoincParamsDistributions(object):
 		store(xml, u"injection", self.injection_rates)
 		store(xml, u"injection_pdf", self.injection_pdf)
 
-		xml.appendChild(ligolw_param.Param.from_pyvalue(u"instruments", lsctables.ifos_from_instrument_set(self.instruments)))
+		xml.appendChild(ligolw_param.Param.from_pyvalue(u"instruments", lsctables.instrumentsproperty.set(self.instruments)))
 		xml.appendChild(ligolw_param.Param.from_pyvalue(u"min_instruments", self.min_instruments))
 		xml.appendChild(ligolw_param.Param.from_pyvalue(u"signal_rate", self.signal_rate))
 		xml.appendChild(ligolw_param.Param.from_pyvalue(u"delta_t", self.delta_t))
@@ -1221,7 +1221,7 @@ WHERE
 	)
 """, (coinc_def_id,)):
 			assert ln_likelihood_ratio is not None, "null likelihood ratio encountered.  probably coincs have not been ranked"
-			self.zero_lag_likelihood_rates[frozenset(lsctables.instrument_set_from_ifos(instruments))][ln_likelihood_ratio,] += 1.
+			self.zero_lag_likelihood_rates[frozenset(lsctables.instrumentsproperty.get(instruments))][ln_likelihood_ratio,] += 1.
 
 		#
 		# update combined rates.  NOTE:  this recomputes all the
@@ -1436,7 +1436,7 @@ WHERE
 		# pull out the likelihood count and PDF arrays
 		def reconstruct(xml, prefix, target_dict):
 			for ba_elem in [elem for elem in xml.getElementsByTagName(ligolw.LIGO_LW.tagName) if elem.hasAttribute(u"Name") and ("_%s" % prefix) in elem.Name]:
-				ifo_set = frozenset(lsctables.instrument_set_from_ifos(ba_elem.Name.split("_")[0]))
+				ifo_set = frozenset(lsctables.instrumentsproperty.get(ba_elem.Name.split("_")[0]))
 				target_dict[ifo_set] = rate.BinnedArray.from_xml(ba_elem, ba_elem.Name.split(":")[0])
 		reconstruct(xml, u"background_likelihood_rate", self.background_likelihood_rates)
 		reconstruct(xml, u"background_likelihood_pdf", self.background_likelihood_pdfs)
@@ -1464,7 +1464,7 @@ WHERE
 		def store(xml, prefix, source_dict):
 			for key, binnedarray in source_dict.items():
 				if key is not None:
-					ifostr = lsctables.ifos_from_instrument_set(key).replace(",","")
+					ifostr = lsctables.instrumentsproperty.set(key).replace(",","")
 					xml.appendChild(binnedarray.to_xml(u"%s_%s" % (ifostr, prefix)))
 		store(xml, u"background_likelihood_rate", self.background_likelihood_rates)
 		store(xml, u"background_likelihood_pdf", self.background_likelihood_pdfs)
diff --git a/gstlal-inspiral/python/stats/inspiral_extrinsics.py b/gstlal-inspiral/python/stats/inspiral_extrinsics.py
index 883d124926..ed0b80db1f 100644
--- a/gstlal-inspiral/python/stats/inspiral_extrinsics.py
+++ b/gstlal-inspiral/python/stats/inspiral_extrinsics.py
@@ -670,7 +670,7 @@ class SNRPDF(object):
 			binnedarray = rate.BinnedArray.from_xml(elem, elem.Name.rsplit(u":", 1)[0])
 
 			key = (
-				frozenset(lsctables.instrument_set_from_ifos(ligolw_param.get_pyvalue(elem, u"instruments:key"))),
+				frozenset(lsctables.instrumentsproperty.get(ligolw_param.get_pyvalue(elem, u"instruments:key"))),
 				frozenset((inst.strip(), float(quant) if math.isinf(float(quant)) else int(quant)) for inst, quant in (inst_quant.split(u"=") for inst_quant in ligolw_param.get_pyvalue(elem, u"quantizedhorizons:key").split(u",")))
 			)
 
@@ -694,7 +694,7 @@ class SNRPDF(object):
 		xml.appendChild(ligolw_param.Param.from_pyvalue(u"log_distance_tolerance", self.log_distance_tolerance))
 		for i, (key, (ignored, binnedarray, ignored)) in enumerate(self.snr_joint_pdf_cache.items()):
 			elem = xml.appendChild(binnedarray.to_xml(u"%d:pdf" % i))
-			elem.appendChild(ligolw_param.Param.from_pyvalue(u"instruments:key", lsctables.ifos_from_instrument_set(key[0])))
+			elem.appendChild(ligolw_param.Param.from_pyvalue(u"instruments:key", lsctables.instrumentsproperty.set(key[0])))
 			elem.appendChild(ligolw_param.Param.from_pyvalue(u"quantizedhorizons:key", u",".join(u"%s=%.17g" % inst_quant for inst_quant in sorted(key[1]))))
 		return xml
 
@@ -705,6 +705,7 @@ class SNRPDF(object):
 			fileobj = open(cls.DEFAULT_FILENAME)
 		return cls.from_xml(ligolw_utils.load_fileobj(fileobj, gz = True, contenthandler = cls.LIGOLWContentHandler)[0])
 
+
 #
 # =============================================================================
 #
diff --git a/gstlal-inspiral/share/refap_with_zerolag/gstlal_inspiral_recalc_rank_pdfs b/gstlal-inspiral/share/refap_with_zerolag/gstlal_inspiral_recalc_rank_pdfs
index 3b6f5bbe6a..a424e638c7 100755
--- a/gstlal-inspiral/share/refap_with_zerolag/gstlal_inspiral_recalc_rank_pdfs
+++ b/gstlal-inspiral/share/refap_with_zerolag/gstlal_inspiral_recalc_rank_pdfs
@@ -53,7 +53,7 @@ from glue import dagfile
 from glue.lal import CacheEntry
 from glue import segments
 from glue.text_progress_bar import ProgressBar
-from glue.ligolw.lsctables import ifos_from_instrument_set
+from glue.ligolw.lsctables import instrumentsproperty
 
 
 #
@@ -88,7 +88,7 @@ for n, filename in enumerate(sorted(sys.argv[1:])):
 			entry.path = os.path.abspath(os.path.join(directory, entry.path))
 
 	cachefiles.append(CacheEntry(
-		ifos_from_instrument_set(seglists),
+		instrumentsproperty.set(seglists),
 		",".join(sorted(set(entry.description for entry in cache))),
 		seglists.extent_all(),
 		os.path.join("gstlal_inspiral_calc_rank_pdfs", "ranking_stat_cache_%04X.cache" % n)
diff --git a/gstlal-ugly/bin/gstlal_glitch_population b/gstlal-ugly/bin/gstlal_glitch_population
index 01671f9fdf..8b6bd42fe8 100755
--- a/gstlal-ugly/bin/gstlal_glitch_population
+++ b/gstlal-ugly/bin/gstlal_glitch_population
@@ -72,7 +72,7 @@ def parse_command_line():
 
 	options.start_time = LIGOTimeGPS(options.gps_start_time)
 	options.end_time = LIGOTimeGPS(options.gps_end_time)
-	options.instruments = lsctables.instrument_set_from_ifos(options.time_slide_instruments)
+	options.instruments = lsctables.instrumentsproperty.get(options.time_slide_instruments)
 
 	return options, filenames
 
-- 
GitLab