本文整理汇总了Python中lalburst.SnglBurstUtils.latexnumber方法的典型用法代码示例。如果您正苦于以下问题:Python SnglBurstUtils.latexnumber方法的具体用法?Python SnglBurstUtils.latexnumber怎么用?Python SnglBurstUtils.latexnumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lalburst.SnglBurstUtils
的用法示例。
在下文中一共展示了SnglBurstUtils.latexnumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finish
# 需要导入模块: from lalburst import SnglBurstUtils [as 别名]
# 或者: from lalburst.SnglBurstUtils import latexnumber [as 别名]
def finish(self):
fig, axes = SnglBurstUtils.make_burst_plot(r"Injection Amplitude (\(\mathrm{s}^{-\frac{1}{3}}\))", "Detection Efficiency", width = 108.0)
axes.set_title(r"Detection Efficiency vs.\ Amplitude")
axes.semilogx()
axes.set_position([0.10, 0.150, 0.86, 0.77])
# set desired yticks
axes.set_yticks((0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0))
axes.set_yticklabels((r"\(0\)", r"\(0.1\)", r"\(0.2\)", r"\(0.3\)", r"\(0.4\)", r"\(0.5\)", r"\(0.6\)", r"\(0.7\)", r"\(0.8\)", r"\(0.9\)", r"\(1.0\)"))
axes.xaxis.grid(True, which = "major,minor")
axes.yaxis.grid(True, which = "major,minor")
# put made and found injections in the denominators and
# numerators of the efficiency bins
bins = rate.NDBins((rate.LogarithmicBins(min(sim.amplitude for sim in self.all), max(sim.amplitude for sim in self.all), 400),))
efficiency_num = rate.BinnedArray(bins)
efficiency_den = rate.BinnedArray(bins)
for sim in self.found:
efficiency_num[sim.amplitude,] += 1
for sim in self.all:
efficiency_den[sim.amplitude,] += 1
# generate and plot trend curves. adjust window function
# normalization so that denominator array correctly
# represents the number of injections contributing to each
# bin: make w(0) = 1.0. note that this factor has no
# effect on the efficiency because it is common to the
# numerator and denominator arrays. we do this for the
# purpose of computing the Poisson error bars, which
# requires us to know the counts for the bins
windowfunc = rate.gaussian_window(self.filter_width)
windowfunc /= windowfunc[len(windowfunc) / 2 + 1]
rate.filter_binned_array(efficiency_num, windowfunc)
rate.filter_binned_array(efficiency_den, windowfunc)
# regularize: adjust unused bins so that the efficiency is
# 0, not NaN
assert (efficiency_num <= efficiency_den).all()
efficiency_den[efficiency_num == 0 & efficiency_den == 0] = 1
line1, A50, A50_err = render_data_from_bins(file("string_efficiency.dat", "w"), axes, efficiency_num, efficiency_den, self.cal_uncertainty, self.filter_width, colour = "k", linestyle = "-", erroralpha = 0.2)
print >>sys.stderr, "Pipeline's 50%% efficiency point for all detections = %g +/- %g%%\n" % (A50, A50_err * 100)
# add a legend to the axes
axes.legend((line1,), (r"\noindent Injections recovered with $\Lambda > %s$" % SnglBurstUtils.latexnumber("%.2e" % self.detection_threshold),), loc = "lower right")
# adjust limits
axes.set_xlim([1e-21, 2e-18])
axes.set_ylim([0.0, 1.0])
#
# dump some information about the highest-amplitude missed
# and quietest-amplitude found injections
#
self.loudest_missed.sort(reverse = True)
self.quietest_found.sort(reverse = True)
f = file("string_loud_missed_injections.txt", "w")
print >>f, "Highest Amplitude Missed Injections"
print >>f, "==================================="
for amplitude, sim, offsetvector, filename, likelihood_ratio in self.loudest_missed:
print >>f
print >>f, "%s in %s:" % (str(sim.simulation_id), filename)
if likelihood_ratio is None:
print >>f, "Not recovered"
else:
print >>f, "Recovered with \\Lambda = %.16g, detection threshold was %.16g" % (likelihood_ratio, self.detection_threshold)
for instrument in self.seglists:
print >>f, "In %s:" % instrument
print >>f, "\tInjected amplitude:\t%.16g" % SimBurstUtils.string_amplitude_in_instrument(sim, instrument, offsetvector)
print >>f, "\tTime of injection:\t%s s" % sim.time_at_instrument(instrument, offsetvector)
print >>f, "Amplitude in waveframe:\t%.16g" % sim.amplitude
t = sim.get_time_geocent()
print >>f, "Time at geocentre:\t%s s" % t
print >>f, "Segments within 60 seconds:\t%s" % segmentsUtils.segmentlistdict_to_short_string(self.seglists & segments.segmentlistdict((instrument, segments.segmentlist([segments.segment(t-offsetvector[instrument]-60, t-offsetvector[instrument]+60)])) for instrument in self.seglists))
print >>f, "Vetoes within 60 seconds:\t%s" % segmentsUtils.segmentlistdict_to_short_string(self.vetoseglists & segments.segmentlistdict((instrument, segments.segmentlist([segments.segment(t-offsetvector[instrument]-60, t-offsetvector[instrument]+60)])) for instrument in self.vetoseglists))
f = file("string_quiet_found_injections.txt", "w")
print >>f, "Lowest Amplitude Found Injections"
print >>f, "================================="
for inv_amplitude, sim, offsetvector, filename, likelihood_ratio in self.quietest_found:
print >>f
print >>f, "%s in %s:" % (str(sim.simulation_id), filename)
if likelihood_ratio is None:
print >>f, "Not recovered"
else:
print >>f, "Recovered with \\Lambda = %.16g, detection threshold was %.16g" % (likelihood_ratio, self.detection_threshold)
for instrument in self.seglists:
print >>f, "In %s:" % instrument
print >>f, "\tInjected amplitude:\t%.16g" % SimBurstUtils.string_amplitude_in_instrument(sim, instrument, offsetvector)
print >>f, "\tTime of injection:\t%s s" % sim.time_at_instrument(instrument, offsetvector)
print >>f, "Amplitude in waveframe:\t%.16g" % sim.amplitude
t = sim.get_time_geocent()
print >>f, "Time at geocentre:\t%s s" % t
print >>f, "Segments within 60 seconds:\t%s" % segmentsUtils.segmentlistdict_to_short_string(self.seglists & segments.segmentlistdict((instrument, segments.segmentlist([segments.segment(t-offsetvector[instrument]-60, t-offsetvector[instrument]+60)])) for instrument in self.seglists))
print >>f, "Vetoes within 60 seconds:\t%s" % segmentsUtils.segmentlistdict_to_short_string(self.vetoseglists & segments.segmentlistdict((instrument, segments.segmentlist([segments.segment(t-offsetvector[instrument]-60, t-offsetvector[instrument]+60)])) for instrument in self.vetoseglists))
#
# done
#.........这里部分代码省略.........