def coords(self, contents, coinc_event_id): x = y = None for burst in SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id): if burst.ifo == self.x_instrument: x = self.magnitude(burst) elif burst.ifo == self.y_instrument: y = self.magnitude(burst) return x, y
def coords(self, contents, coinc_event_id): x = y = None for burst in SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id): if burst.ifo == self.x_instrument: x = self.magnitude(burst) elif burst.ifo == self.y_instrument: y = self.magnitude(burst) return x, y
def coords(self, contents, coinc_event_id): mag = numpy.zeros(3, "Float64") for burst in SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id): if burst.ifo == "H1": mag[0] = math.log10(self.magnitude(burst)) elif burst.ifo == "H2": mag[1] = math.log10(self.magnitude(burst)) elif burst.ifo == "L1": mag[2] = math.log10(self.magnitude(burst)) return numpy.inner(mag, self.x), numpy.inner(mag, self.y)
def coords(self, contents, coinc_event_id): mag = numpy.zeros(3, "Float64") for burst in SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id): if burst.ifo == "H1": mag[0] = math.log10(self.magnitude(burst)) elif burst.ifo == "H2": mag[1] = math.log10(self.magnitude(burst)) elif burst.ifo == "L1": mag[2] = math.log10(self.magnitude(burst)) return numpy.inner(mag, self.x), numpy.inner(mag, self.y)
def add_contents(self, contents): # this outer loop assumes each injection can only be found # in at most one coinc, otherwise the "found" count is # wrong. for coinc_event_id, sim_frequency in contents.connection.cursor( ).execute( """ SELECT coinc_event.coinc_event_id, sim_burst.frequency FROM coinc_event JOIN coinc_event_map ON ( coinc_event_map.coinc_event_id == coinc_event.coinc_event_id ) JOIN sim_burst ON ( coinc_event_map.table_name == 'sim_burst' AND sim_burst.simulation_id == coinc_event_map.event_id ) WHERE coinc_event.coinc_def_id == ? """, (contents.sb_definer_id, )): self.found += 1 bursts = tuple( SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id)) for burst in bursts: if burst.ifo == self.instrument: df = math.log(burst.peak_frequency / sim_frequency, 10) try: self.offsets.count[df, ] += 1.0 except IndexError: # outside plot range pass # snr-weighted mean of peak frequencies coinc_freq = sum(burst.peak_frequency * burst.ms_snr for burst in bursts) / sum(burst.ms_snr for burst in bursts) df = math.log(coinc_freq / sim_frequency, 10) try: self.coinc_offsets.count[df, ] += 1.0 except IndexError: # outside plot range pass
def add_contents(self, contents): # this outer loop assumes each injection can only be found # in at most one coinc, otherwise the "found" count is # wrong. for values in contents.connection.cursor().execute( """ SELECT sim_burst.*, coinc_event.coinc_event_id FROM coinc_event JOIN coinc_event_map ON ( coinc_event_map.coinc_event_id == coinc_event.coinc_event_id ) JOIN sim_burst ON ( coinc_event_map.table_name == 'sim_burst' AND coinc_event_map.event_id == sim_burst.simulation_id ) WHERE coinc_def_id == ? """, (contents.sb_definer_id, )): sim = contents.sim_burst_table.row_from_cols(values) coinc_event_id = values[-1] sim_peak = sim.time_at_instrument(self.instrument) self.found += 1 bursts = tuple( SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id)) coinc_dt = 0 for burst in bursts: dt = float(burst.peak - sim_peak) if burst.ifo == self.instrument: try: self.offsets.count[dt, ] += 1.0 except IndexError: # outside plot range pass coinc_dt += dt * burst.ms_snr coinc_dt /= sum(burst.ms_snr for burst in bursts) try: self.coinc_offsets.count[coinc_dt, ] += 1.0 except IndexError: # outside plot range pass
def add_contents(self, contents): # this outer loop assumes each injection can only be found # in at most one coinc, otherwise the "found" count is # wrong. for values in contents.connection.cursor().execute(""" SELECT sim_burst.*, coinc_event.coinc_event_id FROM coinc_event JOIN coinc_event_map ON ( coinc_event_map.coinc_event_id == coinc_event.coinc_event_id ) JOIN sim_burst ON ( coinc_event_map.table_name == 'sim_burst' AND coinc_event_map.event_id == sim_burst.simulation_id ) WHERE coinc_def_id == ? """, (contents.sb_definer_id,)): sim = contents.sim_burst_table.row_from_cols(values) coinc_event_id = values[-1] sim_peak = sim.time_at_instrument(self.instrument) self.found += 1 bursts = tuple(SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id)) coinc_dt = 0 for burst in bursts: dt = float(burst.peak - sim_peak) if burst.ifo == self.instrument: try: self.offsets.count[dt,] += 1.0 except IndexError: # outside plot range pass coinc_dt += dt * burst.ms_snr coinc_dt /= sum(burst.ms_snr for burst in bursts) try: self.coinc_offsets.count[coinc_dt,] += 1.0 except IndexError: # outside plot range pass
def add_contents(self, contents): # this outer loop assumes each injection can only be found # in at most one coinc, otherwise the "found" count is # wrong. for coinc_event_id, sim_frequency in contents.connection.cursor().execute(""" SELECT coinc_event.coinc_event_id, sim_burst.frequency FROM coinc_event JOIN coinc_event_map ON ( coinc_event_map.coinc_event_id == coinc_event.coinc_event_id ) JOIN sim_burst ON ( coinc_event_map.table_name == 'sim_burst' AND sim_burst.simulation_id == coinc_event_map.event_id ) WHERE coinc_event.coinc_def_id == ? """, (contents.sb_definer_id,)): self.found += 1 bursts = tuple(SnglBurstUtils.coinc_sngl_bursts(contents, coinc_event_id)) for burst in bursts: if burst.ifo == self.instrument: df = math.log(burst.peak_frequency / sim_frequency, 10) try: self.offsets.count[df,] += 1.0 except IndexError: # outside plot range pass # snr-weighted mean of peak frequencies coinc_freq = sum(burst.peak_frequency * burst.ms_snr for burst in bursts) / sum(burst.ms_snr for burst in bursts) df = math.log(coinc_freq / sim_frequency, 10) try: self.coinc_offsets.count[df,] += 1.0 except IndexError: # outside plot range pass