def lal_interleave_01(pipeline, name): caps = "audio/x-raw-float, width=64, rate=2048, channels=1" # # build pipeline # head = test_common_old.test_src(pipeline) headtee = pipeparts.mktee(pipeline, head) head1 = pipeparts.mkfirbank(pipeline, headtee, latency=-10, fir_matrix = [[0,1]]) head1tee = pipeparts.mktee(pipeline, head1) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head1tee), "%s_in_shifted.dump" % name) out = pipeparts.mkgeneric(pipeline, None, "lal_interleave", sync = True) #out = pipeparts.mkgeneric(pipeline, None, "lal_adder", sync = True) pipeparts.mkqueue(pipeline, headtee).link(out) pipeparts.mkqueue(pipeline, head1tee).link(out) #out = calibration_parts.mkinterleave(pipeline, calibration_parts.list_srcs(pipeline, headtee, head1tee), caps) pipeparts.mknxydumpsink(pipeline, out, "%s_out.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, headtee), "%s_in_notshifted.dump" % name) # # done # return pipeline
def lal_smoothkappas_04(pipeline, name): rate = 2000 # Hz width = 64 # bytes wave = 5 freq = 0.1 # Hz volume = 0.03 buffer_length = 1.0 # seconds test_duration = 10.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.5 # Hz control_dump_filename = "control_smoothkappas_02.dump" # # build pipeline # src = test_common.gapped_test_src(pipeline, channels = 1, buffer_length = buffer_length, rate = rate, width = width, test_duration = test_duration, wave = wave, freq = freq, volume = volume, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = control_dump_filename) head = pipeparts.mkmatrixmixer(pipeline, src, matrix = [[1000]]) head = pipeparts.mkgeneric(pipeline, head, "lal_add_constant", value = 340) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_in.dump" % name) median_avg = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 3, avg_array_size = 2, default_kappa_im = 0, default_kappa_re = 330, track_bad_kappa = False, default_to_median = True) kappa_track = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 2049, avg_array_size = 160, default_kappa_im = 0, default_kappa_re = 330, track_bad_kappa = True, default_to_median = True) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, median_avg), "%s_median_avg.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, kappa_track), "%s_kappa_track.dump" % name) # # done # return pipeline
def lal_smoothkappas_02(pipeline, name): # # This is similar to the above test, and makes sure the element treats gaps correctly # rate = 1000 # Hz width = 64 # bytes wave = 5 freq = 0.1 # Hz volume = 0.03 buffer_length = 1.0 # seconds test_duration = 10.0 # seconds gap_frequency = 0.2 # Hz gap_threshold = 0.5 # Hz control_dump_filename = "control_smoothkappas_02.dump" # # build pipeline # src = test_common.gapped_test_src(pipeline, channels = 2, buffer_length = buffer_length, rate = rate, width = width, test_duration = test_duration, wave = wave, freq = freq, volume = volume, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = control_dump_filename) head = pipeparts.mktogglecomplex(pipeline, src) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_in.dump" % name) median_avg = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 3, avg_array_size = 2, default_kappa_im = 0, default_kappa_re = 1, track_bad_kappa = False, default_to_median = True) kappa_track = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 30, avg_array_size = 160, default_kappa_im = 0, default_kappa_re = 1, track_bad_kappa = True, default_to_median = True) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, median_avg), "%s_median_avg.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, kappa_track), "%s_kappa_track.dump" % name) # # done # return pipeline
def filters_01(pipeline, name): # # This tests whether the two filters files above behave identically when passed to a lal_firbank element. If so, the output file is ones. # rate = 32768 # Hz buffer_length = 1.0 # seconds test_duration = 1000.0 # seconds # # build pipeline # src = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, test_duration = test_duration, width = 64) tee = pipeparts.mktee(pipeline, src) py_filt = pipeparts.mkfirbank(pipeline, tee, latency = int(py_ctrl_corr_delay), fir_matrix = [py_ctrl_corr_filt[::-1]], time_domain = True) mat_filt = pipeparts.mkfirbank(pipeline, tee, latency = int(mat_ctrl_corr_delay), fir_matrix = [mat_ctrl_corr_filt[::-1]], time_domain = True) py_filt = pipeparts.mkaudiorate(pipeline, py_filt, skip_to_first = True, silent = False) mat_filt = pipeparts.mkaudiorate(pipeline, mat_filt, skip_to_first = True, silent = False) py_filt_inv = pipeparts.mkpow(pipeline, py_filt, exponent = -1.0) ratio = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, mat_filt, py_filt_inv)) pipeparts.mknxydumpsink(pipeline, ratio, "%s_out.dump" % name) # # done # return pipeline
def lal_add_constant_02(pipeline, name): # # This test adds a constant to a stream of double-precision floats # rate = 1000 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # src = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, test_duration = test_duration, width = 64) capsfilter1 = pipeparts.mkcapsfilter(pipeline, src, "audio/x-raw, format=F64LE, rate=%d" % int(rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee1), "%s_in.dump" % name) add_constant = pipeparts.mkgeneric(pipeline, tee1, "lal_add_constant", value=3) capsfilter2 = pipeparts.mkcapsfilter(pipeline, add_constant, "audio/x-raw, format=F64LE, rate=%d" % int(rate)) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, capsfilter2), "%s_out.dump" % name) # # done # return pipeline
def lal_insertgap_test_03(pipeline, name): # # This tests how the element handles 32 bit unsigned integers # rate = 1000 # Hz width = 32 buffer_length = 1.0 # seconds test_duration = 100.0 # seconds bad_data_intervals = numpy.random.randn(10) print("lal_insertgap_test_03 bad_data_intervals = %s" % bad_data_intervals) head = test_common.int_test_src(pipeline, buffer_length=buffer_length, rate=rate, width=width, test_duration=test_duration) head = pipeparts.mkaudioconvert(pipeline, head, "audio/x-raw,format=U32LE") head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals, insert_gap=False, fill_discont=True, replace_value=0.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) # # done # return pipeline
def lal_resample_01(pipeline, name): # # This test adds various noise into a stream and uses audioresample to remove it # rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 2000.0 # seconds width = 64 # bits # # build pipeline # src = test_common.test_src(pipeline, buffer_length = buffer_length, wave = 5, volume = 1, rate = rate, test_duration = test_duration, width = width, verbose = False) tee = pipeparts.mktee(pipeline, src) identity = pipeparts.mkgeneric(pipeline, tee, "identity") head = pipeparts.mkgeneric(pipeline, tee, "lal_resample", quality = 5) head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw,format=F64LE,rate=2048") head = pipeparts.mkgeneric(pipeline, head, "lal_resample", quality = 5) head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw,format=F64LE,rate=16384") head = calibration_parts.mkinterleave(pipeline, [head, identity]) #pipeparts.mknxydumpsink(pipeline, head, "resampled_data.txt") #head = pipeparts.mkgeneric(pipeline, head, "splitcounter") pipeparts.mkgeneric(pipeline, head, "lal_transferfunction", fft_length = rate, fft_overlap = rate / 2, num_ffts = 1000, update_samples = rate * test_duration, filename = "lal_resample_tf.txt") # # done # return pipeline
def lal_smoothkappas_01(pipeline, name): # # This test is to check that the inputs are smoothed in a desirable way # rate = 10 # Hz width = 64 # bytes wave = 5 freq = 0.1 # Hz volume = 0.9 buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # head = test_common.test_src(pipeline, channels = 2, buffer_length = buffer_length, rate = rate, width = width, test_duration = test_duration, wave = wave, freq = freq, volume = volume) head = pipeparts.mktogglecomplex(pipeline, head) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_in.dump" % name) median = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 3, maximum_offset_re = 0.5, maximum_offset_im = 0.5, default_kappa_im = 0.5, default_kappa_re = 0.5, track_bad_kappa = False, default_to_median = True) median_avg = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = 3, avg_array_size = 2, maximum_offset_re = 0.5, maximum_offset_im = 0.5, default_kappa_im = 0.5, default_kappa_re = 0.5, track_bad_kappa = False, default_to_median = True) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, median), "%s_median.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, median_avg), "%s_median_avg.dump" % name) # # done # return pipeline
def lal_smoothkappas_03(pipeline, name): # # This pipeline uses lal_smoothkappas in a similar way that gstlal_compute_strain will # rate = 2000 # Hz width = 64 # bytes wave = 1 # 0=sine, 1=square freq = 0.05 # Hz volume = 0.01 buffer_length = 1.0 # seconds test_duration = 40.0 # seconds real_expected = 1 imag_expected = 0 N = 2048 Nav = 160 src = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, width = width, test_duration = test_duration, wave = wave, freq = freq, volume = volume) tee = pipeparts.mktee(pipeline, src) real = pipeparts.mkgeneric(pipeline, tee, "lal_add_constant", value=1) kappas = calibration_parts.merge_into_complex(pipeline, real, tee) kappas = pipeparts.mktee(pipeline, kappas) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, kappas), "%s_kappa_in.dump" % name) fake_statevector = pipeparts.mkgeneric(pipeline, tee, "pow", exponent=0) fake_statevector = pipeparts.mkgeneric(pipeline, fake_statevector, "lal_demodulate", line_frequency=0.5) fake_statevector = pipeparts.mkgeneric(pipeline, fake_statevector, "lal_togglecomplex") fake_statevector = pipeparts.mkgeneric(pipeline, fake_statevector, "lal_matrixmixer", matrix = [[1],[0]]) fake_statevector = pipeparts.mkgeneric(pipeline, fake_statevector, "lal_bitvectorgen", threshold=0.1, bit_vector=1) fake_coherence = pipeparts.mkgeneric(pipeline, tee, "pow", exponent=0) fake_coherence = pipeparts.mkgeneric(pipeline, fake_coherence, "lal_demodulate", line_frequency=0.10) fake_coherence = pipeparts.mkgeneric(pipeline, fake_coherence, "lal_togglecomplex") fake_coherence = pipeparts.mkgeneric(pipeline, fake_coherence, "lal_matrixmixer", matrix = [[1],[0]]) fake_coherence = pipeparts.mkgeneric(pipeline, fake_coherence, "lal_bitvectorgen", threshold=0.15, bit_vector=1) re, im = calibration_parts.smooth_complex_kappas(pipeline, kappas, fake_statevector, fake_coherence, real_expected, imag_expected, N, Nav) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, re), "%s_re_kappa_out.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, im), "%s_im_kappa_out.dump" % name) # # done # return pipeline
def lal_property_test_01(pipeline, name): # # This test makes a stream changing between 2's and 8's. # It should square the 2's and take the 8's to the 8th power. # rate = 512 # Hz width = 64 buffer_length = 1.0 # seconds test_duration = 100.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.0 control_dump_filename = "control_property_test_01.dump" bad_data_intervals2 = [0.0, 1e35] bad_data_intervals = [-1e35, 1e-35] head = test_common.test_src(pipeline, buffer_length=buffer_length, rate=rate, width=width, channels=1, test_duration=test_duration, wave=0, freq=0.1, volume=1) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals, insert_gap=False, fill_discont=True, replace_value=2.0) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals2, insert_gap=False, fill_discont=True, replace_value=8.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.dump" % name) lal_prop_exponent = pipeparts.mkgeneric(pipeline, head, "lal_property", update_when_change=True) head = calibration_parts.mkpow(pipeline, head, exponent=0.0) lal_prop_exponent.connect("notify::current-average", calibration_parts.update_property_simple, head, "current_average", "exponent", 1) 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_insertgap_test_02(pipeline, name): # # This tests the element's treatment of complex data streams. # rate = 1000 # Hz width = 32 buffer_length = 1.0 # seconds test_duration = 100.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.0 control_dump_filename = "control_insertgap_test_01.dump" #bad_data_intervals = numpy.random.random((4,)).astype("float64") #bad_data_intervals2 = numpy.random.random((4,)).astype("float64") bad_data_intervals = [-1e35, -1.0, -0.5, 1e35] bad_data_intervals2 = [-1e35, 0.5, 1.0, 1e35] head = test_common.gapped_test_src( pipeline, buffer_length=buffer_length, rate=rate, width=width, channels=2, test_duration=test_duration, wave=0, freq=1, volume=1, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename=control_dump_filename) head = pipeparts.mktogglecomplex(pipeline, head) #head = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, width = width, channels = 1, test_duration = test_duration, wave = 5, freq = 0, volume = 1) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals, insert_gap=True, fill_discont=True, replace_value=3.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.dump" % name) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals2, insert_gap=True, remove_gap=True, fill_discont=True, replace_value=7.0) pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) # # done # return pipeline
def lal_resample_04(pipeline, name): # # This test passes noise through the resampler, downsampling and then upsampling # rate_in = 16384 # Hz rate_out = 2048 # Hz buffer_length = 1.0 # seconds test_duration = 10 # seconds quality = 5 # # build pipeline # head = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, freq=0.0, rate=rate_in, test_duration=test_duration, width=64) #head = calibration_parts.mkinsertgap(pipeline, head, bad_data_intervals = [-2, 2]) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name) head = pipeparts.mkgeneric(pipeline, head, "splitcounter") head = calibration_parts.mkresample( pipeline, head, quality, False, "audio/x-raw,format=F64LE,rate=%d" % rate_out) head = pipeparts.mkgeneric(pipeline, head, "splitcounter") head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_down.txt" % name) head = calibration_parts.mkresample( pipeline, head, quality, False, "audio/x-raw,format=F64LE,rate=%d" % rate_in) pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) # # done # return pipeline
def complex_pow_02(pipeline, name): buffer_length = 1.0 rate = 2048 width = 32 test_duration = 10.0 freq = 0 is_live = False src = pipeparts.mkaudiotestsrc(pipeline, wave=5, freq=freq, blocksize=8 * int(buffer_length * rate), volume=1, num_buffers=int(test_duration / buffer_length), is_live=is_live) src = pipeparts.mkcapsfilter( pipeline, src, "audio/x-raw, format=F%d%s, rate=%d, channels=1, width=%d, channel-mask=0, endianness=1234" % (width, BYTE_ORDER, rate, width)) tee = pipeparts.mktee(pipeline, src) out = pipeparts.mkgeneric(pipeline, None, "interleave") pipeparts.mkqueue(pipeline, tee).link(out) pipeparts.mkqueue(pipeline, tee).link(out) out = pipeparts.mkaudiorate(pipeline, out) mix = numpy.random.random((2, 2)).astype("float64") out = pipeparts.mkmatrixmixer(pipeline, out, matrix=mix) out = pipeparts.mktogglecomplex(pipeline, out) outtee = pipeparts.mktee(pipeline, out) pipeparts.mknxydumpsink(pipeline, outtee, "before_pow_02.dump") out = pipeparts.mkqueue(pipeline, outtee) out = pipeparts.mktogglecomplex(pipeline, out) out = pipeparts.mkgeneric(pipeline, out, "complex_pow", exponent=2) out = pipeparts.mktogglecomplex(pipeline, out) pipeparts.mknxydumpsink(pipeline, out, "after_pow_02.dump") return pipeline
def lal_insertgap_test_01(pipeline, name): # # This test should first replace negative numbers with zeros, and then replace them. # rate = 1000 # Hz width = 64 buffer_length = 1.0 # seconds test_duration = 100.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.0 control_dump_filename = "control_insertgap_test_01.dump" #bad_data_intervals = numpy.random.random((4,)).astype("float64") #bad_data_intervals2 = numpy.random.random((4,)).astype("float64") bad_data_intervals = [-1e35, -1.0, 0.0, 1e35] bad_data_intervals2 = [-1e35, 0.0, 0.0, 1e35] head = test_common.gapped_test_src( pipeline, buffer_length=buffer_length, rate=rate, width=width, channels=1, test_duration=test_duration, wave=0, freq=1, volume=1, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename=control_dump_filename) #head = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, width = width, channels = 1, test_duration = test_duration, wave = 5, freq = 0, volume = 1) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals, insert_gap=False, fill_discont=True, replace_value=0.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.dump" % name) head = pipeparts.mkgeneric(pipeline, head, "lal_insertgap", bad_data_intervals=bad_data_intervals2, insert_gap=True, fill_discont=True, replace_value=7.0) pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name) # # done # return pipeline
def lal_constantupsample_04(pipeline, name): # # This is a simple test to see that the element treats gaps correctly for complex data # in_rate = 10 # Hz out_rate = 20 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.02 # Hz control_dump_filename = "control.dump" # # build pipeline # src = test_common.gapped_test_src( pipeline, buffer_length=buffer_length, channels=2, rate=in_rate, test_duration=test_duration, width=64, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename=control_dump_filename) test_duration = 10.0 # seconds togglecomplex1 = pipeparts.mktogglecomplex(pipeline, src) capsfilter1 = pipeparts.mkcapsfilter( pipeline, togglecomplex1, "audio/x-raw, format=Z128LE, rate=%d" % int(in_rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink( pipeline, pipeparts.mkqueue(pipeline, pipeparts.mktogglecomplex(pipeline, tee1)), "%s_in.dump" % name) upsample = pipeparts.mkgeneric(pipeline, tee1, "lal_constantupsample") capsfilter2 = pipeparts.mkcapsfilter( pipeline, upsample, "audio/x-raw, format=Z128LE, rate=%d" % int(out_rate)) #checktimestamps = pipeparts.mkchecktimestamps(pipeline, capsfilter2) pipeparts.mknxydumpsink( pipeline, pipeparts.mkqueue(pipeline, pipeparts.mktogglecomplex(pipeline, capsfilter2)), "%s_out.dump" % name) # # done # return pipeline
def fill_silence_test_01(pipeline, name, line_sep=0.5): # # This test is intended to help get rid of error messages associated with adding two streams that have different start times # rate = 16 # Hz buffer_length = 1.0 # seconds test_duration = 300.0 # seconds filter_latency = 1.0 # # build pipeline # head = test_common.test_src(pipeline, rate=rate, test_duration=test_duration, wave=5) head = pipeparts.mktee(pipeline, head) smooth = calibration_parts.mkcomplexfirbank( pipeline, head, latency=int((rate * 40 - 1) * filter_latency + 0.5), fir_matrix=[numpy.ones(rate * 40)], time_domain=True) smooth = calibration_parts.mkcomplexfirbank(pipeline, smooth, latency=23, fir_matrix=[numpy.ones(45)], time_domain=True) #smooth = pipeparts.mkgeneric(pipeline, head, "lal_smoothkappas", array_size = rate * 128, avg_array_size = rate * 10, filter_latency = 1) #smooth = pipeparts.mkgeneric(pipeline, smooth, "splitcounter", name = "smooth") #head = pipeparts.mkgeneric(pipeline, head, "splitcounter", name = "unsmooth") #channelmux_input_dict = {} #channelmux_input_dict["unsmooth"] = calibration_parts.mkqueue(pipeline, head) #channelmux_input_dict["smooth"] = calibration_parts.mkqueue(pipeline, smooth) #mux = pipeparts.mkframecppchannelmux(pipeline, channelmux_input_dict, frame_duration = 64, frames_per_file = 1, compression_scheme = 6, compression_level = 3) head = calibration_parts.mkadder( pipeline, calibration_parts.list_srcs(pipeline, head, smooth)) #mux = pipeparts.mkgeneric(pipeline, mux, "splitcounter", name = "sum") #head = calibration_parts.mkgate(pipeline, smooth, head, 0) pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) #pipeparts.mkframecppfilesink(pipeline, mux, frame_type = "H1DCS", instrument = "H1") # # done # return pipeline
def lal_transferfunction_04(pipeline, name): # # This test produces three-channel data to be read into lal_transferfunction # rate = 16384 # Hz buffer_length = 1.0 # seconds test_duration = 500.0 # seconds width = 64 # bits channels = 1 freq = 512 # Hz # # build pipeline # hoft = test_common.test_src(pipeline, buffer_length=buffer_length, wave=5, volume=1, freq=freq, channels=channels, rate=rate, test_duration=test_duration, width=width, verbose=False) hoft = pipeparts.mktee(pipeline, hoft) shifted_hoft = pipeparts.mkgeneric(pipeline, hoft, "lal_shift", shift=35024) interleaved_data = calibration_parts.mkinterleave( pipeline, calibration_parts.list_srcs(pipeline, hoft, shifted_hoft)) pipeparts.mkgeneric(pipeline, interleaved_data, "lal_transferfunction", fft_length=4 * rate, fft_overlap=2 * rate, num_ffts=64, update_samples=rate * test_duration, make_fir_filters=1, fir_length=rate, update_after_gap=True, filename="lpfilter.txt") return pipeline
def gapped_test_src(pipeline, buffer_length=1.0, rate=2048, width=64, channels=1, test_duration=10.0, wave=5, freq=0, volume=0.8, gap_frequency=None, gap_threshold=None, control_dump_filename=None, is_live=False, verbose=True): src = test_src(pipeline, buffer_length=buffer_length, rate=rate, width=width, channels=channels, test_duration=test_duration, wave=wave, freq=freq, volume=volume, is_live=is_live, verbose=verbose) if gap_frequency is None: return src control = pipeparts.mkcapsfilter( pipeline, pipeparts.mkaudiotestsrc(pipeline, wave=0, freq=gap_frequency, blocksize=8 * int(buffer_length * rate), volume=1, num_buffers=int(test_duration / buffer_length)), "audio/x-raw, format=F32%s, rate=%d, channels=1" % (BYTE_ORDER, rate)) if control_dump_filename is not None: control = pipeparts.mktee(pipeline, control) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, control), control_dump_filename) control = pipeparts.mkqueue(pipeline, control) return pipeparts.mkgate(pipeline, src, control=control, threshold=gap_threshold)
def mkcontrolsnksrc(pipeline, rate, verbose=False, suffix=None, control_peak_samples=None): """! This function implements a portion of a gstreamer graph to provide a control signal for deciding when to reconstruct physical SNRS @param pipeline A reference to the gstreamer pipeline in which to add this graph @param rate An integer representing the target sample rate of the resulting src @param verbose Make verbose @param suffix Log name for verbosity @param control_peak_samples If nonzero, this would do peakfinding on the control signal with the window specified by this parameter. The peak finding would give a single sample of "on" state at the peak. This will cause far less CPU to be used if you only want to reconstruct SNR around the peak of the control signal. """ # # start with an adder and caps filter to select a sample rate # snk = pipeparts.mkadder(pipeline, None) src = pipeparts.mkcapsfilter(pipeline, snk, "audio/x-raw, rate=%d" % rate) # # Add a peak finder on the control signal sample number # if control_peak_samples > 0: src = pipeparts.mkpeak(pipeline, src, control_peak_samples) # # verbosity and a tee # logname = suffix and "_%s" % suffix or "" if verbose: src = pipeparts.mkprogressreport(pipeline, src, "progress_sumsquares%s" % logname) src = pipeparts.mkchecktimestamps(pipeline, src, "timestamps%s_sumsquares" % logname) src = pipeparts.mktee(pipeline, src) # # return the adder and tee # return snk, src
def lal_logicalundersample_02(pipeline, name): # # This is similar to the one above, but here, we wish to see how logicalundersample handles unsigned input data. # There is quite possibly a better way to do this... # in_rate = 1024 # Hz out_rate = 512 # Hz odd_inputs = 137 # the odd unsigned int's that, when occurring in pairs, should cause an output of "1". buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build the pipeline # src = pipeparts.mkaudiotestsrc(pipeline, num_buffers=int(test_duration / buffer_length), wave=5) capsfilter1 = pipeparts.mkcapsfilter( pipeline, src, "audio/x-raw, format=S32LE, rate=%d" % int(in_rate)) undersample1 = pipeparts.mkgeneric(pipeline, capsfilter1, "lal_logicalundersample", status_out=odd_inputs) capsfilter2 = pipeparts.mkcapsfilter( pipeline, undersample1, "audio/x-raw, format=U32LE, rate=%d" % int(in_rate)) tee1 = pipeparts.mktee(pipeline, capsfilter2) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee1), "%s_in.dump" % name) undersample2 = pipeparts.mkgeneric(pipeline, tee1, "lal_logicalundersample") capsfilter3 = pipeparts.mkcapsfilter( pipeline, undersample2, "audio/x-raw, format=U32LE, rate=%d" % int(out_rate)) #checktimestamps = pipeparts.mkchecktimestamps(pipeline, capsfilter2) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, capsfilter3), "%s_out.dump" % name) # # done # return pipeline
def lal_constantupsample_03(pipeline, name): # # This is a simple test that the sample rates are adjusted as expected for complex data # in_rate = 1 # Hz out_rate = 10 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # src = test_common.test_src(pipeline, buffer_length=buffer_length, channels=2, rate=in_rate, test_duration=test_duration, width=64) togglecomplex1 = pipeparts.mktogglecomplex(pipeline, src) capsfilter1 = pipeparts.mkcapsfilter( pipeline, togglecomplex1, "audio/x-raw, format=Z128LE, rate=%d" % int(in_rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink( pipeline, pipeparts.mkqueue(pipeline, pipeparts.mktogglecomplex(pipeline, tee1)), "%s_in.dump" % name) upsample = pipeparts.mkgeneric(pipeline, tee1, "lal_constantupsample") capsfilter2 = pipeparts.mkcapsfilter( pipeline, upsample, "audio/x-raw, format=Z128LE, rate=%d" % int(out_rate)) #checktimestamps = pipeparts.mkchecktimestamps(pipeline, capsfilter2) pipeparts.mknxydumpsink( pipeline, pipeparts.mkqueue(pipeline, pipeparts.mktogglecomplex(pipeline, capsfilter2)), "%s_out.dump" % name) # # done # return pipeline
def lal_resample_01(pipeline, name): # # This test passes an impulse through the resampler # rate_in = 128 # Hz rate_out = 1024 # Hz buffer_length = 0.77 # seconds test_duration = 30.0 # seconds quality = 5 # # build pipeline # head = test_common.test_src(pipeline, buffer_length=buffer_length, wave=0, freq=0.25, rate=rate_in, test_duration=test_duration, width=64) head = calibration_parts.mkinsertgap( pipeline, head, bad_data_intervals=[0.999999999, 1.00000001], block_duration=int(0.5 * Gst.SECOND), insert_gap=False, replace_value=0.0) head = pipeparts.mktee(pipeline, head) pipeparts.mknxydumpsink(pipeline, head, "%s_in.txt" % name) head = pipeparts.mkgeneric(pipeline, head, "splitcounter") head = calibration_parts.mkresample( pipeline, head, quality, False, "audio/x-raw,format=F64LE,rate=%d" % rate_out) head = pipeparts.mkgeneric(pipeline, head, "splitcounter") pipeparts.mknxydumpsink(pipeline, head, "%s_out.txt" % name) # # 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_02(pipeline, name): # # This is similar to the above test, and makes sure the element treats gaps correctly # rate = 1000 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.2 # Hz control_dump_filename = "control_demodulate_02.dump" src = test_common.gapped_test_src( pipeline, buffer_length=buffer_length, rate=rate, width=64, test_duration=test_duration, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename=control_dump_filename) capsfilter1 = pipeparts.mkcapsfilter( pipeline, src, "audio/x-raw, format=F64LE, rate=%d" % int(rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee1), "%s_in.dump" % name) demodulate = pipeparts.mkgeneric(pipeline, tee1, "lal_demodulate") capsfilter2 = pipeparts.mkcapsfilter( pipeline, demodulate, "audio/x-raw, format=Z128LE, rate=%d" % int(rate)) togglecomplex = pipeparts.mktogglecomplex(pipeline, capsfilter2) capsfilter3 = pipeparts.mkcapsfilter( pipeline, togglecomplex, "audio/x-raw, format=F64LE, rate=%d" % int(rate)) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, capsfilter3), "%s_out.dump" % name) # # done # return pipeline
def lal_logicalundersample_01(pipeline, name): # # This is a simple test that the undersample element outputs "1" if a pair of two consecutive inputs are odd and "0" otherwise. # Note that the pairing must be such that the two inputs are combined in the logical operation. # in_rate = 1024 # Hz out_rate = 512 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # src = test_common.int_test_src(pipeline, buffer_length=buffer_length, rate=in_rate, width=32, test_duration=test_duration) # src = pipeparts.mkaudiotestsrc(pipeline, num_buffers = int(test_duration / buffer_length)) capsfilter1 = pipeparts.mkcapsfilter( pipeline, src, "audio/x-raw, format=S32LE, rate=%d" % int(in_rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink(pipeline, tee1, "%s_in.txt" % name) undersample = pipeparts.mkgeneric(pipeline, tee1, "lal_logicalundersample", required_on=1, required_off=2, invert_result=True) capsfilter2 = pipeparts.mkcapsfilter( pipeline, undersample, "audio/x-raw, format=S32LE, rate=%d" % int(out_rate)) #checktimestamps = pipeparts.mkchecktimestamps(pipeline, capsfilter2) pipeparts.mknxydumpsink(pipeline, capsfilter2, "%s_out.txt" % name) # # done # return pipeline
def lal_demodulate_01(pipeline, name): # # This test is to check that the inputs are multiplied by exp(2*pi*i*f*t) using the correct timestamps # rate = 1000 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds # # build pipeline # src = test_common.test_src(pipeline, buffer_length=buffer_length, rate=rate, test_duration=test_duration, width=32) capsfilter1 = pipeparts.mkcapsfilter( pipeline, src, "audio/x-raw, format=F32LE, rate=%d" % int(rate)) tee1 = pipeparts.mktee(pipeline, capsfilter1) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee1), "%s_in.dump" % name) demodulate = pipeparts.mkgeneric(pipeline, tee1, "lal_demodulate", line_frequency=100) capsfilter2 = pipeparts.mkcapsfilter( pipeline, demodulate, "audio/x-raw, format=Z64LE, rate=%d" % int(rate)) togglecomplex = pipeparts.mktogglecomplex(pipeline, capsfilter2) capsfilter3 = pipeparts.mkcapsfilter( pipeline, togglecomplex, "audio/x-raw, format=F32LE, rate=%d" % int(rate)) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, capsfilter3), "%s_out.dump" % name) # # done # return pipeline
def lal_logical_undersampler_02(pipeline, name): # # This is a simple test to make sure the element treats gaps correctly # in_rate = 10 # Hz out_rate = 1 # Hz buffer_length = 1.0 # seconds test_duration = 10.0 # seconds gap_frequency = 0.1 # Hz gap_threshold = 0.1 # Hz control_dump_filename = "control.dump" head = test_common.gapped_test_src_ints( pipeline, buffer_length=buffer_length, rate=in_rate, test_duration=test_duration, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename=control_dump_filename) head = tee = pipeparts.mktee(pipeline, head) head = pipeparts.mkgeneric(pipeline, tee, "lal_logical_undersampler", required_on=0x1, status_out=0x7) head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw-int, rate=%d" % int(out_rate)) head = pipeparts.mkchecktimestamps(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_out.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee), "%s_in.dump" % name) # # done # return pipeline
def lal_logical_undersampler_03(pipeline, name): # # This test reads in a gwf file that has certain bits off to test # the logic of the element # Note: To run this test you must first make a frame cache, which can be done with the # following command: # ls *.gwf | lalapps_path2cache > frame.cache # out_rate = 1 src = pipeparts.mklalcachesrc(pipeline, location="frame.cache", cache_dsc_regex="L1") demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum=True, skip_bad_files=True) head = pipeparts.mkqueue(pipeline, None) pipeparts.src_deferred_link(demux, "L1:TEST-CHANNEL", head.get_pad("sink")) head = tee = pipeparts.mktee(pipeline, head) head = pipeparts.mkgeneric(pipeline, tee, "lal_logical_undersampler", required_on=0x1, status_out=0x7) head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw-int, rate=%d" % int(out_rate)) head = pipeparts.mkchecktimestamps(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_out.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee), "%s_in.dump" % name) # # done # return pipeline