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
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
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 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_logical_undersampler_03(pipeline, name): # # This test reads in a gwf file that has certain bits off to test # the logic of the element # Note: To run this test you must first make a frame cache, which can be done with the # following command: # ls *.gwf | lalapps_path2cache > frame.cache # out_rate = 1 src = pipeparts.mklalcachesrc(pipeline, location="frame.cache", cache_dsc_regex="L1") demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum=True, skip_bad_files=True) head = pipeparts.mkqueue(pipeline, None) pipeparts.src_deferred_link(demux, "L1:TEST-CHANNEL", head.get_pad("sink")) head = tee = pipeparts.mktee(pipeline, head) head = pipeparts.mkgeneric(pipeline, tee, "lal_logical_undersampler", required_on=0x1, status_out=0x7) head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw-int, rate=%d" % int(out_rate)) head = pipeparts.mkchecktimestamps(pipeline, head) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_out.dump" % name) pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, tee), "%s_in.dump" % name) # # done # return pipeline
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 mkbasicsrc(pipeline, gw_data_source_info, instrument, verbose=False): if gw_data_source_info.data_source == "frames": if instrument == "V1": #FIXME Hack because virgo often just uses "V" in the file names rather than "V1". We need to sieve on "V" src = pipeparts.mklalcachesrc( pipeline, blocksize=1048576, use_mmap=False, location=gw_data_source_info.frame_cache, cache_src_regex="V") else: src = pipeparts.mklalcachesrc( pipeline, blocksize=1048576, use_mmap=False, location=gw_data_source_info.frame_cache, cache_src_regex=instrument[0], cache_dsc_regex=instrument) demux = pipeparts.mkframecppchanneldemux( pipeline, src, do_file_checksum=False, channel_list=list( map("%s:%s".__mod__, gw_data_source_info.channel_dict.items()))) pipeparts.framecpp_channeldemux_set_units( demux, dict.fromkeys(demux.get_property("channel-list"), "strain")) # allow frame reading and decoding to occur in a diffrent thread src = pipeparts.mkqueue(pipeline, None, max_size_buffers=0, max_size_bytes=0, max_size_time=8 * Gst.SECOND) pipeparts.src_deferred_link( demux, "%s:%s" % (instrument, gw_data_source_info.channel_dict[instrument]), src.get_static_pad("sink")) # FIXME: remove this when pipeline can handle disconts src = pipeparts.mkaudiorate(pipeline, src, skip_to_first=True, silent=False) else: raise ValueError("invalid data_source: %s" % gw_data_source_info.data_source) # provide an audioconvert element to allow Virgo data (which is single-precision) to be adapted into the pipeline src = pipeparts.mkaudioconvert(pipeline, src) # progress report if verbose: src = pipeparts.mkprogressreport(pipeline, src, "progress_src_%s" % instrument) # optional injections if gw_data_source_info.injection_filename is not None: src = pipeparts.mkinjections(pipeline, src, gw_data_source_info.injection_filename) # let the injection code run in a different thread than the whitener, etc., src = pipeparts.mkqueue(pipeline, src, max_size_bytes=0, max_size_buffers=0, max_size_time=Gst.SECOND * 64) return src
def plot_transfer_function(pipeline, name): # Get the data from the denominator frames denominator = pipeparts.mklalcachesrc( pipeline, location=options.denominator_frame_cache, cache_dsc_regex=ifo) denominator = pipeparts.mkframecppchanneldemux( pipeline, denominator, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) denominator = calibration_parts.hook_up(pipeline, denominator, options.denominator_channel_name, ifo, 1.0) denominator = calibration_parts.caps_and_progress( pipeline, denominator, "audio/x-raw,format=F64LE", "denominator") denominator = calibration_parts.mkresample(pipeline, denominator, 5, False, int(sample_rate)) if denominator_correction is not None: if numpy.size(filters[denominator_correction]) == 1: denominator = pipeparts.mkaudioamplify( pipeline, denominator, float(filters[denominator_correction])) denominator = pipeparts.mktee(pipeline, denominator) # Get the data from the numerator frames for i in range(0, len(labels)): numerator = pipeparts.mklalcachesrc( pipeline, location=numerator_frame_cache_list[i], cache_dsc_regex=ifo) numerator = pipeparts.mkframecppchanneldemux( pipeline, numerator, do_file_checksum=False, skip_bad_files=True, channel_list=list(map("%s:%s".__mod__, channel_list))) numerator = calibration_parts.hook_up(pipeline, numerator, numerator_channel_list[i], ifo, 1.0, element_name_suffix="%d" % i) numerator = calibration_parts.caps_and_progress( pipeline, numerator, "audio/x-raw,format=F64LE", labels[i]) numerator = calibration_parts.mkresample(pipeline, numerator, 5, False, int(sample_rate)) if numerator_correction is not None: if numerator_correction[i] is not None: if numpy.size(filters[numerator_correction[i]] == 1): numerator = pipeparts.mkaudioamplify( pipeline, numerator, float(filters[numerator_correction[i]])) # Interleave the channels to make one stream channels = calibration_parts.mkinterleave(pipeline, [numerator, denominator]) # Send the data to lal_transferfunction to compute and write transfer functions pipeparts.mkgeneric(pipeline, channels, "lal_transferfunction", fft_length=fft_length, fft_overlap=fft_overlap, num_ffts=num_ffts, fir_length=td_tf_length, use_median=True if options.use_median else False, update_samples=1e15, filename='%s_%s_over_%s_%d-%d.txt' % (ifo, labels[i].replace(' ', '_').replace( '/', 'over'), options.denominator_channel_name, options.gps_start_time, data_duration)) # # 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
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
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
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