def get_delta_t_rss(pt,coinc,reference_frequency=None): """ returns the rss timing error for a particular location in the sky (longitude,latitude) """ latitude,longitude = pt earth_center = (0.0,0.0,0.0) tref = {} tgeo={} for ifo in coinc.ifo_list: if reference_frequency: tFromRefFreq = get_signal_duration(ifo,coinc,reference_frequency) tref[ifo] = lal.LIGOTimeGPS(int(tFromRefFreq), 1.e9*(tFromRefFreq-int(tFromRefFreq))) else: tref[ifo] = 0.0 #compute the geocentric time from each trigger tgeo[ifo] = coinc.gps[ifo] - tref[ifo] - \ lal.LIGOTimeGPS(0,1.0e9*date.XLALArrivalTimeDiff(detector_locations[ifo],\ earth_center,longitude,latitude,coinc.gps[ifo])) #compute differences in these geocentric times time={} delta_t_rms = 0.0 for ifos in coinc.ifo_coincs: time[ifos[0]+ifos[1]] = float(tgeo[ifos[0]] - tgeo[ifos[1]]) delta_t_rms += time[ifos[0]+ifos[1]] * time[ifos[0]+ifos[1]] return sqrt(delta_t_rms)
def get_time_delay(self, ifo1, ifo2, gpstime): """ Return the time delay for this SkyPosition between arrival at ifo1 relative to ifo2, for the given gpstime. """ det1 = inject.cached_detector.get(inject.prefix_to_name[ifo1]) det2 = inject.cached_detector.get(inject.prefix_to_name[ifo2]) return date.XLALArrivalTimeDiff(det1.location, det2.location,\ self.longitude, self.latitude,\ LIGOTimeGPS(gpstime))
def parseTimeDelayDegeneracy(self, ifos, gpstime=lal.GPSTimeNow(),\ dt=0.0005): # get detectors detectors = [inject.cached_detector.get(inject.prefix_to_name[ifo])\ for ifo in ifos] timeDelays = [] degenerate = [] new = table.new_from_template(self) for n, row in enumerate(self): # get all time delays for this point timeDelays.append([]) for i in xrange(len(ifos)): for j in xrange(i + 1, len(ifos)): timeDelays[n].append(date.XLALArrivalTimeDiff(\ detectors[i].location,\ detectors[j].location,\ row.longitude,\ row.latitude,\ LIGOTimeGPS(gpstime))) # skip the first point if n == 0: degenerate.append(False) new.append(row) continue else: degenerate.append(True) # test this point against all others for i in xrange(0, n): # if check point is degenerate, skip if degenerate[i]: continue # check each time delay individually for j in xrange(0, len(timeDelays[n])): # if this time delay is non-degenerate the point is valid if np.fabs(timeDelays[i][j] - timeDelays[n][j]) >= dt: degenerate[n] = False break else: degenerate[n] = True if degenerate[n]: break if not degenerate[n]: new.append(row) return new
def SkyPatch(ifos, ra, dec, radius, gpstime, dt=0.0005, sigma=1.65,\ grid='circular'): """ Returns a SkyPositionTable of circular rings emanating from a given central ra and dec. out to the maximal radius. """ # form centre point p = SkyPosition() p.longitude = ra p.latitude = dec # get detectors ifos.sort() detectors = [] for ifo in ifos: if ifo not in inject.prefix_to_name.keys(): raise ValueError("Interferometer '%s' not recognised." % ifo) detectors.append(inject.cached_detector.get(\ inject.prefix_to_name[ifo])) alpha = 0 for i in xrange(len(ifos)): for j in xrange(i + 1, len(ifos)): # get opening angle baseline = date.XLALArrivalTimeDiff(detectors[i].location,\ detectors[j].location,\ ra, dec, LIGOTimeGPS(gpstime)) ltt = inject.light_travel_time(ifos[i], ifos[j]) angle = np.arccos(baseline / ltt) # get window lmin = angle - radius lmax = angle + radius if lmin < lal.PI_2 and lmax > lal.PI_2: l = lal.PI_2 elif np.fabs(lal.PI_2-lmin) <\ np.fabs(lal.PI_2-lmax): l = lmin else: l = lmax # get alpha dalpha = ltt * np.sin(l) if dalpha > alpha: alpha = dalpha # get angular resolution angRes = 2 * dt / alpha # generate grid if grid.lower() == 'circular': grid = CircularGrid(angRes, radius) else: raise RuntimeError("Must use grid='circular', others not coded yet") # # Need to rotate grid onto (ra, dec) # # calculate opening angle from north pole north = [0, 0, 1] angle = np.arccos(np.dot(north, SphericalToCartesian(p))) #angle = north.opening_angle(p) # get rotation axis axis = np.cross(north, SphericalToCartesian(p)) axis = axis / np.linalg.norm(axis) # rotate grid R = _rotation(axis, angle) grid = grid.rotate(R) # # calculate probability density function # # assume Fisher distribution in angle from centre kappa = (0.66 * radius / sigma)**(-2) # compute probability for p in grid: overlap = np.cos(p.opening_angle(grid[0])) p.probability = np.exp(kappa * (overlap - 1)) probs = [p.probability for p in grid] for p in grid: p.probability = p.probability / max(probs) return grid