Exemple #1
0
def queue_03(pipeline, name):

	#
	# Very simple test of data storage in queues
	#

	rate = 1000	     # Hz
	buffer_length = 1.0     # seconds
	test_duration = 100.0   # seconds

	#
	# build pipeline
	#

	src = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, test_duration = test_duration, width = 32)
	head = pipeparts.mkgeneric(pipeline, src, "splitcounter", name = "before_queue")
	head = calibration_parts.mkqueue(pipeline, head, 50)
	head = pipeparts.mkgeneric(pipeline, head, "splitcounter", name = "after_queue")
	pipeparts.mkfakesink(pipeline, head)

	#
	# done
	#

	return pipeline
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
def queue_02(pipeline, name):

	#
	# This test is intended to probe data flow with tees, firbanks, and queues
	#

	rate = 16384		# Hz
	buffer_length = 1.0	# seconds
	test_duration = 100.0	# seconds

	#
	# build pipeline
	#

	src = test_common.test_src(pipeline, buffer_length = buffer_length, rate = rate, test_duration = test_duration, width = 32)
#	tee = pipeparts.mktee(pipeline, src)
	head = pipeparts.mkgeneric(pipeline, src, "splitcounter", name = "before_resample")
	head = calibration_parts.mkresample(pipeline, head, "audio/x-raw, format=F32LE,rate=16")#fir_matrix=[numpy.hanning(600)], latency = 300, time_domain = True)
#	head = calibration_parts.mkinsertgap(pipeline, head, bad_data_intervals = [-1e35, 1e35], block_duration = buffer_length * 1000000000, remove_gap = False)
	head = pipeparts.mkgeneric(pipeline, head, "splitcounter", name = "after_resample")
#	head2 = pipeparts.mkfirbank(pipeline, tee, fir_matrix=[numpy.hanning(1000)], latency = 500, time_domain = True)
#	head2 = calibration_parts.mkinsertgap(pipeline, head2, bad_data_intervals = [-1e35, 1e35], block_duration = buffer_length * 1000000000, remove_gap = False)
#	head2 = pipeparts.mkgeneric(pipeline, tee, "splitcounter", name = "tee_to_adder")
#	head = calibration_parts.mkqueue(pipeline, head, 1)
#	head2 = calibration_parts.mkqueue(pipeline, head2, 1)
#	adder = calibration_parts.mkadder(pipeline, calibration_parts.list_srcs(pipeline, head, head2))
#	head = pipeparts.mkgeneric(pipeline, adder, "splitcounter", name = "before_final_dump")
	pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name)

	#
	# done
	#
	
	return pipeline
Exemple #6
0
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_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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
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
Exemple #11
0
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
Exemple #12
0
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
Exemple #13
0
def lal_matrixsolver_01(pipeline, name):

    #
    # Make a bunch of fake data at 16 Hz to pass through the exact kappas function.
    #

    rate_in = 16  # Hz
    buffer_length = 1.0  # seconds
    test_duration = 300.0  # seconds
    channels = 10 * 11  # inputs to lal_matrixsolver

    #
    # build pipeline
    #

    head = test_common.test_src(pipeline,
                                buffer_length=buffer_length,
                                rate=rate_in,
                                width=64,
                                channels=channels,
                                test_duration=test_duration,
                                wave=5,
                                freq=0)
    streams = calibration_parts.mkdeinterleave(pipeline, head, channels)
    head = calibration_parts.mkinterleave(pipeline, streams)
    solutions = pipeparts.mkgeneric(pipeline, head, "lal_matrixsolver")
    solutions = list(calibration_parts.mkdeinterleave(pipeline, solutions, 10))
    for i in range(10):
        pipeparts.mknxydumpsink(pipeline, solutions[i], "solutions_%d.txt" % i)

    #
    # done
    #

    return pipeline
Exemple #14
0
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
Exemple #15
0
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 detect_change(pipeline, name):
    # Get the data from the frames
    data = pipeparts.mklalcachesrc(pipeline,
                                   location=options.frame_cache,
                                   cache_dsc_regex=options.ifo)
    data = pipeparts.mkframecppchanneldemux(pipeline,
                                            data,
                                            do_file_checksum=False,
                                            skip_bad_files=True,
                                            channel_list=list(
                                                map("%s:%s".__mod__,
                                                    ifo_channel_list)))

    streams = []
    for chan in channel_list:
        stream = calibration_parts.hook_up(pipeline, data, chan, options.ifo,
                                           64.0)
        streams.append(stream)
    summed_streams = calibration_parts.mkadder(pipeline, streams)

    if options.statevector_channel is not None:
        state_vector = calibration_parts.hook_up(pipeline, data,
                                                 options.statevector_channel,
                                                 options.ifo, 64.0)
        state_vector = pipeparts.mkgeneric(pipeline,
                                           state_vector,
                                           "lal_logicalundersample",
                                           required_on=1)
        summed_streams = calibration_parts.mkgate(pipeline,
                                                  summed_streams,
                                                  state_vector,
                                                  threshold=1.0)

    summed_streams = pipeparts.mkgeneric(
        pipeline,
        summed_streams,
        "lal_detectchange",
        average_samples=int(options.average_time * options.sample_rate),
        detection_threshold=options.detection_threshold,
        filename=options.filename)
    pipeparts.mkfakesink(pipeline, summed_streams)

    #
    # done
    #

    return pipeline
Exemple #17
0
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 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_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_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
Exemple #21
0
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 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
Exemple #23
0
def queue_01(pipeline, name):

	#
	# This test is intended to probe data flow with a demuxer
	#

	channel1 = "CAL-CS_TDEP_SUS_LINE1_UNCERTAINTY"
	channel2 = "CAL-CS_TDEP_PCALY_LINE1_UNCERTAINTY"
	channel3 = "CAL-CS_TDEP_PCALY_LINE2_UNCERTAINTY"
	channel4 = "CAL-CS_TDEP_DARM_LINE1_UNCERTAINTY"
	channel5 = "CAL-DARM_ERR_WHITEN_OUT_DBL_DQ"

	channel_list = [("L1", channel1), ("L1", channel2), ("L1", channel3), ("L1", channel4), ("L1", channel5)]

	#
	# build pipeline
	#

	src = pipeparts.mklalcachesrc(pipeline, location = "L1_raw_frames.cache", cache_dsc_regex = "L1")
	demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum = False, skip_bad_files = True, channel_list = map("%s:%s".__mod__, channel_list))
	channel1 = calibration_parts.hook_up_and_queue(pipeline, demux, channel1, "L1", 1.0)
	channel2 = calibration_parts.hook_up_and_queue(pipeline, demux, channel2, "L1", 1.0)
	channel3 = calibration_parts.hook_up_and_queue(pipeline, demux, channel3, "L1", 1.0)
	channel4 = calibration_parts.hook_up_and_queue(pipeline, demux, channel4, "L1", 1.0)
	channel5 = calibration_parts.hook_up_and_queue(pipeline, demux, channel5, "L1", 1.0)
	channel1 = pipeparts.mkgeneric(pipeline, channel1, "splitcounter", name = "channel1_1")
	channel2 = pipeparts.mkgeneric(pipeline, channel2, "splitcounter", name = "channel2_1")
	channel3 = pipeparts.mkgeneric(pipeline, channel3, "splitcounter", name = "channel3_1")
	channel4 = pipeparts.mkgeneric(pipeline, channel4, "splitcounter", name = "channel4_1")
	channel5 = pipeparts.mkgeneric(pipeline, channel5, "splitcounter", name = "channel5_1")
	pipeparts.mknxydumpsink(pipeline, channel1, "%s_channel1.dump" % name)
	pipeparts.mknxydumpsink(pipeline, channel2, "%s_channel2.dump" % name)
	pipeparts.mknxydumpsink(pipeline, channel3, "%s_channel3.dump" % name)
	pipeparts.mknxydumpsink(pipeline, channel4, "%s_channel4.dump" % name)
	pipeparts.mknxydumpsink(pipeline, channel5, "%s_channel5.dump" % name)

	#
	# done
	#

	return pipeline
Exemple #24
0
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 deinterleave_01(pipeline, name):

    buffer_length = 1.0
    rate = 2048
    width = 64
    channels = 2
    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=2, layout=interleaved" %
        (width, BYTE_ORDER, rate))

    elem = pipeparts.mkgeneric(pipeline, src, "deinterleave")
    out1 = pipeparts.mkqueue(pipeline, None)
    out2 = pipeparts.mkqueue(pipeline, None)
    pipeparts.src_deferred_link(elem, "src_0", out1.get_static_pad("sink"))
    pipeparts.src_deferred_link(elem, "src_1", out2.get_static_pad("sink"))
    #out1 = pipeparts.mkaudioconvert(pipeline, out1)
    out1 = pipeparts.mkcapsfilter(
        pipeline, out1,
        "audio/x-raw, format=F%d%s, rate=%d, channels=1, layout=interleaved" %
        (width, BYTE_ORDER, rate))
    #out2 = pipeparts.mkaudioconvert(pipeline, out2)
    out2 = pipeparts.mkcapsfilter(
        pipeline, out2,
        "audio/x-raw, format=F%d%s, rate=%d, channels=1, layout=interleaved" %
        (width, BYTE_ORDER, rate))

    pipeparts.mknxydumpsink(pipeline, out1, "out1.dump")
    pipeparts.mknxydumpsink(pipeline, out2, "out2.dump")
    #pipeparts.mkfakesink(pipeline, out1)
    #pipeparts.mkfakesink(pipeline, out2)

    return pipeline
Exemple #26
0
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
Exemple #27
0
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_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_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_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
#
#                                    Main
#
# =============================================================================
#

#
# Set the pipeline up
#

pipeline = gst.Pipeline("veto_receiver")
mainloop = gobject.MainLoop()
handler = simplehandler.Handler(mainloop,pipeline)

# Create the tcpserversrc 
tcpsrc = pipeparts.mkgeneric(pipeline, None, "tcpserversrc")
tcpsrc.set_property("protocol", "GST_TCP_PROTOCOL_GDP")
tcpsrc.set_property("host", options.tcp_host)
tcpsrc.set_property("port", options.tcp_port)

# Final destination.
if options.output_type == "fake":
    fakesink = pipeparts.mkfakesink(pipeline, tcpsrc)    
    fs_pad = fakesink.get_pad("sink")
    fs_pad.add_event_probe(probeEventHandler)
    fs_pad.add_buffer_probe(probeBufferHandler) 
elif options.output_type == "multicast":
    fx = pipeparts.mkgeneric(pipeline, tcpsrc, "gds_framexmitsink", 
        multicast_group = options.multicast_group,
        multicast_iface = options.multicast_network,
        port = options.multicast_port, sync=False)
#obsStr = options.input_prefix.split('-')[0]
obsStr = options.input_prefix[0]
if not options.instrument.startswith(obsStr):
    raise ValueError("Output channel instrument clashes with input prefix.")

# Setup the source class
if options.init_time > 0:
    init_time = options.init_time
else:
    init_time = None
vsrc = vetosrc.vetoSource(options.input_path, options.input_prefix,
            options.input_ext, options.wait_time, init_time, options.dir_digits, 
            options.log_file, options.idq_log_file)

# Create the appsrc with accoutrements
appsrc = pipeparts.mkgeneric(pipeline, None, "appsrc", caps=gst.Caps(vsrc.caps), 
    format="time")
appsrc.connect('need-data', vsrc.need_data)

# Set debug level for logging purposes
gst.debug_set_threshold_for_name('python', gst.LEVEL_INFO)

# Define the muxer.
mux = pipeparts.mkframecppchannelmux(pipeline, None, 
    frames_per_file = options.frames_per_file, 
    frame_duration = options.frame_duration)

# Link the source to the muxer. 
appsrc.get_pad("src").link(mux.get_pad(options.instrument + ':' + options.channel_name))

# XXX Hacking. Attach probe to the muxer.
hc = handlerClass()