def removeDC_01(pipeline, name): # # This test removes the DC component from a stream of ones (i.e., the result should be zero) # rate = 2048 # Hz buffer_length = 1.0 # seconds test_duration = 50.0 # seconds DC = 1.0 wave = 0 volume = 0.0 # # build pipeline # src = test_common.test_src(pipeline, buffer_length=buffer_length, rate=16384, test_duration=test_duration, wave=wave, width=64) head = pipeparts.mkaudioamplify(pipeline, src, volume) head = pipeparts.mkgeneric(pipeline, head, "lal_add_constant", value=DC) head = calibration_parts.mkresample( pipeline, head, 5, True, "audio/x-raw,format=F64LE,rate=%d" % rate) head = calibration_parts.removeDC( pipeline, head, "audio/x-raw,format=F64LE,rate=%d" % rate) pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) # # done # return pipeline
def line_separation_test_01(pipeline, name, line_sep=0.5): # # This test measures and plots the amount of contamination a calibration line adds to the result of demodulating at a nearby frequency as a function of frequency separation. # rate = 1000 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # noise = test_common.test_src(pipeline, rate=16384, test_duration=1000, wave=5, src_suffix='0') noise = pipeparts.mkaudioamplify(pipeline, noise, 2.5) noise = pipeparts.mktee(pipeline, noise) signal = test_common.test_src(pipeline, rate=16384, test_duration=1000, wave=0, freq=16.3 + line_sep, src_suffix='1') noisy_signal = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs(pipeline, signal, noise)) demod_noise = calibration_parts.demodulate(pipeline, noise, 16.3, True, 16, 20, 0) demod_noise = pipeparts.mkgeneric(pipeline, demod_noise, "cabs") rms_noise = calibration_parts.compute_rms(pipeline, demod_noise, 16, 900, filter_latency=0, rate_out=1) pipeparts.mknxydumpsink(pipeline, rms_noise, "rms_noise.txt") demod_signal = calibration_parts.demodulate(pipeline, noisy_signal, 16.3, True, 16, 20, 0) demod_signal = pipeparts.mkgeneric(pipeline, demod_signal, "cabs") rms_signal = calibration_parts.compute_rms(pipeline, demod_signal, 16, 900, filter_latency=0, rate_out=1) pipeparts.mknxydumpsink(pipeline, rms_signal, "rms_signal.txt") # # done # return pipeline
def lal_tdwhiten_01(pipeline, name): # # This test passes ones through lal_tdwhiten # src = test_common.test_src(pipeline, buffer_length = buffer_length, wave = 0, freq = 0, rate = rate, test_duration = test_duration, width = 64) head = pipeparts.mkaudioamplify(pipeline, src, 0.0) head = pipeparts.mkgeneric(pipeline, head, "lal_add_constant", value = 1.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name) head = pipeparts.mkgeneric(pipeline, head, "lal_tdwhiten", kernel = fir_filt[::-1], latency = latency) pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) # # done # return pipeline
def lal_complexfirbank_01(pipeline, name): # # This test passes ones through lal_complexfirbank # src = test_common.test_src(pipeline, buffer_length = buffer_length, wave = 0, freq = 0, rate = rate, test_duration = test_duration, width = 64) head = pipeparts.mkaudioamplify(pipeline, src, 0.0) head = pipeparts.mkgeneric(pipeline, head, "lal_add_constant", value = 1.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name) head = calibration_parts.mkcomplexfirbank(pipeline, head, latency = latency, fir_matrix = [fir_filt], time_domain = True) pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) # # done # return pipeline
def lal_demodulate_03(pipeline, name): # # This test checks sensitivity of the demodulation process used in the calibration pipeline to small changes in line frequency # rate_in = 16384 # Hz rate_out = 16 # Hz buffer_length = 1.0 # seconds test_duration = 1000 # seconds # # build pipeline # # Make fake data with a signal src = test_common.test_src(pipeline, buffer_length=buffer_length, rate=rate_in, test_duration=test_duration, wave=0, volume=1.0, freq=37.00, width=64) # Demodulate it head = calibration_parts.demodulate(pipeline, src, 37.10, True, rate_out, 20, 0.0) # Smoothing # head = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 128 * rate_out, avg_array_size = 10 * rate_out) # Measure the amplitude of the result head = pipeparts.mkgeneric(pipeline, head, "cabs") head = pipeparts.mkaudioamplify(pipeline, head, 2.0) pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) # # done # return pipeline
def pyfilter_test_01(pipeline, name): # # This test removes the DC component from a stream of ones (i.e., the result should be zero) # rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds DC = 1.0 wave = 0 freq = 90 volume = 1.0 # # build pipeline # src = test_common.test_src(pipeline, buffer_length=buffer_length, rate=rate, freq=freq, test_duration=test_duration, wave=wave, width=64) head = pipeparts.mkaudioamplify(pipeline, src, volume) head = pipeparts.mkgeneric(pipeline, head, "lal_add_constant", value=DC) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name) head = calibration_parts.bandstop(pipeline, head, rate) pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) # # done # return pipeline
def pcal2darm(pipeline, name): # Get pcal from the raw frames raw_data = pipeparts.mklalcachesrc(pipeline, location=options.raw_frame_cache, cache_dsc_regex=ifo) raw_data = pipeparts.mkframecppchanneldemux( pipeline, raw_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) pcal = calibration_parts.hook_up(pipeline, raw_data, options.pcal_channel_name, ifo, 1.0) pcal = calibration_parts.caps_and_progress( pipeline, pcal, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", "pcal") pcal = pipeparts.mktee(pipeline, pcal) # Demodulate the pcal channel at the lines of interest for i in range(0, len(frequencies)): demodulated_pcal = calibration_parts.demodulate( pipeline, pcal, frequencies[i], True, rate_out, filter_time, 0.5, prefactor_real=pcal_corrections[2 * i], prefactor_imag=pcal_corrections[2 * i + 1]) demodulated_pcal_list.append( pipeparts.mktee(pipeline, demodulated_pcal)) # Check if we are taking pcal-to-darm ratios for CALCS data for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]): calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel, ifo, 1.0) calcs_deltal = calibration_parts.caps_and_progress( pipeline, calcs_deltal, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal) for i in range(0, len(frequencies)): # Demodulate DELTAL_EXTERNAL at each line demodulated_calcs_deltal = calibration_parts.demodulate( pipeline, calcs_deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Take ratio \DeltaL(f) / pcal(f) deltaL_over_pcal = calibration_parts.complex_division( pipeline, demodulated_calcs_deltaL, demodulated_pcal_list[i]) # Take a running average deltaL_over_pcal = pipeparts.mkgeneric( pipeline, deltaL_over_pcal, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time)) # Write to file pipeparts.mknxydumpsink( pipeline, deltaL_over_pcal, "%s_%s_over_%s_at_line%d.txt" % (ifo, label.replace( ' ', '_'), options.pcal_channel_name, i + 1)) # Check if we are taking pcal-to-darm ratios for gstlal calibrated data if options.gstlal_channel_list is not None: cache_num = 0 for cache, channel, label in zip( gstlal_frame_cache_list, gstlal_channels, labels[len(calcs_channels):len(calcs_channels) + len(gstlal_channels)]): # Get gstlal channels from the gstlal frames hoft_data = pipeparts.mklalcachesrc(pipeline, location=cache, cache_dsc_regex=ifo) hoft_data = pipeparts.mkframecppchanneldemux( pipeline, hoft_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) hoft = calibration_parts.hook_up(pipeline, hoft_data, channel, ifo, 1.0, element_name_suffix="_%d" % cache_num) cache_num = cache_num + 1 hoft = calibration_parts.caps_and_progress( pipeline, hoft, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length) deltal = pipeparts.mktee(pipeline, deltal) for i in range(0, len(frequencies)): # Demodulate \DeltaL at each line demodulated_deltal = calibration_parts.demodulate( pipeline, deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Take ratio \DeltaL(f) / pcal(f) deltaL_over_pcal = calibration_parts.complex_division( pipeline, demodulated_deltal, demodulated_pcal_list[i]) # Take a running average deltaL_over_pcal = pipeparts.mkgeneric( pipeline, deltaL_over_pcal, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time)) # Find the magnitude deltaL_over_pcal = pipeparts.mktee(pipeline, deltaL_over_pcal) magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "cabs") # Find the phase phase = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "carg") phase = pipeparts.mkaudioamplify(pipeline, phase, 180.0 / numpy.pi) # Interleave magnitude_and_phase = calibration_parts.mkinterleave( pipeline, [magnitude, phase]) # Write to file pipeparts.mknxydumpsink( pipeline, magnitude_and_phase, "%s_%s_over_%s_at_%0.1fHz_%d.txt" % (ifo, label.replace(' ', '_'), options.pcal_channel_name, frequencies[i], options.gps_start_time)) # Check of we are reading in kappa channels if options.kappa_channel_list is not None: # Get gstlal channels from the gstlal frames kappa_data = pipeparts.mklalcachesrc( pipeline, location=gstlal_frame_cache_list[0], cache_dsc_regex=ifo) kappa_data = pipeparts.mkframecppchanneldemux( pipeline, kappa_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) for i in range(len(kappa_channels) // 2): kappa_real = calibration_parts.hook_up( pipeline, kappa_data, kappa_channels[2 * i], ifo, 1.0, element_name_suffix="_%d" % (2 * i)) kappa_imag = calibration_parts.hook_up( pipeline, kappa_data, kappa_channels[2 * i + 1], ifo, 1.0, element_name_suffix="_%d" % (2 * i + 1)) kappa_real = calibration_parts.caps_and_progress( pipeline, kappa_real, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", kappa_channels[2 * i]) kappa_imag = calibration_parts.caps_and_progress( pipeline, kappa_imag, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", kappa_channels[2 * i + 1]) kappa = calibration_parts.merge_into_complex( pipeline, kappa_real, kappa_imag) phase_angle = pipeparts.mkgeneric(pipeline, kappa, "carg") actuation_stage = 'UNKNOWN' act_freq = 17.0 # A guess... if 'TST' in kappa_channels[2 * i]: actuation_stage = 'T' act_freq = float(filters["ktst_esd_line_freq"]) elif 'PUM' in kappa_channels[2 * i]: actuation_stage = 'P' act_freq = float(filters["pum_act_line_freq"]) elif 'UIM' in kappa_channels[2 * i]: actuation_stage = 'U' act_freq = float(filters["uim_act_line_freq"]) elif 'PU' in kappa_channels[2 * i]: actuation_stage = 'PU' act_freq = float(filters["ka_esd_line_freq"]) actuation_stages.append(actuation_stage) tau = pipeparts.mkaudioamplify( pipeline, phase_angle, 1000000.0 / 2.0 / numpy.pi / act_freq) pipeparts.mknxydumpsink( pipeline, tau, "%s_%s_%d.txt" % (ifo, actuation_stage, options.gps_start_time)) # # done # return pipeline
def lal_transferfunction_01(pipeline, name): # # This test adds various noise into a stream and uses lal_transferfunction to remove it # rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 3000.0 # seconds width = 64 # bits # # build pipeline # hoft = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, volume=0.001, rate=rate, test_duration=test_duration, width=width, verbose=False) hoft = pipeparts.mktee(pipeline, hoft) common_noise = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, freq=512, volume=1, rate=rate, test_duration=test_duration, width=width, verbose=False) common_noise = pipeparts.mktee(pipeline, common_noise) noise1 = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, freq=512, volume=1, rate=rate, test_duration=test_duration, width=width, verbose=False) noise1 = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs(pipeline, common_noise, noise1)) noise1 = pipeparts.mktee(pipeline, noise1) noise1_for_cleaning = pipeparts.mkgeneric(pipeline, noise1, "identity") hoft_noise1 = pipeparts.mkshift(pipeline, noise1, shift=00000000) hoft_noise1 = pipeparts.mkaudioamplify(pipeline, hoft_noise1, 2) hoft_noise1 = pipeparts.mktee(pipeline, hoft_noise1) noise2 = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, freq=1024, volume=1, rate=rate, test_duration=test_duration, width=width, verbose=False) noise2 = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs(pipeline, common_noise, noise2)) noise2 = pipeparts.mktee(pipeline, noise2) noise2_for_cleaning = pipeparts.mkgeneric(pipeline, noise2, "identity") hoft_noise2 = pipeparts.mkshift(pipeline, noise2, shift=00000) hoft_noise2 = pipeparts.mkaudioamplify(pipeline, hoft_noise2, 3) hoft_noise2 = pipeparts.mktee(pipeline, hoft_noise2) noisy_hoft = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs(pipeline, hoft, hoft_noise1, hoft_noise2)) noisy_hoft = pipeparts.mktee(pipeline, noisy_hoft) clean_hoft = calibration_parts.clean_data( pipeline, calibration_parts.list_srcs(pipeline, noisy_hoft, noise1_for_cleaning, noise2_for_cleaning), rate / 4, rate / 8, 16384, test_duration * rate) clean_hoft = pipeparts.mktee(pipeline, clean_hoft) # hoft_inv = pipeparts.mkpow(pipeline, hoft, exponent = -1.0) # clean_hoft_over_hoft = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, hoft_inv, clean_hoft)) # pipeparts.mknxydumpsink(pipeline, clean_hoft_over_hoft, "%s_clean_hoft_over_hoft.txt" % name) pipeparts.mknxydumpsink(pipeline, hoft, "%s_hoft.txt" % name) pipeparts.mknxydumpsink(pipeline, hoft_noise1, "%s_hoft_noise1.txt" % name) pipeparts.mknxydumpsink(pipeline, hoft_noise2, "%s_hoft_noise2.txt" % name) pipeparts.mknxydumpsink(pipeline, noisy_hoft, "%s_noisy_hoft.txt" % name) pipeparts.mknxydumpsink(pipeline, clean_hoft, "%s_clean_hoft.txt" % name) # # done # return pipeline
def lal_transferfunction_03(pipeline, name): # # This test produces three-channel data to be read into lal_transferfunction # rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 50.0 # seconds width = 64 # bits freq = 512 # Hz num_witnesses = 2 witness_factor = 0.5 # Ratio of amplitudes of witness / signal # # build pipeline # hoft = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, volume=1, freq=freq, channels=1, rate=rate, test_duration=test_duration, width=width, verbose=False) hoft = pipeparts.mktee(pipeline, hoft) noise = [] for i in range(0, num_witnesses): difference = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, volume=0.001, channels=1, rate=rate, test_duration=test_duration, width=width, verbose=False) noisy_hoft = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs( pipeline, pipeparts.mkaudioamplify(pipeline, hoft, witness_factor), difference)) noisy_hoft = pipeparts.mkprogressreport(pipeline, noisy_hoft, "noisy_hoft_%d" % i) noise.append(noisy_hoft) clean_data = calibration_parts.clean_data(pipeline, hoft, rate, noise, rate, 2 * rate, rate, 10, rate * 1000, rate, 4, filename="tfs.txt") pipeparts.mknxydumpsink(pipeline, hoft, "%s_hoft.txt" % name) pipeparts.mknxydumpsink(pipeline, clean_data, "%s_out.txt" % name) return pipeline
def plot_transfer_function(pipeline, name): # Get the data from the denominator frames denominator = pipeparts.mklalcachesrc( pipeline, location=options.denominator_frame_cache, cache_dsc_regex=ifo) denominator = pipeparts.mkframecppchanneldemux( pipeline, denominator, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) denominator = calibration_parts.hook_up(pipeline, denominator, options.denominator_channel_name, ifo, 1.0) denominator = calibration_parts.caps_and_progress( pipeline, denominator, "audio/x-raw,format=F64LE", "denominator") denominator = calibration_parts.mkresample(pipeline, denominator, 5, False, int(sample_rate)) if denominator_correction is not None: if numpy.size(filters[denominator_correction]) == 1: denominator = pipeparts.mkaudioamplify( pipeline, denominator, float(filters[denominator_correction])) denominator = pipeparts.mktee(pipeline, denominator) # Get the data from the numerator frames for i in range(0, len(labels)): numerator = pipeparts.mklalcachesrc( pipeline, location=numerator_frame_cache_list[i], cache_dsc_regex=ifo) numerator = pipeparts.mkframecppchanneldemux( pipeline, numerator, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) numerator = calibration_parts.hook_up(pipeline, numerator, numerator_channel_list[i], ifo, 1.0, element_name_suffix="%d" % i) numerator = calibration_parts.caps_and_progress( pipeline, numerator, "audio/x-raw,format=F64LE", labels[i]) numerator = calibration_parts.mkresample(pipeline, numerator, 5, False, int(sample_rate)) if numerator_correction is not None: if numerator_correction[i] is not None: if numpy.size(filters[numerator_correction[i]] == 1): numerator = pipeparts.mkaudioamplify( pipeline, numerator, float(filters[numerator_correction[i]])) # Interleave the channels to make one stream channels = calibration_parts.mkinterleave(pipeline, [numerator, denominator]) # Send the data to lal_transferfunction to compute and write transfer functions pipeparts.mkgeneric(pipeline, channels, "lal_transferfunction", fft_length=fft_length, fft_overlap=fft_overlap, num_ffts=num_ffts, fir_length=td_tf_length, use_median=True if options.use_median else False, update_samples=1e15, filename='%s_%s_over_%s_%d-%d.txt' % (ifo, labels[i].replace(' ', '_').replace( '/', 'over'), options.denominator_channel_name, options.gps_start_time, data_duration)) # # done # return pipeline
def rms_01(pipeline, name): # # This test passes a random series of integers through rms # rate_in = 2048 # Hz buffer_length = 1.0 # seconds test_duration = 50.0 # seconds # # build pipeline # head = test_common.test_src(pipeline, buffer_length=buffer_length, rate=rate_in, width=64, test_duration=test_duration, wave=5, freq=0) white_noise = pipeparts.mktee(pipeline, head) white_noise_over10 = pipeparts.mkaudioamplify(pipeline, white_noise, 0.1) white_noise_bp100to150 = calibration_parts.bandpass(pipeline, white_noise, 2048, length=1.0, f_low=100, f_high=150) white_noise_bp250to300 = calibration_parts.bandpass(pipeline, white_noise, 2048, length=1.0, f_low=250, f_high=300) white_noise_bp450to500 = calibration_parts.bandpass(pipeline, white_noise, 2048, length=1.0, f_low=450, f_high=500) white_noise_bp400to500 = calibration_parts.bandpass(pipeline, white_noise, 2048, length=1.0, f_low=400, f_high=500) rms = calibration_parts.compute_rms(pipeline, white_noise, 1024, 1.0, f_min=100, f_max=500) rms_over10 = calibration_parts.compute_rms(pipeline, white_noise_over10, 1024, 1.0, f_min=100, f_max=500) rms_bp100to150 = calibration_parts.compute_rms(pipeline, white_noise_bp100to150, 1024, 1.0, f_min=100, f_max=500) rms_bp250to300 = calibration_parts.compute_rms(pipeline, white_noise_bp250to300, 1024, 1.0, f_min=100, f_max=500) rms_bp450to500 = calibration_parts.compute_rms(pipeline, white_noise_bp450to500, 1024, 1.0, f_min=100, f_max=500) rms_bp400to500 = calibration_parts.compute_rms(pipeline, white_noise_bp400to500, 1024, 1.0, f_min=100, f_max=500) pipeparts.mknxydumpsink(pipeline, rms, "rms.txt") pipeparts.mknxydumpsink(pipeline, rms_over10, "rms_over10.txt") pipeparts.mknxydumpsink(pipeline, rms_bp100to150, "rms_bp100to150.txt") pipeparts.mknxydumpsink(pipeline, rms_bp250to300, "rms_bp250to300.txt") pipeparts.mknxydumpsink(pipeline, rms_bp450to500, "rms_bp450to500.txt") pipeparts.mknxydumpsink(pipeline, rms_bp400to500, "rms_bp400to500.txt") # # done # return pipeline
def demod_ratio(pipeline, name): # Get denominator data from the raw frames denominator_data = pipeparts.mklalcachesrc( pipeline, location=options.denominator_frame_cache, cache_dsc_regex=ifo) denominator_data = pipeparts.mkframecppchanneldemux( pipeline, denominator_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) denominator = calibration_parts.hook_up(pipeline, denominator_data, options.denominator_channel_name, ifo, 1.0) denominator = calibration_parts.caps_and_progress( pipeline, denominator, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", "denominator") denominator = pipeparts.mktee(pipeline, denominator) # Get numerator data from the raw frames if not options.denominator_frame_cache == options.numerator_frame_cache: numerator_data = pipeparts.mklalcachesrc( pipeline, location=options.numerator_frame_cache, cache_dsc_regex=ifo) numerator_data = pipeparts.mkframecppchanneldemux( pipeline, numerator_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) numerator = calibration_parts.hook_up(pipeline, numerator_data, options.numerator_channel_name, ifo, 1.0) else: numerator = calibration_parts.hook_up(pipeline, denominator_data, options.numerator_channel_name, ifo, 1.0) numerator = calibration_parts.caps_and_progress( pipeline, numerator, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", "numerator") numerator = pipeparts.mktee(pipeline, numerator) # Demodulate numerator and denominator at each frequency, take ratios, and write to file for i in range(0, len(frequencies)): # Demodulate demodulated_denominator = calibration_parts.demodulate( pipeline, denominator, frequencies[i], True, rate_out, filter_time, 0.5) demodulated_numerator = calibration_parts.demodulate( pipeline, numerator, frequencies[i], True, rate_out, filter_time, 0.5) demodulated_numerator = pipeparts.mktee(pipeline, demodulated_numerator) demodulated_denominator = pipeparts.mktee(pipeline, demodulated_denominator) # Take ratio ratio = calibration_parts.complex_division(pipeline, demodulated_numerator, demodulated_denominator) # Average ratio = pipeparts.mkgeneric(pipeline, ratio, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time), filter_latency=1.0) # Find magnitude and phase ratio = pipeparts.mktee(pipeline, ratio) magnitude = pipeparts.mkgeneric(pipeline, ratio, "cabs") phase = pipeparts.mkgeneric(pipeline, ratio, "carg") phase = pipeparts.mkaudioamplify(pipeline, phase, 180.0 / numpy.pi) # Interleave magnitude_and_phase = calibration_parts.mkinterleave( pipeline, [magnitude, phase]) # Write to file pipeparts.mknxydumpsink( pipeline, magnitude_and_phase, "%s_%s_over_%s_%0.1fHz.txt" % (ifo, options.numerator_channel_name, options.denominator_channel_name, frequencies[i])) # # done # return pipeline
def pcal2darm(pipeline, name): # Get pcal from the raw frames raw_data = pipeparts.mklalcachesrc(pipeline, location=options.raw_frame_cache, cache_dsc_regex=ifo) raw_data = pipeparts.mkframecppchanneldemux( pipeline, raw_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) pcal = calibration_parts.hook_up(pipeline, raw_data, options.pcal_channel_name, ifo, 1.0) pcal = calibration_parts.caps_and_progress( pipeline, pcal, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", "pcal") pcal = pipeparts.mktee(pipeline, pcal) # Demodulate the pcal channel at the lines of interest for i in range(0, len(frequencies)): demodulated_pcal = calibration_parts.demodulate( pipeline, pcal, frequencies[i], True, rate_out, filter_time, 0.5, prefactor_real=pcal_corrections[2 * i], prefactor_imag=pcal_corrections[2 * i + 1]) demodulated_pcal_list.append( pipeparts.mktee(pipeline, demodulated_pcal)) # Check if we are taking pcal-to-darm ratios for CALCS data for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]): calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel, ifo, 1.0) calcs_deltal = calibration_parts.caps_and_progress( pipeline, calcs_deltal, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal) for i in range(0, len(frequencies)): # Demodulate DELTAL_EXTERNAL at each line demodulated_calcs_deltal = calibration_parts.demodulate( pipeline, calcs_deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Take ratio \DeltaL(f) / pcal(f) deltaL_over_pcal = calibration_parts.complex_division( pipeline, demodulated_calcs_deltaL, demodulated_pcal_list[i]) # Take a running average deltaL_over_pcal = pipeparts.mkgeneric( pipeline, deltaL_over_pcal, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time)) # Write to file pipeparts.mknxydumpsink( pipeline, deltaL_over_pcal, "%s_%s_over_%s_at_line%d.txt" % (ifo, label.replace( ' ', '_'), options.pcal_channel_name, i + 1)) # Check if we are taking pcal-to-darm ratios for gstlal calibrated data if options.gstlal_channel_list is not None: cache_num = 0 for cache, channel, label in zip( gstlal_frame_cache_list, gstlal_channels, labels[len(calcs_channels):len(channel_list)]): # Get gstlal channels from the gstlal frames hoft_data = pipeparts.mklalcachesrc(pipeline, location=cache, cache_dsc_regex=ifo) hoft_data = pipeparts.mkframecppchanneldemux( pipeline, hoft_data, do_file_checksum=False, skip_bad_files=True, channel_list=list( map("%s:%s".__mod__, channel_list + DQ_channels))) hoft = calibration_parts.hook_up(pipeline, hoft_data, channel, ifo, 1.0, element_name_suffix="_%d" % cache_num) hoft = calibration_parts.caps_and_progress( pipeline, hoft, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length) deltal = pipeparts.mktee(pipeline, deltal) # Get a DQ channel DQ_channel = "%sCALIB_STATE_VECTOR%s" % (chan_prefixes[cache_num], chan_suffixes[cache_num]) DQ = calibration_parts.hook_up(pipeline, hoft_data, DQ_channel, ifo, 1.0, element_name_suffix="_%d" % cache_num) DQ = calibration_parts.caps_and_progress( pipeline, DQ, "audio/x-raw,format=U32LE,channels=1,channel-mask=(bitmask)0x0", "DQ_%s" % label) DQ = pipeparts.mkgeneric(pipeline, DQ, "lal_logicalundersample", required_on=1, status_out=1) DQ = pipeparts.mkcapsfilter( pipeline, DQ, "audio/x-raw,format=U32LE,rate=%d,channels=1,channel-mask=(bitmask)0x0" % rate_out) DQ = pipeparts.mkgeneric( pipeline, DQ, "lal_drop", drop_samples=int((7.0 + 0.5 * filter_time) * rate_out + 0.5)) DQ = pipeparts.mktee(pipeline, DQ) for i in range(0, len(frequencies)): # Demodulate \DeltaL at each line demodulated_deltal = calibration_parts.demodulate( pipeline, deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Take ratio \DeltaL(f) / pcal(f) deltaL_over_pcal = calibration_parts.complex_division( pipeline, demodulated_deltal, demodulated_pcal_list[i]) # Take a running average deltaL_over_pcal = pipeparts.mkgeneric( pipeline, deltaL_over_pcal, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time)) # Find the magnitude deltaL_over_pcal = pipeparts.mktee(pipeline, deltaL_over_pcal) magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "cabs") # Find the phase phase = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "carg") phase = pipeparts.mkaudioamplify(pipeline, phase, 180.0 / numpy.pi) # Interleave magnitude_and_phase = calibration_parts.mkinterleave( pipeline, [magnitude, phase]) # Gate with DQ channel magnitude_and_phase = calibration_parts.mkgate( pipeline, magnitude_and_phase, DQ, 1) magnitude_and_phase = pipeparts.mkprogressreport( pipeline, magnitude_and_phase, name="progress_sink_%s_%d" % (label, i)) # Write to file pipeparts.mknxydumpsink( pipeline, magnitude_and_phase, "%s_%s_over_%s_at_%0.1fHz_%d.txt" % (ifo, label.replace(' ', '_'), options.pcal_channel_name, frequencies[i], options.gps_start_time)) cache_num = cache_num + 1 # # done # return pipeline
def single_pole_filter_test(pipeline, name, line_sep=0.5): rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 1000 # seconds fcc_rate = 16 # Hz gain = 1.1 fcc = 430 # Hz update_time = 20 # seconds # # build pipeline # # Make a source of fake data to act as input values for a gain and a zero gain_fcc_data = test_common.test_src(pipeline, rate=fcc_rate, test_duration=test_duration, wave=5, src_suffix="_gain_fcc_data") # Take to the power of 0 to make it a stream of ones gain_fcc_data = calibration_parts.mkpow(pipeline, gain_fcc_data, exponent=0.0) # Make a copy which we can use to make both the gain and the fcc data gain_fcc_data = pipeparts.mktee(pipeline, gain_fcc_data) # Make the gain data by multiplying ones by the gain gain_data = pipeparts.mkaudioamplify(pipeline, gain_fcc_data, gain) # Make the fcc data by multiplying ones by fcc fcc_data = pipeparts.mkaudioamplify(pipeline, gain_fcc_data, fcc) # Now, this needs to be used in the element lal_adaptivefirfilt to turn it into a FIR filter. # lal_adaptivefirfilt takes as inputs (in this order) zeros, poles, a complex factor containing gain and phase. # Type "$ gst-inspect-1.0 lal_adaptivefirfilt" for info about the element. # Each of the inputs must be a complex data stream, so we first must make these real streams complex gain_data = pipeparts.mktogglecomplex( pipeline, pipeparts.mkmatrixmixer(pipeline, gain_data, matrix=[[1.0, 0.0]])) fcc_data = pipeparts.mktogglecomplex( pipeline, pipeparts.mkmatrixmixer(pipeline, fcc_data, matrix=[[1.0, 0.0]])) # Now we must interleave these streams, since lal_adaptivefirfilt takes a single multi-channel stream of interleaved data. # The fcc data (the zero frequency) must come first so that it is channel 0; that way lal_adaptivefirfilt recognizes it as such. filter_data = calibration_parts.mkinterleave(pipeline, [fcc_data, gain_data], complex_data=True) # Finally, send the interleaved data to lal_adaptivefirfilt, which will make a FIR filter. # Note that it needs to know the number of zeros and poles. # update_samples tells it how often to send a new filter to the filtering element # minimize_filter_length must be True for it to use a 2-tap filter. Otherwise, it makes a longer FIR filter using and iFFT from a frequency-domain model. # This will also write the filter coefficients to file. adaptive_invsens_filter = calibration_parts.mkadaptivefirfilt( pipeline, filter_data, update_samples=int(update_time * fcc_rate), average_samples=1, num_zeros=1, num_poles=0, filter_sample_rate=rate, minimize_filter_length=True, filename="%s_FIR_filter.txt" % name) # Now make time series source of white noise to be filtered (wave = 5 means white noise) in_signal = test_common.test_src(pipeline, rate=rate, test_duration=test_duration, wave=5, src_suffix="_in_signal") # Make a copy of input data so that we can write it to file in_signal = pipeparts.mktee(pipeline, in_signal) # Write input time series to file pipeparts.mknxydumpsink(pipeline, in_signal, "%s_in.txt" % name) # Filter the data using lal_tdwhiten, which handles smooth filter updates # The property "kernel" is the FIR filter we will update. To start, give a trivial default value. # The "taper_length" is the number of samples over which to handle filter transitions. It is set to be 1 second. out_signal = pipeparts.mkgeneric(pipeline, in_signal, "lal_tdwhiten", kernel=[0, 1], latency=0, taper_length=rate) # Hook up the adaptive filter from lal_adaptivefirfilt to lal_tdwhiten so that the filter gets updated adaptive_invsens_filter.connect("notify::adaptive-filter", calibration_parts.update_filter, out_signal, "adaptive_filter", "kernel") # Correct the 1/2-sample shift in timestamps by applying a linear-phase FIR filter # The last argument here (0.5) is the number of samples worth of timestamp advance to apply to the data. You might want to try -0.5 as well, since I often get advances and delays mixed up. out_signal = calibration_parts.linear_phase_filter(pipeline, out_signal, 0.5) # Make a copy, so that we can write the time series to file and send it to lal_transferfunction out_signal = pipeparts.mktee(pipeline, out_signal) # Finally, write the output to file pipeparts.mknxydumpsink(pipeline, out_signal, "%s_out.txt" % name) # Now, take the input and output and compute a transfer function. # First, we need to interleave the data for use by lal_transferfunction. The numerator comes first tf_input = calibration_parts.mkinterleave(pipeline, [out_signal, in_signal]) # Remove some initial samples in case they were filtered by the default dummy filter [0, 1] tf_input = calibration_parts.mkinsertgap( pipeline, tf_input, chop_length=Gst.SECOND * 50) # Removing 50 s of initial data # Send to lal_transferfunction, which will compute the frequency-domain transfer function between the input and output data and write it to file calibration_parts.mktransferfunction( pipeline, tf_input, fft_length=16 * rate, fft_overlap=8 * rate, num_ffts=(test_duration - 50) / 8 - 3, use_median=True, update_samples=1e15, filename="%s_filter_transfer_function.txt" % name) # You could, for instance, compare this transfer function to what you expect, i.e., gain * (1 + i f / fcc), and plot the comparison in the frequency-domain. I'm guessing there will be a fair amount of work involved in getting everything to work and getting the result correct. # # done # return pipeline
def act2darm(pipeline, name): # Get actuation injection channels from the raw frames act_inj_channels = [] raw_data = pipeparts.mklalcachesrc(pipeline, location=options.raw_frame_cache, cache_dsc_regex=ifo) raw_data = pipeparts.mkframecppchanneldemux( pipeline, raw_data, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) for i in range(len(act_channels)): act_inj_channels.append( calibration_parts.hook_up(pipeline, raw_data, act_channels[i], ifo, 1.0)) act_inj_channels[i] = calibration_parts.caps_and_progress( pipeline, act_inj_channels[i], "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", "act_inj_%d" % i) act_inj_channels[i] = pipeparts.mktee(pipeline, act_inj_channels[i]) # Demodulate the actuation injection channels at the lines of interest for i in range(0, len(frequencies)): demodulated_act = calibration_parts.demodulate( pipeline, act_inj_channels[i], frequencies[i], True, rate_out, filter_time, 0.5, prefactor_real=act_corrections[2 * i], prefactor_imag=act_corrections[2 * i + 1]) demodulated_act_list.append(pipeparts.mktee(pipeline, demodulated_act)) # Check if we are taking act-to-darm ratios for CALCS data for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]): calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel, ifo, 1.0) calcs_deltal = calibration_parts.caps_and_progress( pipeline, calcs_deltal, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal) for i in range(0, len(frequencies)): # Demodulate DELTAL_EXTERNAL at each line demodulated_calcs_deltal = calibration_parts.demodulate( pipeline, calcs_deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Take ratio \DeltaL(f) / act_injection(f) deltaL_over_act = calibration_parts.complex_division( pipeline, demodulated_calcs_deltaL, demodulated_act_list[i]) # Take a running average deltaL_over_act = pipeparts.mkgeneric(pipeline, deltaL_over_act, "lal_smoothkappas", array_size=1, avg_array_size=int( rate_out * average_time)) # Write to file pipeparts.mknxydumpsink( pipeline, deltaL_over_act, "%s_%s_over_%s_at_line%d.txt" % (ifo, label.replace(' ', '_'), act_channels[i], i + 1)) # Check if we are taking act-to-darm ratios for gstlal calibrated data if options.gstlal_channel_list is not None: cache_num = 0 for cache, channel, label in zip( gstlal_frame_cache_list, gstlal_channels, labels[len(calcs_channels):len(channel_list)]): # Get gstlal channels from the gstlal frames hoft_data = pipeparts.mklalcachesrc(pipeline, location=cache, cache_dsc_regex=ifo) hoft_data = pipeparts.mkframecppchanneldemux( pipeline, hoft_data, do_file_checksum=False, skip_bad_files=True, channel_list=list( map("%s:%s".__mod__, channel_list + TDCF_channels[cache_num] + DQ_channels))) hoft = calibration_parts.hook_up(pipeline, hoft_data, channel, ifo, 1.0, element_name_suffix="_%d" % cache_num) hoft = calibration_parts.caps_and_progress( pipeline, hoft, "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0", label) deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length) deltal = pipeparts.mktee(pipeline, deltal) # Get a DQ channel DQ_channel = "%sCALIB_STATE_VECTOR%s" % (chan_prefixes[cache_num], chan_suffixes[cache_num]) DQ = calibration_parts.hook_up(pipeline, hoft_data, DQ_channel, ifo, 1.0, element_name_suffix="_%d" % cache_num) DQ = calibration_parts.caps_and_progress( pipeline, DQ, "audio/x-raw,format=U32LE,channels=1,channel-mask=(bitmask)0x0", "DQ_%s" % label) DQ = pipeparts.mkgeneric(pipeline, DQ, "lal_logicalundersample", required_on=1, status_out=1) DQ = pipeparts.mkcapsfilter( pipeline, DQ, "audio/x-raw,format=U32LE,rate=%d,channels=1,channel-mask=(bitmask)0x0" % rate_out) DQ = pipeparts.mktee(pipeline, DQ) for i in range(0, len(frequencies)): # Demodulate \DeltaL at each line demodulated_deltal = calibration_parts.demodulate( pipeline, deltal, frequencies[i], True, rate_out, filter_time, 0.5) # Divide by a TDCF if needed if ('tst' in act_line_names[i] or 'esd' in act_line_names[i] ) and (apply_complex_kappatst[cache_num] or apply_kappatst[cache_num]): # Get KAPPA_TST TDCF_real = "%sCALIB_KAPPA_TST_REAL%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_imag = "%sCALIB_KAPPA_TST_IMAGINARY%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_real = calibration_parts.hook_up( pipeline, hoft_data, TDCF_real, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF_imag = calibration_parts.hook_up( pipeline, hoft_data, TDCF_imag, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF = calibration_parts.merge_into_complex( pipeline, TDCF_real, TDCF_imag) TDCF = calibration_parts.caps_and_progress( pipeline, TDCF, "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0", 'KAPPA_TST_%s' % label) TDCF = calibration_parts.mkresample( pipeline, TDCF, 3, False, rate_out) if not apply_complex_kappatst[cache_num]: # Only divide by the magnitude TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs") TDCF = pipeparts.mktogglecomplex( pipeline, pipeparts.mkmatrixmixer(pipeline, TDCF, matrix=[[1.0, 0.0]])) demodulated_deltal = calibration_parts.complex_division( pipeline, demodulated_deltal, TDCF) elif 'pum' in act_line_names[i] and ( apply_complex_kappapum[cache_num] or apply_kappapum[cache_num]): # Get KAPPA_PUM TDCF_real = "%sCALIB_KAPPA_PUM_REAL%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_imag = "%sCALIB_KAPPA_PUM_IMAGINARY%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_real = calibration_parts.hook_up( pipeline, hoft_data, TDCF_real, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF_imag = calibration_parts.hook_up( pipeline, hoft_data, TDCF_imag, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF = calibration_parts.merge_into_complex( pipeline, TDCF_real, TDCF_imag) TDCF = calibration_parts.caps_and_progress( pipeline, TDCF, "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0", 'KAPPA_PUM_%s' % label) TDCF = calibration_parts.mkresample( pipeline, TDCF, 3, False, rate_out) if not apply_complex_kappapum[cache_num]: # Only divide by the magnitude TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs") TDCF = pipeparts.mktogglecomplex( pipeline, pipeparts.mkmatrixmixer(pipeline, TDCF, matrix=[[1.0, 0.0]])) demodulated_deltal = calibration_parts.complex_division( pipeline, demodulated_deltal, TDCF) elif 'uim' in act_line_names[i] and ( apply_complex_kappauim[cache_num] or apply_kappauim[cache_num]): # Get KAPPA_UIM TDCF_real = "%sCALIB_KAPPA_UIM_REAL%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_imag = "%sCALIB_KAPPA_UIM_IMAGINARY%s" % ( chan_prefixes[cache_num], chan_suffixes[cache_num]) TDCF_real = calibration_parts.hook_up( pipeline, hoft_data, TDCF_real, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF_imag = calibration_parts.hook_up( pipeline, hoft_data, TDCF_imag, ifo, 1.0, element_name_suffix="_%d" % cache_num) TDCF = calibration_parts.merge_into_complex( pipeline, TDCF_real, TDCF_imag) TDCF = calibration_parts.caps_and_progress( pipeline, TDCF, "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0", 'KAPPA_UIM_%s' % label) TDCF = calibration_parts.mkresample( pipeline, TDCF, 3, False, rate_out) if not apply_complex_kappauim[cache_num]: # Only divide by the magnitude TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs") TDCF = pipeparts.mktogglecomplex( pipeline, pipeparts.mkmatrixmixer(pipeline, TDCF, matrix=[[1.0, 0.0]])) demodulated_deltal = calibration_parts.complex_division( pipeline, demodulated_deltal, TDCF) # Take ratio \DeltaL(f) / act_injection(f) deltaL_over_act = calibration_parts.complex_division( pipeline, demodulated_deltal, demodulated_act_list[i]) # Take a running average deltaL_over_act = pipeparts.mkgeneric( pipeline, deltaL_over_act, "lal_smoothkappas", array_size=1, avg_array_size=int(rate_out * average_time)) # Find the magnitude deltaL_over_act = pipeparts.mktee(pipeline, deltaL_over_act) magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_act, "cabs") # Find the phase phase = pipeparts.mkgeneric(pipeline, deltaL_over_act, "carg") phase = pipeparts.mkaudioamplify(pipeline, phase, 180.0 / numpy.pi) # Interleave magnitude_and_phase = calibration_parts.mkinterleave( pipeline, [magnitude, phase]) # Gate with DQ channel magnitude_and_phase = calibration_parts.mkgate( pipeline, magnitude_and_phase, DQ, 1) magnitude_and_phase = pipeparts.mkprogressreport( pipeline, magnitude_and_phase, name="progress_sink_%s_%d" % (label, i)) # Write to file pipeparts.mknxydumpsink( pipeline, magnitude_and_phase, "%s_%s_over_%s_at_%0.1fHz_%d.txt" % (ifo, label.replace(' ', '_'), act_channels[i], frequencies[i], options.gps_start_time)) cache_num = cache_num + 1 # # done # return pipeline
def __init__(self): super(lal_compute_gamma, self).__init__() # Make an oscillator at calibration line frequency for computation of gamma factors cos = gst.element_factory_make("tee") self.add(cos) sin = gst.element_factory_make("tee") self.add(sin) self.add_pad(gst.GhostPad("cos", cos.get_pad("sink"))) self.add_pad(gst.GhostPad("sin", sin.get_pad("sink"))) # Tee off sources exc = gst.element_factory_make("tee") self.add(exc) dctrl = gst.element_factory_make("tee") self.add(dctrl) self.add_pad(gst.GhostPad("exc_sink", exc.get_pad("sink"))) self.add_pad(gst.GhostPad("dctrl_sink", dctrl.get_pad("sink"))) # EXC branch for gamma excR = gst.element_factory_make("lal_multiplier") excR.set_property("sync", True) self.add(excR) pipeparts.mkqueue(self, exc).link(excR) pipeparts.mkqueue(self, cos).link(excR) excR = pipeparts.mkresample(self, excR, quality=9) self.excR_capsfilter = excR = pipeparts.mkgeneric(self, excR, "capsfilter") self.excR_firbank = excR = pipeparts.mkfirbank(self, excR) excR = pipeparts.mktee(self, excR) excI = gst.element_factory_make("lal_multiplier") excI.set_property("sync", True) self.add(excI) pipeparts.mkqueue(self, exc).link(excI) pipeparts.mkqueue(self, sin).link(excI) excI = pipeparts.mkresample(self, excI, quality=9) self.excI_capsfilter = excI = pipeparts.mkgeneric(self, excI, "capsfilter") self.excI_firbank = excI = pipeparts.mkfirbank(self, excI) excI = pipeparts.mktee(self, excI) # DARM_CTRL branch for gamma dctrlR = gst.element_factory_make("lal_multiplier") dctrlR.set_property("sync", True) self.add(dctrlR) pipeparts.mkqueue(self, dctrl).link(dctrlR) pipeparts.mkqueue(self, cos).link(dctrlR) dctrlR = pipeparts.mkresample(self, dctrlR, quality=9) self.dctrlR_capsfilter = dctrlR = pipeparts.mkgeneric(self, dctrlR, "capsfilter") self.dctrlR_firbank = dctrlR = pipeparts.mkfirbank(self, dctrlR) dctrlR = pipeparts.mktee(self, dctrlR) dctrlI = gst.element_factory_make("lal_multiplier") dctrlI.set_property("sync", True) self.add(dctrlI) pipeparts.mkqueue(self, dctrl).link(dctrlI) pipeparts.mkqueue(self, sin).link(dctrlI) dctrlI = pipeparts.mkresample(self, dctrlI, quality=9) self.dctrlI_capsfilter = dctrlI = pipeparts.mkgeneric(self, dctrlI, "capsfilter") self.dctrlI_firbank = dctrlI = pipeparts.mkfirbank(self, dctrlI) dctrlI = pipeparts.mktee(self, dctrlI) # Make useful combos of channels for calculating gamma dctrl_mod = gst.element_factory_make("lal_adder") dctrl_mod.set_property("sync", True) self.add(dctrl_mod) pipeparts.mkqueue(self, pipeparts.mkpow(self, dctrlR, exponent = 2.0)).link(dctrl_mod) pipeparts.mkqueue(self, pipeparts.mkpow(self, dctrlI, exponent = 2.0)).link(dctrl_mod) self.dctrl_mod_w_mod = dctrl_mod_w_mod = pipeparts.mkgeneric(self, dctrl_mod, "audioamplify") dctrl_mod_w_mod = pipeparts.mktee(self, dctrl_mod_w_mod) self.dctrl_mod_w_mod_olgR = dctrl_mod_w_mod_olgR = pipeparts.mkgeneric(self, dctrl_mod_w_mod, "audioamplify") self.dctrl_mod_w_mod_olgI = dctrl_mod_w_mod_olgI = pipeparts.mkgeneric(self, dctrl_mod_w_mod, "audioamplify") self.dctrl_mod_w_mod_olg_mod = dctrl_mod_w_mod_olg_mod = pipeparts.mkgeneric(self, dctrl_mod_w_mod, "audioamplify") dctrlR_excI = gst.element_factory_make("lal_multiplier") dctrlR_excI.set_property("sync", True) self.add(dctrlR_excI) pipeparts.mkqueue(self, dctrlR).link(dctrlR_excI) pipeparts.mkqueue(self, excI).link(dctrlR_excI) dctrlR_excI = pipeparts.mktee(self, dctrlR_excI) self.dctrlR_excI_olgI = dctrlR_excI_olgI = pipeparts.mkgeneric(self, dctrlR_excI, "audioamplify") dctrlR_excI_olgI = pipeparts.mktee(self, dctrlR_excI_olgI) self.dctrlR_excI_olgI_wI = dctrlR_excI_olgI_wI = pipeparts.mkgeneric(self, dctrlR_excI_olgI, "audioamplify") self.dctrlR_excI_olgI_wR = dctrlR_excI_olgI_wR = pipeparts.mkgeneric(self, dctrlR_excI_olgI, "audioamplify") self.dctrlR_excI_olgR = dctrlR_excI_olgR = pipeparts.mkgeneric(self, dctrlR_excI, "audioamplify") dctrlR_excI_olgR = pipeparts.mktee(self, dctrlR_excI_olgR) self.dctrlR_excI_olgR_wI = dctrlR_excI_olgR_wI = pipeparts.mkgeneric(self, dctrlR_excI_olgR, "audioamplify") self.dctrlR_excI_olgR_wR = dctrlR_excI_olgR_wR = pipeparts.mkgeneric(self, dctrlR_excI_olgR, "audioamplify") dctrlI_excR = gst.element_factory_make("lal_multiplier") dctrlI_excR.set_property("sync", True) self.add(dctrlI_excR) pipeparts.mkqueue(self, dctrlI).link(dctrlI_excR) pipeparts.mkqueue(self, excR).link(dctrlI_excR) dctrlI_excR = pipeparts.mktee(self, dctrlI_excR) self.dctrlI_excR_olgI = dctrlI_excR_olgI = pipeparts.mkgeneric(self, dctrlI_excR, "audioamplify") dctrlI_excR_olgI = pipeparts.mktee(self, dctrlI_excR_olgI) self.dctrlI_excR_olgI_wR = dctrlI_excR_olgI_wR = pipeparts.mkgeneric(self, dctrlI_excR_olgI, "audioamplify") self.dctrlI_excR_olgI_wI = dctrlI_excR_olgI_wI = pipeparts.mkgeneric(self, dctrlI_excR_olgI, "audioamplify") self.dctrlI_excR_olgR = dctrlI_excR_olgR = pipeparts.mkgeneric(self, dctrlI_excR, "audioamplify") dctrlI_excR_olgR = pipeparts.mktee(self, dctrlI_excR_olgR) self.dctrlI_excR_olgR_wI = dctrlI_excR_olgR_wI = pipeparts.mkgeneric(self, dctrlI_excR_olgR, "audioamplify") self.dctrlI_excR_olgR_wR = dctrlI_excR_olgR_wR = pipeparts.mkgeneric(self, dctrlI_excR_olgR, "audioamplify") dctrlI_excI = gst.element_factory_make("lal_multiplier") dctrlI_excI.set_property("sync", True) self.add(dctrlI_excI) pipeparts.mkqueue(self, dctrlI).link(dctrlI_excI) pipeparts.mkqueue(self, excI).link(dctrlI_excI) dctrlI_excI = pipeparts.mktee(self, dctrlI_excI) self.dctrlI_excI_olgR = dctrlI_excI_olgR = pipeparts.mkgeneric(self, dctrlI_excI, "audioamplify") dctrlI_excI_olgR = pipeparts.mktee(self, dctrlI_excI_olgR) self.dctrlI_excI_olgR_wR = dctrlI_excI_olgR_wR = pipeparts.mkgeneric(self, dctrlI_excI_olgR, "audioamplify") self.dctrlI_excI_olgR_wI = dctrlI_excI_olgR_wI = pipeparts.mkgeneric(self, dctrlI_excI_olgR, "audioamplify") self.dctrlI_excI_olgI = dctrlI_excI_olgI = pipeparts.mkgeneric(self, dctrlI_excI, "audioamplify") dctrlI_excI_olgI = pipeparts.mktee(self, dctrlI_excI_olgI) self.dctrlI_excI_olgI_wI = dctrlI_excI_olgI_wI = pipeparts.mkgeneric(self, dctrlI_excI_olgI, "audioamplify") self.dctrlI_excI_olgI_wR = dctrlI_excI_olgI_wR = pipeparts.mkgeneric(self, dctrlI_excI_olgI, "audioamplify") dctrlR_excR = gst.element_factory_make("lal_multiplier") dctrlR_excR.set_property("sync", True) self.add(dctrlR_excR) pipeparts.mkqueue(self, dctrlR).link(dctrlR_excR) pipeparts.mkqueue(self, excR).link(dctrlR_excR) dctrlR_excR = pipeparts.mktee(self, dctrlR_excR) self.dctrlR_excR_olgR = dctrlR_excR_olgR = pipeparts.mkgeneric(self, dctrlR_excR, "audioamplify") dctrlR_excR_olgR = pipeparts.mktee(self, dctrlR_excR_olgR) self.dctrlR_excR_olgR_wR = dctrlR_excR_olgR_wR = pipeparts.mkgeneric(self, dctrlR_excR_olgR, "audioamplify") self.dctrlR_excR_olgR_wI = dctrlR_excR_olgR_wI = pipeparts.mkgeneric(self, dctrlR_excR_olgR, "audioamplify") self.dctrlR_excR_olgI = dctrlR_excR_olgI = pipeparts.mkgeneric(self, dctrlR_excR, "audioamplify") dctrlR_excR_olgI = pipeparts.mktee(self, dctrlR_excR_olgI) self.dctrlR_excR_olgI_wI = dctrlR_excR_olgI_wI = pipeparts.mkgeneric(self, dctrlR_excR_olgI, "audioamplify") self.dctrlR_excR_olgI_wR = dctrlR_excR_olgI_wR = pipeparts.mkgeneric(self, dctrlR_excR_olgI, "audioamplify") # Combine all of these branches into real and imaginary gamma denom = pipeparts.mktee(self, dctrl_mod_w_mod_olg_mod) gammaI_num = gst.element_factory_make("lal_adder") gammaI_num.set_property("sync", True) self.add(gammaI_num) pipeparts.mkqueue(self, dctrl_mod_w_mod_olgI).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlR_excI_olgI_wI, -1.0)).link(gammaI_num) pipeparts.mkqueue(self, dctrlI_excR_olgI_wI).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excI_olgR_wI, -1.0)).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlR_excR_olgR_wI, -1.0)).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excI_olgI_wR, -1.0)).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlR_excR_olgI_wR, -1.0)).link(gammaI_num) pipeparts.mkqueue(self, dctrlR_excI_olgR_wR).link(gammaI_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excR_olgR_wR, -1.0)).link(gammaI_num) gammaR_num = gst.element_factory_make("lal_adder") gammaR_num.set_property("sync", True) self.add(gammaR_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrl_mod_w_mod_olgR, -1.0)).link(gammaR_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excI_olgI_wI, -1.0)).link(gammaR_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlR_excR_olgI_wI, -1.0)).link(gammaR_num) pipeparts.mkqueue(self, dctrlR_excI_olgR_wI).link(gammaR_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excR_olgR_wI, -1.0)).link(gammaR_num) pipeparts.mkqueue(self, dctrlR_excI_olgI_wR).link(gammaR_num) pipeparts.mkqueue(self, pipeparts.mkaudioamplify(self, dctrlI_excR_olgI_wR, -1.0)).link(gammaR_num) pipeparts.mkqueue(self, dctrlI_excI_olgR_wR).link(gammaR_num) pipeparts.mkqueue(self, dctrlR_excR_olgR_wR).link(gammaR_num) gammaR = gst.element_factory_make("lal_multiplier") gammaR.set_property("sync", True) self.add(gammaR) pipeparts.mkqueue(self, gammaR_num).link(gammaR) pipeparts.mkqueue(self, pipeparts.mkpow(self, denom, exponent = -1.0)).link(gammaR) gammaI = gst.element_factory_make("lal_multiplier") gammaI.set_property("sync", True) self.add(gammaI) pipeparts.mkqueue(self, gammaI_num).link(gammaI) pipeparts.mkqueue(self, pipeparts.mkpow(self, denom, exponent = -1.0)).link(gammaI) # Set up src pads self.add_pad(gst.GhostPad("gammaR", gammaR.get_pad("src"))) self.add_pad(gst.GhostPad("gammaI", gammaI.get_pad("src")))