From 03b3ac1bc174c038cec78eef7a30738a2e2d399d Mon Sep 17 00:00:00 2001 From: Madeline Wade <wademc@ldas-pcdev1.ligo-wa.caltech.edu> Date: Tue, 30 Jul 2019 11:51:25 -0700 Subject: [PATCH] Fixing what I broke when added monitoring for state vector --- gstlal-calibration/bin/gstlal_compute_strain | 14 +++++++++----- gstlal-calibration/python/Makefile.am | 3 ++- gstlal-calibration/python/calibhandler.py | 18 +++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/gstlal-calibration/bin/gstlal_compute_strain b/gstlal-calibration/bin/gstlal_compute_strain index a261d75d55..2b10482d82 100755 --- a/gstlal-calibration/bin/gstlal_compute_strain +++ b/gstlal-calibration/bin/gstlal_compute_strain @@ -174,6 +174,11 @@ SampleRates = ConfigSectionMap("SampleRates") Bitmasks = ConfigSectionMap("Bitmasks") PipelineConfigs = ConfigSectionMap("PipelineConfigurations") DataCleaningConfigs = ConfigSectionMap("DataCleaningConfigurations") +try: + MonitorConfigs = ConfigSectionMap("MonitoringConfigurations") + kafka_server = MonitorConfigs["kafkaserver"] +except: + kafka_server = None # Sanity checks for command line options @@ -1095,7 +1100,7 @@ if compute_calib_statevector and (any(line_witness_channel_list) or any(witness_ pipeline = Gst.Pipeline(name="gstlal_compute_strain") mainloop = GObject.MainLoop() -handler = calibhandler.Handler(mainloop, pipeline, kafka_server = MonitorConfigs["kafkaserver"]) +handler = calibhandler.Handler(mainloop, pipeline, kafka_server = kafka_server) # # Turn off debugging tools or verboseness @@ -2437,10 +2442,9 @@ if apply_fcc: TDCFs_valid_bitmask_list.append(pow(2, fcc_smooth_bitnum)) if apply_fs: TDCFs_valid_bitmask_list.append(pow(2, fs_smooth_bitnum)) -if apply_Qinv: +if apply_srcq: TDCFs_valid_bitmask_list.append(pow(2, Qinv_smooth_bitnum)) TDCFs_valid_bitmask = sum(TDCFs_valid_bitmask_list) -print(TDCFs_valid_bitmask) monitor_bitmask_dict = {'monitor_on': check_state_bitmask, 'TDCFs_valid': TDCFs_valid_bitmask} if compute_calib_statevector: @@ -2982,9 +2986,9 @@ if compute_calib_statevector: dqtagstr = "channel-name=%s:GDS-CALIB_STATE_VECTOR, instrument=%s" % (instrument, instrument) calibstatevector = pipeparts.mktaginject(pipeline, calibstatevector, dqtagstr) calibstatevector = pipeparts.mktee(pipeline, calibstatevector) - statevector_monitor = pipeparts.generic(pipeline, calibstatevector, "lal_nxydump") + statevector_monitor = pipeparts.mkgeneric(pipeline, calibstatevector, "lal_nxydump") statevector_monitor = pipeparts.mkappsink(pipeline, statevector_monitor, max_buffers = 1) - statevector_monitor.connect("new-sample", handler.appsink_statevector_new_buffer, ifo, monitor_bitmask_dict) + statevector_monitor.connect("new-sample", handler.appsink_statevector_new_buffer, instrument, monitor_bitmask_dict) # # Produce time-dependent correction factors to be recorded in the frames diff --git a/gstlal-calibration/python/Makefile.am b/gstlal-calibration/python/Makefile.am index 69da51dd13..6eb17f924c 100644 --- a/gstlal-calibration/python/Makefile.am +++ b/gstlal-calibration/python/Makefile.am @@ -5,6 +5,7 @@ pkgpythondir = $(pkgpyexecdir) pkgpython_PYTHON = \ - calibration_parts.py + calibration_parts.py \ + calibhandler.py diff --git a/gstlal-calibration/python/calibhandler.py b/gstlal-calibration/python/calibhandler.py index dcabcb2c6d..1ce41e8f61 100644 --- a/gstlal-calibration/python/calibhandler.py +++ b/gstlal-calibration/python/calibhandler.py @@ -33,7 +33,7 @@ GObject.threads_init() Gst.init(None) from gstlal import simplehandler -from kafka import KafkaProducer +from lal import LIGOTimeGPS # # ============================================================================= @@ -71,6 +71,7 @@ class Handler(simplehandler.Handler): self.verbose = verbose self.kafka_server = kafka_server if self.kafka_server is not None: + from kafka import KafkaProducer self.producer = KafkaProducer( bootstrap_servers = [kafka_server], key_serializer = lambda m: json.dumps(m).encode('utf-8'), @@ -87,12 +88,11 @@ class Handler(simplehandler.Handler): s = StringIO.StringIO(mapinfo.data) time, state = s.getvalue().split('\n')[0].split() state = int(state) - buf.unmap(mapinfo) - monitor_dict = {} - for keys, bitmask in bitmaskdict.items(): - monitor_dict[key] = state & bitmask - if self.kafka_server is not None: - self.producer.send("%s_statevector_bit_check" % ifo, value = monitor_dict) - - + buf.unmap(mapinfo) + monitor_dict = {} + for key, bitmask in bitmaskdict.items(): + monitor_dict[key] = state & bitmask + if self.kafka_server is not None: + self.producer.send("%s_statevector_bit_check" % ifo, value = monitor_dict) + return Gst.FlowReturn.OK -- GitLab