Exemplo n.º 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
Exemplo n.º 2
0
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 pcal2darm(pipeline, name):

    # Get pcal from the raw frames
    raw_data = pipeparts.mklalcachesrc(pipeline,
                                       location=options.raw_frame_cache,
                                       cache_dsc_regex=ifo)
    raw_data = pipeparts.mkframecppchanneldemux(
        pipeline,
        raw_data,
        do_file_checksum=False,
        skip_bad_files=True,
        channel_list=list(map("%s:%s".__mod__, channel_list)))
    pcal = calibration_parts.hook_up(pipeline, raw_data,
                                     options.pcal_channel_name, ifo, 1.0)
    pcal = calibration_parts.caps_and_progress(
        pipeline, pcal,
        "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
        "pcal")
    pcal = pipeparts.mktee(pipeline, pcal)

    # Demodulate the pcal channel at the lines of interest
    for i in range(0, len(frequencies)):
        demodulated_pcal = calibration_parts.demodulate(
            pipeline,
            pcal,
            frequencies[i],
            True,
            rate_out,
            filter_time,
            0.5,
            prefactor_real=pcal_corrections[2 * i],
            prefactor_imag=pcal_corrections[2 * i + 1])
        demodulated_pcal_list.append(
            pipeparts.mktee(pipeline, demodulated_pcal))

    # Check if we are taking pcal-to-darm ratios for CALCS data
    for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]):
        calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel,
                                                 ifo, 1.0)
        calcs_deltal = calibration_parts.caps_and_progress(
            pipeline, calcs_deltal,
            "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
            label)
        calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal)
        for i in range(0, len(frequencies)):
            # Demodulate DELTAL_EXTERNAL at each line
            demodulated_calcs_deltal = calibration_parts.demodulate(
                pipeline, calcs_deltal, frequencies[i], True, rate_out,
                filter_time, 0.5)
            # Take ratio \DeltaL(f) / pcal(f)
            deltaL_over_pcal = calibration_parts.complex_division(
                pipeline, demodulated_calcs_deltaL, demodulated_pcal_list[i])
            # Take a running average
            deltaL_over_pcal = pipeparts.mkgeneric(
                pipeline,
                deltaL_over_pcal,
                "lal_smoothkappas",
                array_size=1,
                avg_array_size=int(rate_out * average_time))
            # Write to file
            pipeparts.mknxydumpsink(
                pipeline, deltaL_over_pcal,
                "%s_%s_over_%s_at_line%d.txt" % (ifo, label.replace(
                    ' ', '_'), options.pcal_channel_name, i + 1))

    # Check if we are taking pcal-to-darm ratios for gstlal calibrated data
    if options.gstlal_channel_list is not None:
        cache_num = 0
        for cache, channel, label in zip(
                gstlal_frame_cache_list, gstlal_channels,
                labels[len(calcs_channels):len(calcs_channels) +
                       len(gstlal_channels)]):
            # Get gstlal channels from the gstlal frames
            hoft_data = pipeparts.mklalcachesrc(pipeline,
                                                location=cache,
                                                cache_dsc_regex=ifo)
            hoft_data = pipeparts.mkframecppchanneldemux(
                pipeline,
                hoft_data,
                do_file_checksum=False,
                skip_bad_files=True,
                channel_list=list(map("%s:%s".__mod__, channel_list)))
            hoft = calibration_parts.hook_up(pipeline,
                                             hoft_data,
                                             channel,
                                             ifo,
                                             1.0,
                                             element_name_suffix="_%d" %
                                             cache_num)
            cache_num = cache_num + 1
            hoft = calibration_parts.caps_and_progress(
                pipeline, hoft,
                "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
                label)
            deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length)
            deltal = pipeparts.mktee(pipeline, deltal)
            for i in range(0, len(frequencies)):
                # Demodulate \DeltaL at each line
                demodulated_deltal = calibration_parts.demodulate(
                    pipeline, deltal, frequencies[i], True, rate_out,
                    filter_time, 0.5)
                # Take ratio \DeltaL(f) / pcal(f)
                deltaL_over_pcal = calibration_parts.complex_division(
                    pipeline, demodulated_deltal, demodulated_pcal_list[i])
                # Take a running average
                deltaL_over_pcal = pipeparts.mkgeneric(
                    pipeline,
                    deltaL_over_pcal,
                    "lal_smoothkappas",
                    array_size=1,
                    avg_array_size=int(rate_out * average_time))
                # Find the magnitude
                deltaL_over_pcal = pipeparts.mktee(pipeline, deltaL_over_pcal)
                magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_pcal,
                                                "cabs")
                # Find the phase
                phase = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "carg")
                phase = pipeparts.mkaudioamplify(pipeline, phase,
                                                 180.0 / numpy.pi)
                # Interleave
                magnitude_and_phase = calibration_parts.mkinterleave(
                    pipeline, [magnitude, phase])
                # Write to file
                pipeparts.mknxydumpsink(
                    pipeline, magnitude_and_phase,
                    "%s_%s_over_%s_at_%0.1fHz_%d.txt" %
                    (ifo, label.replace(' ', '_'), options.pcal_channel_name,
                     frequencies[i], options.gps_start_time))

        # Check of we are reading in kappa channels
        if options.kappa_channel_list is not None:
            # Get gstlal channels from the gstlal frames
            kappa_data = pipeparts.mklalcachesrc(
                pipeline,
                location=gstlal_frame_cache_list[0],
                cache_dsc_regex=ifo)
            kappa_data = pipeparts.mkframecppchanneldemux(
                pipeline,
                kappa_data,
                do_file_checksum=False,
                skip_bad_files=True,
                channel_list=list(map("%s:%s".__mod__, channel_list)))
            for i in range(len(kappa_channels) // 2):
                kappa_real = calibration_parts.hook_up(
                    pipeline,
                    kappa_data,
                    kappa_channels[2 * i],
                    ifo,
                    1.0,
                    element_name_suffix="_%d" % (2 * i))
                kappa_imag = calibration_parts.hook_up(
                    pipeline,
                    kappa_data,
                    kappa_channels[2 * i + 1],
                    ifo,
                    1.0,
                    element_name_suffix="_%d" % (2 * i + 1))
                kappa_real = calibration_parts.caps_and_progress(
                    pipeline, kappa_real,
                    "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
                    kappa_channels[2 * i])
                kappa_imag = calibration_parts.caps_and_progress(
                    pipeline, kappa_imag,
                    "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
                    kappa_channels[2 * i + 1])
                kappa = calibration_parts.merge_into_complex(
                    pipeline, kappa_real, kappa_imag)
                phase_angle = pipeparts.mkgeneric(pipeline, kappa, "carg")

                actuation_stage = 'UNKNOWN'
                act_freq = 17.0  # A guess...
                if 'TST' in kappa_channels[2 * i]:
                    actuation_stage = 'T'
                    act_freq = float(filters["ktst_esd_line_freq"])
                elif 'PUM' in kappa_channels[2 * i]:
                    actuation_stage = 'P'
                    act_freq = float(filters["pum_act_line_freq"])
                elif 'UIM' in kappa_channels[2 * i]:
                    actuation_stage = 'U'
                    act_freq = float(filters["uim_act_line_freq"])
                elif 'PU' in kappa_channels[2 * i]:
                    actuation_stage = 'PU'
                    act_freq = float(filters["ka_esd_line_freq"])

                actuation_stages.append(actuation_stage)

                tau = pipeparts.mkaudioamplify(
                    pipeline, phase_angle,
                    1000000.0 / 2.0 / numpy.pi / act_freq)

                pipeparts.mknxydumpsink(
                    pipeline, tau, "%s_%s_%d.txt" %
                    (ifo, actuation_stage, options.gps_start_time))

    #
    # done
    #

    return pipeline
def gstlal_compute_kappas_without_D(pipeline, name):

    # The first line makes the element lal_cachesrc, which reads in raw data using the cache file
    source = pipeparts.mklalcachesrc(pipeline,
                                     location=frame_cache,
                                     cache_dsc_regex=ifo)

    # Next, the demuxer splits it into separate channels
    demux = pipeparts.mkframecppchanneldemux(pipeline,
                                             source,
                                             do_file_checksum=False,
                                             skip_bad_files=True,
                                             channel_list=list(
                                                 map("%s:%s".__mod__,
                                                     channel_list)))

    # Next, we use a function from calibration_parts.py that hooks up to the demuxer
    # and does a few sanity checks on the data.  This uses multiple elements.
    darm_err = calibration_parts.hook_up(pipeline, demux,
                                         "CAL-DARM_ERR_DBL_DQ", ifo, 1.0)

    # Another calibration_parts function to set the "caps", which are stream parameters
    # that tell gstreamer the data type, sample rate, etc.  A progress report will produce
    # output to the screen so that you can see it is running.
    darm_err = calibration_parts.caps_and_progress(
        pipeline, darm_err,
        "audio/x-raw, format=F64LE, rate=%d, channels=1, channel-mask=(bitmask)0x0",
        "darm_err")

    # You will need to use the error signal in more than one place (you'll have to
    # demodulate it at all five frequencies), so we need a tee here.
    darm_err = pipeparts.mktee(pipeline, darm_err)

    # Finally, an interesting operation - now you need to demodulate the error signal.
    # You will have to do this to every input signal.  darm_err is currently a time series,
    # but you want to know its amplitude and phase at a single frequency.  To do this, we
    # Demodulate it at the specified frequency
    darm_err_at_f1 = calibration_parts.demodulate(pipeline, darm_err, f1, True,
                                                  16, 20, 0)

    # You'll also need this in multiple places, so here's a tee
    darm_err_at_f1 = pipeparts.mktee(pipeline, darm_err_at_f1)

    # This writes the data to a file, currently called "darm_err_at_f1.txt."  Eventually,
    # you will want to write the TDCFs to a file.
    pipeparts.mknxydumpsink(pipeline, darm_err_at_f1, "darm_err_at_f1.txt")

    # To move forward, you can remove the nxydumpsink above and use darm_err_at_f1 for
    # your calculations.  You will also need to demodulate the Pcal channel at f1.  And
    # you will have to do several more demodulations (10 total I think, since each of
    # the five lines is present in darm_err and in one injection channel).  Then, you
    # will need to do additions, multiplications, divisions, powers, etc.  I would
    # suggest looking in gstlal_compute_strain (the calibration pipeline) and
    # calibration_parts.py for examples of how to do these.  calibration_parts has lots
    # of functions that should be helpful.

    #
    # done
    #

    return pipeline
Exemplo n.º 5
0
def demod_ratio(pipeline, name):

    # Get denominator data from the raw frames
    denominator_data = pipeparts.mklalcachesrc(
        pipeline,
        location=options.denominator_frame_cache,
        cache_dsc_regex=ifo)
    denominator_data = pipeparts.mkframecppchanneldemux(
        pipeline,
        denominator_data,
        do_file_checksum=False,
        skip_bad_files=True,
        channel_list=list(map("%s:%s".__mod__, channel_list)))
    denominator = calibration_parts.hook_up(pipeline, denominator_data,
                                            options.denominator_channel_name,
                                            ifo, 1.0)
    denominator = calibration_parts.caps_and_progress(
        pipeline, denominator,
        "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
        "denominator")
    denominator = pipeparts.mktee(pipeline, denominator)

    # Get numerator data from the raw frames
    if not options.denominator_frame_cache == options.numerator_frame_cache:
        numerator_data = pipeparts.mklalcachesrc(
            pipeline,
            location=options.numerator_frame_cache,
            cache_dsc_regex=ifo)
        numerator_data = pipeparts.mkframecppchanneldemux(
            pipeline,
            numerator_data,
            do_file_checksum=False,
            skip_bad_files=True,
            channel_list=list(map("%s:%s".__mod__, channel_list)))
        numerator = calibration_parts.hook_up(pipeline, numerator_data,
                                              options.numerator_channel_name,
                                              ifo, 1.0)
    else:
        numerator = calibration_parts.hook_up(pipeline, denominator_data,
                                              options.numerator_channel_name,
                                              ifo, 1.0)
    numerator = calibration_parts.caps_and_progress(
        pipeline, numerator,
        "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
        "numerator")
    numerator = pipeparts.mktee(pipeline, numerator)

    # Demodulate numerator and denominator at each frequency, take ratios, and write to file
    for i in range(0, len(frequencies)):
        # Demodulate
        demodulated_denominator = calibration_parts.demodulate(
            pipeline, denominator, frequencies[i], True, rate_out, filter_time,
            0.5)
        demodulated_numerator = calibration_parts.demodulate(
            pipeline, numerator, frequencies[i], True, rate_out, filter_time,
            0.5)
        demodulated_numerator = pipeparts.mktee(pipeline,
                                                demodulated_numerator)
        demodulated_denominator = pipeparts.mktee(pipeline,
                                                  demodulated_denominator)
        # Take ratio
        ratio = calibration_parts.complex_division(pipeline,
                                                   demodulated_numerator,
                                                   demodulated_denominator)
        # Average
        ratio = pipeparts.mkgeneric(pipeline,
                                    ratio,
                                    "lal_smoothkappas",
                                    array_size=1,
                                    avg_array_size=int(rate_out *
                                                       average_time),
                                    filter_latency=1.0)
        # Find magnitude and phase
        ratio = pipeparts.mktee(pipeline, ratio)
        magnitude = pipeparts.mkgeneric(pipeline, ratio, "cabs")
        phase = pipeparts.mkgeneric(pipeline, ratio, "carg")
        phase = pipeparts.mkaudioamplify(pipeline, phase, 180.0 / numpy.pi)
        # Interleave
        magnitude_and_phase = calibration_parts.mkinterleave(
            pipeline, [magnitude, phase])
        # Write to file
        pipeparts.mknxydumpsink(
            pipeline, magnitude_and_phase, "%s_%s_over_%s_%0.1fHz.txt" %
            (ifo, options.numerator_channel_name,
             options.denominator_channel_name, frequencies[i]))

    #
    # done
    #

    return pipeline
Exemplo n.º 6
0
def pcal2darm(pipeline, name):

    # Get pcal from the raw frames
    raw_data = pipeparts.mklalcachesrc(pipeline,
                                       location=options.raw_frame_cache,
                                       cache_dsc_regex=ifo)
    raw_data = pipeparts.mkframecppchanneldemux(
        pipeline,
        raw_data,
        do_file_checksum=False,
        skip_bad_files=True,
        channel_list=list(map("%s:%s".__mod__, channel_list)))
    pcal = calibration_parts.hook_up(pipeline, raw_data,
                                     options.pcal_channel_name, ifo, 1.0)
    pcal = calibration_parts.caps_and_progress(
        pipeline, pcal,
        "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
        "pcal")
    pcal = pipeparts.mktee(pipeline, pcal)

    # Demodulate the pcal channel at the lines of interest
    for i in range(0, len(frequencies)):
        demodulated_pcal = calibration_parts.demodulate(
            pipeline,
            pcal,
            frequencies[i],
            True,
            rate_out,
            filter_time,
            0.5,
            prefactor_real=pcal_corrections[2 * i],
            prefactor_imag=pcal_corrections[2 * i + 1])
        demodulated_pcal_list.append(
            pipeparts.mktee(pipeline, demodulated_pcal))

    # Check if we are taking pcal-to-darm ratios for CALCS data
    for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]):
        calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel,
                                                 ifo, 1.0)
        calcs_deltal = calibration_parts.caps_and_progress(
            pipeline, calcs_deltal,
            "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
            label)
        calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal)
        for i in range(0, len(frequencies)):
            # Demodulate DELTAL_EXTERNAL at each line
            demodulated_calcs_deltal = calibration_parts.demodulate(
                pipeline, calcs_deltal, frequencies[i], True, rate_out,
                filter_time, 0.5)
            # Take ratio \DeltaL(f) / pcal(f)
            deltaL_over_pcal = calibration_parts.complex_division(
                pipeline, demodulated_calcs_deltaL, demodulated_pcal_list[i])
            # Take a running average
            deltaL_over_pcal = pipeparts.mkgeneric(
                pipeline,
                deltaL_over_pcal,
                "lal_smoothkappas",
                array_size=1,
                avg_array_size=int(rate_out * average_time))
            # Write to file
            pipeparts.mknxydumpsink(
                pipeline, deltaL_over_pcal,
                "%s_%s_over_%s_at_line%d.txt" % (ifo, label.replace(
                    ' ', '_'), options.pcal_channel_name, i + 1))

    # Check if we are taking pcal-to-darm ratios for gstlal calibrated data
    if options.gstlal_channel_list is not None:
        cache_num = 0
        for cache, channel, label in zip(
                gstlal_frame_cache_list, gstlal_channels,
                labels[len(calcs_channels):len(channel_list)]):
            # Get gstlal channels from the gstlal frames
            hoft_data = pipeparts.mklalcachesrc(pipeline,
                                                location=cache,
                                                cache_dsc_regex=ifo)
            hoft_data = pipeparts.mkframecppchanneldemux(
                pipeline,
                hoft_data,
                do_file_checksum=False,
                skip_bad_files=True,
                channel_list=list(
                    map("%s:%s".__mod__, channel_list + DQ_channels)))
            hoft = calibration_parts.hook_up(pipeline,
                                             hoft_data,
                                             channel,
                                             ifo,
                                             1.0,
                                             element_name_suffix="_%d" %
                                             cache_num)
            hoft = calibration_parts.caps_and_progress(
                pipeline, hoft,
                "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
                label)
            deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length)
            deltal = pipeparts.mktee(pipeline, deltal)

            # Get a DQ channel
            DQ_channel = "%sCALIB_STATE_VECTOR%s" % (chan_prefixes[cache_num],
                                                     chan_suffixes[cache_num])
            DQ = calibration_parts.hook_up(pipeline,
                                           hoft_data,
                                           DQ_channel,
                                           ifo,
                                           1.0,
                                           element_name_suffix="_%d" %
                                           cache_num)
            DQ = calibration_parts.caps_and_progress(
                pipeline, DQ,
                "audio/x-raw,format=U32LE,channels=1,channel-mask=(bitmask)0x0",
                "DQ_%s" % label)
            DQ = pipeparts.mkgeneric(pipeline,
                                     DQ,
                                     "lal_logicalundersample",
                                     required_on=1,
                                     status_out=1)
            DQ = pipeparts.mkcapsfilter(
                pipeline, DQ,
                "audio/x-raw,format=U32LE,rate=%d,channels=1,channel-mask=(bitmask)0x0"
                % rate_out)
            DQ = pipeparts.mkgeneric(
                pipeline,
                DQ,
                "lal_drop",
                drop_samples=int((7.0 + 0.5 * filter_time) * rate_out + 0.5))
            DQ = pipeparts.mktee(pipeline, DQ)

            for i in range(0, len(frequencies)):
                # Demodulate \DeltaL at each line
                demodulated_deltal = calibration_parts.demodulate(
                    pipeline, deltal, frequencies[i], True, rate_out,
                    filter_time, 0.5)
                # Take ratio \DeltaL(f) / pcal(f)
                deltaL_over_pcal = calibration_parts.complex_division(
                    pipeline, demodulated_deltal, demodulated_pcal_list[i])
                # Take a running average
                deltaL_over_pcal = pipeparts.mkgeneric(
                    pipeline,
                    deltaL_over_pcal,
                    "lal_smoothkappas",
                    array_size=1,
                    avg_array_size=int(rate_out * average_time))
                # Find the magnitude
                deltaL_over_pcal = pipeparts.mktee(pipeline, deltaL_over_pcal)
                magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_pcal,
                                                "cabs")
                # Find the phase
                phase = pipeparts.mkgeneric(pipeline, deltaL_over_pcal, "carg")
                phase = pipeparts.mkaudioamplify(pipeline, phase,
                                                 180.0 / numpy.pi)
                # Interleave
                magnitude_and_phase = calibration_parts.mkinterleave(
                    pipeline, [magnitude, phase])
                # Gate with DQ channel
                magnitude_and_phase = calibration_parts.mkgate(
                    pipeline, magnitude_and_phase, DQ, 1)
                magnitude_and_phase = pipeparts.mkprogressreport(
                    pipeline,
                    magnitude_and_phase,
                    name="progress_sink_%s_%d" % (label, i))
                # Write to file
                pipeparts.mknxydumpsink(
                    pipeline, magnitude_and_phase,
                    "%s_%s_over_%s_at_%0.1fHz_%d.txt" %
                    (ifo, label.replace(' ', '_'), options.pcal_channel_name,
                     frequencies[i], options.gps_start_time))
            cache_num = cache_num + 1

    #
    # done
    #

    return pipeline
Exemplo n.º 7
0
def act2darm(pipeline, name):

    # Get actuation injection channels from the raw frames
    act_inj_channels = []
    raw_data = pipeparts.mklalcachesrc(pipeline,
                                       location=options.raw_frame_cache,
                                       cache_dsc_regex=ifo)
    raw_data = pipeparts.mkframecppchanneldemux(
        pipeline,
        raw_data,
        do_file_checksum=False,
        skip_bad_files=True,
        channel_list=list(map("%s:%s".__mod__, channel_list)))
    for i in range(len(act_channels)):
        act_inj_channels.append(
            calibration_parts.hook_up(pipeline, raw_data, act_channels[i], ifo,
                                      1.0))
        act_inj_channels[i] = calibration_parts.caps_and_progress(
            pipeline, act_inj_channels[i],
            "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
            "act_inj_%d" % i)
        act_inj_channels[i] = pipeparts.mktee(pipeline, act_inj_channels[i])

    # Demodulate the actuation injection channels at the lines of interest
    for i in range(0, len(frequencies)):
        demodulated_act = calibration_parts.demodulate(
            pipeline,
            act_inj_channels[i],
            frequencies[i],
            True,
            rate_out,
            filter_time,
            0.5,
            prefactor_real=act_corrections[2 * i],
            prefactor_imag=act_corrections[2 * i + 1])
        demodulated_act_list.append(pipeparts.mktee(pipeline, demodulated_act))

    # Check if we are taking act-to-darm ratios for CALCS data
    for channel, label in zip(calcs_channels, labels[0:len(calcs_channels)]):
        calcs_deltal = calibration_parts.hook_up(pipeline, raw_data, channel,
                                                 ifo, 1.0)
        calcs_deltal = calibration_parts.caps_and_progress(
            pipeline, calcs_deltal,
            "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
            label)
        calcs_deltal = pipeparts.mktee(pipeline, calcs_deltal)
        for i in range(0, len(frequencies)):
            # Demodulate DELTAL_EXTERNAL at each line
            demodulated_calcs_deltal = calibration_parts.demodulate(
                pipeline, calcs_deltal, frequencies[i], True, rate_out,
                filter_time, 0.5)
            # Take ratio \DeltaL(f) / act_injection(f)
            deltaL_over_act = calibration_parts.complex_division(
                pipeline, demodulated_calcs_deltaL, demodulated_act_list[i])
            # Take a running average
            deltaL_over_act = pipeparts.mkgeneric(pipeline,
                                                  deltaL_over_act,
                                                  "lal_smoothkappas",
                                                  array_size=1,
                                                  avg_array_size=int(
                                                      rate_out * average_time))
            # Write to file
            pipeparts.mknxydumpsink(
                pipeline, deltaL_over_act, "%s_%s_over_%s_at_line%d.txt" %
                (ifo, label.replace(' ', '_'), act_channels[i], i + 1))

    # Check if we are taking act-to-darm ratios for gstlal calibrated data
    if options.gstlal_channel_list is not None:
        cache_num = 0
        for cache, channel, label in zip(
                gstlal_frame_cache_list, gstlal_channels,
                labels[len(calcs_channels):len(channel_list)]):
            # Get gstlal channels from the gstlal frames
            hoft_data = pipeparts.mklalcachesrc(pipeline,
                                                location=cache,
                                                cache_dsc_regex=ifo)
            hoft_data = pipeparts.mkframecppchanneldemux(
                pipeline,
                hoft_data,
                do_file_checksum=False,
                skip_bad_files=True,
                channel_list=list(
                    map("%s:%s".__mod__, channel_list +
                        TDCF_channels[cache_num] + DQ_channels)))
            hoft = calibration_parts.hook_up(pipeline,
                                             hoft_data,
                                             channel,
                                             ifo,
                                             1.0,
                                             element_name_suffix="_%d" %
                                             cache_num)
            hoft = calibration_parts.caps_and_progress(
                pipeline, hoft,
                "audio/x-raw,format=F64LE,channels=1,channel-mask=(bitmask)0x0",
                label)
            deltal = pipeparts.mkaudioamplify(pipeline, hoft, arm_length)
            deltal = pipeparts.mktee(pipeline, deltal)

            # Get a DQ channel
            DQ_channel = "%sCALIB_STATE_VECTOR%s" % (chan_prefixes[cache_num],
                                                     chan_suffixes[cache_num])
            DQ = calibration_parts.hook_up(pipeline,
                                           hoft_data,
                                           DQ_channel,
                                           ifo,
                                           1.0,
                                           element_name_suffix="_%d" %
                                           cache_num)
            DQ = calibration_parts.caps_and_progress(
                pipeline, DQ,
                "audio/x-raw,format=U32LE,channels=1,channel-mask=(bitmask)0x0",
                "DQ_%s" % label)
            DQ = pipeparts.mkgeneric(pipeline,
                                     DQ,
                                     "lal_logicalundersample",
                                     required_on=1,
                                     status_out=1)
            DQ = pipeparts.mkcapsfilter(
                pipeline, DQ,
                "audio/x-raw,format=U32LE,rate=%d,channels=1,channel-mask=(bitmask)0x0"
                % rate_out)
            DQ = pipeparts.mktee(pipeline, DQ)
            for i in range(0, len(frequencies)):
                # Demodulate \DeltaL at each line
                demodulated_deltal = calibration_parts.demodulate(
                    pipeline, deltal, frequencies[i], True, rate_out,
                    filter_time, 0.5)

                # Divide by a TDCF if needed
                if ('tst' in act_line_names[i] or 'esd' in act_line_names[i]
                    ) and (apply_complex_kappatst[cache_num]
                           or apply_kappatst[cache_num]):
                    # Get KAPPA_TST
                    TDCF_real = "%sCALIB_KAPPA_TST_REAL%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_imag = "%sCALIB_KAPPA_TST_IMAGINARY%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_real = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_real,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF_imag = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_imag,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF = calibration_parts.merge_into_complex(
                        pipeline, TDCF_real, TDCF_imag)
                    TDCF = calibration_parts.caps_and_progress(
                        pipeline, TDCF,
                        "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0",
                        'KAPPA_TST_%s' % label)
                    TDCF = calibration_parts.mkresample(
                        pipeline, TDCF, 3, False, rate_out)
                    if not apply_complex_kappatst[cache_num]:
                        # Only divide by the magnitude
                        TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs")
                        TDCF = pipeparts.mktogglecomplex(
                            pipeline,
                            pipeparts.mkmatrixmixer(pipeline,
                                                    TDCF,
                                                    matrix=[[1.0, 0.0]]))
                    demodulated_deltal = calibration_parts.complex_division(
                        pipeline, demodulated_deltal, TDCF)
                elif 'pum' in act_line_names[i] and (
                        apply_complex_kappapum[cache_num]
                        or apply_kappapum[cache_num]):
                    # Get KAPPA_PUM
                    TDCF_real = "%sCALIB_KAPPA_PUM_REAL%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_imag = "%sCALIB_KAPPA_PUM_IMAGINARY%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_real = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_real,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF_imag = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_imag,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF = calibration_parts.merge_into_complex(
                        pipeline, TDCF_real, TDCF_imag)
                    TDCF = calibration_parts.caps_and_progress(
                        pipeline, TDCF,
                        "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0",
                        'KAPPA_PUM_%s' % label)
                    TDCF = calibration_parts.mkresample(
                        pipeline, TDCF, 3, False, rate_out)
                    if not apply_complex_kappapum[cache_num]:
                        # Only divide by the magnitude
                        TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs")
                        TDCF = pipeparts.mktogglecomplex(
                            pipeline,
                            pipeparts.mkmatrixmixer(pipeline,
                                                    TDCF,
                                                    matrix=[[1.0, 0.0]]))
                    demodulated_deltal = calibration_parts.complex_division(
                        pipeline, demodulated_deltal, TDCF)
                elif 'uim' in act_line_names[i] and (
                        apply_complex_kappauim[cache_num]
                        or apply_kappauim[cache_num]):
                    # Get KAPPA_UIM
                    TDCF_real = "%sCALIB_KAPPA_UIM_REAL%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_imag = "%sCALIB_KAPPA_UIM_IMAGINARY%s" % (
                        chan_prefixes[cache_num], chan_suffixes[cache_num])
                    TDCF_real = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_real,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF_imag = calibration_parts.hook_up(
                        pipeline,
                        hoft_data,
                        TDCF_imag,
                        ifo,
                        1.0,
                        element_name_suffix="_%d" % cache_num)
                    TDCF = calibration_parts.merge_into_complex(
                        pipeline, TDCF_real, TDCF_imag)
                    TDCF = calibration_parts.caps_and_progress(
                        pipeline, TDCF,
                        "audio/x-raw,format=Z128LE,channels=1,channel-mask=(bitmask)0x0",
                        'KAPPA_UIM_%s' % label)
                    TDCF = calibration_parts.mkresample(
                        pipeline, TDCF, 3, False, rate_out)
                    if not apply_complex_kappauim[cache_num]:
                        # Only divide by the magnitude
                        TDCF = pipeparts.mkgeneric(pipeline, TDCF, "cabs")
                        TDCF = pipeparts.mktogglecomplex(
                            pipeline,
                            pipeparts.mkmatrixmixer(pipeline,
                                                    TDCF,
                                                    matrix=[[1.0, 0.0]]))
                    demodulated_deltal = calibration_parts.complex_division(
                        pipeline, demodulated_deltal, TDCF)

                # Take ratio \DeltaL(f) / act_injection(f)
                deltaL_over_act = calibration_parts.complex_division(
                    pipeline, demodulated_deltal, demodulated_act_list[i])
                # Take a running average
                deltaL_over_act = pipeparts.mkgeneric(
                    pipeline,
                    deltaL_over_act,
                    "lal_smoothkappas",
                    array_size=1,
                    avg_array_size=int(rate_out * average_time))
                # Find the magnitude
                deltaL_over_act = pipeparts.mktee(pipeline, deltaL_over_act)
                magnitude = pipeparts.mkgeneric(pipeline, deltaL_over_act,
                                                "cabs")
                # Find the phase
                phase = pipeparts.mkgeneric(pipeline, deltaL_over_act, "carg")
                phase = pipeparts.mkaudioamplify(pipeline, phase,
                                                 180.0 / numpy.pi)
                # Interleave
                magnitude_and_phase = calibration_parts.mkinterleave(
                    pipeline, [magnitude, phase])
                # Gate with DQ channel
                magnitude_and_phase = calibration_parts.mkgate(
                    pipeline, magnitude_and_phase, DQ, 1)
                magnitude_and_phase = pipeparts.mkprogressreport(
                    pipeline,
                    magnitude_and_phase,
                    name="progress_sink_%s_%d" % (label, i))
                # Write to file
                pipeparts.mknxydumpsink(
                    pipeline, magnitude_and_phase,
                    "%s_%s_over_%s_at_%0.1fHz_%d.txt" %
                    (ifo, label.replace(' ', '_'), act_channels[i],
                     frequencies[i], options.gps_start_time))
            cache_num = cache_num + 1

    #
    # done
    #

    return pipeline