diff --git a/gstlal-calibration/bin/Makefile.am b/gstlal-calibration/bin/Makefile.am
index be839aa0c4337fe73c5f1f89ad92a98f20614c0d..93657f56ca25d3df5e6d78cfa56a1501064dfdd7 100644
--- a/gstlal-calibration/bin/Makefile.am
+++ b/gstlal-calibration/bin/Makefile.am
@@ -1,4 +1,2 @@
 dist_bin_SCRIPTS = \
-	gstlal_compute_strain \
-	gstlal_clean_strain \
-	gstlal_compute_kappas
+	gstlal_compute_strain
diff --git a/gstlal-calibration/bin/gstlal_clean_strain b/gstlal-calibration/bin/gstlal_clean_strain
deleted file mode 100755
index 65063c0ad12365dfbbe4cf0e9c379a071a82af11..0000000000000000000000000000000000000000
--- a/gstlal-calibration/bin/gstlal_clean_strain
+++ /dev/null
@@ -1,826 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2010-2015  Madeline Wade, Aaron Viets, Jenne Driggers
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-
-"""
-This pipeline is designed to perform various cleaning operations on h(t). Currently, the possible cleaning modes include:
-- Line removal for calibration lines
-- Line removal for 60 Hz lines and harmonics
-- De-jittering as developed by Jenne Driggers
-"""
-
-import sys
-import numpy
-import time
-import resource
-
-from optparse import OptionParser, Option
-
-import gi
-gi.require_version('Gst', '1.0')
-from gi.repository import GObject, Gst
-GObject.threads_init()
-Gst.init(None)
-
-import lal
-
-from gstlal import pipeparts
-from gstlal import calibration_parts
-from gstlal import simplehandler
-from gstlal import datasource
-
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
-from ligo import segments
-
-def write_graph(demux):
-	pipeparts.write_dump_dot(pipeline, "%s.%s" % (options.write_pipeline, "PLAYING"), verbose = True)
-
-#
-# Make sure we have sufficient resources
-# We allocate far more memory than we need, so this is okay
-#
-
-def setrlimit(res, lim):
-	hard_lim = resource.getrlimit(res)[1]
-	resource.setrlimit(res, (lim if lim is not None else hard_lim, hard_lim))
-# set the number of processes and total set size up to hard limit and
-# shrink the per-thread stack size (default is 10 MiB)
-setrlimit(resource.RLIMIT_NPROC, None)
-setrlimit(resource.RLIMIT_AS, None)
-setrlimit(resource.RLIMIT_RSS, None)
-setrlimit(resource.RLIMIT_STACK, 1024*1024)
-
-def now():
-	return lal.LIGOTimeGPS(lal.UTCToGPS(time.gmtime()), 0)
-	
-
-###################################################################################################
-############################## Program Command Line Options #######################################
-###################################################################################################
-
-parser = OptionParser(description = __doc__)
-
-# Append program specific options
-
-# These options should be used whether the pipeline runs in full calibration mode or partial calibration mode
-parser.add_option("--data-source", metavar = "source", help = "Set the data source from [frames|lvshm]. Required.")
-parser.add_option("--raw-frame-cache", metavar = "filename", help = "Set the name of the LAL cache listing the LIGO .gwf frame files containing raw data (optional).  This is required iff --data-source=frames")
-parser.add_option("--hoft-frame-cache", metavar = "filename", help = "Set the name of the LAL cache listing the LIGO .gwf frame files containing h(t) data (optional).  This is required iff --data-source=frames")
-parser.add_option("--gps-start-time", metavar = "seconds", help = "Set the start time of the segment to analyze in GPS seconds. This is required iff --data-source=frames")
-parser.add_option("--gps-end-time", metavar = "seconds", help = "Set the end time of the segment to analyze in GPS seconds. This is required iff --data-source=frames")
-parser.add_option("--wings", metavar = "seconds", type = "int", help = "Number of seconds to trim off of the beginning and end of the output. Should only be used if --data-source=frames.")
-parser.add_option("--do-file-checksum", action = "store_true", help = "Set this option to turn on file checksum in the demuxer.")
-parser.add_option("--ifo", metavar = "name", help = "Name of the IFO strain to be cleaned.")
-parser.add_option("--raw-shared-memory-partition", metavar = "name", help = "Set the name of the shared memory partition to read from for raw data.  This is required iff --data-source=lvshm.")
-parser.add_option("--hoft-shared-memory-partition", metavar = "name", help = "Set the name of the shared memory partition to read from for h(t) data.  This is required iff --data-source=lvshm.")
-parser.add_option("--raw-frame-segments-file", metavar = "filename", help = "Set the name of the LIGO light-weight XML file from which to load frame segments for raw data.  This can only be used if --data-source=frames")
-parser.add_option("--hoft-frame-segments-file", metavar = "filename", help = "Set the name of the LIGO light-weight XML file from which to load frame segments for h(t) data.  This can only be used if --data-source=frames")
-parser.add_option("--hoft-frame-segments-name", metavar = "name", help = "Set the name of the segments to extract from the segment tables for h(t) data.  This can only be used if --frame-segments-file is given")
-parser.add_option("--raw-frame-segments-name", metavar = "name", help = "Set the name of the segments to extract from the segment tables for raw data.  This can only be used if --frame-segments-file is given")
-parser.add_option("--hoft-sample-rate", metavar = "Hz", default = 16384, type = "int", help = "Sample rate of the h(t) channel. (Default = 16384 Hz)")
-parser.add_option("--buffer-length", metavar = "seconds", type = float, default = 1.0, help = "Set the length in seconds of buffers to be used in the pipeline (Default = 1.0)")
-parser.add_option("--frame-duration", metavar = "seconds", type = "int", default = 4, help = "Set the number of seconds for each frame. (Default = 4)")
-parser.add_option("--frames-per-file", metavar = "count", type = "int", default = 1, help = "Set the number of frames per frame file. (Default = 1)")
-parser.add_option("--frame-size", metavar = "bytes", type = "int", default = 405338, help = "Approximate size in bytes of frame file images; used when writing to shared memory.  (Default=405338)")
-parser.add_option("--compression-scheme", metavar = "scheme", type = "int", default = 256, help = "Set the compression scheme for the framecpp_channelmux element. (Default=256, no compression)")
-parser.add_option("--compression-level", metavar = "level", type = "int", default = 0, help = "Set the compression level for the framecpp_channelmux element. (Default=0)")
-parser.add_option("--write-to-shm-partition", metavar = "name", help = "Set the name of the shared memory partition to write to. If this is not provided, frames will be written to a file.")
-parser.add_option("--buffer-mode", metavar = "number", type = "int", default = 2, help = "Set the buffer mode for the lvshmsink element. (Default=2)")
-parser.add_option("--frame-type", metavar = "name", default = "TEST", help = "Set the frame type as input to the frame writing element. (Default=TEST)")
-parser.add_option("--output-path", metavar = "name", default = ".", help = "Set the output path for writing frame files. (Default=Current)")
-parser.add_option("--frequency-domain-filtering", action = "store_true", help = "Set this to perform filtering routines in the frequency domain instead of using direct convolution.")
-parser.add_option("--obs-ready-bitmask", metavar = "bitmask", type = "int", default = 4, help = "Bitmask used on ODC state vector in order to determine OBSERVATION_READY bit information. (Default=4)")
-parser.add_option("--obs-intent-bitmask", metavar = "bitmask", type = "int", default = 2, help = "Bitmask used on ODC state vector in order to determine OBSERVATION_INTENT bit information. (Default=2)")
-parser.add_option("--chan-prefix", metavar = "name", default = "GDS-", help = "Prefix for all output channel names. (Default = GDS)") 
-parser.add_option("--chan-suffix", metavar = "name", help = "Suffix for all output channel names.") 
-
-# These are debugging options
-parser.add_option("--write-pipeline", metavar = "filename", help = "Write a DOT graph description of the as-built pipeline to this file (optional).  The environment variable GST_DEBUG_DUMP_DOT_DIR must be set for this option to work.")
-parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose (optional).")
-
-# These are options specific to the calibration procedure
-parser.add_option("--filters-file", metavar="filename", help = "Name of file containing filters (in npz format)")
-parser.add_option("--factors-from-filters-file", action = "store_true", help = "Compute the calibration factors from reference values contained in the filters file instead of from EPICS channels.")
-parser.add_option("--tst-exc-channel-name", metavar = "name", default = "SUS-ETMY_L3_CAL_LINE_OUT_DQ", help = "Set the name of the TST excitation channel.  (Default = SUS-ETMY_L3_CAL_LINE_OUT_DQ)")
-parser.add_option("--tst-exc-sample-rate", metavar = "Hz", default = 512, type = "int", help = "Sample rate for the control signals being read in. (Default = 512 Hz)")
-parser.add_option("--pcal-channel-name", metavar = "name", default = "CAL-PCALY_RX_PD_OUT_DQ", help = "Set the name of the PCal channel used. (Default = CAL-PCALY_RX_PD_OUT_DQ)")
-parser.add_option("--low-latency", action = "store_true", help = "Run the pipeline in low-latency mode. This uses minimal queueing. Otherwise, maximal queueing is used to prevent the pipeline from locking up.")
-parser.add_option("--remove-callines", action = "store_true", help = "Remove calibration lines at known freqencies from h(t) using software.")
-parser.add_option("--remove-powerlines", action = "store_true", help = "Remove 60 Hz spectral lines and some harmonics caused by power lines using witness channel PEM-EY_MAINSMON_EBAY_1_DQ.")
-parser.add_option("--powerlines-channel-name", metavar = "name", default = "PEM-EY_MAINSMON_EBAY_1_DQ", help = "Set the name of the channel used as input for 60 Hz power lines to be removed. (Default = PEM-EY_MAINSMON_EBAY_1_DQ)")
-parser.add_option("--remove-jitter-imc", action = "store_true", help = "Remove laser beam jitter using 4 IMC channels.  This can significantly reduce noise in the spectrum.")
-parser.add_option("--imc-a-pitch-channel-name", metavar = "name", default = "IMC-WFS_A_DC_PIT_OUT_DQ", help = "Set the name of one of the channels used as input from the IMC for removal of beam jitter noise. (Default = IMC-WFS_A_DC_PIT_OUT_DQ)")
-parser.add_option("--imc-b-pitch-channel-name", metavar = "name", default = "IMC-WFS_B_DC_PIT_OUT_DQ", help = "Set the name of one of the channels used as input from the IMC for removal of beam jitter noise. (Default = IMC-WFS_B_DC_PIT_OUT_DQ)")
-parser.add_option("--imc-a-yaw-channel-name", metavar = "name", default = "IMC-WFS_A_DC_YAW_OUT_DQ", help = "Set the name of one of the channels used as input from the IMC for removal of beam jitter noise. (Default = IMC-WFS_A_DC_YAW_OUT_DQ)")
-parser.add_option("--imc-b-yaw-channel-name", metavar = "name", default = "IMC-WFS_B_DC_YAW_OUT_DQ", help = "Set the name of one of the channels used as input from the IMC for removal of beam jitter noise. (Default = IMC-WFS_B_DC_YAW_OUT_DQ)")
-parser.add_option("--remove-jitter-psl", action = "store_true", help = "Remove laser beam jitter using the bullseye photodiode with 3 PSL channels.  This can significantly reduce noise in the spectrum.")
-parser.add_option("--bullseye-width-channel-name", metavar = "name", default = "PSL-DIAG_BULLSEYE_WID_OUT_DQ", help = "Set the name of one of the channels used as input from the bullseye photodiode for removal of beam jitter noise. (Default = PSL-DIAG_BULLSEYE_WID_OUT_DQ)")
-parser.add_option("--bullseye-pitch-channel-name", metavar = "name", default = "PSL-DIAG_BULLSEYE_PIT_OUT_DQ", help = "Set the name of one of the channels used as input from the bullseye photodiode for removal of beam jitter noise. (Default = PSL-DIAG_BULLSEYE_PIT_OUT_DQ)")
-parser.add_option("--bullseye-yaw-channel-name", metavar = "name", default = "PSL-DIAG_BULLSEYE_YAW_OUT_DQ", help = "Set the name of one of the channels used as input from the bullseye photodiode for removal of beam jitter noise. (Default = PSL-DIAG_BULLSEYE_YAW_OUT_DQ)")
-parser.add_option("--remove-angular-control", action = "store_true", help = "Remove noise caused by angular control.  Uses 4 ASC channels.")
-parser.add_option("--asc-dhard-pitch-channel-name", metavar = "name", default = "ASC-DHARD_P_OUT_DQ", help = "Set the name of one of the channels used as input from the ASC to remove angular control noise. (Default = ASC-DHARD_P_OUT_DQ)")
-parser.add_option("--asc-dhard-yaw-channel-name", metavar = "name", default = "ASC-DHARD_Y_OUT_DQ", help = "Set the name of one of the channels used as input from the ASC to remove angular control noise. (Default = ASC-DHARD_Y_OUT_DQ)")
-parser.add_option("--asc-chard-pitch-channel-name", metavar = "name", default = "ASC-CHARD_P_OUT_DQ", help = "Set the name of one of the channels used as input from the ASC to remove angular control noise. (Default = ASC-CHARD_P_OUT_DQ)")
-parser.add_option("--asc-chard-yaw-channel-name", metavar = "name", default = "ASC-CHARD_Y_OUT_DQ", help = "Set the name of one of the channels used as input from the ASC to remove angular control noise. (Default = ASC-CHARD_Y_OUT_DQ)")
-parser.add_option("--remove-length-control", action = "store_true", help = "Remove noise caused by length control.  Uses 3 LSC channels.")
-parser.add_option("--lsc-srcl-channel-name", metavar = "name", default = "LSC-SRCL_IN1_DQ", help = "Set the name of one of the channels used as input from the LSC to remove length control noise. (Default = LSC-SRCL_IN1_DQ)")
-parser.add_option("--lsc-mich-channel-name", metavar = "name", default = "LSC-MICH_IN1_DQ", help = "Set the name of one of the channels used as input from the LSC to remove length control noise. (Default = LSC-MICH_IN1_DQ)")
-parser.add_option("--lsc-prcl-channel-name", metavar = "name", default = "LSC-PRCL_IN1_DQ", help = "Set the name of one of the channels used as input from the LSC to remove length control noise. (Default = LSC-PRCL_IN1_DQ)")
-parser.add_option("--kappa-tst-channel-name", metavar = "name", default = "GDS-CALIB_KAPPA_TST_REAL", help = "Set the name of the channel to be used for kappa_tst. (Default = GDS-CALIB_KAPPA_TST_REAL)")
-parser.add_option("--hoft-channel-name", metavar = "name", default = "GDS-CALIB_STRAIN", help = "Set the name of the channel to be used for h(t). (Default = GDS-CALIB_STRAIN)")
-parser.add_option("--kappa-sample-rate", metavar = "Hz", default = 16, type = "int", help = "Sample rate of the kappa_tst channel (Default = 16 Hz)")
-parser.add_option("--demodulation-sample-rate", metavar = "Hz", default = 16, type = "int", help = "Sample rate to compute deomdulation of channels (Default = 16 Hz)")
-parser.add_option("--demodulation-filter-time", metavar = "s", type = int, default = 20, help = "Length in seconds of low-pass FIR filter used in demodulation of the calibration lines. (Default = 20 seconds)")
-parser.add_option("--kappatst-applied", action = "store_true", help = "Note whether or not kappa_tst was applied to input h(t) channel.")
-
-# These are all options related to the reference channels used in the calibration factors computation
-parser.add_option("--ref-channels-sr", metavar = "Hz", default = 16, help = "Set the sample rate for the reference model channels used in the calibration factors calculation. (Default = 16 Hz)")
-parser.add_option("--EP10-real", metavar = "name", default = "CAL-CS_TDEP_ESD_LINE1_REF_A_TST_NOLOCK_REAL", help = "Set the name of the channel containing the real part of A_tst at the ESD line used for removal of the ESD line. (Default = CAL-CS_TDEP_ESD_LINE1_REF_A_TST_REAL")
-parser.add_option("--EP10-imag", metavar = "name", default = "CAL-CS_TDEP_ESD_LINE1_REF_A_TST_NOLOCK_IMAG", help = "Set the name of the channel containing the imaginary part of A_tst at the ESD line used for removal of the ESD line. (Default = CAL-CS_TDEP_ESD_LINE1_REF_A_TST_IMAG")
-
-
-# Parse options
-
-options, filenames = parser.parse_args()
-
-# Sanity checks for command line options
-data_sources = set(("frames", "lvshm"))
-
-if options.data_source not in data_sources:
-	raise ValueError("--data-source must be one of %s" % ",".join(data_sources))
-
-if options.data_source == "frames" and (options.hoft_frame_cache or options.raw_frame_cache) is None:
-	raise ValueError("--raw-frame-cache and --hoft-frame-cache must be specified when using --data-source=frames")
-
-if options.ifo is None:
-	raise ValueError("must specify --ifo")
-
-if (options.raw_frame_segments_file or options.hoft_frame_segments_file) is not None and options.data_source != "frames":
-	raise ValueError("can only give --raw-frame-segments-file or --hoft-frame-segments-file if --data-source=frames")
-
-if options.raw_frame_segments_name is not None and options.raw_frame_segments_file is None:
-	raise ValueError("can only specify --raw-frame-segments-name if --raw-frame-segments-file is given")
-
-if options.hoft_frame_segments_name is not None and options.hoft_frame_segments_file is None:
-	raise ValueError("can only specify --hoft-frame-segments-name if --hoft-frame-segments-file is given")
-
-if options.data_source == "frames" and (options.gps_start_time is None or options.gps_end_time is None):
-	raise ValueError("must specify --gps-start-time and --gps-end-time when --data-source=frames")
-
-if options.gps_start_time is not None:
-	if options.gps_end_time is None:
-		raise ValueError("must provide both --gps-start-time and --gps-end-time")
-	if options.data_source == "lvshm" or options.data_source == "white":
-		raise ValueError("cannot set --gps-start-time or --gps-end-time with --data-source=lvshm or --data-source=white")
-	try:
-		start = lal.LIGOTimeGPS(options.gps_start_time)
-	except ValueError:
-		raise ValueError("invalid --gps-start-time %s" % options.gps_start_time)
-	try:
-		end = lal.LIGOTimeGPS(options.gps_end_time)
-	except ValueError:
-		raise ValueError("invalid --gps-end-time %s" % options.gps_end_time)
-	if start >= end:
-		raise ValueError("--gps-start-time must be < --gps-end-time: %s < %s" % (options.gps_start_time, options.gps_end_time))
-	# segment from gps start and stop time if given
-	seg = segments.segment(start, end)
-	gps_start_time = seg[0]
-	gps_end_time = seg[1]
-elif options.gps_end_time is not None:
-	raise ValueError("must provide both --gps-start-time and --gps-end-time")
-
-###################################################################################################
-######################################## Setup ####################################################
-###################################################################################################
-
-# Set up instrument and channel name info from command line options
-instrument = options.ifo
-
-# Make segment list if a frame segments file is provided, other set frame_segments to None
-if options.raw_frame_segments_file is not None:
-	# Frame segments from a user defined file
-	raw_frame_segments = ligolw_segments.segmenttable_get_by_name(utils.load_filename(options.raw_frame_segments_file, contenthandler = datasource.ContentHandler), options.raw_frame_segments_name).coalesce()
-	if seg is not None:
-		# clip frame segments to seek segment if it exists (not required, just saves some meory and I/O overhead)
-		raw_frame_segments = segments.segmentlistdict((instrument, seglist & segments.segmentlist([seg])) for instrument, seglist in raw_frame_segments.items())
-else:
-	raw_frame_segments = None
-
-if options.hoft_frame_segments_file is not None:
-	# Frame segments from a user defined file
-	hoft_frame_segments = ligolw_segments.segmenttable_get_by_name(utils.load_filename(options.hoft_frame_segments_file, contenthandler = datasource.ContentHandler), options.hoft_frame_segments_name).coalesce()
-	if seg is not None:
-		# clip frame segments to seek segment if it exists (not required, just saves some meory and I/O overhead)
-		hoft_frame_segments = segments.segmentlistdict((instrument, seglist & segments.segmentlist([seg])) for instrument, seglist in hoft_frame_segments.items())
-else:
-	hoft_frame_segments = None
-
-# Set up short-cut names for each of the sample rates used throughout the pipeline and establish caps string shortcuts
-hoftsr = options.hoft_sample_rate  # Sample rate for h(t)
-kappasr = options.kappa_sample_rate # sample rate for kappa_tst
-demodulatesr = options.demodulation_sample_rate
-hoft_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr
-kappa_caps = "audio/x-raw, format=F32LE, rate=%d, channel-mask=(bitmask)0x0" % kappasr
-ref_factors_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % options.ref_channels_sr
-tstexccaps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % options.tst_exc_sample_rate
-complex_caps = "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % demodulatesr
-integration_samples = int(options.demodulation_filter_time) * demodulatesr
-
-# Set up string for the channels suffix and prefix as provided by the user
-if options.chan_suffix is not None:
-	chan_suffix = options.chan_suffix
-else:
-	chan_suffix = ""
-chan_prefix = options.chan_prefix
-
-# If td is true we will perform filtering in the time domain (direct convolution) in all FIR filtering routines below
-td = not options.frequency_domain_filtering
-
-# If we are using EPICS from frames and removing calibration lines, we need EP10 to remove the ESD line. Otherwise, we just remove the other lines if possible.
-if (not options.factors_from_filters_file) and options.remove_callines and ((options.ifo == "H1" and options.data_source == "frames" and int(options.gps_start_time) > 1175954418) or (options.ifo == "H1" and options.data_source == "lvshm" and now() > 1175954418) or (options.ifo == "L1" and options.data_source == "frames" and int(options.gps_start_time) > 1180184418) or (options.ifo == "L1" and options.data_source == "lvshm" and now() > 1180184418)):
-	remove_esd_act_line = True
-elif not options.factors_from_filters_file:
-	remove_esd_act_line = False
-
-#
-# Load in the filters file that contains filter coefficients, etc.
-#
-
-filters = numpy.load(options.filters_file)
-
-# Read in information from filterse file
-if options.remove_callines:
-	# Read in the EP10 factor from filters file, if relevant
-	if options.factors_from_filters_file:
-		try:
-			EP10_real = float(filters["EP10_real"])
-			EP10_imag = float(filters["EP10_imag"])
-			remove_esd_act_line = True
-		except:
-			remove_esd_act_line = False
-	darm_act_line_freq = float(filters["ka_pcal_line_freq"])
-	pcal_corr_at_darm_act_freq_real = float(filters["ka_pcal_corr_re"])
-	pcal_corr_at_darm_act_freq_imag = float(filters["ka_pcal_corr_im"])
-	opt_gain_fcc_line_freq = float(filters["kc_pcal_line_freq"])
-	pcal_corr_at_opt_gain_fcc_freq_real = float(filters["kc_pcal_corr_re"])
-	pcal_corr_at_opt_gain_fcc_freq_imag = float(filters["kc_pcal_corr_im"])
-	esd_act_line_freq = float(filters["ktst_esd_line_freq"])
-	# Read in info for removing the src_pcal line
-	try:
-		src_pcal_line_freq = float(filters["src_pcal_line_freq"])
-		pcal_corr_at_src_freq_real = float(filters["src_pcal_corr_re"])
-		pcal_corr_at_src_freq_imag = float(filters["src_pcal_corr_im"])
-		if src_pcal_line_freq > 10.0:
-			remove_src_pcal_line = True
-		else:
-			remove_src_pcal_line = False
-	except:
-		remove_src_pcal_line = False
-	# Read in info for removing the high pcal line
-	try:
-		high_pcal_line_freq = float(filters["high_pcal_line_freq"])
-		pcal_corr_at_high_line_freq_real = float(filters["high_pcal_corr_re"])
-		pcal_corr_at_high_line_freq_imag = float(filters["high_pcal_corr_im"])
-		if high_pcal_line_freq > 0:
-			remove_high_pcal_line = True
-		else:
-			remove_high_pcal_line = False
-	except:
-		remove_high_pcal_line = False
-	# Read in info for removing the roaming pcal line
-	try:
-		roaming_pcal_line_freq = float(filters["roaming_pcal_line_freq"])
-		pcal_corr_at_roaming_line_real = float(filters["roaming_pcal_corr_re"])
-		pcal_corr_at_roaming_line_imag = float(filters["roaming_pcal_corr_im"])
-		if roaming_pcal_line_freq > 0.0:
-			remove_roaming_pcal_line = True
-		else:
-			remove_roaming_pcal_line = False
-	except:
-		remove_roaming_pcal_line = False
-
-# If we're removing 60 Hz lines from the spectrum, load another filter
-if options.remove_powerlines:
-	try:
-		powerlinessr = int(filters["powerlines_sr"])
-		powerlinesdelay = int(filters["powerlines_delay"])
-		powerlinesfilt = filters["powerlines_filt"]
-	except:
-		raise ValueError("Cannot remove 60 Hz lines because the filters file does contain the needed information")
-
-# If we're removing laser beam jitter noise from the spectrum, load several more filters
-if options.remove_jitter_imc:
-	try:
-		imcapitsr = int(filters["jitter_imc_a_pit_sr"])
-		imcayawsr = int(filters["jitter_imc_a_yaw_sr"])
-		imcbpitsr = int(filters["jitter_imc_b_pit_sr"])
-		imcbyawsr = int(filters["jitter_imc_b_yaw_sr"])
-		imcapitdelay = int(filters["jitter_imc_a_pit_delay"])
-		imcayawdelay = int(filters["jitter_imc_a_yaw_delay"])
-		imcbpitdelay = int(filters["jitter_imc_b_pit_delay"])
-		imcbyawdelay = int(filters["jitter_imc_b_yaw_delay"])
-		imcapitfilt = filters["jitter_imc_a_pit_filt"]
-		imcayawfilt = filters["jitter_imc_a_yaw_filt"]
-		imcbpitfilt = filters["jitter_imc_b_pit_filt"]
-		imcbyawfilt = filters["jitter_imc_b_yaw_filt"]
-	except:
-		raise ValueError("Cannot remove beam jitter using imc inputs because the filters file does contain the needed information")
-if options.remove_jitter_psl:
-	try:
-		bullseyewidsr = int(filters["jitter_bullseye_wid_sr"])
-		bullseyepitsr = int(filters["jitter_bullseye_pit_sr"])
-		bullseyeyawsr = int(filters["jitter_bullseye_yaw_sr"])
-		bullseyewiddelay = int(filters["jitter_bullseye_wid_delay"])
-		bullseyepitdelay = int(filters["jitter_bullseye_pit_delay"])
-		bullseyeyawdelay = int(filters["jitter_bullseye_yaw_delay"])
-		bullseyewidfilt = filters["jitter_bullseye_wid_filt"]
-		bullseyepitfilt = filters["jitter_bullseye_pit_filt"]
-		bullseyeyawfilt = filters["jitter_bullseye_yaw_filt"]
-	except:
-		raise ValueError("Cannot remove beam jitter using bullseye inputs because the filters file does contain the needed information")
-if options.remove_angular_control:
-	try:
-		ascdpitsr = int(filters["asc_d_pit_sr"])
-		ascdyawsr = int(filters["asc_d_yaw_sr"])
-		asccpitsr = int(filters["asc_c_pit_sr"])
-		asccyawsr = int(filters["asc_c_yaw_sr"])
-		ascdpitdelay = int(filters["asc_d_pit_delay"])
-		asccyawdelay = int(filters["asc_d_yaw_delay"])
-		asccpitdelay = int(filters["asc_c_pit_delay"])
-		ascdyawdelay = int(filters["asc_c_yaw_delay"])
-		ascdpitfilt = filters["asc_d_pit_filt"]
-		ascdyawfilt = filters["asc_d_yaw_filt"]
-		asccpitfilt = filters["asc_c_pit_filt"]
-		asccyawfilt = filters["asc_c_yaw_filt"]
-	except:
-		raise ValueError("Cannot remove angular control noise using ASC inputs because the filters file does contain the needed information")
-if options.remove_length_control:
-	try:
-		lscsrclsr = int(filters["lsc_srcl_sr"])
-		lscmichsr = int(filters["lsc_mich_sr"])
-		lscprclsr = int(filters["lsc_prcl_sr"])
-		lscsrcldelay = int(filters["lsc_srcl_delay"])
-		lscmichdelay = int(filters["lsc_mich_delay"])
-		lscprcldelay = int(filters["lsc_prcl_delay"])
-		lscsrclfilt = filters["lsc_srcl_filt"]
-		lscmichfilt = filters["lsc_mich_filt"]
-		lscprclfilt = filters["lsc_prcl_filt"]
-	except:
-		raise ValueError("Cannot remove length control noise using LSC inputs because the filters file does contain the needed information")
-
-
-# Set up queue parameters - do we need this??
-if options.low_latency:
-	queue_factor = 1
-else:
-	queue_factor = 0
-
-#FIXME: Replace long queue logic with something real
-#long_queue = queue_factor * max(float(len(reschainfilt) - 1) / hoftsr, float(len(tstfilt) - 1) / tstchainsr, float(len(pumuimfilt) - 1) / pumuimchainsr)
-long_queue = queue_factor * 16384
-short_queue = -1.0 * queue_factor
-
-#
-# Set up the appropriate channel list. In this section, we also fill a list called headkeys
-# that will be the keys for the dictionary holding each pipeline branch name, and we set up
-# a dictionary that will be populated with pipeline branch names based on the channel list.
-#
-
-hoft_head_dict = {}
-head_dict = {}
-hoft_channel_list = []
-channel_list = []
-hoft_headkeys = []
-headkeys = []
-
-# We will need to read in the h(t) channel
-hoft_channel_list.append((instrument, options.hoft_channel_name))
-hoft_headkeys.append("hoft")
-
-"""
-# FIXME: Do we need to read in the statevector? Maybe, because maybe the filter settle time is different for cleaned data... But should we really be modifying the CALIB_STATE_VECTOR? probably not...
-if not options.no_dq_vector:
-	hoft_channel_list.append((instrument, options.dq_channel_name))
-	hoft_headkeys.append("calibstatevector")
-"""
-
-if options.remove_callines:
-	if remove_esd_act_line and not options.factors_from_filters_file:
-		# EP10 is needed to remove the ESD line
-		channel_list.extend(((instrument, options.EP10_real), (instrument, options.EP10_imag)))
-		headkeys.extend(("EP10_real", "EP10_imag"))
-
-	# read in the pcal channel
-	channel_list.append((instrument, options.pcal_channel_name))
-	headkeys.append("pcal")
-
-	# read in the tst excitation channel
-	channel_list.append((instrument, options.tst_exc_channel_name))
-	headkeys.append("tstexc")
-
-	# read in kappa_tst
-	if options.kappatst_applied:
-		hoft_channel_list.append((instrument, options.kappa_tst_channel_name))
-		hoft_headkeys.append("kappa_tst")
-
-# If we are removing additional noise from the spectrum (beam jitter, angular control, 60 Hz lines, etc.), we need more channels
-if options.remove_powerlines:
-	channel_list.append((instrument, options.powerlines_channel_name))
-	headkeys.append("powerlines")
-if options.remove_jitter_imc:
-	channel_list.extend(((instrument, options.imc_a_pitch_channel_name), (instrument, options.imc_a_yaw_channel_name), (instrument, options.imc_b_pitch_channel_name), (instrument, options.imc_b_yaw_channel_name)))
-	headkeys.extend(("imc_a_pitch", "imc_a_yaw", "imc_b_pitch", "imc_b_yaw"))
-if options.remove_jitter_psl:
-	channel_list.extend(((instrument, options.bullseye_width_channel_name), (instrument, options.bullseye_pitch_channel_name), (instrument, options.bullseye_yaw_channel_name)))
-	headkeys.extend(("bullseye_width", "bullseye_pitch", "bullseye_yaw"))
-if options.remove_angular_control:
-	channel_list.extend(((instrument, options.asc_dhard_pitch_channel_name), (instrument, options.asc_dhard_yaw_channel_name), (instrument, options.asc_chard_pitch_channel_name), (instrument, options.asc_chard_yaw_channel_name)))
-	headkeys.extend(("asc_dhard_pitch", "asc_dhard_yaw", "asc_chard_pitch", "asc_chard_yaw"))
-if options.remove_length_control:
-	channel_list.extend(((instrument, options.lsc_srcl_channel_name), (instrument, options.lsc_mich_channel_name), (instrument, options.lsc_prcl_channel_name)))
-	headkeys.extend(("lsc_srcl", "lsc_mich", "lsc_prcl"))
-
-
-####################################################################################################
-####################################### Main Pipeline ##############################################
-####################################################################################################
-
-pipeline = Gst.Pipeline(name="gstlal_clean_strain")
-mainloop = GObject.MainLoop()
-handler = simplehandler.Handler(mainloop, pipeline)
-
-# 
-# Turn off debugging tools or verboseness
-#
-
-pipeparts.mkchecktimestamps = lambda pipeline, src, *args: src # comment this line out to turn on the checktimestamps debugging
-if not options.verbose:
-	pipeparts.mkprogressreport = lambda pipeline, src, *args: src
-
-#
-# Read in data from frames or shared memory
-#
-
-if options.data_source == "lvshm": # Data is to be read from shared memory; "low-latency" mode
-	hoft_src = pipeparts.mklvshmsrc(pipeline, shm_name = options.hoft_shared_memory_partition, assumed_duration = 4)
-	raw_src = pipeparts.mklvshmsrc(pipeline, shm_name = options.raw_shared_memory_partition, assumed_duration = 1)
-elif options.data_source == "frames": # Data is to be read from frame files; "offline" mode
-	hoft_src = pipeparts.mklalcachesrc(pipeline, location = options.hoft_frame_cache, cache_dsc_regex = instrument)
-	raw_src = pipeparts.mklalcachesrc(pipeline, location = options.raw_frame_cache, cache_dsc_regex = instrument)
-
-#
-# Hook up the relevant channels to the demuxer
-#
-
-if options.data_source == "lvshm":
-	hoft_demux = pipeparts.mkframecppchanneldemux(pipeline, hoft_src, do_file_checksum = options.do_file_checksum, skip_bad_files = True, channel_list = map("%s:%s".__mod__, hoft_channel_list))
-	raw_demux = pipeparts.mkframecppchanneldemux(pipeline, raw_src, do_file_checksum = options.do_file_checksum, skip_bad_files = True, channel_list = map("%s:%s".__mod__, channel_list))
-elif options.data_source == "frames":
-	hoft_demux = pipeparts.mkframecppchanneldemux(pipeline, hoft_src, do_file_checksum = options.do_file_checksum, skip_bad_files = False, channel_list = map("%s:%s".__mod__, hoft_channel_list))
-	raw_demux = pipeparts.mkframecppchanneldemux(pipeline, raw_src, do_file_checksum = options.do_file_checksum, skip_bad_files = False, channel_list = map("%s:%s".__mod__, channel_list))
-
-# Write the pipeline graph after pads have been hooked up to the demuxer
-if options.write_pipeline is not None:
-	raw_demux.connect("no-more-pads", write_graph)	
-	hoft_demux.connect("no-more-pads", write_graph)
-
-# Get everything hooked up and fill in discontinuities
-for key, chan in zip(hoft_headkeys, hoft_channel_list):
-	hoft_head_dict[key] = calibration_parts.hook_up(pipeline, hoft_demux, chan[1], instrument, options.buffer_length)
-for key, chan in zip(headkeys, channel_list):
-	head_dict[key] = calibration_parts.hook_up(pipeline, raw_demux, chan[1], instrument, options.buffer_length)
-
-# When reading from disk, clip the incoming data stream(s) to segment list if one is provided
-if options.data_source == "frames" and raw_frame_segments is not None:
-	for key in headkeys:
-		currenthead = head_dict[key]
-		head_dict[key] = calibration_parts.mkgate(pipeline, currenthead, pipeparts.mksegmentsrc(pipeline, raw_frame_segments[instrument]), 1, long_queue, long_queue)
-
-if options.data_source == "frames" and hoft_frame_segments is not None:
-	for key in hoft_headkeys:
-		currenthead = hoft_head_dict[key]
-		hoft_head_dict[key] = calibration_parts.mkgate(pipeline, currenthead, pipeparts.mksegmentsrc(pipeline, hoft_frame_segments[instrument]), 1, long_queue, long_queue)
-
-#
-# REMOVE CALIBRATION LINES
-#
-
-if options.remove_callines:
-	if not options.factors_from_filters_file:
-		EP10_real = calibration_parts.caps_and_progress(pipeline, head_dict["EP10_real"], ref_factors_caps, "EP10_real")
-		EP10_real = calibration_parts.mkresample(pipeline, EP10_real, 0, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % demodulatesr)
-		EP10_imag = calibration_parts.caps_and_progress(pipeline, head_dict["EP10_imag"], ref_factors_caps, "EP10_imag")
-		EP10_imag = calibration_parts.mkresample(pipeline, EP10_imag, 0, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % demodulatesr)
-
-	tstexc = calibration_parts.caps_and_progress(pipeline, head_dict["tstexc"], tstexccaps, "tstexc")
-
-	# pcal excitation channel, which will be demodulated
-	pcal = calibration_parts.caps_and_progress(pipeline, head_dict["pcal"], hoft_caps, "pcal")
-	pcaltee = pipeparts.mktee(pipeline, pcal)
-	
-	# demodulate the PCAL channel and apply the PCAL correction factor at the DARM actuation line frequency
-	pcal_at_darm_act_freq = calibration_parts.demodulate(pipeline, pcaltee, darm_act_line_freq, td, complex_caps, integration_samples, pcal_corr_at_darm_act_freq_real, pcal_corr_at_darm_act_freq_imag)
-
-	# demodulate the TST excitation channel at the ESD actuation line frequency
-	tstexc_at_esd_act_freq = calibration_parts.demodulate(pipeline, tstexc, esd_act_line_freq, td, complex_caps, integration_samples)
-
-	# demodulate PCAL channel and apply the PCAL correction factor at optical gain and f_cc line frequency
-	pcal_at_opt_gain_freq = calibration_parts.demodulate(pipeline, pcaltee, opt_gain_fcc_line_freq, td, complex_caps, integration_samples, pcal_corr_at_opt_gain_fcc_freq_real, pcal_corr_at_opt_gain_fcc_freq_imag)
-
-	# demodulate PCAL channel and apply the PCAL correction factor at SRC detuning line frequency
-	pcal_at_src_freq = calibration_parts.demodulate(pipeline, pcaltee, src_pcal_line_freq, td, complex_caps, integration_samples, pcal_corr_at_src_freq_real, pcal_corr_at_src_freq_imag)
-
-	# Reconstruct a calibrated (negative) pcal at only the ~30 Hz pcal line
-	pcaly_line1 = calibration_parts.mkresample(pipeline, pcal_at_darm_act_freq, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	pcaly_line1 = pipeparts.mkgeneric(pipeline, pcaly_line1, "lal_demodulate", line_frequency = -1.0 * darm_act_line_freq, prefactor_real = 2.0)
-	remove_pcaly_line1, trash = calibration_parts.split_into_real(pipeline, pcaly_line1)
-	pipeparts.mkfakesink(pipeline, trash)
-
-	# Reconstruct a calibrated (negative) pcal at only the ~300 Hz pcal line
-	pcaly_line2 = calibration_parts.mkresample(pipeline, pcal_at_opt_gain_freq, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	pcaly_line2 = pipeparts.mkgeneric(pipeline, pcaly_line2, "lal_demodulate", line_frequency = -1.0 * opt_gain_fcc_line_freq, prefactor_real = 2.0)
-	remove_pcaly_line2, trash = calibration_parts.split_into_real(pipeline, pcaly_line2)
-	pipeparts.mkfakesink(pipeline, trash)
-
-	# Add the first two components together. We will add this to h(t) to remove these lines
-	remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_pcaly_line1, long_queue], [remove_pcaly_line2, short_queue]))
-
-	if remove_esd_act_line:
-		if options.factors_from_filters_file:
-			esd_act_line = calibration_parts.complex_audioamplify(pipeline, tstexc_at_esd_act_freq, EP10_real, EP10_imag)
-		else:
-			# EP10 was read from the frames
-			EP10 = calibration_parts.merge_into_complex(pipeline, EP10_real, EP10_imag, long_queue, short_queue)
-			esd_act_line = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, [tstexc_at_esd_act_freq, long_queue], [EP10, short_queue]))
-		# Reconstruct a calibrated (negative) ESD injection at the ~30 Hz ESD line
-		if options.kappatst_applied:
-			# Multiply by the real part of kappa_tst
-			kappa_tst = calibration_parts.caps_and_progress(pipeline, hoft_head_dict["kappa_tst"], kappa_caps, "kappa_tst")
-			esd_act_line = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, [esd_act_line, long_queue], [kappa_tst, short_queue]))
-		esd_act_line = calibration_parts.mkresample(pipeline, esd_act_line, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-		esd_act_line_remove = pipeparts.mkgeneric(pipeline, esd_act_line, "lal_demodulate", line_frequency = -1.0 * esd_act_line_freq, prefactor_real = 2.0)
-		esd_act_line_remove, trash = calibration_parts.split_into_real(pipeline, esd_act_line_remove)
-		pipeparts.mkfakesink(pipeline, trash)
-		# Add into the total line removal stream
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, short_queue], [esd_act_line_remove, long_queue]))
-
-	if remove_high_pcal_line:
-		# Demodulate pcal at the ~1kHz pcal line
-		pcaly_line3 = calibration_parts.demodulate(pipeline, pcaltee, high_pcal_line_freq, td, complex_caps, integration_samples, pcal_corr_at_high_line_freq_real, pcal_corr_at_high_line_freq_imag)
-		# Reconstruct a calibrated (negative) pcal at only the ~1kHz pcal line
-		pcaly_line3 = calibration_parts.mkresample(pipeline, pcaly_line3, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-		pcaly_line3 = pipeparts.mkgeneric(pipeline, pcaly_line3, "lal_demodulate", line_frequency = -1.0 * high_pcal_line_freq, prefactor_real = 2.0)
-		remove_pcaly_line3, trash = calibration_parts.split_into_real(pipeline, pcaly_line3)
-		pipeparts.mkfakesink(pipeline, trash)
-		# Add into the total line removal stream
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [remove_pcaly_line3, short_queue]))
-
-	if remove_roaming_pcal_line:
-		# Demodulate pcal at the ~3kHz pcal line
-		pcaly_line4 = calibration_parts.demodulate(pipeline, pcaltee, roaming_pcal_line_freq, td, complex_caps, integration_samples, pcal_corr_at_roaming_line_real, pcal_corr_at_roaming_line_imag)
-		# Reconstruct a calibrated (negative) pcal at only the ~3kHz pcal line
-		pcaly_line4 = calibration_parts.mkresample(pipeline, pcaly_line4, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-		pcaly_line4 = pipeparts.mkgeneric(pipeline, pcaly_line4, "lal_demodulate", line_frequency = -1.0 * roaming_pcal_line_freq, prefactor_real = 2.0)
-		remove_pcaly_line4, trash = calibration_parts.split_into_real(pipeline, pcaly_line4)
-		pipeparts.mkfakesink(pipeline, trash)
-		# Add into the total line removal stream
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [remove_pcaly_line4, short_queue]))
-
-	if remove_src_pcal_line:
-		# Reconstruct a calibrated (negative) pcal at only the ~3kHz pcal line
-		pcaly_line0 = calibration_parts.mkresample(pipeline, pcal_at_src_freq, 3, False, "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-		pcaly_line0 = pipeparts.mkgeneric(pipeline, pcaly_line0, "lal_demodulate", line_frequency = -1.0 * src_pcal_line_freq, prefactor_real = 2.0)
-		remove_pcaly_line0, trash = calibration_parts.split_into_real(pipeline, pcaly_line0)
-		pipeparts.mkfakesink(pipeline, trash)
-		# Add into the total line removal stream
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [remove_pcaly_line0, short_queue]))
-
-
-#
-# REMOVE POWER LINES
-#
-
-if options.remove_powerlines:
-	powerlines = calibration_parts.caps_and_progress(pipeline, head_dict["powerlines"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % powerlinessr, "powerlines")
-	powerlines = pipeparts.mkfirbank(pipeline, powerlines, latency = int(powerlinesdelay), fir_matrix = [powerlinesfilt[::-1]], time_domain = td)
-	powerlines = calibration_parts.mkresample(pipeline, powerlines, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	if options.remove_callines:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [powerlines, short_queue]))
-	else:
-		remove_from_strain = powerlines
-
-#
-# REMOVE IMC JITTER
-#
-
-if options.remove_jitter_imc:
-	imc_a_pitch = calibration_parts.caps_and_progress(pipeline, head_dict["imc_a_pitch"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % imcapitsr, "imc_a_pitch")
-	imc_a_yaw = calibration_parts.caps_and_progress(pipeline, head_dict["imc_a_yaw"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % imcayawsr, "imc_a_yaw")
-	imc_b_pitch = calibration_parts.caps_and_progress(pipeline, head_dict["imc_b_pitch"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % imcbpitsr, "imc_b_pitch")
-        imc_b_yaw = calibration_parts.caps_and_progress(pipeline, head_dict["imc_b_yaw"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % imcbyawsr, "imc_b_yaw")
-
-	imc_a_pitch = pipeparts.mkfirbank(pipeline, imc_a_pitch, latency = int(imcapitdelay), fir_matrix = [imcapitfilt[::-1]], time_domain = td)
-	imc_a_yaw = pipeparts.mkfirbank(pipeline, imc_a_yaw, latency = int(imcayawdelay), fir_matrix = [imcayawfilt[::-1]], time_domain = td)
-	imc_b_pitch = pipeparts.mkfirbank(pipeline, imc_b_pitch, latency = int(imcbpitdelay), fir_matrix = [imcbpitfilt[::-1]], time_domain = td)
-        imc_b_yaw = pipeparts.mkfirbank(pipeline, imc_b_yaw, latency = int(imcbyawdelay), fir_matrix = [imcbyawfilt[::-1]], time_domain = td)
-
-	imc_a_pitch = calibration_parts.mkresample(pipeline, imc_a_pitch, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	imc_a_yaw = calibration_parts.mkresample(pipeline, imc_a_yaw, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	imc_b_pitch = calibration_parts.mkresample(pipeline, imc_b_pitch, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-        imc_b_yaw = calibration_parts.mkresample(pipeline, imc_b_yaw, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-
-	if options.remove_callines or options.remove_powerlines:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [imc_a_pitch, long_queue], [imc_a_yaw, long_queue], [imc_b_pitch, long_queue], [imc_b_yaw, long_queue]))
-	else:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [imc_a_pitch, long_queue], [imc_a_yaw, long_queue], [imc_b_pitch, long_queue], [imc_b_yaw, long_queue]))
-
-if options.remove_jitter_psl:
-	bullseye_width = calibration_parts.caps_and_progress(pipeline, head_dict["bullseye_width"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % bullseyewidsr, "bullseye_width")
-	bullseye_pitch = calibration_parts.caps_and_progress(pipeline, head_dict["bullseye_pitch"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % bullseyepitsr, "bullseye_pitch")
-	bullseye_yaw = calibration_parts.caps_and_progress(pipeline, head_dict["bullseye_yaw"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % bullseyeyawsr, "bullseye_yaw")
-
-	bullseye_width = pipeparts.mkfirbank(pipeline, bullseye_width, latency = int(bullseyewiddelay), fir_matrix = [bullseyewidfilt[::-1]], time_domain = td)
-	bullseye_pitch = pipeparts.mkfirbank(pipeline, bullseye_pitch, latency = int(bullseyepitdelay), fir_matrix = [bullseyepitfilt[::-1]], time_domain = td)
-	bullseye_yaw = pipeparts.mkfirbank(pipeline, bullseye_yaw, latency = int(bullseyeyawdelay), fir_matrix = [bullseyeyawfilt[::-1]], time_domain = td)
-
-	bullseye_width = calibration_parts.mkresample(pipeline, bullseye_width, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	bullseye_pitch = calibration_parts.mkresample(pipeline, bullseye_pitch, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	bullseye_yaw = calibration_parts.mkresample(pipeline, bullseye_yaw, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-
-	if options.remove_callines or options.remove_powerlines or options.remove_jitter_imc:
-                remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [bullseye_width, long_queue], [bullseye_pitch, long_queue], [bullseye_yaw, long_queue]))
-	else:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [bullseye_width, long_queue], [bullseye_pitch, long_queue], [bullseye_yaw, long_queue]))
-
-#
-# REMOVE ANGULAR CONTROL
-#
-
-if options.remove_angular_control:
-	asc_dhard_pitch = calibration_parts.caps_and_progress(pipeline, head_dict["asc_dhard_pitch"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % ascdpitsr, "asc_dhard_pitch")
-	asc_dhard_yaw = calibration_parts.caps_and_progress(pipeline, head_dict["asc_dhard_yaw"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % ascdyawsr, "asc_dhard_yaw")
-	asc_chard_pitch = calibration_parts.caps_and_progress(pipeline, head_dict["asc_chard_pitch"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % asccpitsr, "asc_chard_pitch")
-	asc_chard_yaw = calibration_parts.caps_and_progress(pipeline, head_dict["asc_chard_yaw"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % asccyawsr, "asc_chard_yaw")
-
-	asc_dhard_pitch = pipeparts.mkfirbank(pipeline, asc_dhard_pitch, latency = int(ascdpitdelay), fir_matrix = [ascdpitfilt[::-1]], time_domain = td)
-	asc_dhard_yaw = pipeparts.mkfirbank(pipeline, asc_dhard_yaw, latency = int(ascdyawdelay), fir_matrix = [ascdyawfilt[::-1]], time_domain = td)
-	asc_chard_pitch = pipeparts.mkfirbank(pipeline, asc_chard_pitch, latency = int(asccpitdelay), fir_matrix = [asccpitfilt[::-1]], time_domain = td)
-	asc_chard_yaw = pipeparts.mkfirbank(pipeline, asc_chard_yaw, latency = int(asccyawdelay), fir_matrix = [asccyawfilt[::-1]], time_domain = td)
-
-	asc_dhard_pitch = calibration_parts.mkresample(pipeline, asc_dhard_pitch, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	asc_dhard_yaw = calibration_parts.mkresample(pipeline, asc_dhard_yaw, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	asc_chard_pitch = calibration_parts.mkresample(pipeline, asc_chard_pitch, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	asc_chard_yaw = calibration_parts.mkresample(pipeline, asc_chard_yaw, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-
-	if options.remove_callines or options.remove_powerlines or options.remove_jitter_imc or options.remove_jitter_psl:
-                remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [asc_dhard_pitch, long_queue], [asc_dhard_yaw, long_queue], [asc_chard_pitch, long_queue], [asc_chard_yaw, long_queue]))
-	else:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [asc_dhard_pitch, long_queue], [asc_dhard_yaw, long_queue], [asc_chard_pitch, long_queue], [asc_chard_yaw, long_queue]))
-
-if options.remove_length_control:
-	lsc_srcl = calibration_parts.caps_and_progress(pipeline, head_dict["lsc_srcl"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % lscsrclsr, "lsc_srcl")
-	lsc_mich = calibration_parts.caps_and_progress(pipeline, head_dict["lsc_mich"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % lscmichsr, "lsc_mich")
-	lsc_prcl = calibration_parts.caps_and_progress(pipeline, head_dict["lsc_prcl"], "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % lscprclsr, "lsc_prcl")
-
-	lsc_srcl = pipeparts.mkfirbank(pipeline, lsc_srcl, latency = int(lscsrcldelay), fir_matrix = [lscsrclfilt[::-1]], time_domain = td)
-	lsc_mich = pipeparts.mkfirbank(pipeline, lsc_mich, latency = int(lscmichdelay), fir_matrix = [lscmichfilt[::-1]], time_domain = td)
-	lsc_prcl = pipeparts.mkfirbank(pipeline, lsc_prcl, latency = int(lscprcldelay), fir_matrix = [lscprclfilt[::-1]], time_domain = td)
-
-	lsc_srcl = calibration_parts.mkresample(pipeline, lsc_srcl, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	lsc_mich = calibration_parts.mkresample(pipeline, lsc_mich, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-	lsc_prcl = calibration_parts.mkresample(pipeline, lsc_prcl, 3, False, "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % hoftsr)
-
-	if options.remove_callines or options.remove_powerlines or options.remove_jitter_imc or options.remove_jitter_psl or options.remove_angular_control:
-                remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [remove_from_strain, long_queue], [lsc_srcl, long_queue], [lsc_mich, long_queue], [lsc_prcl, long_queue]))
-	else:
-		remove_from_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [lsc_srcl, long_queue], [lsc_mich, long_queue], [lsc_prcl, long_queue]))
-
-
-#
-# REMOVE EVERYTHING FROM THE STRAIN
-#
-
-strain = calibration_parts.caps_and_progress(pipeline, hoft_head_dict["hoft"], hoft_caps, "hoft")
-remove_from_strain = pipeparts.mkaudioamplify(pipeline, remove_from_strain, -1.0)
-cleaned_strain = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, [strain, short_queue], [remove_from_strain, long_queue]))
-
-cleaned_strain = pipeparts.mkprogressreport(pipeline, cleaned_strain, "progress_hoft_cleaned_%s" % instrument)
-
-# Put the units back to strain before writing to frames
-cleaned_straintagstr = "units=strain,channel-name=%sCALIB_STRAIN_CLEAN%s,instrument=%s" % (chan_prefix, chan_suffix, instrument)
-cleaned_strain = pipeparts.mktaginject(pipeline, cleaned_strain, cleaned_straintagstr)
-
-#
-# CREATE MUXER AND HOOK EVERYTHING UP TO IT
-#
-
-mux = pipeparts.mkframecppchannelmux(pipeline, None)
-
-if options.frame_duration is not None:
-	mux.set_property("frame-duration", options.frame_duration)
-if options.frames_per_file is not None:
-	mux.set_property("frames-per-file", options.frames_per_file)
-mux.set_property("compression-scheme", options.compression_scheme)
-mux.set_property("compression-level", options.compression_level)
-
-
-# Link the strain branch to the muxer
-strain_queue_length = short_queue
-calibration_parts.mkqueue(pipeline, cleaned_strain, strain_queue_length).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_STRAIN_CLEAN%s" % (instrument, chan_prefix, chan_suffix)))
-
-# FIXME: Need to addd this back in when the filter latency is sorted out from the cleaning
-"""
-# Check that all frames are long enough, that they have all of the channels by requring a certain amount of time from start-up, and that frames aren't written for times requested by the wings option
-def check_complete_frames(pad, info, (output_start, frame_duration, wings_start, wings_end)):
-	buf = info.get_buffer()
-	startts = lal.LIGOTimeGPS(0, buf.pts)
-	duration = lal.LIGOTimeGPS(0, buf.duration)
-	if not (startts % frame_duration == 0):
-		return Gst.PadProbeReturn.DROP
-	if startts < output_start:
-		return Gst.PadProbeReturn.DROP
-	if duration != frame_duration:
-		return Gst.PadProbeReturn.DROP
-	if wings_start is not None and wings_end is not None:
-		if startts < wings_start or (startts+duration) > wings_end:
-			return Gst.PadProbeReturn.DROP
-	return Gst.PadProbeReturn.OK
-if options.data_source == "frames":
-	start = int(options.gps_start_time)
-elif options.data_source == "lvshm":
-	tm = time.gmtime()
-	start = int(lal.UTCToGPS(tm))
-# start time of first frame file is the desired start time + either filter latency or kappa settling (if computing kappas), whichever is bigger
-if not options.no_kappatst or not options.no_kappapu or not options.no_kappac or not options.no_fcc:
-	output_start = start + max(int(filter_settle_time), options.demodulation_filter_time + options.median_smoothing_time + options.factors_averaging_time)
-else:
-	output_start = start + int(filter_settle_time)
-"""
-
-"""
-# If the wings option is set, need to also check that frames aren't written during the requested wing time
-if options.wings is not None:
-	wings_start = int(options.gps_start_time) + options.wings
-	wings_end = int(options.gps_end_time) - options.wings
-	mux.get_static_pad("src").add_probe(Gst.PadProbeType.BUFFER, check_complete_frames, (lal.LIGOTimeGPS(output_start,0), lal.LIGOTimeGPS(options.frame_duration*options.frames_per_file,0), lal.LIGOTimeGPS(wings_start, 0), lal.LIGOTimeGPS(wings_end, 0)))
-else:
-	mux.get_static_pad("src").add_probe(Gst.PadProbeType.BUFFER, check_complete_frames, (lal.LIGOTimeGPS(output_start,0), lal.LIGOTimeGPS(options.frame_duration*options.frames_per_file,0), None, None))
-"""
-
-mux = pipeparts.mkprogressreport(pipeline, mux, "progress_sink_%s" % instrument)
-
-if options.write_to_shm_partition is not None:
-	pipeparts.mkgeneric(pipeline, mux, "gds_lvshmsink", sync=False, async=False, shm_name = options.write_to_shm_partition, num_buffers=10, blocksize=options.frame_size*options.frame_duration*options.frames_per_file, buffer_mode=options.buffer_mode)
-else:
-	pipeparts.mkframecppfilesink(pipeline, mux, frame_type = options.frame_type, path = options.output_path, instrument = instrument) 
-
-# Run pipeline
-
-if options.write_pipeline is not None:
-	pipeparts.write_dump_dot(pipeline, "%s.%s" %(options.write_pipeline, "NULL"), verbose = options.verbose)
-
-# Seek the pipeline when necessary
-if options.data_source == "frames":
-	if options.verbose:
-		print >>sys.stderr, "seeking GPS start and stop times ..."
-	if pipeline.set_state(Gst.State.READY) != Gst.StateChangeReturn.SUCCESS:
-		raise RuntimeError("pipeline failed to enter READY state")
-	datasource.pipeline_seek_for_gps(pipeline, gps_start_time, gps_end_time)
-
-if options.verbose:
-	print >>sys.stderr, "setting pipeline state to playing ..."
-if pipeline.set_state(Gst.State.PLAYING) != Gst.StateChangeReturn.SUCCESS:
-	raise RuntimeError("pipeline failed to enter PLAYING state")
-else:
-	print "set to playing successfully"
-if options.write_pipeline is not None:
-	pipeparts.write_dump_dot(pipeline, "%s.%s" %(options.write_pipeline, "PLAYING"), verbose = options.verbose)
-	
-if options.verbose:
-	print >>sys.stderr, "running pipeline ..."
-
-mainloop.run()
-
-if pipeline.set_state(Gst.State.NULL) != Gst.StateChangeReturn.SUCCESS:
-	raise RuntimeError("pipeline could not be set to NULL")
diff --git a/gstlal-calibration/bin/gstlal_compute_kappas b/gstlal-calibration/bin/gstlal_compute_kappas
deleted file mode 100755
index 69833997304603331c11a513b2b0e69760aeedcd..0000000000000000000000000000000000000000
--- a/gstlal-calibration/bin/gstlal_compute_kappas
+++ /dev/null
@@ -1,1313 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2010-2015  Jordi Burguet-Castell, Madeline Wade, Aaron Viets
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-
-"""
-This pipeline computes the time-dependent correction factors (kappas) using DARM_ERR and the injection channels PCALY, x_tst, and x_ctrl. It can also read in a filter that is applied to DARM_ERR to simulate the effect of the kappas or undo the effect of the kappas.
-
-Type gstlal_compute_kappas --help to see the full list of command line options.
-"""
-
-import sys
-import numpy
-import time
-import resource
-
-from optparse import OptionParser, Option
-
-import gi
-gi.require_version('Gst', '1.0')
-from gi.repository import GObject, Gst
-GObject.threads_init()
-Gst.init(None)
-
-import lal
-
-from gstlal import pipeparts
-from gstlal import calibration_parts
-from gstlal import simplehandler
-from gstlal import datasource
-
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
-from ligo import segments
-
-#
-# Function definition for writing pipeline graph
-#
-
-def write_graph(demux):
-	pipeparts.write_dump_dot(pipeline, "%s.%s" % (options.write_pipeline, "PLAYING"), verbose = True)
-
-#
-# Make sure we have sufficient resources
-# We allocate far more memory than we need, so this is okay
-#
-
-def setrlimit(res, lim):
-	hard_lim = resource.getrlimit(res)[1]
-	resource.setrlimit(res, (lim if lim is not None else hard_lim, hard_lim))
-# set the number of processes and total set size up to hard limit and
-# shrink the per-thread stack size (default is 10 MiB)
-setrlimit(resource.RLIMIT_NPROC, None)
-setrlimit(resource.RLIMIT_AS, None)
-setrlimit(resource.RLIMIT_RSS, None)
-setrlimit(resource.RLIMIT_STACK, 1024*1024)
-
-#
-# Function definition to obtain the current GPS time
-#
-
-def now():
-	return lal.LIGOTimeGPS(lal.UTCToGPS(time.gmtime()), 0)
-	
-
-###################################################################################################
-############################## Program Command Line Options #######################################
-###################################################################################################
-
-parser = OptionParser(description = __doc__)
-
-# Append program specific options
-
-# These options should be used whether the pipeline runs in full calibration mode or partial calibration mode
-parser.add_option("--data-source", metavar = "source", help = "Set the data source from [frames|lvshm]. Required.")
-parser.add_option("--frame-cache", metavar = "filename", help = "Set the name of the LAL cache listing the LIGO .gwf frame files (optional).  This is required iff --data-source=frames")
-parser.add_option("--gps-start-time", metavar = "seconds", help = "Set the start time of the segment to analyze in GPS seconds. This is required iff --data-source=frames")
-parser.add_option("--gps-end-time", metavar = "seconds", help = "Set the end time of the segment to analyze in GPS seconds. This is required iff --data-source=frames")
-parser.add_option("--wings", metavar = "seconds", type = "int", help = "Number of seconds to trim off of the beginning and end of the output. Should only be used if --data-source=frames.")
-parser.add_option("--do-file-checksum", action = "store_true", help = "Set this option to turn on file checksum in the demuxer.")
-parser.add_option("--ifo", metavar = "name", help = "Name of the IFO to be calibrated.")
-parser.add_option("--shared-memory-partition", metavar = "name", help = "Set the name of the shared memory partition to read from.  This is required iff --data-source=lvshm.")
-parser.add_option("--derr-sample-rate", metavar = "Hz", default = 16384, type = "int", help = "Sample rate of the error signal channel. (Default = 16384 Hz)")
-parser.add_option("--kappas-state-sample-rate", metavar = "Hz", default = 16, type = "int", help = "Sample rate for the outgoing DQ vector GDS-KAPPAS_STATE_VECTOR. (Default = 16 Hz)")
-parser.add_option("--tst-exc-sample-rate", metavar = "Hz", default = 512, type = "int", help = "Sample rate for the control signals being read in. (Default = 512 Hz)")
-parser.add_option("--coh-sample-rate", metavar = "Hz", default = 16, type = "int", help = "Sample rate for the coherence uncertainty channels. (Default = 16 Hz).")
-parser.add_option("--buffer-length", metavar = "seconds", type = float, default = 1.0, help = "Set the length in seconds of buffers to be used in the pipeline (Default = 1.0)")
-parser.add_option("--frame-duration", metavar = "seconds", type = "int", default = 4, help = "Set the number of seconds for each frame. (Default = 4)")
-parser.add_option("--frames-per-file", metavar = "count", type = "int", default = 1, help = "Set the number of frames per frame file. (Default = 1)")
-parser.add_option("--frame-size", metavar = "bytes", type = "int", default = 405338, help = "Approximate size in bytes of frame file images; used when writing to shared memory.  (Default=405338)")
-parser.add_option("--compression-scheme", metavar = "scheme", type = "int", default = 256, help = "Set the compression scheme for the framecpp_channelmux element. (Default=256, no compression)")
-parser.add_option("--compression-level", metavar = "level", type = "int", default = 0, help = "Set the compression level for the framecpp_channelmux element. (Default=0)")
-parser.add_option("--write-to-shm-partition", metavar = "name", help = "Set the name of the shared memory partition to write to. If this is not provided, frames will be written to a file.")
-parser.add_option("--buffer-mode", metavar = "number", type = "int", default = 2, help = "Set the buffer mode for the lvshmsink element. (Default=2)")
-parser.add_option("--frame-type", metavar = "name", default = "TEST", help = "Set the frame type as input to the frame writing element. (Default=TEST)")
-parser.add_option("--output-path", metavar = "name", default = ".", help = "Set the output path for writing frame files. (Default=Current)")
-parser.add_option("--no-dq-vector", action = "store_true", help = "Set this if you want to turn off all interpretation and calculation of a data quality vector.")
-parser.add_option("--chan-prefix", metavar = "name", default = "GDS-", help = "Prefix for all output channel names. (Default = GDS)") 
-parser.add_option("--chan-suffix", metavar = "name", help = "Suffix for all output channel names.") 
-
-# These are debugging options
-parser.add_option("--write-pipeline", metavar = "filename", help = "Write a DOT graph description of the as-built pipeline to this file (optional).  The environment variable GST_DEBUG_DUMP_DOT_DIR must be set for this option to work.")
-parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose (optional).")
-
-# These are options specific to the calibration procedure
-parser.add_option("--filters-file", metavar="filename", help = "Name of file containing calibration filters (in npz format)")
-parser.add_option("--kappas-filters-file", metavar="filename", help = "Name of file containing kappas simulation filters (in npz format)")
-parser.add_option("--factors-from-filters-file", action = "store_true", help = "Compute the calibration factors from reference values contained in the filters file instead of from EPICS channels.")
-parser.add_option("--no-coherence", action = "store_true", help = "Gate the calibration factors with a pre-computed coherence channel.")
-parser.add_option("--coherence-uncertainty-threshold", metavar = "float", type = float, default = 0.0025, help = "Threshold for the coherence uncertainty for each calibration line. (Default = 0.0025)")
-parser.add_option("--coherence-time", metavar = "seconds", type = "int", default = 130, help = "Amount of time used in front end to compute coherence of calibration lines. (Default = 130)")
-parser.add_option("--coh-unc-sus-line1-channel", metavar="name", default="CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY", help = "Channel name for SUS line 1 coherence uncertainty. (Default=CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY)")
-parser.add_option("--coh-unc-pcaly-line1-channel", metavar="name", default="CAL-CS_TDEP_PCALY_LINE1_UNCERTAINTY", help = "Channel name for PCALY line 1 coherence uncertainty. (Default=CAL-CS_TDEP_PCALY_LINE1_UNCERTAINTY)")
-parser.add_option("--coh-unc-pcaly-line2-channel", metavar="name", default="CAL-CS_TDEP_PCALY_LINE2_UNCERTAINTY", help = "Channel name for PCALY line 2 coherence uncertainty. (Default=CAL-CS_TDEP_PCALY_LINE2_UNCERTAINTY)")
-parser.add_option("--coh-unc-darm-line1-channel", metavar="name", default="CAL-CS_TDEP_DARM_LINE1_UNCERTAINTY", help = "Channel name for DARM line 1 coherence uncertainty. (Default=CAL-CS_TDEP_DARM_LINE1_UNCERTAINTY)")
-parser.add_option("--no-kappatst", action = "store_true", help = "Set this to turn off the calculation of \kappa_tst.")
-parser.add_option("--no-kappapu", action = "store_true", help = "Set this to turn off the calculation of \kappa_pu.")
-parser.add_option("--no-kappap", action = "store_true", help = "Set this to turn off the calculation of \kappa_p.")
-parser.add_option("--no-kappau", action = "store_true", help = "Set this to turn off the calculation of \kappa_u.")
-parser.add_option("--no-kappac", action = "store_true", help = "Set this to turn off the calculation of \kappa_c.")
-parser.add_option("--no-fcc", action = "store_true", help = "Set this to turn off the calculation of f_cc.")
-parser.add_option("--no-srcQ", action = "store_true", help = "Set this to turn off the calculation of the SRC Q.")
-parser.add_option("--no-fs", action = "store_true", help = "Set this to turn off the calculation of the SRC spring frequency.")
-parser.add_option("--act-timing-from-kappapu", action = "store_true", help = "Set this to use the calculated value of \kappa_pu to measure any timing error in the actuation. If this is set, the phase of \kappa_tst will be adjusted accordingly.")
-parser.add_option("--act-timing-from-kappatst", action = "store_true", help = "Set this to use the calculated value of \kappa_tst to measure any timing error in the actuation. If this is set, the phase of \kappa_pu will be adjusted accordingly.")
-parser.add_option("--factors-averaging-time", metavar = "Sec", type = int, default = 10, help = "Time over which to average the smoothed time-varying calibration factors (\kappas), given in seconds. (Default = 10 seconds)")
-parser.add_option("--src-averaging-time", metavar = "Sec", type = int, default = 600, help = "Time over which to average the smoothed SRC detuning parameters fs and Q, given in seconds. (Default = 600 seconds)")
-parser.add_option("--compute-factors-sr", metavar = "Hz", type = int, default = 16, help = "Sample rate at which time-dependent correction factors are computed. (Default = 16 Hz)")
-parser.add_option("--demodulation-filter-time", metavar = "s", type = int, default = 20, help = "Length in seconds of low-pass FIR filter used in demodulation of the calibration lines. (Default = 20 seconds)")
-parser.add_option("--median-smoothing-time", metavar = "s", type = int, default = 128, help = "Time (in seconds) to smooth out \kappas with a median-like method. (Default = 128 s)")
-parser.add_option("--kappas-default-to-median", action = "store_true", help = "If set, bad computed kappas will be replaced by the previous computed median in the running median array. Otherwise, they are replaced with the default value.")
-parser.add_option("--filter-latency", metavar = "float", type = float, default = 0.0, help = "Latency of all filtering/averaging/median processes (other than calibration model filters) as a fraction of filter length. Value should be set between 0.0 and 1.0. (Default = 0.0)")
-parser.add_option("--record-factors-sr", metavar = "Hz", type = int, default = 16, help = "Sample rate at which calibration factors are recorded. (Default = 16 Hz)")
-parser.add_option("--expected-kappapu-real", metavar = "float", type = float, default = 1.0, help = "Expected value for the real part of \kappa_pu. (Default = 1.0)")
-parser.add_option("--expected-kappap-real", metavar = "float", type = float, default = 1.0, help = "Expected value for the real part of \kappa_p. (Default = 1.0)")
-parser.add_option("--expected-kappau-real", metavar = "float", type = float, default = 1.0, help = "Expected value for the real part of \kappa_u. (Default = 1.0)")
-parser.add_option("--expected-kappatst-real", metavar = "float", type = float, default = 1.0, help = "Expected value for the real part of \kappa_tst. (Default = 1.0)")
-parser.add_option("--expected-kappapu-imag", metavar = "float", type = float, default = 0.0, help = "Expected value for the imaginary part of \kappa_pu. (Default = 0.0)")
-parser.add_option("--expected-kappap-imag", metavar = "float", type = float, default = 0.0, help = "Expected value for the imaginary part of \kappa_p. (Default = 0.0)")
-parser.add_option("--expected-kappau-imag", metavar = "float", type = float, default = 0.0, help = "Expected value for the imaginary part of \kappa_u. (Default = 0.0)")
-parser.add_option("--expected-kappatst-imag", metavar = "float", type = float, default = 0.0, help = "Expected value for the imaginary part of \kappa_tst. (Default = 0.0)")
-parser.add_option("--expected-kappac", metavar = "float", type = float, default = 1.0, help = "Expected value for \kappa_c. (Default = 1.0)")
-parser.add_option("--expected-fcc", metavar = "Hz", type = float, default = 360.0, help = "Expected value for the coupled cavity pole. (Default = 360.0 Hz)")
-parser.add_option("--expected-fs", metavar = "Hz", type = float, default = 8.0, help = "Expected value for the SRC optical spring frequency. (Default = 8.0 Hz)")
-parser.add_option("--expected-srcQ", metavar = "float", type = float, default = 28.0, help = "Expected value for the SRC Q. (Default = 28.0)")
-parser.add_option("--kappapu-real-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the real part of \kappa_pu +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappap-real-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the real part of \kappa_p +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappau-real-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the real part of \kappa_u +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappatst-real-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the real part of \kappa_tst +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappapu-imag-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the imaginary part of \kappa_pu +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappap-imag-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the imaginary part of \kappa_p +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappau-imag-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the imaginary part of \kappa_u +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappatst-imag-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of the imaginary part of \kappa_tst +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--kappac-ok-var", metavar = "float", type = float, default = 0.2, help = "Values of \kappa_c +/- this number will be considered OK. (Default = 0.2)")
-parser.add_option("--fcc-ok-var", metavar = "Hz", type = float, default = 50, help = "Values of f_cc +/- this number (in Hz) will be considered OK. (Default = 50 Hz)")
-parser.add_option("--fs-ok-var", metavar = "Hz", type = float, default = 5, help = "Values of SRC spring frequency +/- this number (in Hz) will be considered OK. (Default = 5 Hz)")
-parser.add_option("--srcQinv-min", metavar = "float", type = float, default = 0.0, help = "Minimum value of SRC Q inverse that will be considered OK. (Default = 0.0)")
-parser.add_option("--srcQinv-max", metavar = "float", type = float, default = 0.5, help = "Maximum value of SRC Q inverse that will be considered OK. (Default = 0.5)")
-parser.add_option("--exc-channel-name", metavar = "name", default = "CAL-CS_LINE_SUM_DQ", help = "Set the name of the excitation channel.  This is only necessary when the calibration factors computation is turned on, which is the default behavior. (Default = CAL-CS_LINE_SUM_DQ)")
-parser.add_option("--tst-exc-channel-name", metavar = "name", default = "SUS-ETMY_L3_CAL_LINE_OUT_DQ", help = "Set the name of the TST excitation channel.  This is only necessary when the \kappa_tst factors computation is turned on, which is the default behavior. (Default = SUS-ETMY_L3_CAL_LINE_OUT_DQ)")
-parser.add_option("--pcal-channel-name", metavar = "name", default = "CAL-PCALY_RX_PD_OUT_DQ", help = "Set the name of the PCal channel used for calculating the calibration factors. (Default = CAL-PCALY_RX_PD_OUT_DQ)")
-parser.add_option("--darm-err-channel-name", metavar = "name", default = "CAL-DARM_ERR_WHITEN_OUT_DBL_DQ", help = "Set the name of the error signal channel. (Default = CAL-DARM_ERR_WHITEN_OUT_DBL_DQ)")
-
-# These are all options related to the reference channels used in the calibration factors computation
-parser.add_option("--ref-channels-sr", metavar = "Hz", default = 16, help = "Set the sample rate for the reference model channels used in the calibration factors calculation. (Default = 16 Hz)")
-parser.add_option("--EP4-real", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_TST_REAL", help = "Set the name of the channel containing the real part of A_tst at the ESD line used for the \kappa_a and \kappa_pu calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_TST_REAL)")
-parser.add_option("--EP5-real", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_REAL", help = "Set the name of the channel containing the real part of A_pu at the ESD line used for the \kappa_a calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_REAL)")
-parser.add_option("--EP3-real", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_INV_REAL", help = "Set the name of the channel containing the real part of 1/A_pu at the ESD line used for the \kappa_pu calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_INV_REAL)")
-parser.add_option("--EP4-imag", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_TST_IMAG", help = "Set the name of the channel containing the imaginary part of A_tst at the ESD line used for the \kappa_a and \kappa_pu calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_TST_IMAG")
-parser.add_option("--EP5-imag", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_IMAG", help = "Set the name of the channel containing the imaginary part of A_pu at the ESD line used for the \kappa_A calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_IMAG")
-parser.add_option("--EP3-imag", metavar = "name", default = "CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_INV_IMAG", help = "Set the name of the channel containing the imaginary part of 1/A_pu at the ESD line used for the \kappa_PU calculation. (Default = CAL-CS_TDEP_DARM_LINE1_REF_A_USUM_INV_IMAG")
-parser.add_option("--EP2-real", metavar = "name", default = "CAL-CS_TDEP_REF_CLGRATIO_CTRL_REAL", help = "Set the name of the channel containing the real part of the factors used to compute A(f_ctrl). (Default = CAL-CS_TDEP_REF_CLGRATIO_CTRL_REAL)")
-parser.add_option("--EP2-imag", metavar = "name", default = "CAL-CS_TDEP_REF_CLGRATIO_CTRL_IMAG", help = "Set the name of the channel containing the imaginary part of the factors used to compute A(f_ctrl). (Default = CAL-CS_TDEP_REF_CLGRATIO_CTRL_IMAG)")
-parser.add_option("--EP6-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_C_NOCAVPOLE_REAL", help = "Set the name of the channel containing the real part of C_res at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_C_NOCAVPOLE_REAL")
-parser.add_option("--EP6-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_C_NOCAVPOLE_IMAG", help = "Set the name of the channel containing the imaginary part of C_res at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_C_NOCAVPOLE_IMAG")
-parser.add_option("--EP7-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_D_REAL", help = "Set the name of the channel containing the real part of D at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_D_REAL")
-parser.add_option("--EP7-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_D_IMAG", help = "Set the name of the channel containing the imaginary part of D at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_D_IMAG")
-parser.add_option("--EP8-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_A_TST_REAL", help = "Set the name of the channel containing the real part of A_tst at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_A_TST_REAL")
-parser.add_option("--EP8-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_A_TST_IMAG", help = "Set the name of the channel containing the imaginary part of A_tst at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_A_TST_IMAG")
-parser.add_option("--EP9-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_A_USUM_REAL", help = "Set the name of the channel containing the real part of A_pu at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_A_USUM_REAL")
-parser.add_option("--EP9-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE2_REF_A_USUM_IMAG", help = "Set the name of the channel containing the imaginary part of A_pu at the PCal line used for the \kappa_c and f_cc calculation. (Default = CAL-CS_TDEP_PCALY_LINE2_REF_A_USUM_IMAG")
-parser.add_option("--EP1-real", metavar = "name", default = "CAL-CS_TDEP_REF_INVA_CLGRATIO_TST_REAL", help = "Set the name of the channel containing the real part of the \kappa_tst reference factors. (Default = CAL-CS_TDEP_REF_INVA_CLGRATIO_TST_REAL)")
-parser.add_option("--EP1-imag", metavar = "name", default = "CAL-CS_TDEP_REF_INVA_CLGRATIO_TST_IMAG", help = "Set the name of the channel containing the imaginary part of the \kappa_tst reference factors. (Default = CAL-CS_TDEP_REF_INVA_CLGRATIO_TST_IMAG)")
-parser.add_option("--EP10-real", metavar = "name", default = "CAL-CS_TDEP_ESD_LINE1_REF_A_TST_NOLOCK_REAL", help = "Set the name of the channel containing the real part of A_tst at the ESD line used for removal of the ESD line. (Default = CAL-CS_TDEP_ESD_LINE1_REF_A_TST_REAL")
-parser.add_option("--EP10-imag", metavar = "name", default = "CAL-CS_TDEP_ESD_LINE1_REF_A_TST_NOLOCK_IMAG", help = "Set the name of the channel containing the imaginary part of A_tst at the ESD line used for removal of the ESD line. (Default = CAL-CS_TDEP_ESD_LINE1_REF_A_TST_IMAG")
-parser.add_option("--EP11-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_C_NOCAVPOLE_REAL", help = "Set the name of the channel containing the real part of C_res at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_C_NOCAVPOLE_REAL")
-parser.add_option("--EP11-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_C_NOCAVPOLE_IMAG", help = "Set the name of the channel containing the imaginary part of C_res at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_C_NOCAVPOLE_IMAG")
-parser.add_option("--EP12-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_D_REAL", help = "Set the name of the channel containing the real part of D at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_D_REAL")
-parser.add_option("--EP12-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_D_IMAG", help = "Set the name of the channel containing the imaginary part of D at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_D_IMAG")
-parser.add_option("--EP13-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_A_TST_REAL", help = "Set the name of the channel containing the real part of A_tst at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_A_TST_REAL")
-parser.add_option("--EP13-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_A_TST_IMAG", help = "Set the name of the channel containing the imaginary part of A_tst at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_A_TST_IMAG")
-parser.add_option("--EP14-real", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_A_USUM_REAL", help = "Set the name of the channel containing the real part of A_pu at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_A_USUM_REAL")
-parser.add_option("--EP14-imag", metavar = "name", default = "CAL-CS_TDEP_PCALY_LINE4_REF_A_USUM_IMAG", help = "Set the name of the channel containing the imaginary part of A_pu at the PCal line used for the src_Q and f_s calculation. (Default = CAL-CS_TDEP_PCALY_LINE4_REF_A_USUM_IMAG")
-
-
-# Parse options
-options, filenames = parser.parse_args()
-
-# Sanity checks for command line options
-data_sources = set(("frames", "lvshm"))
-
-if options.data_source not in data_sources:
-	raise ValueError("--data-source must be one of %s" % ",".join(data_sources))
-
-if options.data_source == "frames" and options.frame_cache is None:
-	raise ValueError("--frame-cache must be specified when using --data-source=frames")
-
-if options.no_kappatst and options.no_kappapu and options.no_kappap and options.no_kappau and options.no_kappac and options.no_fcc and options.no_fs and options.no_srcQ:
-	raise ValueError("Must compute at least one of the time-dependent correction factors")
-
-if options.wings is not None and options.data_source != "frames":
-	raise ValueError("--wings can only be set when --data-source=frames")
-
-if options.ifo is None:
-	raise ValueError("must specify --ifo")
-
-if options.data_source == "frames" and (options.gps_start_time is None or options.gps_end_time is None):
-	raise ValueError("must specify --gps-start-time and --gps-end-time when --data-source=frames")
-
-if int(options.record_factors_sr) > int(options.compute_factors_sr):
-	raise ValueError("--record-factors-sr must be less than or equal to --compute-factors-sr")
-
-if not options.factors_from_filters_file and (not options.no_fs or not options.no_srcQ) and ((options.data_source == "frames" and int(options.gps_start_time) < 1175954418) or (options.data_source == "lvshm" and now() < 1175954418)):
-	raise ValueError("Cannot compute SRC detuning parameters as the needed EPICS channels are not in the frames until GPS time 1175954418. Use command line options --no-srcQ and --no-fs.")
-
-if options.gps_start_time is not None:
-	if options.gps_end_time is None:
-		raise ValueError("must provide both --gps-start-time and --gps-end-time")
-	if options.data_source == "lvshm":
-		raise ValueError("cannot set --gps-start-time or --gps-end-time with --data-source=lvshm")
-	try:
-		start = lal.LIGOTimeGPS(options.gps_start_time)
-	except ValueError:
-		raise ValueError("invalid --gps-start-time %s" % options.gps_start_time)
-	try:
-		end = lal.LIGOTimeGPS(options.gps_end_time)
-	except ValueError:
-		raise ValueError("invalid --gps-end-time %s" % options.gps_end_time)
-	if start >= end:
-		raise ValueError("--gps-start-time must be < --gps-end-time: %s < %s" % (options.gps_start_time, options.gps_end_time))
-	# segment from gps start and stop time if given
-	seg = segments.segment(start, end)
-	gps_start_time = seg[0]
-	gps_end_time = seg[1]
-elif options.gps_end_time is not None:
-	raise ValueError("must provide both --gps-start-time and --gps-end-time")
-
-###################################################################################################
-######################################## Setup ####################################################
-###################################################################################################
-
-# Set up instrument and channel name info from command line options
-instrument = options.ifo
-
-# Set up short-cut names for each of the sample rates used throughout the pipeline and establish caps string shortcuts
-derr_sr = options.derr_sample_rate # Sample rate for the error signal
-kappasstatesr = options.kappas_state_sample_rate  # Sample rate for the KAPPA_STATE_VECTOR
-cohsr = options.coh_sample_rate # Sample rate for the coherence uncertainty channels
-derr_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % derr_sr
-calibstate_caps = "audio/x-raw, format=U32LE, rate=%d, channel-mask=(bitmask)0x0" % kappasstatesr
-coh_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % cohsr
-# caps strings for the computation kappas
-ref_factors_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0x0" % options.ref_channels_sr
-compute_calib_factors_caps = "audio/x-raw, format=F64LE, rate=%d, channel-mask=(bitmask)0X0" % options.compute_factors_sr
-compute_calib_factors_complex_caps = "audio/x-raw, format=Z128LE, rate=%d, channel-mask=(bitmask)0x0" % options.compute_factors_sr
-
-# Set up smoothing, averaging and integration sample sizes for kappa calulations
-integration_samples = int(options.demodulation_filter_time) * options.compute_factors_sr
-factors_average_samples = int(options.factors_averaging_time) * options.compute_factors_sr
-src_average_samples = int(options.src_averaging_time) * options.compute_factors_sr
-median_smoothing_samples = int(options.median_smoothing_time) * options.compute_factors_sr
-kappa_gate_attack_length = -integration_samples * (1.0 - options.filter_latency)
-kappa_gate_hold_length = -integration_samples * options.filter_latency - (options.filter_latency != 0) * options.coherence_time * options.compute_factors_sr
-
-# Set up string for the channels suffix and prefix as provided by the user
-if options.chan_suffix is not None:
-	chan_suffix = options.chan_suffix
-else:
-	chan_suffix = ""
-chan_prefix = options.chan_prefix
-
-# How many EPICS will we for the KAPPA_STATE_VECTOR calculation? It depends on the IFO and the time we are calibrating
-if options.no_dq_vector:
-	num_dq_epics = 0
-elif options.ifo == "H1" and int(options.gps_start_time) > 1175976256:
-	num_dq_epics = 14
-elif options.ifo == "L1" and int(options.gps_start_time) > 1179588864:
-	num_dq_epics = 10
-else:
-	num_dq_epics = 9
-
-#
-# Load in the filters files that contains filter coefficients, etc.
-#
-
-filters = numpy.load(options.filters_file)
-if options.kappas_filters_file is not None:
-	kappas_filters = numpy.load(options.kappas_filters_file)
-	derr_kappas_filter = kappas_filters["kappas_filter_td"]
-	kappas_filter_sr = kappas_filters["kappas_filter_sr"]
-	kappas_filter_delay = kappas_filters["kappas_filter_delay"]
-else:
-	derr_kappas_filter = numpy.ones(1)
-	kappas_filter_delay = 0
-	kappas_filter_sr = derr_sr
-
-# If we're reading the reference model factors from the filters file, load them
-if options.factors_from_filters_file or not options.no_dq_vector:
-	try:
-		EP1_real = float(filters["EP1_real"])
-		EP1_imag = float(filters["EP1_imag"])
-		EP2_real = float(filters["EP2_real"])
-		EP2_imag = float(filters["EP2_imag"])
-		EP3_real = float(filters["EP3_real"])
-		EP3_imag = float(filters["EP3_imag"])
-		EP4_real = float(filters["EP4_real"])
-		EP4_imag = float(filters["EP4_imag"])
-		EP5_real = float(filters["EP5_real"])
-		EP5_imag = float(filters["EP5_imag"])
-		EP6_real = float(filters["EP6_real"])
-		EP6_imag = float(filters["EP6_imag"])
-		EP7_real = float(filters["EP7_real"])
-		EP7_imag = float(filters["EP7_imag"])
-		EP8_real = float(filters["EP8_real"])
-		EP8_imag = float(filters["EP8_imag"])
-		EP9_real = float(filters["EP9_real"])
-		EP9_imag = float(filters["EP9_imag"])
-	except:
-		if options.factors_from_filters_file:
-			raise ValueError("Cannot compute time-dependent correction factors, as the needed EPICS are not contained in the specified filters file.")
-	try:
-		EP10_real = float(filters["EP10_real"])
-		EP10_imag = float(filters["EP10_imag"])
-	except:
-		if num_dq_epics > 9:
-			num_dq_epics = 9
-	try:
-		EP11_real = float(filters["EP11_real"])
-		EP11_imag = float(filters["EP11_imag"])
-		EP12_real = float(filters["EP12_real"])
-		EP12_imag = float(filters["EP12_imag"])
-		EP13_real = float(filters["EP13_real"])
-		EP13_imag = float(filters["EP13_imag"])
-		EP14_real = float(filters["EP14_real"])
-		EP14_imag = float(filters["EP14_imag"])
-	except:
-		if options.factors_from_filters_file and (not options.no_srcQ or not options.no_fs):
-			raise ValueError("Cannot compute SRC spring frequency or Q, as the needed EPICS are not contained in the specified filters file.")
-		if num_dq_epics > 10:
-			num_dq_epics = 10
-
-# Load all of the kappa dewhitening and correction factors
-darm_act_line_freq = float(filters["ka_pcal_line_freq"])
-pcal_corr_at_darm_act_freq_real = float(filters["ka_pcal_corr_re"])
-pcal_corr_at_darm_act_freq_imag = float(filters["ka_pcal_corr_im"])
-pu_act_esd_line_freq = float(filters["ka_esd_line_freq"])
-opt_gain_fcc_line_freq = float(filters["kc_pcal_line_freq"])
-pcal_corr_at_opt_gain_fcc_freq_real = float(filters["kc_pcal_corr_re"])
-pcal_corr_at_opt_gain_fcc_freq_imag = float(filters["kc_pcal_corr_im"])
-esd_act_line_freq = float(filters["ktst_esd_line_freq"])
-try:
-	src_pcal_line_freq = float(filters["src_pcal_line_freq"])
-	pcal_corr_at_src_freq_real = float(filters["src_pcal_corr_re"])
-	pcal_corr_at_src_freq_imag = float(filters["src_pcal_corr_im"])
-except:
-	if not options.no_srcQ or not options.no_fs:
-		raise ValueError("Cannot compute SRC spring frequency or Q, as the calibration line frequency is not contained in the specified filters file.")
-try:
-	fcc_default = float(filters["fcc"])
-except:
-	fcc_default = options.expected_fcc
-try:
-	fs_default = float(filters["fs"])
-	srcQ_default = float(filters["srcQ"])
-except:
-	fs_default = options.expected_fs
-	srcQ_default = options.expected_srcQ
-
-#
-# Set up the appropriate channel list. In this section, we also fill a list called headkeys
-# that will be the keys for the dictionary holding each pipeline branch name, and we set up
-# a dictionary that will be populated with pipeline branch names based on the channel list.
-#
-
-head_dict = {}
-channel_list = []
-headkeys = []
-
-# We need DARM_ERR and at least the pcal and tst excitation channels for computing kappas
-
-channel_list.extend(((instrument, options.darm_err_channel_name), (instrument, options.pcal_channel_name), (instrument, options.tst_exc_channel_name)))
-headkeys.extend(("darm_err", "pcal", "tstexc"))
-
-# Most likely, we need the excitation channel as well
-if not options.no_kappac or not options.no_fcc or not options.no_kappapu or not options.no_fs or not options.no_srcQ:
-	channel_list.append((instrument, options.exc_channel_name))
-	headkeys.append("exc")
-
-# If we are not reading the EPICS records from the filters, we need them from the frames
-# Needed for kappa_tst
-if not options.factors_from_filters_file and (not options.no_kappatst or not options.no_kappapu or not options.no_kappap or not options.no_kappau or not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ) or num_dq_epics > 0:
-	channel_list.extend(((instrument, options.EP1_real), (instrument, options.EP1_imag)))
-	headkeys.extend(("EP1_real", "EP1_imag"))
-# These are needed for kappa_pu
-if not options.factors_from_filters_file and (not options.no_kappac or not options.no_fcc or not options.no_kappapu or not options.no_fs or not options.no_srcQ) or num_dq_epics > 3:
-	channel_list.extend(((instrument, options.EP2_real), (instrument, options.EP2_imag), (instrument, options.EP3_real), (instrument, options.EP3_imag), (instrument, options.EP4_real), (instrument, options.EP4_imag)))
-	headkeys.extend(("EP2_real", "EP2_imag", "EP3_real", "EP3_imag", "EP4_real", "EP4_imag"))
-# If we are computing either kappa_c or f_cc, we need some more EPICS records
-if not options.factors_from_filters_file and (not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ) or num_dq_epics > 8:
-	channel_list.extend(((instrument, options.EP6_real), (instrument, options.EP6_imag), (instrument, options.EP7_real), (instrument, options.EP7_imag), (instrument, options.EP8_real), (instrument, options.EP8_imag), (instrument, options.EP9_real), (instrument, options.EP9_imag)))
-	headkeys.extend(("EP6_real", "EP6_imag", "EP7_real", "EP7_imag", "EP8_real", "EP8_imag", "EP9_real", "EP9_imag"))
-
-# EP10 is needed to remove the ESD line, so it only gets used to compare to the filters-file EP10 here
-if num_dq_epics > 9:
-	channel_list.extend(((instrument, options.EP10_real), (instrument, options.EP10_imag)))
-	headkeys.extend(("EP10_real", "EP10_imag"))
-
-# These are needed if we compute the optical spring frequency and/or Q-factor of the Signal Recycling Cavity (SRC)
-if not options.factors_from_filters_file and (not options.no_fs or not options.no_srcQ) or num_dq_epics > 13:
-	channel_list.extend(((instrument, options.EP11_real), (instrument, options.EP11_imag), (instrument, options.EP12_real), (instrument, options.EP12_imag), (instrument, options.EP13_real), (instrument, options.EP13_imag), (instrument, options.EP14_real), (instrument, options.EP14_imag)))
-	headkeys.extend(("EP11_real", "EP11_imag", "EP12_real", "EP12_imag", "EP13_real", "EP13_imag", "EP14_real", "EP14_imag"))
-
-# If we are using pre-computed coherence to gate kappas
-if not options.no_coherence:
-	if not options.no_kappatst or not options.no_kappapu or not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ:
-		channel_list.extend(((instrument, options.coh_unc_sus_line1_channel), (instrument, options.coh_unc_pcaly_line1_channel), (instrument, options.coh_unc_darm_line1_channel)))
-		headkeys.extend(("pcaly_line1_coh", "sus_coh", "darm_coh"))
-	if not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ:
-		channel_list.append((instrument, options.coh_unc_pcaly_line2_channel))
-		headkeys.append("pcaly_line2_coh")
-
-
-####################################################################################################
-####################################### Main Pipeline ##############################################
-####################################################################################################
-
-pipeline = Gst.Pipeline(name="gstlal_compute_kappas")
-mainloop = GObject.MainLoop()
-handler = simplehandler.Handler(mainloop, pipeline)
-
-# 
-# Turn off debugging tools or verboseness
-#
-
-pipeparts.mkchecktimestamps = lambda pipeline, src, *args: src # comment this line out to turn on the checktimestamps debugging
-if not options.verbose:
-	pipeparts.mkprogressreport = lambda pipeline, src, *args: src
-
-#
-# Read in data from frames or shared memory
-#
-
-if options.data_source == "lvshm": # Data is to be read from shared memory; "low-latency" mode
-	src = pipeparts.mklvshmsrc(pipeline, shm_name = options.shared_memory_partition, assumed_duration = 1)
-elif options.data_source == "frames": # Data is to be read from frame files; "offline" mode
-	src = pipeparts.mklalcachesrc(pipeline, location = options.frame_cache, cache_dsc_regex = instrument)
-
-#
-# Hook up the relevant channels to the demuxer
-#
-
-if options.data_source == "lvshm":
-	demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum = options.do_file_checksum, skip_bad_files = True, channel_list = map("%s:%s".__mod__, channel_list))
-
-elif options.data_source == "frames":
-	demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum = options.do_file_checksum, skip_bad_files = False, channel_list = map("%s:%s".__mod__, channel_list))
-
-# Write the pipeline graph after pads have been hooked up to the demuxer
-if options.write_pipeline is not None:
-	demux.connect("no-more-pads", write_graph)	
-
-# Get everything hooked up and fill in discontinuities
-for key, chan in zip(headkeys, channel_list):
-	head_dict[key] = calibration_parts.hook_up(pipeline, demux, chan[1], instrument, options.buffer_length)
-
-#
-# TIME-VARYING FACTORS COMPUTATIONS
-#
-
-# Get all the channels we need first and make sure they have the desired sample rate and caps
-darm_err = calibration_parts.caps_and_progress(pipeline, head_dict["darm_err"], derr_caps, "darm_err")
-darm_err = calibration_parts.mkresample(pipeline, darm_err, 5, False, int(kappas_filter_sr))
-
-# Apply a filter to DARM_ERR to simulate time-dependence (if the filter is not provided, is is set to [1])
-darm_err = pipeparts.mkfirbank(pipeline, darm_err, latency = int(kappas_filter_delay), fir_matrix = [derr_kappas_filter[::-1]], time_domain = True)
-derrtee = pipeparts.mktee(pipeline, darm_err)
-
-# Get the injection channels
-pcal = calibration_parts.caps_and_progress(pipeline, head_dict["pcal"], derr_caps, "pcal")
-pcal = calibration_parts.mkresample(pipeline, pcal, 5, False, int(kappas_filter_sr))
-pcaltee = pipeparts.mktee(pipeline, pcal)
-tstexccaps = "audio/x-raw, format=F64LE, rate=%d" % options.tst_exc_sample_rate
-tstexc = calibration_parts.caps_and_progress(pipeline, head_dict["tstexc"], tstexccaps, "tstexc")
-
-if not options.no_kappac or not options.no_fcc or not options.no_kappapu or not options.no_kappap or not options.no_kappau or not options.no_fs or not options.no_srcQ:
-	exc = calibration_parts.caps_and_progress(pipeline, head_dict["exc"], derr_caps, "exc")
-	exc = calibration_parts.mkresample(pipeline, exc, 5, False, int(kappas_filter_sr))
-
-# Get the EPICS channels
-for key in headkeys:
-	if key.startswith("EP"):
-		head_dict[key] = calibration_parts.caps_and_progress(pipeline, head_dict[key], ref_factors_caps, key)
-		head_dict[key] = calibration_parts.mkresample(pipeline, head_dict[key], 0, False, compute_calib_factors_caps)
-		head_dict[key] = pipeparts.mktee(pipeline, head_dict[key])
-
-# Get the coherence channels
-if not options.no_coherence:
-	if not options.no_kappatst or not options.no_kappapu or not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ:
-		pcaly_line1_coh = calibration_parts.caps_and_progress(pipeline, head_dict["pcaly_line1_coh"], coh_caps, "pcaly_line1_coh")
-		pcaly_line1_coh = calibration_parts.mkresample(pipeline, pcaly_line1_coh, 0, False, compute_calib_factors_caps)
-		sus_coh = calibration_parts.caps_and_progress(pipeline, head_dict["sus_coh"], coh_caps, "sus_coh")
-		sus_coh = calibration_parts.mkresample(pipeline, sus_coh, 0, False, compute_calib_factors_caps)
-		darm_coh = calibration_parts.caps_and_progress(pipeline, head_dict["darm_coh"], coh_caps, "darm_coh")
-		darm_coh = calibration_parts.mkresample(pipeline, darm_coh, 0, False, compute_calib_factors_caps)
-		pcaly_line1_coh = pipeparts.mktee(pipeline, pcaly_line1_coh)
-		sus_coh = pipeparts.mktee(pipeline, sus_coh)
-		darm_coh = pipeparts.mktee(pipeline, darm_coh)
-	if not options.no_kappac or not options.no_fcc or not options.no_fs or not options.no_srcQ:
-		pcaly_line2_coh = calibration_parts.caps_and_progress(pipeline, head_dict["pcaly_line2_coh"], coh_caps, "pcaly_line2_coh")
-		pcaly_line2_coh = calibration_parts.mkresample(pipeline, pcaly_line2_coh, 0, False, compute_calib_factors_caps)
-		pcaly_line2_coh = pipeparts.mktee(pipeline, pcaly_line2_coh)
-
-# Set up computations for \kappa_tst,\kappa_c, \kappa_pu, f_cc, if applicable
-
-# demodulate the PCAL channel and apply the PCAL correction factor at the DARM actuation line frequency
-pcal_at_darm_act_freq = calibration_parts.demodulate(pipeline, pcaltee, darm_act_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency, prefactor_real = pcal_corr_at_darm_act_freq_real, prefactor_imag = pcal_corr_at_darm_act_freq_imag)
-if not options.no_kappapu or not options.no_kappac or not options.no_fcc or not options.no_srcQ or not options.no_fs:
-	pcal_at_darm_act_freq = pipeparts.mktee(pipeline, pcal_at_darm_act_freq)
-
-# demodulate DARM_ERR at the DARM actuation line frequency
-derr_at_darm_act_freq = calibration_parts.demodulate(pipeline, derrtee, darm_act_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-if not options.no_kappapu or not options.no_kappac or not options.no_fcc or not options.no_srcQ or not options.no_fs:
-	derr_at_darm_act_freq = pipeparts.mktee(pipeline, derr_at_darm_act_freq)
-
-# demodulate the TST excitation channel at the ESD actuation line frequency
-tstexc_at_esd_act_freq = calibration_parts.demodulate(pipeline, tstexc, esd_act_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-# demodulate DARM_ERR at the ESD actuation line frequency
-derr_at_esd_act_freq = calibration_parts.demodulate(pipeline, derrtee, esd_act_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-# compute kappa_tst, either using reference factors from the filters file or reading them from EPICS channels
-if not options.factors_from_filters_file:
-	EP1 = calibration_parts.merge_into_complex(pipeline, head_dict["EP1_real"], head_dict["EP1_imag"])
-	ktst = calibration_parts.compute_kappatst(pipeline, derr_at_esd_act_freq, tstexc_at_esd_act_freq, pcal_at_darm_act_freq, derr_at_darm_act_freq, EP1)
-elif options.factors_from_filters_file:
-	ktst = calibration_parts.compute_kappatst_from_filters_file(pipeline, derr_at_esd_act_freq, tstexc_at_esd_act_freq, pcal_at_darm_act_freq, derr_at_darm_act_freq, EP1_real, EP1_imag)
-
-ktst = pipeparts.mktee(pipeline, ktst)
-
-# Put off smoothing \kappa_tst until after \kappa_pu is computed in case we are correcting the phase of \kappa_tst using \kappa_pu
-
-# If we're also computing \kappa_pu, \kappa_c, f_cc, fs, or Q, keep going
-if not options.no_kappac or not options.no_fcc or not options.no_kappapu or not options.np_kappap or not options.no_kappau or not options.no_srcQ or not options.no_fs or (not options.no_kappatst and options.act_timing_from_kappapu):
-	# demodulate excitation channel at PU actuation line frequency
-	exc_at_pu_act_freq = calibration_parts.demodulate(pipeline, exc, pu_act_esd_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-	# demodulate DARM_ERR at PU actuation line frequency
-	derr_at_pu_act_freq = calibration_parts.demodulate(pipeline, derrtee, pu_act_esd_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-	# compute the factor Afctrl that will be used in the computation of kappa_pu and kappa_a, either using reference factors from the filters file or reading them from EPICS channels
-	if not options.factors_from_filters_file:
-		EP2 = calibration_parts.merge_into_complex(pipeline, head_dict["EP2_real"], head_dict["EP2_imag"])
-		EP3 = calibration_parts.merge_into_complex(pipeline, head_dict["EP3_real"], head_dict["EP3_imag"])
-		EP4 = calibration_parts.merge_into_complex(pipeline, head_dict["EP4_real"], head_dict["EP4_imag"])
-		afctrl = calibration_parts.compute_afctrl(pipeline, derr_at_pu_act_freq, exc_at_pu_act_freq, pcal_at_darm_act_freq, derr_at_darm_act_freq, EP2)
-	elif options.factors_from_filters_file:
-		afctrl = calibration_parts.compute_afctrl_from_filters_file(pipeline, derr_at_pu_act_freq, exc_at_pu_act_freq, pcal_at_darm_act_freq, derr_at_darm_act_freq, EP2_real, EP2_imag)
-
-	# \kappa_pu calcuation, which needs to happen for any of the other kappas to be computed
-	if not options.factors_from_filters_file:
-		kpu = calibration_parts.compute_kappapu(pipeline, EP3, afctrl, ktst, EP4)
-	elif options.factors_from_filters_file:
-		kpu = calibration_parts.compute_kappapu_from_filters_file(pipeline, EP3_real, EP3_imag, afctrl, ktst, EP4_real, EP4_imag)
-
-	kpu = pipeparts.mktee(pipeline, kpu)
-
-	# Put off smoothing \kappa_pu in case we are correcting the phase of \kappa_pu using \kappa_tst
-
-	# If desired, correct the phase of \kappa_pu using \kappa_tst (This assumes that all stages of actuation have the same variable time delay, and that \kappa_tst is doing a better job of measuring it)
-	if options.act_timing_from_kappatst:
-		# Find the magnitude of \kappa_pu
-		kpu = pipeparts.mkgeneric(pipeline, kpu, "cabs")
-		# Find the phase of \kappa_tst
-		phi_ktst = pipeparts.mkgeneric(pipeline, ktst, "carg")
-		# Multiply by the line-frequency ratio to get the phase of \kappa_pu
-		phi_kpu = pipeparts.mkaudioamplify(pipeline, phi_ktst, pu_act_esd_line_freq / esd_act_line_freq)
-		# Find the phase factor
-		kpu_phase_factor = pipeparts.mkgeneric(pipeline, pipeparts.mktogglecomplex(pipeline, pipeparts.mkmatrixmixer(pipeline, phi_kpu, matrix = [[0.0, 1.0]])), "cexp")
-		# Multiply by the magnitude of \kappa_pu
-		kpu = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, pipeparts.mktogglecomplex(pipeline, pipeparts.mkmatrixmixer(pipeline, kpu, matrix = [[1.0, 0.0]])), kpu_phase_factor))
-		kpu = pipeparts.mktee(pipeline, kpu)
-
-	# If desired, correct the phase of \kappa_tst using \kappa_pu (This assumes that all stages of actuation have the same variable time delay, and that \kappa_pu is doing a better job of measuring it)
-	if options.act_timing_from_kappapu:
-		# Find the magnitude of \kappa_tst
-		ktst = pipeparts.mkgeneric(pipeline, ktst, "cabs")
-		# Find the phase of \kappa_tst
-		phi_kpu = pipeparts.mkgeneric(pipeline, kpu, "carg")
-		# Multiply by the line-frequency ratio to get the phase of \kappa_tst
-		phi_ktst = pipeparts.mkaudioamplify(pipeline, phi_kpu, esd_act_line_freq / pu_act_esd_line_freq)
-		# Find the phase factor
-		ktst_phase_factor = pipeparts.mkgeneric(pipeline, pipeparts.mktogglecomplex(pipeline, pipeparts.mkmatrixmixer(pipeline, phi_ktst, matrix = [[0.0, 1.0]])), "cexp")
-		# Multiply by the magnitude of \kappa_tst
-		ktst = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, pipeparts.mktogglecomplex(pipeline, pipeparts.mkmatrixmixer(pipeline, ktst, matrix = [[1.0, 0.0]])), ktst_phase_factor))
-		ktst = pipeparts.mktee(pipeline, ktst)
-
-	# Now apply the gating and smoothing to \kappa_tst and \kappa_pu
-	if not options.no_kappatst:
-		smooth_ktst_nogate = pipeparts.mkgeneric(pipeline, ktst, "lal_smoothkappas", default_kappa_re = options.expected_kappatst_real, default_kappa_im = options.expected_kappatst_imag, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = options.kappas_default_to_median, filter_latency = options.filter_latency)
-		smooth_ktstR_nogate, smooth_ktstI_nogate = calibration_parts.split_into_real(pipeline, smooth_ktst_nogate)
-
-		if not options.no_coherence:
-			# Gate kappa_tst with the coherence of the PCALY_line1 line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst, pcaly_line1_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_tst with the coherence of the suspension line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst_gated, sus_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_tst with the coherence of the DARM line
-			ktst_gated = calibration_parts.mkgate(pipeline, ktst_gated, darm_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-
-			# Smooth kappa_tst
-			smooth_ktst = calibration_parts.smooth_complex_kappas(pipeline, ktst_gated, options.expected_kappatst_real, options.expected_kappatst_imag, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		else:
-			# Smooth kappa_tst
-			smooth_ktst = calibration_parts.smooth_complex_kappas_no_coherence(pipeline, ktst, options.kappatst_real_ok_var, options.kappatst_imag_ok_var, options.expected_kappatst_real, options.expected_kappatst_imag, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		smooth_ktsttee = pipeparts.mktee(pipeline, smooth_ktst)
-		smooth_ktstR, smooth_ktstI = calibration_parts.split_into_real(pipeline, smooth_ktsttee)
-
-		smooth_ktstRtee = pipeparts.mktee(pipeline, smooth_ktstR)
-		smooth_ktstItee = pipeparts.mktee(pipeline, smooth_ktstI)
-
-
-
-	if not options.no_kappapu:
-		smooth_kpu_nogate = pipeparts.mkgeneric(pipeline, kpu, "lal_smoothkappas", default_kappa_re = options.expected_kappapu_real, default_kappa_im = options.expected_kappapu_imag, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = options.kappas_default_to_median, filter_latency = options.filter_latency)
-		smooth_kpuR_nogate, smooth_kpuI_nogate = calibration_parts.split_into_real(pipeline, smooth_kpu_nogate)
-
-		if not options.no_coherence:
-			# Gate kappa_pu with the coherence of the DARM line
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu, darm_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pu with the coherence of the PCALY_line1 line
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, pcaly_line1_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			# Gate kappa_pu with the coherence of the suspension coherence
-			kpu_gated = calibration_parts.mkgate(pipeline, kpu_gated, sus_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-
-			# Smooth kappa_pu
-			smooth_kpu = calibration_parts.smooth_complex_kappas(pipeline, kpu_gated, options.expected_kappapu_real, options.expected_kappapu_imag, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		else:
-			# Smooth kappa_pu
-			smooth_kpu = calibration_parts.smooth_complex_kappas_no_coherence(pipeline, kpu, options.kappapu_real_ok_var, options.kappapu_imag_ok_var, options.expected_kappapu_real, options.expected_kappapu_imag, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		smooth_kputee = pipeparts.mktee(pipeline, smooth_kpu)
-		smooth_kpuR, smooth_kpuI = calibration_parts.split_into_real(pipeline, smooth_kputee)
-
-		smooth_kpuRtee = pipeparts.mktee(pipeline, smooth_kpuR)
-		smooth_kpuItee = pipeparts.mktee(pipeline, smooth_kpuI)	
-
-	# Finally, compute \kappa_c and f_cc
-	if not options.no_kappac or not options.no_fcc or not options.no_srcQ or not options.no_fs:
-		# demodulate the PCAL channel and apply the PCAL correction factor at optical gain and f_cc line frequency
-		pcal_at_opt_gain_freq = calibration_parts.demodulate(pipeline, pcaltee, opt_gain_fcc_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency, prefactor_real = pcal_corr_at_opt_gain_fcc_freq_real, prefactor_imag = pcal_corr_at_opt_gain_fcc_freq_imag)
-
-		# demodulate DARM_ERR at optical gain and f_cc line frequency
-		derr_at_opt_gain_freq = calibration_parts.demodulate(pipeline, derrtee, opt_gain_fcc_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-		# Compute the factor S which will be used for the kappa_c and f_cc calculations
-		# \kappa_tst and \kappa_pu need to be evaluated at the higher pcal line frequency
-		ktst_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, ktst, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / esd_act_line_freq)
-		kpu_at_opt_gain_freq = pipeparts.mkgeneric(pipeline, kpu, "lpshiftfreq", frequency_ratio = opt_gain_fcc_line_freq / pu_act_esd_line_freq)
-		if not options.factors_from_filters_file:
-			EP6 = calibration_parts.merge_into_complex(pipeline, head_dict["EP6_real"], head_dict["EP6_imag"])
-			EP7 = calibration_parts.merge_into_complex(pipeline, head_dict["EP7_real"], head_dict["EP7_imag"])
-			EP8 = calibration_parts.merge_into_complex(pipeline, head_dict["EP8_real"], head_dict["EP8_imag"])
-			EP9 = calibration_parts.merge_into_complex(pipeline, head_dict["EP9_real"], head_dict["EP9_imag"])
-			S = calibration_parts.compute_S(pipeline, EP6, pcal_at_opt_gain_freq, derr_at_opt_gain_freq, EP7, ktst_at_opt_gain_freq, EP8, kpu_at_opt_gain_freq, EP9)
-		elif options.factors_from_filters_file:
-			S = calibration_parts.compute_S_from_filters_file(pipeline, EP6_real, EP6_imag, pcal_at_opt_gain_freq, derr_at_opt_gain_freq, EP7_real, EP7_imag, ktst_at_opt_gain_freq, EP8_real, EP8_imag, kpu_at_opt_gain_freq, EP9_real, EP9_imag)
-
-		S = pipeparts.mktee(pipeline, S)
-
-		SR, SI = calibration_parts.split_into_real(pipeline, S)
-
-		if not options.no_kappac and not options.no_fcc:
-			SR = pipeparts.mktee(pipeline, SR)
-			SI = pipeparts.mktee(pipeline, SI)
-
-		# compute kappa_c
-		if not options.no_kappac or not options.no_srcQ or not options.no_fs:
-			kc = calibration_parts.compute_kappac(pipeline, SR, SI)
-		if not options.no_kappac:
-			kc = pipeparts.mktee(pipeline, kc)
-			smooth_kc_nogate = pipeparts.mkgeneric(pipeline, kc, "lal_smoothkappas", default_kappa_re = options.expected_kappac, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = options.kappas_default_to_median, filter_latency = options.filter_latency)
-
-			if not options.no_coherence:
-				# Gate kappa_c with the coherence of all four of the calibration lines
-				kc_gated = calibration_parts.mkgate(pipeline, kc, pcaly_line2_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, darm_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, pcaly_line1_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				kc_gated = calibration_parts.mkgate(pipeline, kc_gated, sus_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-
-				# Smooth kappa_c
-				smooth_kc = calibration_parts.smooth_kappas(pipeline, kc_gated, options.expected_kappac, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-			else:
-				# Smooth kappa_c
-				smooth_kc = calibration_parts.smooth_kappas_no_coherence(pipeline, kc, options.kappac_ok_var, options.expected_kappac, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		smooth_kctee = pipeparts.mktee(pipeline, smooth_kc)
-
-		# compute f_cc
-		if not options.no_fcc or not options.no_srcQ or not options.no_fs:
-			fcc = calibration_parts.compute_fcc(pipeline, SR, SI, opt_gain_fcc_line_freq)
-		if not options.no_fcc:
-			fcc = pipeparts.mktee(pipeline, fcc)
-			smooth_fcc_nogate = pipeparts.mkgeneric(pipeline, fcc, "lal_smoothkappas", default_kappa_re = fcc_default, array_size = median_smoothing_samples, avg_array_size = factors_average_samples, default_to_median = options.kappas_default_to_median, filter_latency = options.filter_latency)
-
-			if not options.no_coherence:
-				# Gate f_cc with all four of the calibration lines
-				fcc_gated = calibration_parts.mkgate(pipeline, fcc, pcaly_line2_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, darm_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, pcaly_line1_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-				fcc_gated = calibration_parts.mkgate(pipeline, fcc_gated, sus_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-
-				# Smooth f_cc
-				smooth_fcc = calibration_parts.smooth_kappas(pipeline, fcc_gated, fcc_default, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-			else:
-				# Smooth f_cc
-				smooth_fcc = calibration_parts.smooth_kappas_no_coherence(pipeline, fcc, options.fcc_ok_var, fcc_default, median_smoothing_samples, factors_average_samples, options.kappas_default_to_median, options.filter_latency)
-				
-			smooth_fcctee = pipeparts.mktee(pipeline, smooth_fcc)
-
-	# compute f_s and Q
-	if not options.no_fs or not options.no_srcQ:
-		expected_Xi = complex((fs_default * fs_default - 1j * src_pcal_line_freq * fs_default / srcQ_default) / (src_pcal_line_freq * src_pcal_line_freq))
-		Xi_real_ok_var = float((pow(fs_default + options.fs_ok_var, 2) - pow(fs_default, 2.0)) / pow(src_pcal_line_freq, 2))
-		Xi_imag_ok_var = float(options.fs_ok_var / (srcQ_default * src_pcal_line_freq))
-
-		# demodulate PCAL channel and apply the PCAL correction factor at SRC detuning line frequency
-		pcal_at_src_freq = calibration_parts.demodulate(pipeline, pcaltee, src_pcal_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency, prefactor_real = pcal_corr_at_src_freq_real, prefactor_imag = pcal_corr_at_src_freq_imag)
-
-		# demodulate DARM_ERR at SRC detuning line frequency
-		derr_at_src_freq = calibration_parts.demodulate(pipeline, derrtee, src_pcal_line_freq, True, options.compute_factors_sr, options.demodulation_filter_time, options.filter_latency)
-
-		# Compute the factor Xi which will be used for the f_s and src_Q calculations
-		# \kappa_tst and \kappa_pu need to be evaluated at the SRC pcal line frequency
-		ktst_at_src_freq = pipeparts.mkgeneric(pipeline, ktst, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / esd_act_line_freq)
-		kpu_at_src_freq = pipeparts.mkgeneric(pipeline, kpu, "lpshiftfreq", frequency_ratio = src_pcal_line_freq / pu_act_esd_line_freq)
-		if not options.factors_from_filters_file:
-			EP11 = calibration_parts.merge_into_complex(pipeline, head_dict["EP11_real"], head_dict["EP11_imag"])
-			EP12 = calibration_parts.merge_into_complex(pipeline, head_dict["EP12_real"], head_dict["EP12_imag"])
-			EP13 = calibration_parts.merge_into_complex(pipeline, head_dict["EP13_real"], head_dict["EP13_imag"])
-			EP14 = calibration_parts.merge_into_complex(pipeline, head_dict["EP14_real"], head_dict["EP14_imag"])
-			Xi = calibration_parts.compute_Xi(pipeline, pcal_at_src_freq, derr_at_src_freq, src_pcal_line_freq, EP11, EP12, EP13, EP14, ktst_at_src_freq, kpu_at_src_freq, kc, fcc)
-		elif options.factors_from_filters_file:
-			Xi = calibration_parts.compute_Xi_from_filters_file(pipeline, pcal_at_src_freq, derr_at_src_freq, src_pcal_line_freq, EP11_real, EP11_imag, EP12_real, EP12_imag, EP13_real, EP13_imag, EP14_real, EP14_imag, ktst_at_src_freq, kpu_at_src_freq, kc, fcc)
-
-		Xi = pipeparts.mktee(pipeline, Xi)
-		smooth_Xi_nogate = pipeparts.mkgeneric(pipeline, Xi, "lal_smoothkappas", default_kappa_re = float(numpy.real(expected_Xi)), default_kappa_im = float(numpy.imag(expected_Xi)), array_size = median_smoothing_samples, avg_array_size = src_average_samples, default_to_median = options.kappas_default_to_median, filter_latency = options.filter_latency)
-
-		if not options.no_coherence:
-			# Gate Xi with all coherences. We apply the gating and smoothing here since Q depends on the inverse of Im(Xi), which fluctuates about zero.
-			Xi_gated = calibration_parts.mkgate(pipeline, Xi, pcaly_line2_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, darm_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, pcaly_line2_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-			Xi_gated = calibration_parts.mkgate(pipeline, Xi_gated, sus_coh, options.coherence_uncertainty_threshold, attack_length = kappa_gate_attack_length, hold_length = kappa_gate_hold_length, invert_control = True)
-
-			smooth_Xi = calibration_parts.smooth_complex_kappas(pipeline, Xi_gated, float(numpy.real(expected_Xi)), float(numpy.imag(expected_Xi)), median_smoothing_samples, src_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		else:
-			smooth_Xi = calibration_parts.smooth_complex_kappas_no_coherence(pipeline, Xi, Xi_real_ok_var, Xi_real_ok_var, float(numpy.real(expected_Xi)), float(numpy.imag(expected_Xi)), median_smoothing_samples, src_average_samples, options.kappas_default_to_median, options.filter_latency)
-
-		if options.no_srcQ:
-			# the imaginary part is only used to compute Q
-			smooth_XiR = pipeparts.mkgeneric(pipeline, smooth_Xi, "creal")
-			smooth_XiR_nogate = pipeparts.mkgeneric(pipeline, smooth_Xi_nogate, "creal")
-		else:
-			smooth_XiR, smooth_XiI = calibration_parts.split_into_real(pipeline, smooth_Xi)
-			smooth_XiR_nogate, smooth_XiI_nogate = calibration_parts.split_into_real(pipeline, smooth_Xi_nogate)
-
-		smooth_sqrtXiR = calibration_parts.mkpow(pipeline, smooth_XiR, exponent = 0.5)
-		smooth_sqrtXiR_nogate = calibration_parts.mkpow(pipeline, smooth_XiR_nogate, exponent = 0.5)
-
-		if not options.no_fs and not options.no_srcQ:
-			smooth_sqrtXiR = pipeparts.mktee(pipeline, smooth_sqrtXiR)
-			smooth_sqrtXiR_nogate = pipeparts.mktee(pipeline, smooth_sqrtXiR_nogate)
-
-		# compute f_s
-		if not options.no_fs:
-			smooth_fs = pipeparts.mkaudioamplify(pipeline, smooth_sqrtXiR, src_pcal_line_freq)
-			smooth_fs_nogate = pipeparts.mkaudioamplify(pipeline, smooth_sqrtXiR_nogate, src_pcal_line_freq)
-
-			if not options.no_dq_vector:
-				smooth_fs = pipeparts.mktee(pipeline, smooth_fs)
-
-		# compute SRC Q_inv
-		if not options.no_srcQ:
-			smooth_sqrtXiR_inv = calibration_parts.mkpow(pipeline, smooth_sqrtXiR, exponent = -1.0)
-			smooth_sqrtXiR_inv_nogate = calibration_parts.mkpow(pipeline, smooth_sqrtXiR_nogate, exponent = -1.0)
-			smooth_srcQ_inv = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, smooth_sqrtXiR_inv, pipeparts.mkaudioamplify(pipeline, smooth_XiI, -1.0)))
-			smooth_srcQ_inv_nogate = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, smooth_sqrtXiR_inv_nogate, pipeparts.mkaudioamplify(pipeline, smooth_XiI_nogate, -1.0)))
-
-			if not options.no_dq_vector:
-				smooth_srcQ_inv = pipeparts.mktee(pipeline, smooth_srcQ_inv)
-
-
-#
-# KAPPA_STATE_VECTOR BRANCH
-#
-
-#FIXME: Add more comments!
-
-if not options.no_dq_vector:
-
-	#
-	# KAPPATST BITS BRANCH
-	#
-	if not options.no_kappatst:
-		ktstSmoothInRange = calibration_parts.compute_kappa_bits(pipeline, smooth_ktstRtee, smooth_ktstItee, options.expected_kappatst_real, options.expected_kappatst_imag, options.kappatst_real_ok_var, options.kappatst_imag_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,9), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# KAPPAP BITS BRANCH
-	#
-	if not options.no_kappap:
-		kpSmoothInRange = calibration_parts.compute_kappa_bits(pipeline, smooth_kpRtee, smooth_kpItee, options.expected_kappap_real, options.expected_kappap_imag, options.kappap_real_ok_var, options.kappap_imag_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,10), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# KAPPAPU BITS BRANCH
-	#
-	elif not options.no_kappapu:
-		kpSmoothInRange = calibration_parts.compute_kappa_bits(pipeline, smooth_kpuRtee, smooth_kpuItee, options.expected_kappapu_real, options.expected_kappapu_imag, options.kappapu_real_ok_var, options.kappapu_imag_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,10), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# KAPPAU BITS BRANCH
-	#
-	if not options.no_kappau:
-		kuSmoothInRange = calibration_parts.compute_kappa_bits(pipeline, smooth_kuRtee, smooth_kuItee, options.expected_kappau_real, options.expected_kappau_imag, options.kappau_real_ok_var, options.kappau_imag_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,11), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# KAPPAC BITS BRANCH
-	#
-	if not options.no_kappac:
-		kcSmoothInRange = calibration_parts.compute_kappa_bits_only_real(pipeline, smooth_kctee, options.expected_kappac, options.kappac_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,12), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# FCC BITS BRANCH
-	#
-	if not options.no_fcc:
-		fccSmoothInRange = calibration_parts.compute_kappa_bits_only_real(pipeline, smooth_fcctee, fcc_default, options.fcc_ok_var, int(median_smoothing_samples / 2) + factors_average_samples, status_out_smooth = pow(2,13), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# FS BITS BRANCH
-	#
-	if not options.no_fs:
-		fsSmoothInRange = calibration_parts.compute_kappa_bits_only_real(pipeline, smooth_fs, fs_default, options.fs_ok_var, int(median_smoothing_samples / 2) + src_average_samples, status_out_smooth = pow(2,14), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# SRCQ BITS BRANCH
-	#
-	if not options.no_srcQ:
-		srcQSmoothInRange = calibration_parts.compute_kappa_bits_only_real(pipeline, smooth_srcQ_inv, 1.0 / srcQ_default, [options.srcQinv_min, options.srcQinv_max], int(median_smoothing_samples / 2) + src_average_samples, status_out_smooth = pow(2,15), starting_rate = options.compute_factors_sr, ending_rate = kappasstatesr)
-
-	#
-	# COHERENCE BITS BRANCH
-	#
-	if not options.no_coherence:
-		if not options.no_kappatst or not options.no_kappapu or not options.no_kappac or not options.no_fcc or not options.no_srcQ or not options.no_fs:
-			pcaly_line1_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line1_coh, threshold = options.coherence_uncertainty_threshold, bit_vector = pow(2,18), invert_control = True)
-			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % cohsr)
-			pcaly_line1_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line1_coh_ok, "lal_logicalundersample", required_on = pow(2,18), status_out = pow(2,18))
-			pcaly_line1_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line1_coh_ok, calibstate_caps)
-
-			sus_coh_ok = pipeparts.mkbitvectorgen(pipeline, sus_coh, threshold = options.coherence_uncertainty_threshold, bit_vector = pow(2,16), invert_control = True)
-			sus_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % cohsr)
-			sus_coh_ok = pipeparts.mkgeneric(pipeline, sus_coh_ok, "lal_logicalundersample", required_on = pow(2,16), status_out = pow(2,16))
-			sus_coh_ok = pipeparts.mkcapsfilter(pipeline, sus_coh_ok, calibstate_caps)
-
-			darm_coh_ok = pipeparts.mkbitvectorgen(pipeline, darm_coh, threshold = options.coherence_uncertainty_threshold, bit_vector = pow(2,17), invert_control = True)
-			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % cohsr)
-			darm_coh_ok = pipeparts.mkgeneric(pipeline, darm_coh_ok, "lal_logicalundersample", required_on = pow(2,17), status_out = pow(2,17))
-			darm_coh_ok = pipeparts.mkcapsfilter(pipeline, darm_coh_ok, calibstate_caps)
-			coherence_bits = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, pcaly_line1_coh_ok, sus_coh_ok, darm_coh_ok))
-		if not options.no_kappac or not options.no_fcc or not options.no_srcQ or not options.no_fs:
-			pcaly_line2_coh_ok = pipeparts.mkbitvectorgen(pipeline, pcaly_line2_coh, threshold = options.coherence_uncertainty_threshold, bit_vector = pow(2,19), invert_control = True)
-			pcaly_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line2_coh_ok, "audio/x-raw, format=U32LE, rate=%d" % cohsr)
-			pcaly_line2_coh_ok = pipeparts.mkgeneric(pipeline, pcaly_line2_coh_ok, "lal_logicalundersample", required_on = pow(2,19), status_out = pow(2,19))
-			pcaly_line2_coh_ok = pipeparts.mkcapsfilter(pipeline, pcaly_line2_coh_ok, calibstate_caps)
-			coherence_bits = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, coherence_bits, pcaly_line2_coh_ok))
-
-	#
-	# EPICS BITS
-	#
-
-	D_epics_threshold = 0.0
-	A_epics_threshold = 0.0
-	C_epics_threshold = 0.0
-	other_epics_threshold = 0.0
-
-	# First, check the EPICS that involve only the digital filter D, EP7 and EP12
-	if num_dq_epics > 6:
-		D_epics_threshold += 1.5
-		EP7_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP7_real"], 1.0 / EP7_real)
-		EP7_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP7_imag"], 1.0 / EP7_imag)
-
-		# The above values should be close to one (within 1 / 10^4)
-		EP7_real_check = pipeparts.mkgeneric(pipeline, EP7_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		EP7_imag_check = pipeparts.mkgeneric(pipeline, EP7_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		D_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, EP7_real_check, EP7_imag_check))
-
-		if num_dq_epics > 11:
-			D_epics_threshold += 2.0
-			EP12_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP12_real"], 1.0 / EP12_real)
-			EP12_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP12_imag"], 1.0 / EP12_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP12_real_check = pipeparts.mkgeneric(pipeline, EP12_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP12_imag_check = pipeparts.mkgeneric(pipeline, EP12_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			D_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, D_epics_check, EP12_real_check, EP12_imag_check))
-
-		D_epics_bit = pipeparts.mkbitvectorgen(pipeline, D_epics_check, bit_vector = pow(2,21), threshold = D_epics_threshold)
-		D_epics_bit = pipeparts.mkgeneric(pipeline, D_epics_bit, "lal_logicalundersample", required_on = pow(2,21), status_out = pow(2,21))
-		D_epics_bit = pipeparts.mkcapsfilter(pipeline, D_epics_bit, calibstate_caps)
-
-	# Next, check the EPICS that involve only the actuation function A, EP3, EP4, EP8, EP9, EP10, EP13, EP14
-	if num_dq_epics > 2:
-		A_epics_threshold += 1.5
-		EP3_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP3_real"], 1.0 / EP3_real)
-		EP3_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP3_imag"], 1.0 / EP3_imag)
-
-		# The above values should be close to one (within 1 / 10^4)
-		EP3_real_check = pipeparts.mkgeneric(pipeline, EP3_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		EP3_imag_check = pipeparts.mkgeneric(pipeline, EP3_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, EP3_real_check, EP3_imag_check))
-
-		if num_dq_epics > 3:
-			A_epics_threshold += 2.0
-			EP4_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP4_real"], 1.0 / EP4_real)
-			EP4_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP4_imag"], 1.0 / EP4_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP4_real_check = pipeparts.mkgeneric(pipeline, EP4_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP4_imag_check = pipeparts.mkgeneric(pipeline, EP4_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP4_real_check, EP4_imag_check))
-
-		if num_dq_epics > 7:
-			A_epics_threshold += 2.0
-			EP8_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP8_real"], 1.0 / EP8_real)
-			EP8_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP8_imag"], 1.0 / EP8_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP8_real_check = pipeparts.mkgeneric(pipeline, EP8_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP8_imag_check = pipeparts.mkgeneric(pipeline, EP8_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP8_real_check, EP8_imag_check))
-
-		if num_dq_epics > 8:
-			A_epics_threshold += 2.0
-			EP9_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP9_real"], 1.0 / EP9_real)
-			EP9_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP9_imag"], 1.0 / EP9_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP9_real_check = pipeparts.mkgeneric(pipeline, EP9_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP9_imag_check = pipeparts.mkgeneric(pipeline, EP9_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP9_real_check, EP9_imag_check))
-
-		if num_dq_epics > 9:
-			A_epics_threshold += 2.0
-			EP10_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP10_real"], 1.0 / EP10_real)
-			EP10_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP10_imag"], 1.0 / EP10_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP10_real_check = pipeparts.mkgeneric(pipeline, EP10_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP10_imag_check = pipeparts.mkgeneric(pipeline, EP10_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP10_real_check, EP10_imag_check))
-
-		if num_dq_epics > 12:
-			A_epics_threshold += 2.0
-			EP13_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP13_real"], 1.0 / EP13_real)
-			EP13_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP13_imag"], 1.0 / EP13_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP13_real_check = pipeparts.mkgeneric(pipeline, EP13_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP13_imag_check = pipeparts.mkgeneric(pipeline, EP13_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP13_real_check, EP13_imag_check))
-
-		if num_dq_epics > 13:
-			A_epics_threshold += 2.0
-			EP14_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP14_real"], 1.0 / EP14_real)
-			EP14_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP14_imag"], 1.0 / EP14_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP14_real_check = pipeparts.mkgeneric(pipeline, EP14_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP14_imag_check = pipeparts.mkgeneric(pipeline, EP14_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			A_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, A_epics_check, EP14_real_check, EP14_imag_check))
-
-		A_epics_bit = pipeparts.mkbitvectorgen(pipeline, A_epics_check, bit_vector = pow(2,22), threshold = A_epics_threshold)
-		A_epics_bit = pipeparts.mkgeneric(pipeline, A_epics_bit, "lal_logicalundersample", required_on = pow(2,22), status_out = pow(2,22))
-		A_epics_bit = pipeparts.mkcapsfilter(pipeline, A_epics_bit, calibstate_caps)
-
-	# Next, check the EPICS that involve only the sensing function C, EP6 and EP11
-	if num_dq_epics > 5:
-		C_epics_threshold += 1.5
-		EP6_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP6_real"], 1.0 / EP6_real)
-		EP6_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP6_imag"], 1.0 / EP6_imag)
-
-		# The above values should be close to one (within 1 / 10^4)
-		EP6_real_check = pipeparts.mkgeneric(pipeline, EP6_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		EP6_imag_check = pipeparts.mkgeneric(pipeline, EP6_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		C_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, EP6_real_check, EP6_imag_check))
-
-		if num_dq_epics > 10:
-			C_epics_threshold += 2.0
-			EP11_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP11_real"], 1.0 / EP11_real)
-			EP11_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP11_imag"], 1.0 / EP11_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP11_real_check = pipeparts.mkgeneric(pipeline, EP11_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP11_imag_check = pipeparts.mkgeneric(pipeline, EP11_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			C_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, C_epics_check, EP11_real_check, EP11_imag_check))
-
-		C_epics_bit = pipeparts.mkbitvectorgen(pipeline, C_epics_check, bit_vector = pow(2,23), threshold = C_epics_threshold)
-		C_epics_bit = pipeparts.mkgeneric(pipeline, C_epics_bit, "lal_logicalundersample", required_on = pow(2,23), status_out = pow(2,23))
-		C_epics_bit = pipeparts.mkcapsfilter(pipeline, C_epics_bit, calibstate_caps)
-
-	# Next, check the remaining EPICS that are combinations of D, A, and C, EP1 and EP2
-	if num_dq_epics > 0:
-		other_epics_threshold += 1.5
-		EP1_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP1_real"], 1.0 / EP1_real)
-		EP1_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP1_imag"], 1.0 / EP1_imag)
-
-		# The above values should be close to one (within 1 / 10^4)
-		EP1_real_check = pipeparts.mkgeneric(pipeline, EP1_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		EP1_imag_check = pipeparts.mkgeneric(pipeline, EP1_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-		other_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, EP1_real_check, EP1_imag_check))
-
-		if num_dq_epics > 1:
-			other_epics_threshold += 2.0
-			EP2_real_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP2_real"], 1.0 / EP2_real)
-			EP2_imag_check = pipeparts.mkaudioamplify(pipeline, head_dict["EP2_imag"], 1.0 / EP2_imag)
-
-			# The above values should be close to one (within 1 / 10^4)
-			EP2_real_check = pipeparts.mkgeneric(pipeline, EP2_real_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			EP2_imag_check = pipeparts.mkgeneric(pipeline, EP2_imag_check, "lal_insertgap", bad_data_intervals = [0.9999, 1.0001], replace_value = 0.0, insert_gap = False)
-			other_epics_check = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, other_epics_check, EP2_real_check, EP2_imag_check))
-
-		other_epics_bit = pipeparts.mkbitvectorgen(pipeline, other_epics_check, bit_vector = pow(2,24), threshold = other_epics_threshold)
-		other_epics_bit = pipeparts.mkgeneric(pipeline, other_epics_bit, "lal_logicalundersample", required_on = pow(2,24), status_out = pow(2,24))
-		epics_bits = pipeparts.mkcapsfilter(pipeline, other_epics_bit, calibstate_caps)
-
-		# Add the EPICS bits together
-		if num_dq_epics > 6:
-			# There are EPICS for D, A, and C
-			epics_bits = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, epics_bits, A_epics_bit, C_epics_bit, D_epics_bit))
-		elif num_dq_epics > 5:
-			# There are EPICS for A and C
-			epics_bits = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, epics_bits, A_epics_bit, C_epics_bit))
-		elif num_dq_epics > 2:
-			# There are EPICS for A
-			epics_bits = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, epics_bits, A_epics_bit))
-
-	#
-	# COMBINE ALL BITS TO MAKE GDS-KAPPA_STATE_VECTOR
-	#
-
-	# We don't know what is going to be in the state vector, but we know there will be something, so make a list and send that to an adder
-	dq_list = []
-	if not options.no_kappatst:
-		dq_list.append(ktstSmoothInRange)
-	if not options.no_kappap or not options.no_kappapu:
-		dq_list.append(kpSmoothInRange)
-	if not options.no_kappau:
-		dq_list.append(kuSmoothInRange)
-	if not options.no_kappac:
-		dq_list.append(kcSmoothInRange)
-	if not options.no_fcc:
-		dq_list.append(fccSmoothInRange)
-	if not options.no_fs:
-		dq_list.append(fsSmoothInRange)
-	if not options.no_srcQ:
-		dq_list.append(srcQSmoothInRange)
-	if not options.no_coherence:
-		dq_list.append(coherence_bits)
-	if num_dq_epics > 0:
-		dq_list.append(epics_bits)
-
-	kappastatevector = calibration_parts.mkadder(pipeline, tuple(dq_list))
-
-	kappastatevector = pipeparts.mkprogressreport(pipeline, kappastatevector, "progress_calibstatevec_%s" % instrument)
-	dqtagstr = "channel-name=%s:GDS-KAPPA_STATE_VECTOR, instrument=%s" % (instrument, instrument)
-	kappastatevector = pipeparts.mktaginject(pipeline, kappastatevector, dqtagstr)
-
-
-#
-# Produce time-dependent correction factors to be recorded in the frames
-#
-
-record_kappa_caps = "audio/x-raw, format=F32LE, rate=%d" % options.record_factors_sr
-
-# Resample the \kappa_pu channels at the specified recording sample rate and change them to single precision channels
-if not options.no_kappapu:
-
-	kpuRout = pipeparts.mkaudioconvert(pipeline, smooth_kpuRtee)
-	kpuRout = calibration_parts.mkresample(pipeline, kpuRout, 1, False, record_kappa_caps)
-	kpuRout = pipeparts.mkprogressreport(pipeline, kpuRout, "progress_kappa_pu_real_%s" % instrument)
-
-	kpuIout = pipeparts.mkaudioconvert(pipeline, smooth_kpuItee)
-	kpuIout = calibration_parts.mkresample(pipeline, kpuIout, 1, False, record_kappa_caps)
-	kpuIout = pipeparts.mkprogressreport(pipeline, kpuIout, "progress_kappa_pu_imag_%s" % instrument)
-
-	smooth_kpuR_nogate = pipeparts.mkaudioconvert(pipeline, smooth_kpuR_nogate)
-	smooth_kpuR_nogate = calibration_parts.mkresample(pipeline, smooth_kpuR_nogate, 1, False, record_kappa_caps)
-	smooth_kpuR_nogate = pipeparts.mkprogressreport(pipeline, smooth_kpuR_nogate, "progress_kappa_pu_real_nogate_%s" % instrument)
-
-	smooth_kpuI_nogate = pipeparts.mkaudioconvert(pipeline, smooth_kpuI_nogate)
-	smooth_kpuI_nogate = calibration_parts.mkresample(pipeline, smooth_kpuI_nogate, 1, False, record_kappa_caps)
-	smooth_kpuI_nogate = pipeparts.mkprogressreport(pipeline, smooth_kpuI_nogate, "progress_kappa_pu_imag_nogate_%s" % instrument)
-
-# Resample the \kappa_tst channels at the specified recording sample rate and change them to single precision channels
-if not options.no_kappatst:
-
-	ktstRout = pipeparts.mkaudioconvert(pipeline, smooth_ktstRtee)
-	ktstRout = calibration_parts.mkresample(pipeline, ktstRout, 1, False, record_kappa_caps)
-	ktstRout = pipeparts.mkprogressreport(pipeline, ktstRout, "progress_kappa_tst_real_%s" % instrument)
-
-	ktstIout = pipeparts.mkaudioconvert(pipeline, smooth_ktstItee)
-	ktstIout = calibration_parts.mkresample(pipeline, ktstIout, 1, False, record_kappa_caps)
-	ktstIout = pipeparts.mkprogressreport(pipeline, ktstIout, "progress_kappa_tst_imag_%s" % instrument)
-
-	smooth_ktstR_nogate = pipeparts.mkaudioconvert(pipeline, smooth_ktstR_nogate)
-	smooth_ktstR_nogate = calibration_parts.mkresample(pipeline, smooth_ktstR_nogate, 1, False, record_kappa_caps)
-	smooth_ktstR_nogate = pipeparts.mkprogressreport(pipeline, smooth_ktstR_nogate, "progress_kappa_tst_real_nogate_%s" % instrument)
-
-	smooth_ktstI_nogate = pipeparts.mkaudioconvert(pipeline, smooth_ktstI_nogate)
-	smooth_ktstI_nogate = calibration_parts.mkresample(pipeline, smooth_ktstI_nogate, 1, False, record_kappa_caps)
-	smooth_ktstI_nogate = pipeparts.mkprogressreport(pipeline, smooth_ktstI_nogate, "progress_kappa_tst_imag_nogate_%s" % instrument)
-
-# Resample the \kappa_c channels at the specified recording sample rate and change it to a single precision channel
-if not options.no_kappac:
-	kcout = pipeparts.mkaudioconvert(pipeline, smooth_kctee)
-	kcout = calibration_parts.mkresample(pipeline, kcout, 1, False, record_kappa_caps)
-	kcout = pipeparts.mkprogressreport(pipeline, kcout, "progress_kappa_c_%s" % instrument)
-
-	smooth_kc_nogate = pipeparts.mkaudioconvert(pipeline, smooth_kc_nogate)
-	smooth_kc_nogate = calibration_parts.mkresample(pipeline, smooth_kc_nogate, 1, False, record_kappa_caps)
-	smooth_kc_nogate = pipeparts.mkprogressreport(pipeline, smooth_kc_nogate, "progress_kappa_c_nogate_%s" % instrument)
-
-# Resample the f_cc channels at the specified recording sample rate and change it to a single precision channel
-if not options.no_fcc:
-	fccout = pipeparts.mkaudioconvert(pipeline, smooth_fcctee)
-	fccout = calibration_parts.mkresample(pipeline, fccout, 1, False, record_kappa_caps)
-	fccout = pipeparts.mkprogressreport(pipeline, fccout, "progress_f_cc_%s" % instrument)
-
-	smooth_fcc_nogate = pipeparts.mkaudioconvert(pipeline, smooth_fcc_nogate)
-	smooth_fcc_nogate = calibration_parts.mkresample(pipeline, smooth_fcc_nogate, 1, False, record_kappa_caps)
-	smooth_fcc_nogate = pipeparts.mkprogressreport(pipeline, smooth_fcc_nogate, "progress_f_cc_nogate_%s" % instrument)
-
-# Resample the f_s channels at the specified recording sample rate and change it to a single precision channel
-if not options.no_fs:
-	fsout = pipeparts.mkaudioconvert(pipeline, smooth_fs)
-	fsout = calibration_parts.mkresample(pipeline, fsout, 1, False, record_kappa_caps)
-	fsout = pipeparts.mkprogressreport(pipeline, fsout, "progress_f_s_%s" % instrument)
-
-	smooth_fs_nogate = pipeparts.mkaudioconvert(pipeline, smooth_fs_nogate)
-	smooth_fs_nogate = calibration_parts.mkresample(pipeline, smooth_fs_nogate, 1, False, record_kappa_caps)
-	smooth_fs_nogate = pipeparts.mkprogressreport(pipeline, smooth_fs_nogate, "progress_f_s_nogate_%s" % instrument)
-
-# Resample the f_s channels at the specified recording sample rate and change it to a single precision channel
-if not options.no_srcQ:
-	srcQ_inv_out = pipeparts.mkaudioconvert(pipeline, smooth_srcQ_inv)
-	srcQ_inv_out = calibration_parts.mkresample(pipeline, srcQ_inv_out, 1, False, record_kappa_caps)
-	srcQ_inv_out = pipeparts.mkprogressreport(pipeline, srcQ_inv_out, "progress_SRC_Q_%s" % instrument)
-
-	smooth_srcQ_inv_nogate = pipeparts.mkaudioconvert(pipeline, smooth_srcQ_inv_nogate)
-	smooth_srcQ_inv_nogate = calibration_parts.mkresample(pipeline, smooth_srcQ_inv_nogate, 1, False, record_kappa_caps)
-	smooth_srcQ_inv_nogate = pipeparts.mkprogressreport(pipeline, smooth_srcQ_inv_nogate, "progress_SRC_Q_nogate_%s" % instrument)
-
-#
-# CREATE MUXER AND HOOK EVERYTHING UP TO IT
-#
-
-mux = pipeparts.mkframecppchannelmux(pipeline, None)
-
-if options.frame_duration is not None:
-	mux.set_property("frame-duration", options.frame_duration)
-if options.frames_per_file is not None:
-	mux.set_property("frames-per-file", options.frames_per_file)
-mux.set_property("compression-scheme", options.compression_scheme)
-mux.set_property("compression-level", options.compression_level)
-
-# Link the output DQ vectors up to the muxer, if applicable
-if not options.no_dq_vector:
-	calibration_parts.mkqueue(pipeline, kappastatevector).get_static_pad("src").link(mux.get_request_pad("%s:%sKAPPA_STATE_VECTOR%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the real and imaginary parts of \kappa_tst to the muxer
-if not options.no_kappatst:
-	calibration_parts.mkqueue(pipeline, ktstRout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_TST_REAL%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, ktstIout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_TST_IMAGINARY%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_ktstR_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_TST_REAL_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_ktstI_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_TST_IMAGINARY_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the real and imaginary parts of \kappa_pu to the muxer
-if not options.no_kappapu:
-	calibration_parts.mkqueue(pipeline, kpuRout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_PU_REAL%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, kpuIout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_PU_IMAGINARY%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_kpuR_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_PU_REAL_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_kpuI_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_PU_IMAGINARY_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the \kappa_c to the muxer
-if not options.no_kappac:
-	calibration_parts.mkqueue(pipeline, kcout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_C%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_kc_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_KAPPA_C_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the f_cc to the muxer
-if not options.no_fcc:
-	calibration_parts.mkqueue(pipeline, fccout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_F_CC%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_fcc_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_F_CC_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the f_s to the muxer
-if not options.no_fs:
-	calibration_parts.mkqueue(pipeline, fsout).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_F_S%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_fs_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_F_S_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Link the src_Q to the muxer
-if not options.no_srcQ:
-	calibration_parts.mkqueue(pipeline, srcQ_inv_out).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_SRC_Q_INVERSE%s" % (instrument, chan_prefix, chan_suffix)))
-	calibration_parts.mkqueue(pipeline, smooth_srcQ_inv_nogate).get_static_pad("src").link(mux.get_request_pad("%s:%sCALIB_SRC_Q_INVERSE_NOGATE%s" % (instrument, chan_prefix, chan_suffix)))
-
-# Check that all frames are long enough, that they have all of the channels by requring a certain amount of time from start-up, and that frames aren't written for times requested by the wings option
-def check_complete_frames(pad, info, (output_start, frame_duration, wings_start, wings_end)):
-	buf = info.get_buffer()
-	startts = lal.LIGOTimeGPS(0, buf.pts)
-	duration = lal.LIGOTimeGPS(0, buf.duration)
-	if not (startts % frame_duration == 0):
-		return Gst.PadProbeReturn.DROP
-	if startts < output_start:
-		return Gst.PadProbeReturn.DROP
-	if duration != frame_duration:
-		return Gst.PadProbeReturn.DROP
-	if wings_start is not None and wings_end is not None:
-		if startts < wings_start or (startts+duration) > wings_end:
-			return Gst.PadProbeReturn.DROP
-	return Gst.PadProbeReturn.OK
-if options.data_source == "frames":
-	start = int(options.gps_start_time)
-elif options.data_source == "lvshm":
-	tm = time.gmtime()
-	start = int(lal.UTCToGPS(tm))
-# start time of first frame file is the desired start time + kappa settling
-output_start = start + options.demodulation_filter_time + options.median_smoothing_time + options.factors_averaging_time
-
-# If the wings option is set, need to also check that frames aren't written during the requested wing time
-if options.wings is not None:
-	wings_start = int(options.gps_start_time) + options.wings
-	wings_end = int(options.gps_end_time) - options.wings
-	mux.get_static_pad("src").add_probe(Gst.PadProbeType.BUFFER, check_complete_frames, (lal.LIGOTimeGPS(output_start,0), lal.LIGOTimeGPS(options.frame_duration*options.frames_per_file,0), lal.LIGOTimeGPS(wings_start, 0), lal.LIGOTimeGPS(wings_end, 0)))
-else:
-	mux.get_static_pad("src").add_probe(Gst.PadProbeType.BUFFER, check_complete_frames, (lal.LIGOTimeGPS(output_start,0), lal.LIGOTimeGPS(options.frame_duration*options.frames_per_file,0), None, None))
-
-mux = pipeparts.mkprogressreport(pipeline, mux, "progress_sink_%s" % instrument)
-
-if options.write_to_shm_partition is not None:
-	pipeparts.mkgeneric(pipeline, mux, "gds_lvshmsink", sync=False, async=False, shm_name = options.write_to_shm_partition, num_buffers=10, blocksize=options.frame_size*options.frame_duration*options.frames_per_file, buffer_mode=options.buffer_mode)
-else:
-	pipeparts.mkframecppfilesink(pipeline, mux, frame_type = options.frame_type, path = options.output_path, instrument = instrument) 
-
-# Run pipeline
-
-if options.write_pipeline is not None:
-	pipeparts.write_dump_dot(pipeline, "%s.%s" %(options.write_pipeline, "NULL"), verbose = options.verbose)
-
-# Seek the pipeline when necessary
-if options.data_source == "frames":
-	if options.verbose:
-		print >>sys.stderr, "seeking GPS start and stop times ..."
-	if pipeline.set_state(Gst.State.READY) != Gst.StateChangeReturn.SUCCESS:
-		raise RuntimeError("pipeline failed to enter READY state")
-	datasource.pipeline_seek_for_gps(pipeline, gps_start_time, gps_end_time)
-
-if options.verbose:
-	print >>sys.stderr, "setting pipeline state to playing ..."
-if pipeline.set_state(Gst.State.PLAYING) != Gst.StateChangeReturn.SUCCESS:
-	raise RuntimeError("pipeline failed to enter PLAYING state")
-else:
-	print "set to playing successfully"
-if options.write_pipeline is not None:
-	pipeparts.write_dump_dot(pipeline, "%s.%s" %(options.write_pipeline, "PLAYING"), verbose = options.verbose)
-	
-if options.verbose:
-	print >>sys.stderr, "running pipeline ..."
-
-mainloop.run()
-
-if pipeline.set_state(Gst.State.NULL) != Gst.StateChangeReturn.SUCCESS:
-	raise RuntimeError("pipeline could not be set to NULL")
diff --git a/gstlal-calibration/bin/gstlal_compute_strain b/gstlal-calibration/bin/gstlal_compute_strain
index 404ab22a61cc65cef244147fb11b6f590254f8ff..d446ecc69e7c39ed12189b1b7a3f1f10a02392ce 100755
--- a/gstlal-calibration/bin/gstlal_compute_strain
+++ b/gstlal-calibration/bin/gstlal_compute_strain
@@ -71,12 +71,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 
 #
diff --git a/gstlal-calibration/configure.ac b/gstlal-calibration/configure.ac
index 68399bcee3959f5904d65eeeedeec94abe3be3fa..dc1d6b11b45838eab506ea4c9af952b8a8d296b4 100644
--- a/gstlal-calibration/configure.ac
+++ b/gstlal-calibration/configure.ac
@@ -231,6 +231,8 @@ AC_SUBST([LAL_LIBS])
 
 AC_SUBST([MIN_GLUE_VERSION], [1.50])
 AX_PYTHON_GLUE()
+AC_SUBST([MIN_LIGO_SEGMENTS_VERSION], [1.1.0])
+AX_PYTHON_LIGO_SEGMENTS([$MIN_LIGO_SEGMENTS_VERSION])
 
 
 #
diff --git a/gstlal-calibration/debian/control.in b/gstlal-calibration/debian/control.in
index 57513b372c52be267a40c2a74748cf66671299ed..050335616c2e78b612ac71403fa17ecc6d485379 100644
--- a/gstlal-calibration/debian/control.in
+++ b/gstlal-calibration/debian/control.in
@@ -37,7 +37,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends},
  python (>= @MIN_PYTHON_VERSION@),
  python-gi,
  python-glue (>= @MIN_GLUE_VERSION@),
- python-glue-segments (>= @MIN_GLUE_VERSION@),
+ python-ligo-segments (>= @MIN_LIGO_SEGMENTS_VERSION@),
  python-gst-1.0,
  python-numpy,
  python-scipy
diff --git a/gstlal-calibration/gstlal-calibration.spec.in b/gstlal-calibration/gstlal-calibration.spec.in
index 3823304ea47ea88923d51b19fdbfc9febf28d5e0..7f7720059134b39b43ceefc1382220365a466803 100644
--- a/gstlal-calibration/gstlal-calibration.spec.in
+++ b/gstlal-calibration/gstlal-calibration.spec.in
@@ -11,7 +11,7 @@ Requires: gstlal >= @MIN_GSTLAL_VERSION@
 Requires: gstlal-ugly >= @MIN_GSTLALUGLY_VERSION@
 Requires: python >= @MIN_PYTHON_VERSION@
 Requires: glue >= @MIN_GLUE_VERSION@
-Requires: glue-segments >= @MIN_GLUE_VERSION@
+Requires: python2-ligo-segments >= @MIN_LIGO_SEGMENTS_VERSION@
 Requires: %{gstreamername} >= @MIN_GSTREAMER_VERSION@
 Requires: %{gstreamername}-plugins-base >= @MIN_GSTREAMER_VERSION@
 Requires: %{gstreamername}-plugins-good >= @MIN_GSTREAMER_VERSION@
diff --git a/gstlal-calibration/tests/check_calibration/demod_ratio_timeseries.py b/gstlal-calibration/tests/check_calibration/demod_ratio_timeseries.py
index 91a1bbb96806395cb44203b88ad382df4ad9f2d3..d768cdb3b33dff0a46042308919120f9edf9275f 100644
--- a/gstlal-calibration/tests/check_calibration/demod_ratio_timeseries.py
+++ b/gstlal-calibration/tests/check_calibration/demod_ratio_timeseries.py
@@ -55,13 +55,6 @@ from gstlal import test_common
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 
 parser = OptionParser()
diff --git a/gstlal-calibration/tests/check_calibration/frame_manipulator.py b/gstlal-calibration/tests/check_calibration/frame_manipulator.py
index caadc80b77a143c3c451dde43f6bb1182b17fd35..c8259e42b184be7e74199d2fc4fba70a0a49364b 100644
--- a/gstlal-calibration/tests/check_calibration/frame_manipulator.py
+++ b/gstlal-calibration/tests/check_calibration/frame_manipulator.py
@@ -46,13 +46,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/check_calibration/pcal2darm_timeseries.py b/gstlal-calibration/tests/check_calibration/pcal2darm_timeseries.py
index 7404c48204d82205c3349997ebd3ceb3ec244a27..84d8dad67140e24629e341de182273d89f20d85a 100644
--- a/gstlal-calibration/tests/check_calibration/pcal2darm_timeseries.py
+++ b/gstlal-calibration/tests/check_calibration/pcal2darm_timeseries.py
@@ -58,13 +58,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/check_calibration/plot_transfer_function.py b/gstlal-calibration/tests/check_calibration/plot_transfer_function.py
index 30a9c68342b25249898e35f60e5a559a3d46619e..aae66e9b37e90b244eba696c2e415fa0386f771e 100644
--- a/gstlal-calibration/tests/check_calibration/plot_transfer_function.py
+++ b/gstlal-calibration/tests/check_calibration/plot_transfer_function.py
@@ -58,13 +58,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/fill_silence_test.py b/gstlal-calibration/tests/fill_silence_test.py
index a5857f80a834c666e7b1900bdfb344d722799898..8508c0912eceddebeba6250e562262257d262182 100755
--- a/gstlal-calibration/tests/fill_silence_test.py
+++ b/gstlal-calibration/tests/fill_silence_test.py
@@ -59,13 +59,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/line_separation_nonoise_test.py b/gstlal-calibration/tests/line_separation_nonoise_test.py
index 758062f6644f3cc1ad7e5ba27657e8a6b241d2dd..8950edc517c565a38728264bdf39826ac6ba5b68 100755
--- a/gstlal-calibration/tests/line_separation_nonoise_test.py
+++ b/gstlal-calibration/tests/line_separation_nonoise_test.py
@@ -59,13 +59,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/line_separation_test.py b/gstlal-calibration/tests/line_separation_test.py
index 6bf05eef8bb68328488f3cb8633fd84cd2c2cfac..000e694b48da6ce24d173f5aad5d530524f7b7f7 100755
--- a/gstlal-calibration/tests/line_separation_test.py
+++ b/gstlal-calibration/tests/line_separation_test.py
@@ -59,13 +59,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 from gstlal import test_common
 
diff --git a/gstlal-calibration/tests/queue_test.py b/gstlal-calibration/tests/queue_test.py
index 4b5c6e00a58313c807e720ba05f9a5264ef20554..64aa26891330940c9d69949bb02f8ec01cd90461 100755
--- a/gstlal-calibration/tests/queue_test.py
+++ b/gstlal-calibration/tests/queue_test.py
@@ -45,13 +45,6 @@ from gstlal import calibration_parts
 from gstlal import simplehandler
 from gstlal import datasource
 
-from glue.ligolw import ligolw
-from glue.ligolw import array
-from glue.ligolw import param
-from glue.ligolw.utils import segments as ligolw_segments
-array.use_in(ligolw.LIGOLWContentHandler)
-param.use_in(ligolw.LIGOLWContentHandler)
-from glue.ligolw import utils
 from ligo import segments
 import test_common