Skip to content
Snippets Groups Projects
Commit 30a7abc1 authored by Kipp Cannon's avatar Kipp Cannon
Browse files

gstlal.hoftcache: add cache_hoft() function

parent 8b2f12aa
No related branches found
Tags gstlal-calibration-1.2.11-v1
No related merge requests found
......@@ -112,35 +112,11 @@ data_source_info = datasource.GWDataSourceInfo(options)
#
# Build pipeline
# Cache h(t)
#
mainloop = gobject.MainLoop()
pipeline = gst.Pipeline("gstlal_inspiral_condition_data")
handler = hoftcache.Handler(mainloop, pipeline)
if options.verbose:
print >>sys.stderr, "assembling pipeline ...",
hoftcache.build_pipeline(pipeline, data_source_info, options.output_path, sample_rate = options.sample_rate, description = options.description, channel_comment = "cached h(t) for inspiral search", verbose = options.verbose)
if options.verbose:
print >>sys.stderr, "done"
#
# Run pipeline
#
if options.verbose:
print >>sys.stderr, "setting pipeline state to playing ..."
if pipeline.set_state(gst.STATE_PLAYING) != gst.STATE_CHANGE_SUCCESS:
raise RuntimeError("pipeline did not enter playing state")
if options.verbose:
print >>sys.stderr, "running pipeline ..."
mainloop.run()
cache = hoftcache.cache_hoft(data_source_info, output_path = options.output_path, sample_rate = options.sample_rate, description = options.description, verbose = options.verbose)
#
......@@ -150,7 +126,9 @@ mainloop.run()
if options.verbose:
print >>sys.stderr, "writing %s ..." % output_cache_filename
handler.write_cache(open(output_cache_filename, "w"))
cache_file = open(output_cache_filename, "w")
for entry in cache:
print >>cache_file, str(entry)
#
......
......@@ -25,6 +25,7 @@
import os
import sys
import tempfile
......@@ -117,10 +118,6 @@ class Handler(simplehandler.Handler):
return True
return False
def write_cache(self, fileobj):
for cacheentry in self.cache:
print >>fileobj, str(cacheentry)
#
# =============================================================================
......@@ -165,3 +162,55 @@ def build_pipeline(pipeline, data_source_info, output_path = tempfile.gettempdir
pad.set_property("comment", channel_comment)
pad.set_property("pad-type", "FrProcData")
pipeparts.mkframecppfilesink(pipeline, src, frame_type = description, path = output_path)
#
# =============================================================================
#
# Collect and Cache h(t)
#
# =============================================================================
#
def cache_hoft(data_source_info, channel_comment = "cached h(t) for inspiral search", verbose = False, **kwargs):
#
# build pipeline
#
mainloop = gobject.MainLoop()
pipeline = gst.Pipeline("pipeline")
handler = Handler(mainloop, pipeline)
if verbose:
print >>sys.stderr, "assembling pipeline ...",
build_pipeline(pipeline, data_source_info, channel_comment = channel_comment, verbose = verbose, **kwargs)
if verbose:
print >>sys.stderr, "done"
#
# run pipeline
#
if verbose:
print >>sys.stderr, "setting pipeline state to playing ..."
if pipeline.set_state(gst.STATE_PLAYING) != gst.STATE_CHANGE_SUCCESS:
raise RuntimeError("pipeline did not enter playing state")
if verbose:
print >>sys.stderr, "running pipeline ..."
mainloop.run()
#
# return tempcache object. when this object is garbage collected
# the frame files will be deleted. keep a reference alive as long
# as you wish to preserve the files.
#
return handler.cache
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment