示例#1
0
def get_delta_D_rss(pt,coinc):
  """
  compute the rms difference in the ratio of the difference of the squares of Deff to
  the sum of the squares of Deff between the measured values and a "marginalized" effective
  distance this is just the squared Deff integrated over inclination and polarization which
  is proportional to (F+^2 + Fx^2)^(-1)
  """
  latitude,longitude = pt
  gmst = {}
  D_marg_sq = {}
  F_plus = {}
  F_cross = {}
  for ifo in coinc.ifo_list:
    gmst[ifo] = date.XLALGreenwichMeanSiderealTime(coinc.gps[ifo])
    F_plus[ifo], F_cross[ifo] = lal.ComputeDetAMResponse(detector_responses[ifo],\
                                longitude,latitude,0,gmst[ifo])
    D_marg_sq[ifo] = 1/(F_plus[ifo]*F_plus[ifo]+F_cross[ifo]*F_cross[ifo])

  delta_D = {}
  effD_diff = 0.0
  effD_sum = 0.0
  Dmarg_diff = 0.0
  Dmarg_sum = 0.0
  delta_D_rss = 0.0
  for ifos in coinc.ifo_coincs:
    effD_diff = coinc.eff_distances[ifos[0]] * coinc.eff_distances[ifos[0]]\
                - coinc.eff_distances[ifos[1]] * coinc.eff_distances[ifos[1]]
    effD_sum = coinc.eff_distances[ifos[0]] * coinc.eff_distances[ifos[0]]\
               + coinc.eff_distances[ifos[1]] * coinc.eff_distances[ifos[1]]
    Dmarg_diff = D_marg_sq[ifos[0]] - D_marg_sq[ifos[1]]
    Dmarg_sum = D_marg_sq[ifos[0]] + D_marg_sq[ifos[1]]
    delta_D[ifos[0]+ifos[1]] = (effD_diff/effD_sum) - (Dmarg_diff/Dmarg_sum)
    delta_D_rss += delta_D[ifos[0]+ifos[1]]*delta_D[ifos[0]+ifos[1]]

  return sqrt(delta_D_rss)
def delay_and_amplitude_correct(event, ra, dec):
    # retrieve station metadata

    detector = inject.cached_detector[inject.prefix_to_name[event.ifo]]

    # delay-correct the event to the geocentre

    delay = date.XLALTimeDelayFromEarthCenter(detector.location, ra, dec,
                                              event.peak)
    event.peak -= delay
    event.start -= delay
    event.ms_start -= delay

    # amplitude-correct the event using the polarization-averaged
    # antenna response

    fp, fc = inject.XLALComputeDetAMResponse(
        detector.response, ra, dec, 0,
        date.XLALGreenwichMeanSiderealTime(peak))
    mean_response = math.sqrt(fp**2 + fc**2)
    event.amplitude /= mean_response
    event.ms_hrss /= mean_response

    # done

    return event
示例#3
0
def delay_and_amplitude_correct(event, ra, dec):
    # retrieve station metadata

    detector = lal.cached_detector_by_prefix[event.ifo]

    # delay-correct the event to the geocentre

    delay = date.XLALTimeDelayFromEarthCenter(detector.location, ra, dec,
                                              event.peak)
    event.peak -= delay
    event.period = event.period.shift(-delay)
    try:
        event.ms_peak -= delay
    except AttributeError:
        pass
    try:
        event.ms_period = event.ms_period.shift(-delay)
    except AttributeError:
        pass

    # amplitude-correct the event using the polarization-averaged
    # antenna response

    fp, fc = lal.ComputeDetAMResponse(
        detector.response, ra, dec, 0,
        date.XLALGreenwichMeanSiderealTime(event.peak))
    mean_response = math.sqrt(fp**2 + fc**2)
    event.amplitude /= mean_response
    event.ms_hrss /= mean_response

    # done

    return event
示例#4
0
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 observed in the instrument.  That is,
	project the waveform onto the instrument, and return the root
	integrated strain squared.
	"""
    # FIXME:  this function is really only correct for sine-Gaussian
    # injections.  that's OK because I only quote sensitivities in
    # units of hrss when discussing sine-Gaussians.
    #
    # the problem is the following.  first,
    #
    #	h = F+ h+ + Fx hx
    #
    # so
    #
    #	h^{2} = F+^2 h+^2 + Fx^2 hx^2 + 2 F+ Fx h+ hx
    #
    # which means to calculate the hrss in the instrument you need to
    # know:  mean-square h in the + polarization, mean-square h in the
    # x polarization, and the correlation between the polarizations <h+
    # hx>.  these could be recorded in the sim_burst table, but they
    # aren't at present.

    # semimajor and semiminor axes of polarization ellipse

    a = 1.0 / math.sqrt(2.0 - sim.pol_ellipse_e**2)
    b = a * math.sqrt(1.0 - sim.pol_ellipse_e**2)

    # hrss in plus and cross polarizations

    hplusrss = sim.hrss * (a * math.cos(sim.pol_ellipse_angle) -
                           b * math.sin(sim.pol_ellipse_angle))
    hcrossrss = sim.hrss * (b * math.cos(sim.pol_ellipse_angle) +
                            a * math.sin(sim.pol_ellipse_angle))

    # antenna response factors

    fplus, fcross = inject.XLALComputeDetAMResponse(
        inject.cached_detector[inject.prefix_to_name[instrument]].response,
        sim.ra, sim.dec, sim.psi,
        date.XLALGreenwichMeanSiderealTime(
            time_at_instrument(sim, instrument, offsetvector)))

    # hrss in detector

    return math.sqrt((fplus * hplusrss)**2 + (fcross * hcrossrss)**2)
示例#5
0
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 should be observed in the
	instrument.
	"""
    assert sim.waveform == "StringCusp"

    # antenna response factors

    fplus, fcross = inject.XLALComputeDetAMResponse(
        inject.cached_detector[inject.prefix_to_name[instrument]].response,
        sim.ra, sim.dec, sim.psi,
        date.XLALGreenwichMeanSiderealTime(
            time_at_instrument(sim, instrument, offsetvector)))

    # amplitude in detector

    return fplus * sim.amplitude
    def coinc_params(events, offsetvector):
        #
        # check for coincs that have been vetoed entirely
        #

        if len(events) < 2:
            return None

        params = {}

        # the "time" is the ms_snr squared weighted average of the
        # peak times neglecting light-travel times.  because
        # LIGOTimeGPS objects have overflow problems in this sort
        # of a calculation, the first event's peak time is used as
        # an epoch and the calculations are done w.r.t. that time.

        # FIXME: this time is available as the peak_time in the
        # multi_burst table, and it should be retrieved from that
        # table instead of being recomputed
        events = tuple(events)
        t = events[0].peak
        t += sum(
            float(event.peak - t) * event.ms_snr**2.0
            for event in events) / sum(event.ms_snr**2.0 for event in events)
        gmst = date.XLALGreenwichMeanSiderealTime(t) % (2 * math.pi)

        for event1, event2 in iterutils.choices(
                sorted(events, lambda a, b: cmp(a.ifo, b.ifo)), 2):
            if event1.ifo == event2.ifo:
                # a coincidence is parameterized only by
                # inter-instrument deltas
                continue

            prefix = "%s_%s_" % (event1.ifo, event2.ifo)

            # in each of the following, if the list of events contains
            # more than one event from a given instrument, the smallest
            # deltas are recorded

            dt = float(event1.peak + offsetvector[event1.ifo] - event2.peak -
                       offsetvector[event2.ifo])
            name = "%sdt" % prefix
            if name not in params or abs(params[name][0]) > abs(dt):
                #params[name] = (dt,)
                params[name] = (dt, gmst)

            df = (event1.peak_frequency - event2.peak_frequency) / (
                (event1.peak_frequency + event2.peak_frequency) / 2)
            name = "%sdf" % prefix
            if name not in params or abs(params[name][0]) > abs(df):
                #params[name] = (df,)
                params[name] = (df, gmst)

            dh = (event1.ms_hrss - event2.ms_hrss) / (
                (event1.ms_hrss + event2.ms_hrss) / 2)
            name = "%sdh" % prefix
            if name not in params or abs(params[name][0]) > abs(dh):
                #params[name] = (dh,)
                params[name] = (dh, gmst)

            dband = (event1.ms_bandwidth - event2.ms_bandwidth) / (
                (event1.ms_bandwidth + event2.ms_bandwidth) / 2)
            name = "%sdband" % prefix
            if name not in params or abs(params[name][0]) > abs(dband):
                #params[name] = (dband,)
                params[name] = (dband, gmst)

            ddur = (event1.ms_duration - event2.ms_duration) / (
                (event1.ms_duration + event2.ms_duration) / 2)
            name = "%sddur" % prefix
            if name not in params or abs(params[name][0]) > abs(ddur):
                #params[name] = (ddur,)
                params[name] = (ddur, gmst)

        return params