示例#1
0
    def project_strain(self, hplus, hcross, skypoint, psi):
        """ Project hplus and hcross onto the detector frame 
        assuming a given sky location and polarization of the source.
        Apply consistent time delay due to wave propagation.

        hplus, hcross: plus and cross polarisation (REAL8TimeSeries)
        skypoint: Skypoint object
        psi: polarization angle in radians

        This function uses SimDetectorStrainREAL8TimeSeries() that takes equatorial 
        coordinates (RA and dec) and the epoch signal epoch to define the sky location
        and corresponding mapping to an Earth-fixed coordinate system.

        If the skypoint is given in the geographic coordinate system,
        they are mapped to the equatorial coordinate system with
        reference time set to the epoch of hplus and hcross.

        """
        assert hplus.data.length == hcross.data.length, \
                          'The polarization time series must have same size'
        assert hplus.deltaT == hcross.deltaT, \
                          'The polarization time series must have the same sampling step'
        assert hplus.epoch == hcross.epoch, \
                          'The polarization time series must have the same epoch'

        assert skypoint.coordsystem.is_valid(), "Unsupported coordinate system"

        # If the skypoint is in the geographic coordinate system we transform
        # to the equatorial frame at the signal epoch
        if skypoint.coordsystem.name == 'geographic':
            skypoint = skypoint.transformed_to(
                Coordsystem('equatorial', hplus.epoch))

        #print(skypoint.coords(fmt='lonlat',unit='radians'))

        return TimeSeries.from_lal(SimDetectorStrainREAL8TimeSeries( \
                                        hplus, hcross, \
                                        *skypoint.coords(fmt='lonlat',unit='radians'), \
                                        psi, self.descriptor))
示例#2
0
def burst_inject(ts_data,
                 loc=0.5,
                 duration=0.1,
                 hrss=0.0275,
                 amp=100.,
                 plot=True,
                 sine=False):
    '''
    Inject burst signal in time series data

    Parameters
    ----------
    ts_data : TimeSeries
      Time series magnetic field data
    duration : float
      Duration of the burst
    hrss : float
      hrss

    Return
    ------
    ts_data : TimeSeries
      New time series data with injected burst
    hp : TimeSeries
      Time series data of the burst signal only
    '''
    # Define sampling rate
    sample_rate = float(ts_data.sample_rate)
    # Define time period from sampling rate
    delta_t = 1.0 / sample_rate
    # Define start time of the time series
    t0 = float(ts_data.start_time)
    # Define final time of the time series
    t1 = t0 + len(ts_data) / sample_rate
    if sine:
        # First method to create sine gaussian burst
        f_0 = 18
        filter_band = 4
        q = math.sqrt(2) * f_0 / filter_band * 2
        # Create sine gaussian burst
        hp, hx = SimBurstSineGaussian(q * 2, f_0, hrss, 1, 0, delta_t)
    else:
        # Create  gaussian burst
        hp, hx = SimBurstGaussian(duration, hrss, delta_t)
    hp = TimeSeries.from_lal(hp)
    hx = TimeSeries.from_lal(hx)
    # We rescale the amplitude to hide or expose it in the data a bit better
    hp *= amp
    if plot:
        # Plot fake burst signal
        pyplot.plot(hp.times, hp, 'k-')
        #pyplot.xlim([-0.5, 0.5])
        #pyplot.ylim([-0.1, 0.1]);
        pyplot.xlabel('Time (s)')
        pyplot.ylabel('Magnitude')
        pyplot.savefig('fakesignal.png')
        pyplot.close()
    # Define burst epoch
    hp.epoch = int(t0 + loc * (t1 - t0))
    # Define burst first timestamp
    st = int((hp.epoch.value - t0) * sample_rate - len(hp) / 2)
    # Define burst final timestamp
    en = st + len(hp)
    # Convert time series into gwpy.timeseries.TimeSeries format
    ts_data = TimeSeries(ts_data, sample_rate=sample_rate, epoch=t0)
    # Include burst in data
    ts_data[st:en] += hp
    # Convert back to pycbc.types.TimeSeries format
    ts_data = types.TimeSeries(ts_data.value,
                               delta_t=1.0 / sample_rate,
                               epoch=t0)
    # Return time series with burst included
    return ts_data, hp