Example #1
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
def deinterleave_02(pipeline, name):

    buffer_length = 1.0
    rate = 2048
    width = 64
    channels = 3
    test_duration = 10.0
    freq = 10
    is_live = False

    src = test_common.test_src(pipeline,
                               wave=5,
                               freq=freq,
                               test_duration=test_duration,
                               volume=1,
                               width=64,
                               rate=rate,
                               channels=channels,
                               verbose=False)
    streams = calibration_parts.mkdeinterleave(pipeline, src, channels)
    for i in range(0, channels):
        pipeparts.mknxydumpsink(pipeline, streams[i],
                                "%s_stream%d.txt" % (name, i))

    return pipeline
Example #3
0
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
Example #4
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
Example #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
Example #6
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
Example #7
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 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
Example #9
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
Example #10
0
def frame_manipulator(pipeline, name):

    #
    # This pipeline reads the channels needed for calibration from the raw frames
    # and writes them to smaller frames for faster access.
    #

    head_dict = {}

    # Get the data from the raw frames and pick out the channels we want
    src = pipeparts.mklalcachesrc(pipeline,
                                  location=frame_cache,
                                  cache_dsc_regex=ifo)
    src = pipeparts.mkprogressreport(pipeline, src, "start")
    demux = pipeparts.mkframecppchanneldemux(pipeline,
                                             src,
                                             do_file_checksum=False,
                                             skip_bad_files=True,
                                             channel_list=list(
                                                 map("%s:%s".__mod__,
                                                     ifo_channel_list)))

    # Make a muxer to collect the channels we need
    channelmux_input_dict = {}
    for key, chan in zip(channel_list, channel_list):
        head_dict[key] = calibration_parts.hook_up(pipeline, demux, chan, ifo,
                                                   1.0)
        head_dict[key] = pipeparts.mkprogressreport(pipeline, head_dict[key],
                                                    "before muxer %s" % key)
        channelmux_input_dict["%s:%s" %
                              (ifo, chan)] = calibration_parts.mkqueue(
                                  pipeline, head_dict[key])

    if output_path == 'txt':
        for chan in channel_list:
            pipeparts.mknxydumpsink(
                pipeline, channelmux_input_dict["%s:%s" % (ifo, chan)],
                "%s-%s.txt" % (ifo, chan))
    else:
        mux = pipeparts.mkframecppchannelmux(pipeline,
                                             channelmux_input_dict,
                                             frame_duration=frame_length,
                                             frames_per_file=frames_per_file,
                                             compression_scheme=6,
                                             compression_level=3)
        mux = pipeparts.mkprogressreport(pipeline, mux, "end")
        pipeparts.mkframecppfilesink(pipeline,
                                     mux,
                                     frame_type=frame_type,
                                     path=output_path,
                                     instrument=ifo)

    #
    # done
    #

    return pipeline
Example #11
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
Example #12
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
Example #13
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
Example #14
0
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 compute_RMS_timeseries(pipeline, name):
	# Get the data from the frames
	for i in range(len(channel_list)):
		data = pipeparts.mklalcachesrc(pipeline, location = frame_cache_list[i], cache_dsc_regex = ifo)
		data = pipeparts.mkframecppchanneldemux(pipeline, data, do_file_checksum = False, skip_bad_files = True, channel_list = list(map("%s:%s".__mod__, channel_list)))
		data = calibration_parts.hook_up(pipeline, data, channel_list[i][1], ifo, 1.0)
		data = calibration_parts.caps_and_progress(pipeline, data, "audio/x-raw,format=F64LE", labels[i])
		RMS = calibration_parts.compute_rms(pipeline, data, rates[i], average_time, filter_length = 10.0, f_min = fmin, f_max = fmax, rate_out = 1)
		pipeparts.mknxydumpsink(pipeline, RMS, "%s_RMS_%s_%d-%d.txt" % (ifo, labels[i].replace(' ', '_'), gps_start_time, data_duration))

	#
	# done
	#

	return pipeline
Example #16
0
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 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
Example #18
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
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
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
Example #21
0
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
Example #22
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
Example #23
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 lal_multiple_srcs(pipeline, name):

    #
    # This test uses multiple source elements
    #

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

    #
    # build pipeline
    #

    src1 = test_common.test_src(pipeline,
                                buffer_length=buffer_length,
                                rate=rate,
                                test_duration=test_duration,
                                width=32,
                                verbose=False)
    capsfilter1 = pipeparts.mkcapsfilter(
        pipeline, src1, "audio/x-raw, format=F32LE, rate=%d" % int(rate))
    src2 = test_common.test_src(pipeline,
                                buffer_length=buffer_length,
                                rate=rate,
                                test_duration=test_duration,
                                width=32,
                                verbose=False)
    capsfilter2 = pipeparts.mkcapsfilter(
        pipeline, src2, "audio/x-raw, format=F32LE, rate=%d" % int(rate))

    combined = calibration_parts.mkadder(
        pipeline,
        calibration_parts.list_srcs(pipeline, capsfilter1, capsfilter2))
    pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, combined),
                            "multiple_srcs_out.dump")

    #
    # 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
Example #27
0
def exact_kappas_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
    num_stages = 1  # stages of actuation

    freqs = [17.1, 410.1, 17.6]  # 16.4, 15.6]
    EPICS = []
    for i in range(2 * (1 + num_stages) * (2 + num_stages)):
        EPICS.append(numpy.random.rand())

    #
    # build pipeline
    #

    X = []
    for i in range(2 + num_stages):
        X.append(
            test_common.complex_test_src(pipeline,
                                         buffer_length=buffer_length,
                                         rate=rate_in,
                                         width=64,
                                         test_duration=test_duration,
                                         wave=5,
                                         freq=0,
                                         src_suffix=str(i)))
    kappas = calibration_parts.compute_exact_kappas_from_filters_file(
        pipeline, X, freqs, EPICS, rate_in)
    for i in range(4 + 2 * num_stages):
        pipeparts.mknxydumpsink(pipeline, kappas[i], "kappas_%d.txt" % i)

    #
    # done
    #

    return pipeline
Example #28
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
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 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