35from .
import SnglBurstUtils
38__author__ =
"Kipp Cannon <kipp.cannon@ligo.org>"
39from .git_version
import date
as __date__
40from .git_version
import version
as __version__
54 Return a set of the names of the instruments that were on at the
55 time of the injection.
57 return set(instrument
for instrument, seglist
in seglists.items()
if sim.time_at_instrument(instrument, offsetvector)
in seglist)
71 Given an injection and an instrument, compute and return the h_rss
72 of the injection as should be observed in the instrument. That is,
73 project the waveform onto the instrument,
and return the root
74 integrated strain squared.
76 # FIXME: this function is really only correct
for sine-Gaussian
96 a = 1.0 / math.sqrt(2.0 - sim.pol_ellipse_e**2)
97 b = a * math.sqrt(1.0 - sim.pol_ellipse_e**2)
101 hplusrss = sim.hrss * (a * math.cos(sim.pol_ellipse_angle) - b * math.sin(sim.pol_ellipse_angle))
102 hcrossrss = sim.hrss * (b * math.cos(sim.pol_ellipse_angle) + a * math.sin(sim.pol_ellipse_angle))
106 fplus, fcross = lal.ComputeDetAMResponse(
107 lal.cached_detector_by_prefix[instrument].response,
111 lal.GreenwichMeanSiderealTime(sim.time_at_instrument(instrument, offsetvector))
116 return math.sqrt((fplus * hplusrss)**2 + (fcross * hcrossrss)**2)
121 Given a string cusp injection and an instrument, compute and return
122 the amplitude of the injection as should be observed in the
125 assert sim.waveform ==
"StringCusp"
129 fplus, fcross = lal.ComputeDetAMResponse(
130 lal.cached_detector_by_prefix[instrument].response,
134 lal.GreenwichMeanSiderealTime(sim.time_at_instrument(instrument, offsetvector))
139 return fplus * sim.amplitude
160stringcusp_autocorrelation_width = .016
169burst_is_near_injection_window = 2.0
178 def __init__(self, instruments, amplitude_func, amplitude_lbl, error):
192 cursor = contents.connection.cursor()
193 for values
in contents.connection.cursor().execute(
"""
196 coinc_event.coinc_event_id
199 -- The rest of this join can yield at most 1 row for each sim_burst
201 LEFT OUTER JOIN coinc_event_map ON (
202 coinc_event_map.table_name == 'sim_burst'
203 AND coinc_event_map.event_id == sim_burst.simulation_id
205 LEFT OUTER JOIN coinc_event ON (
206 coinc_event.coinc_event_id == coinc_event_map.coinc_event_id
209 coinc_event.coinc_def_id == ?
210 """, (contents.sb_definer_id,)):
211 sim = contents.sim_burst_table.row_from_cols(values)
212 coinc_event_id = values[-1]
213 instruments = set(cursor.execute("""
219 coinc_event_map.table_name == 'sngl_burst'
220 AND coinc_event_map.event_id == sngl_burst.event_id
223 coinc_event_map.coinc_event_id == ?
224 """, (coinc_event_id,)))
229 if injection_was_made(sim, contents.seglists, self.
instruments):
238 print(
"odd, injection %s was found in %s but not injected..." % (sim.simulation_id,
"+".join(self.
instruments)), file=sys.stderr)
240 def _bin_events(self, binning = None):
245 binning = rate.NDBins((rate.LogarithmicBins(minx, maxx, 256), rate.LogarithmicBins(miny, maxy, 256)))
269 raise ValueError(
"smoothing filter too large (not enough injections)")
272 print(
"which is %g%% x %g%% of the binning" % (100.0 * self.
window_size_x / binning[0].n, 100.0 * self.
window_size_y / binning[1].n), file=sys.stderr)
282 print(
"Sum of numerator bins before smoothing = %g" % self.
efficiency.numerator.array.sum(), file=sys.stderr)
283 print(
"Sum of denominator bins before smoothing = %g" % self.
efficiency.denominator.array.sum(), file=sys.stderr)
285 print(
"Sum of numerator bins after smoothing = %g" % self.
efficiency.numerator.array.sum(), file=sys.stderr)
286 print(
"Sum of denominator bins after smoothing = %g" % self.
efficiency.denominator.array.sum(), file=sys.stderr)
294 Generate a plot from an Efficiency_hrss_vs_freq instance.
296 fig, axes = SnglBurstUtils.make_burst_plot(
"Frequency (Hz)", efficiency.amplitude_lbl)
299 xcoords, ycoords = efficiency.efficiency.centres()
300 zvals = efficiency.efficiency.ratio()
301 cset = axes.contour(xcoords, ycoords, zvals.T, (.1, .2, .3, .4, .5, .6, .7, .8, .9))
302 cset.clabel(inline =
True, fontsize = 5, fmt =
r"$%%g \pm %g$" % efficiency.error, colors =
"k")
303 axes.set_title(
r"%s Injection Detection Efficiency (%d of %d Found)" % (
"+".join(sorted(efficiency.instruments)), len(efficiency.found_x), len(efficiency.injected_x)))
323MW_CENTER_J2000_RA_RAD = 2.0318570464121519
324MW_CENTER_J2000_DEC_RAD = -0.50628171572274738
static double max(double a, double b)
static double min(double a, double b)
def on_instruments(sim, seglists, offsetvector)
Return a set of the names of the instruments that were on at the time of the injection.
def string_amplitude_in_instrument(sim, instrument, offsetvector)
Given a string cusp injection and an instrument, compute and return the amplitude of the injection as...
def plot_Efficiency_hrss_vs_freq(efficiency)
Generate a plot from an Efficiency_hrss_vs_freq instance.
def hrss_in_instrument(sim, instrument, offsetvector)
Given an injection and an instrument, compute and return the h_rss of the injection as should be obse...