def timeDelay(gpsTime, det1, det2):
    """
  Computes the time delay between two detectors dependant on a theoretical signals sky orientation.
  gpsTime is kept constant, however, right ascension and declination are random. Declination is 
  passed through arcsin function to remove over representation of signals in detectors blind spots.
  A positive time delay means the GW arrives first at 'det2', then at 'det1'.
  """

    ra_rad = np.random.uniform(0, 2 * pi)  # right ascension in rads
    de_rad = np.arcsin(np.random.uniform(-1, 1))  # declination

    if det1 == det2:
        return 0.0

    gps = lal.LIGOTimeGPS(gpsTime)

    # create detector-name map
    detMap = {
        'H1': 'LHO_4k',
        'H2': 'LHO_2k',
        'L1': 'LLO_4k',
        'G1': 'GEO_600',
        'V1': 'VIRGO',
        'T1': 'TAMA_300'
    }

    x1 = inject.cached_detector[detMap[det1]].location
    x2 = inject.cached_detector[detMap[det2]].location
    timedelay = lal.ArrivalTimeDiff(list(x1), list(x2), ra_rad, de_rad, gps)

    return timedelay
Exemple #2
0
    def time_delay_from_detector(self, other_detector, right_ascension,
                                 declination, t_gps):
        """Return the time delay from the given to detector for a signal with
        the given sky location; i.e. return `t1 - t2` where `t1` is the
        arrival time in this detector and `t2` is the arrival time in the
        other detector. Note that this would return the same value as
        `time_delay_from_earth_center` if `other_detector` was geocentric.

        Parameters
        ----------
        other_detector : detector.Detector
            A detector instance.
        right_ascension : float
            The right ascension (in rad) of the signal.
        declination : float
            The declination (in rad) of the signal.
        t_gps : float
            The GPS time (in s) of the signal.

        Returns
        -------
        float
            The arrival time difference between the detectors.
        """
        return lal.ArrivalTimeDiff(self.location, other_detector.location,
                                   float(right_ascension), float(declination),
                                   float(t_gps))
Exemple #3
0
def timeDelay(gpsTime, rightAscension, declination, unit, det1, det2):
    """
  timeDelay( gpsTime, rightAscension, declination, unit, det1, det2 )
  
  Calculates the time delay in seconds between the detectors
  'det1' and 'det2' (e.g. 'H1') for a sky location at (rightAscension
  and declination) which must be given in certain units
  ('radians' or 'degree'). The time is passes as GPS time.
  A positive time delay means the GW arrives first at 'det2', then at 'det1'.
    
  Example:
  antenna.timeDelay( 877320548.000, 355.084,31.757, 'degree','H1','L1')
  0.0011604683260994519

  Given these values, the signal arrives first at detector L1,
  and 1.16 ms later at H2
  """

    # check the input arguments
    if unit == 'radians':
        ra_rad = rightAscension
        de_rad = declination
    elif unit == 'degree':
        ra_rad = rightAscension / 180.0 * pi
        de_rad = declination / 180.0 * pi
    else:
        raise ValueError, "Unknown unit %s" % unit

    # check input values
    if ra_rad < 0.0 or ra_rad > 2 * pi:
        raise ValueError, "ERROR. right ascension=%f "\
              "not within reasonable range."\
              % (rightAscension)

    if de_rad < -pi or de_rad > pi:
        raise ValueError, "ERROR. declination=%f not within reasonable range."\
              % (declination)

    if det1 == det2:
        return 0.0

    gps = lal.LIGOTimeGPS(gpsTime)

    # create detector-name map
    detMap = {
        'H1': 'LHO_4k',
        'H2': 'LHO_2k',
        'L1': 'LLO_4k',
        'G1': 'GEO_600',
        'V1': 'VIRGO',
        'T1': 'TAMA_300'
    }

    x1 = inject.cached_detector[detMap[det1]].location
    x2 = inject.cached_detector[detMap[det2]].location
    timedelay = lal.ArrivalTimeDiff(list(x1), list(x2), ra_rad, de_rad, gps)

    return timedelay
Exemple #4
0
    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 = cached_detector.get(prefix_to_name[ifo1])
        det2 = cached_detector.get(prefix_to_name[ifo2])

        return lal.ArrivalTimeDiff(det1.location, det2.location,\
                                        self.longitude, self.latitude,\
                                        lal.LIGOTimeGPS(gpstime))
Exemple #5
0
 def test_delay_from_detector(self):
     ra, dec, time = self.ra[0:10], self.dec[0:10], self.time[0:10]
     for d1 in self.d:
         for d2 in self.d:
             time1 = []
             for ra1, dec1, tim1 in zip(ra, dec, time):
                 t1 = lal.ArrivalTimeDiff(d1.location, d2.location,
                                          ra1, dec1, tim1)
                 time1.append(t1)
             time1 = numpy.array(time1)
             time2 = d1.time_delay_from_detector(d2, ra, dec, time)
             self.assertLess(abs(time1 - time2).max(), 1e-3)
Exemple #6
0
    def parseTimeDelayDegeneracy(self, ifos, gpstime=lal.GPSTimeNow(),\
                                 dt=0.0005):

        # get detectors
        detectors = [cached_detector.get(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(lal.ArrivalTimeDiff(\
                                             detectors[i].location,\
                                             detectors[j].location,\
                                             row.longitude,\
                                             row.latitude,\
                                             lal.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
Exemple #7
0
def XLALTimeDelayFromEarthCenter(pos, ra, dec, gps):
	return lal.ArrivalTimeDiff(pos, (0.0, 0.0, 0.0), ra, dec, gps)
Exemple #8
0
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 prefix_to_name.keys():
            raise ValueError("Interferometer '%s' not recognised." % ifo)
        detectors.append(cached_detector.get(\
                             prefix_to_name[ifo]))

    alpha = 0
    for i in xrange(len(ifos)):
        for j in xrange(i + 1, len(ifos)):
            # get opening angle
            baseline = lal.ArrivalTimeDiff(detectors[i].location,\
                                                detectors[j].location,\
                                                ra, dec, lal.LIGOTimeGPS(gpstime))
            ltt = float(
                lal.LIGOTimeGPS(
                    0, lal.LightTravelTime(detectors[i], detectors[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