当前位置: 首页>>代码示例>>Python>>正文


Python SnglBurstUtils.get_time_slides方法代码示例

本文整理汇总了Python中lalburst.SnglBurstUtils.get_time_slides方法的典型用法代码示例。如果您正苦于以下问题:Python SnglBurstUtils.get_time_slides方法的具体用法?Python SnglBurstUtils.get_time_slides怎么用?Python SnglBurstUtils.get_time_slides使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lalburst.SnglBurstUtils的用法示例。


在下文中一共展示了SnglBurstUtils.get_time_slides方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_from

# 需要导入模块: from lalburst import SnglBurstUtils [as 别名]
# 或者: from lalburst.SnglBurstUtils import get_time_slides [as 别名]
	def update_from(self, contents, filename = "", verbose = False):
		#
		# Add the live times from this file to the totals.
		#

		if verbose:
			print >>sys.stderr, "measuring live time ..."
		zero_lag_time_slides, background_time_slides = SnglBurstUtils.get_time_slides(contents.connection)
		self.zero_lag_live_time += SnglBurstUtils.time_slides_livetime(contents.seglists, zero_lag_time_slides.values(), verbose = verbose)
		self.background_live_time += SnglBurstUtils.time_slides_livetime(contents.seglists, background_time_slides.values(), verbose = verbose)

		#
		# Iterate over burst<-->burst coincidences.  Assume there
		# are no injections in this file.
		#

		if verbose:
			print >>sys.stderr, "retrieving sngl_burst<-->sngl_burst coincs ..."
		for id, likelihood, confidence, is_background in bb_id_likelihood_confidence_background(contents):
			record = coinc_detection_statistic(likelihood, confidence)
			if is_background:
				# remember the total number, but only keep
				# the highest ranked
				self.n_background_amplitudes += 1
				if len(self.background_amplitudes) < 1e7:
					heapq.heappush(self.background_amplitudes, record)
				else:
					heapq.heappushpop(self.background_amplitudes, record)
			else:
				self.zero_lag_amplitudes.append((record, filename, id))
		if verbose:
			print >>sys.stderr, "done"
开发者ID:GeraintPratten,项目名称:lalsuite,代码行数:34,代码来源:lalapps_power_final.py

示例2: add_contents

# 需要导入模块: from lalburst import SnglBurstUtils [as 别名]
# 或者: from lalburst.SnglBurstUtils import get_time_slides [as 别名]
	def add_contents(self, contents, verbose = False):
		#
		# retrieve the offset vectors, retain only instruments that
		# are available
		#

		zero_lag_time_slides, background_time_slides = SnglBurstUtils.get_time_slides(contents.connection)
		assert len(zero_lag_time_slides) == 1

		#
		# compute the live time
		#

		seglists = contents.seglists - contents.vetoseglists
		self.zero_lag_time += stringutils.time_slides_livetime(seglists, zero_lag_time_slides.values(), 2, clip = contents.coincidence_segments)
		self.background_time += stringutils.time_slides_livetime(seglists, background_time_slides.values(), 2, clip = contents.coincidence_segments)
		if set(("H1", "H2")).issubset(set(contents.seglists)):
			# we have segments for both H1 and H2, remove time
			# when exactly that pair are on
			self.zero_lag_time -= stringutils.time_slides_livetime_for_instrument_combo(seglists, zero_lag_time_slides.values(), ("H1", "H2"), clip = contents.coincidence_segments)
			self.background_time -= stringutils.time_slides_livetime_for_instrument_combo(seglists, background_time_slides.values(), ("H1", "H2"), clip = contents.coincidence_segments)

		#
		# count events
		#

		for ln_likelihood_ratio, instruments, coinc_event_id, peak_time, is_background in contents.connection.cursor().execute("""
SELECT
	coinc_event.likelihood,
	coinc_event.instruments,
	coinc_event.coinc_event_id,
	(
		SELECT
			AVG(sngl_burst.peak_time) + 1e-9 * AVG(sngl_burst.peak_time_ns)
		FROM
			sngl_burst
			JOIN coinc_event_map ON (
				coinc_event_map.coinc_event_id == coinc_event.coinc_event_id
				AND coinc_event_map.table_name == 'sngl_burst'
				AND coinc_event_map.event_id == sngl_burst.event_id
			)
	),
	EXISTS (
		SELECT
			*
		FROM
			time_slide
		WHERE
			time_slide.time_slide_id == coinc_event.time_slide_id
			AND time_slide.offset != 0
	)
FROM
	coinc_event
WHERE
	coinc_event.coinc_def_id == ?
		""", (contents.bb_definer_id,)):
			# likelihood ratio must be listed first to
			# act as the sort key
			record = (ln_likelihood_ratio, contents.filename, coinc_event_id, dbtables.lsctables.instrumentsproperty.get(instruments), peak_time)
			if ln_likelihood_ratio is None:
				# coinc got vetoed (unable to compute
				# likelihood)
				pass
			elif is_background:
				# non-vetoed background
				self.n_background += 1
				if len(self.background) < self.record_background:
					heapq.heappush(self.background, ln_likelihood_ratio)
				else:
					heapq.heappushpop(self.background, ln_likelihood_ratio)
				if len(self.most_significant_background) < self.record_candidates:
					heapq.heappush(self.most_significant_background, record)
				else:
					heapq.heappushpop(self.most_significant_background, record)
			else:
				# non-vetoed zero lag
				self.zero_lag.append(ln_likelihood_ratio)
				if len(self.candidates) < self.record_candidates:
					heapq.heappush(self.candidates, record)
				else:
					heapq.heappushpop(self.candidates, record)
开发者ID:lscsoft,项目名称:lalsuite,代码行数:83,代码来源:lalapps_string_final.py


注:本文中的lalburst.SnglBurstUtils.get_time_slides方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。