Beispiel #1
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
Beispiel #2
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 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
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
Beispiel #5
0
def lal_transferfunction_01(pipeline, name):

    #
    # This test adds various noise into a stream and uses lal_transferfunction to remove it
    #

    rate = 16384  # Hz
    buffer_length = 1.0  # seconds
    test_duration = 3000.0  # seconds
    width = 64  # bits

    #
    # build pipeline
    #

    hoft = test_common.test_src(pipeline,
                                buffer_length=buffer_length,
                                wave=5,
                                volume=0.001,
                                rate=rate,
                                test_duration=test_duration,
                                width=width,
                                verbose=False)
    hoft = pipeparts.mktee(pipeline, hoft)

    common_noise = test_common.test_src(pipeline,
                                        buffer_length=buffer_length,
                                        wave=5,
                                        freq=512,
                                        volume=1,
                                        rate=rate,
                                        test_duration=test_duration,
                                        width=width,
                                        verbose=False)
    common_noise = pipeparts.mktee(pipeline, common_noise)

    noise1 = test_common.test_src(pipeline,
                                  buffer_length=buffer_length,
                                  wave=5,
                                  freq=512,
                                  volume=1,
                                  rate=rate,
                                  test_duration=test_duration,
                                  width=width,
                                  verbose=False)
    noise1 = calibration_parts.mkadder(
        pipeline, calibration_parts.list_srcs(pipeline, common_noise, noise1))
    noise1 = pipeparts.mktee(pipeline, noise1)
    noise1_for_cleaning = pipeparts.mkgeneric(pipeline, noise1, "identity")
    hoft_noise1 = pipeparts.mkshift(pipeline, noise1, shift=00000000)
    hoft_noise1 = pipeparts.mkaudioamplify(pipeline, hoft_noise1, 2)
    hoft_noise1 = pipeparts.mktee(pipeline, hoft_noise1)

    noise2 = test_common.test_src(pipeline,
                                  buffer_length=buffer_length,
                                  wave=5,
                                  freq=1024,
                                  volume=1,
                                  rate=rate,
                                  test_duration=test_duration,
                                  width=width,
                                  verbose=False)
    noise2 = calibration_parts.mkadder(
        pipeline, calibration_parts.list_srcs(pipeline, common_noise, noise2))
    noise2 = pipeparts.mktee(pipeline, noise2)
    noise2_for_cleaning = pipeparts.mkgeneric(pipeline, noise2, "identity")
    hoft_noise2 = pipeparts.mkshift(pipeline, noise2, shift=00000)
    hoft_noise2 = pipeparts.mkaudioamplify(pipeline, hoft_noise2, 3)
    hoft_noise2 = pipeparts.mktee(pipeline, hoft_noise2)

    noisy_hoft = calibration_parts.mkadder(
        pipeline,
        calibration_parts.list_srcs(pipeline, hoft, hoft_noise1, hoft_noise2))
    noisy_hoft = pipeparts.mktee(pipeline, noisy_hoft)

    clean_hoft = calibration_parts.clean_data(
        pipeline,
        calibration_parts.list_srcs(pipeline, noisy_hoft, noise1_for_cleaning,
                                    noise2_for_cleaning), rate / 4, rate / 8,
        16384, test_duration * rate)
    clean_hoft = pipeparts.mktee(pipeline, clean_hoft)

    #	hoft_inv = pipeparts.mkpow(pipeline, hoft, exponent = -1.0)
    #	clean_hoft_over_hoft = calibration_parts.mkmultiplier(pipeline, calibration_parts.list_srcs(pipeline, hoft_inv, clean_hoft))
    #	pipeparts.mknxydumpsink(pipeline, clean_hoft_over_hoft, "%s_clean_hoft_over_hoft.txt" % name)

    pipeparts.mknxydumpsink(pipeline, hoft, "%s_hoft.txt" % name)
    pipeparts.mknxydumpsink(pipeline, hoft_noise1, "%s_hoft_noise1.txt" % name)
    pipeparts.mknxydumpsink(pipeline, hoft_noise2, "%s_hoft_noise2.txt" % name)
    pipeparts.mknxydumpsink(pipeline, noisy_hoft, "%s_noisy_hoft.txt" % name)
    pipeparts.mknxydumpsink(pipeline, clean_hoft, "%s_clean_hoft.txt" % name)

    #
    # done
    #

    return pipeline
Beispiel #6
0
def lal_transferfunction_03(pipeline, name):

    #
    # This test produces three-channel data to be read into lal_transferfunction
    #

    rate = 16384  # Hz
    buffer_length = 1.0  # seconds
    test_duration = 50.0  # seconds
    width = 64  # bits
    freq = 512  # Hz
    num_witnesses = 2
    witness_factor = 0.5  # Ratio of amplitudes of witness / signal

    #
    # build pipeline
    #

    hoft = test_common.test_src(pipeline,
                                buffer_length=buffer_length,
                                wave=5,
                                volume=1,
                                freq=freq,
                                channels=1,
                                rate=rate,
                                test_duration=test_duration,
                                width=width,
                                verbose=False)
    hoft = pipeparts.mktee(pipeline, hoft)

    noise = []
    for i in range(0, num_witnesses):
        difference = test_common.test_src(pipeline,
                                          buffer_length=buffer_length,
                                          wave=5,
                                          volume=0.001,
                                          channels=1,
                                          rate=rate,
                                          test_duration=test_duration,
                                          width=width,
                                          verbose=False)
        noisy_hoft = calibration_parts.mkadder(
            pipeline,
            calibration_parts.list_srcs(
                pipeline,
                pipeparts.mkaudioamplify(pipeline, hoft, witness_factor),
                difference))
        noisy_hoft = pipeparts.mkprogressreport(pipeline, noisy_hoft,
                                                "noisy_hoft_%d" % i)
        noise.append(noisy_hoft)

    clean_data = calibration_parts.clean_data(pipeline,
                                              hoft,
                                              rate,
                                              noise,
                                              rate,
                                              2 * rate,
                                              rate,
                                              10,
                                              rate * 1000,
                                              rate,
                                              4,
                                              filename="tfs.txt")
    pipeparts.mknxydumpsink(pipeline, hoft, "%s_hoft.txt" % name)
    pipeparts.mknxydumpsink(pipeline, clean_data, "%s_out.txt" % name)

    return pipeline
Beispiel #7
0
def lal_transferfunction_02(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)

    noise = 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)
    noise = pipeparts.mktee(pipeline, noise)

    witness1 = calibration_parts.mkadder(
        pipeline,
        calibration_parts.list_srcs(
            pipeline, calibration_parts.highpass(pipeline,
                                                 hoft,
                                                 rate,
                                                 fcut=400),
            calibration_parts.lowpass(pipeline, noise, rate, fcut=400)))
    witness2 = calibration_parts.mkadder(
        pipeline,
        calibration_parts.list_srcs(
            pipeline, calibration_parts.lowpass(pipeline, hoft, rate,
                                                fcut=600),
            calibration_parts.highpass(pipeline, noise, rate, fcut=600)))

    hoft = calibration_parts.highpass(pipeline, hoft, rate)
    clean_data = calibration_parts.clean_data(
        pipeline,
        hoft,
        rate,
        calibration_parts.list_srcs(pipeline, witness1, witness2),
        rate,
        4 * rate,
        2 * rate,
        128,
        rate * test_duration,
        int(0.5 * rate),
        10.0,
        filename="highpass_lowpass_tfs.txt")
    pipeparts.mknxydumpsink(pipeline, clean_data, "%s_out.txt" % name)

    return pipeline