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
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)
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 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] = inject.XLALComputeDetAMResponse(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 response(gpsTime, rightAscension, declination, inclination, polarization, unit, det): """ response( gpsTime, rightAscension, declination, inclination, polarization, unit, detector ) Calculates the antenna factors for a detector 'detector' (e.g. 'H1') at a given gps time (as integer) for a given sky location (rightAscension, declination) in some unit (degree/radians). This computation also takes into account a specific inclination and polarization. The returned values are: (f-plus, f-cross, f-average, q-value). Example: antenna.response( 854378604.780, 11.089, 42.308, 0, 0, 'radians', 'H1' ) """ # check the input arguments if unit == 'radians': ra_rad = rightAscension de_rad = declination psi_rad = polarization iota_rad = inclination elif unit == 'degree': ra_rad = rightAscension / 180.0 * pi de_rad = declination / 180.0 * pi psi_rad = polarization / 180.0 * pi iota_rad = inclination / 180.0 * pi else: raise ValueError, "Unknown unit %s" % unit # calculate GMST if the GPS time gps = LIGOTimeGPS(gpsTime) gmst_rad = GreenwichMeanSiderealTime(gps) # create detector-name map detMap = { 'H1': 'LHO_4k', 'H2': 'LHO_2k', 'L1': 'LLO_4k', 'G1': 'GEO_600', 'V1': 'VIRGO', 'T1': 'TAMA_300' } try: detector = detMap[det] except KeyError: raise ValueError, "ERROR. Key %s is not a valid detector name."\ % (det) # get detector if detector not in inject.cached_detector.keys(): raise ValueError, "%s is not a cached detector. "\ "Cached detectors are: %s" \ % (det, inject.cached_detector.keys()) # get the correct response data response = inject.cached_detector[detector].response # actual computation of antenna factors f_plus, f_cross = inject.XLALComputeDetAMResponse(response, ra_rad, de_rad, psi_rad, gmst_rad) f_ave = sqrt((f_plus * f_plus + f_cross * f_cross) / 2.0) ci = cos(iota_rad) cc = ci * ci # calculate q-value, e.g. ratio of effective to real distance # ref: Duncans PhD, eq. (4.3) on page 57 f_q = sqrt(f_plus * f_plus * (1 + cc) * (1 + cc) / 4.0 + f_cross * f_cross * cc) # output return f_plus, f_cross, f_ave, f_q