예제 #1
0
    def times(self, times):
        """
        Set an array of times, and also a @b LIGOTimeGPSVector() containing the
        times.
        """

        if times is None:
            self.__times = None
            self.__gpstimes = None
            return
        elif isinstance(times, lal.LIGOTimeGPS):
            self.__times = np.array(
                [times.gpsSeconds + 1e-9 * times.gpsNanoSeconds],
                dtype='float64')
            self.__gpstimes = lalpulsar.CreateTimestampVector(1)
            self.__gpstimes.data[0] = times
            return
        elif isinstance(times, lalpulsar.LIGOTimeGPSVector):
            self.__gpstimes = times
            self.__times = np.zeros(len(times.data), dtype='float64')
            for i, gpstime in enumerate(times.data):
                self.__times[i] = times.data[
                    i].gpsSeconds + 1e-9 * times.data[i].gpsNanoSeconds
            return
        elif isinstance(times, (int, float)):
            self.__times = np.array([times], dtype='float64')
        elif isinstance(times, (list, np.ndarray)):
            self.__times = np.array(times, dtype='float64')
        else:
            raise TypeError("Unknown data type for times")

        self.__gpstimes = lalpulsar.CreateTimestampVector(len(self.__times))
        for i, time in enumerate(self.__times):
            self.__gpstimes.data[i] = lal.LIGOTimeGPS(time)
예제 #2
0
    def times(self, times):
        """
        Set an array of times, and also a ``LIGOTimeGPSVector()`` containing
        the times.

        Parameters
        ----------
        times: array_like
            An array of GPS times. This can be a :class:`astropy.time.Time`
            object, for which inputs will be converted to GPS is not already
            held as GPS times.
        """

        from astropy.time import Time

        if times is None:
            self.__times = None
            self.__gpstimes = None
            return
        elif isinstance(times, lal.LIGOTimeGPS):
            self.__times = np.array(
                [times.gpsSeconds + 1e-9 * times.gpsNanoSeconds], dtype=np.float128
            )
            self.__gpstimes = lalpulsar.CreateTimestampVector(1)
            self.__gpstimes.data[0] = times
            return
        elif isinstance(times, lalpulsar.LIGOTimeGPSVector):
            self.__gpstimes = times
            self.__times = np.zeros(len(times.data), dtype=np.float128)
            for i in range(len(times.data)):
                self.__times[i] = (
                    times.data[i].gpsSeconds + 1e-9 * times.data[i].gpsNanoSeconds
                )
            return
        elif isinstance(times, (int, float, np.float128, list, tuple, np.ndarray)):
            self.__times = np.atleast_1d(np.array(times, dtype=np.float128))
        elif isinstance(times, Time):
            self.__times = np.atleast_1d(times.gps).astype(np.float128)
        else:
            raise TypeError("Unknown data type for times")

        self.__gpstimes = lalpulsar.CreateTimestampVector(len(self.__times))
        for i, time in enumerate(self.__times):
            seconds = int(np.floor(time))
            nanoseconds = int((time - seconds) * 1e9)
            self.__gpstimes.data[i] = lal.LIGOTimeGPS(seconds, nanoseconds)
예제 #3
0
def test_two():
    parhet = PulsarParametersPy()
    parhet['F'] = [123.4567, -9.876e-12]  # set frequency
    parhet['RAJ'] = lal.TranslateHMStoRAD('01:23:34.6')  # set right ascension
    parhet['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.5')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parhet['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parhet['H0'] = 5.6e-26
    parhet['COSIOTA'] = -0.2
    parhet['PSI'] = 0.4
    parhet['PHI0'] = 2.3

    parinj = PulsarParametersPy()
    parinj['F'] = [123.456789, -9.87654321e-12]  # set frequency
    parinj['DELTAF'] = parinj['F'] - parhet['F']  # frequency difference
    parinj['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')  # set right ascension
    parinj['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parinj['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parinj['H0'] = 5.6e-26
    parinj['COSIOTA'] = -0.2
    parinj['PSI'] = 0.4
    parinj['PHI0'] = 2.3

    freqfactor = 2.  # set frequency factor
    det = 'H1'  # the detector

    # convert into GPS times
    gpstimes = lalpulsar.CreateTimestampVector(len(t2output))
    for i, time in enumerate(t2output[:, 0]):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    detector = lalpulsar.GetSiteInfo(det)

    # set the response function look-up table
    dt = t2output[1, 0] - t2output[0, 0]  # time step
    resp = lalpulsar.DetResponseLookupTable(t2output[0, 0], detector,
                                            parhet['RAJ'], parhet['DECJ'],
                                            2880, dt)

    # get the heterodyned file SSB delay
    hetSSBdelay = lalpulsar.HeterodynedPulsarGetSSBDelay(
        parhet.PulsarParameters(), gpstimes, detector, edat, tdat,
        lalpulsar.TIMECORRECTION_TCB)

    fullsignal = lalpulsar.HeterodynedPulsarGetModel(
        parinj.PulsarParameters(), freqfactor, 1, 0, 0, gpstimes, hetSSBdelay,
        1, None, 0, resp, edat, tdat, lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_pulsar_parameter_estimation_nested
    if np.any(np.abs(fullsignal.data.data.real - t2output[:, 1]) > 1e-34):
        return False
    elif np.any(np.abs(fullsignal.data.data.imag - t2output[:, 2]) > 1e-34):
        return False
    else:
        return True
예제 #4
0
def test_three(harmonic):
    parhet = PulsarParametersPy()
    parhet['F'] = [123.4567, -9.876e-12]  # set frequency
    parhet['RAJ'] = lal.TranslateHMStoRAD('01:23:34.6')  # set right ascension
    parhet['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.5')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parhet['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parhet['C22'] = 5.6e-26
    parhet['C21'] = 1.4e-25
    parhet['COSIOTA'] = -0.2
    parhet['PSI'] = 0.4
    parhet['PHI21'] = 2.3
    parhet['PHI22'] = 4.5

    parinj = PulsarParametersPy()
    parinj['F'] = [123.456789, -9.87654321e-12]  # set frequency
    parinj['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')  # set right ascension
    parinj['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parinj['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parinj['C22'] = 5.6e-26
    parinj['C21'] = 1.4e-25
    parinj['COSIOTA'] = -0.2
    parinj['PSI'] = 0.4
    parinj['PHI21'] = 2.3
    parinj['PHI22'] = 4.5

    det = 'H1'  # the detector
    detector = lalpulsar.GetSiteInfo(det)

    freqfactor = float(harmonic)  # set frequency factor

    # convert into GPS times
    gpstimes = lalpulsar.CreateTimestampVector(len(t3output[harmonic]))
    for i, time in enumerate(t3output[harmonic][:, 0]):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    # set the response function look-up table
    dt = t3output[harmonic][1, 0] - t3output[harmonic][0, 0]  # time step
    resp = lalpulsar.DetResponseLookupTable(t3output[harmonic][0, 0], detector,
                                            parhet['RAJ'], parhet['DECJ'],
                                            2880, dt)

    # get the heterodyned file SSB delay
    hetSSBdelay = lalpulsar.HeterodynedPulsarGetSSBDelay(
        parhet.PulsarParameters(), gpstimes, detector, edat, tdat,
        lalpulsar.TIMECORRECTION_TCB)

    fullsignal = lalpulsar.HeterodynedPulsarGetModel(
        parinj.PulsarParameters(), parhet.PulsarParameters(), freqfactor, 1, 0,
        0, gpstimes, hetSSBdelay, 1, None, 0, None, 0, None, 0, resp, edat,
        tdat, lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_pulsar_parameter_estimation_nested
    assert_allclose(fullsignal.data.data.real, t3output[harmonic][:, 1])
    assert_allclose(fullsignal.data.data.imag, t3output[harmonic][:, 2])
예제 #5
0
    def get_sfts(self, fmax, Tsft, noise_sqrt_Sh=0, noise_seed=0, window=None, window_param=0):
        """
        Generate SFTs [2] containing strain time series of a continuous-wave signal.

        @param fmax: maximum SFT frequency, in Hz
        @param Tsft: length of each SFT, in seconds; should divide evenly into @b Tdata
        @param noise_sqrt_Sh: if >0, add Gaussian noise with square-root single-sided power
            spectral density given by this value, in Hz^(-1/2)
        @param noise_seed: use this need for the random number generator used to create noise
        @param window: if not None, window the time series before performing the FFT, using
            the named window function; see XLALCreateNamedREAL8Window()
        @param window_param: parameter for the window function given by @b window, if needed

        @return (@b sft, @b i, @b N), where:
            @b sft = SFT;
            @b i = SFT file index, starting from zero;
            @b N = number of SFTs

        This is a Python generator function and so should be called as follows:
        ~~~
        S = CWSimulator(...)
        for sft, i, N in S.get_sfts(...):
            ...
        ~~~

        [2] https://dcc.ligo.org/LIGO-T040164/public
        """

        # create timestamps for generating one SFT per time series
        sft_ts = lalpulsar.CreateTimestampVector(1)
        sft_ts.deltaT = Tsft

        # generate strain time series in blocks of length 'Tsft'
        sft_h = None
        sft_fs = 2 * fmax
        for t, h, i, N in self.get_strain_blocks(sft_fs, Tsft, noise_sqrt_Sh=noise_sqrt_Sh, noise_seed=noise_seed):

            # create and initialise REAL8TimeSeries to write to SFT files
            if sft_h is None:
                sft_name = self.__site.frDetector.prefix
                sft_h = lal.CreateREAL8TimeSeries(sft_name, t, 0, 1.0 / sft_fs, lal.DimensionlessUnit, len(h))
            sft_h.epoch = t
            sft_h.data.data = h

            # create SFT, possibly with windowing
            sft_ts.data[0] = t
            sft_vect = lalpulsar.MakeSFTsFromREAL8TimeSeries(sft_h, sft_ts, window, window_param)

            # yield current SFT
            yield sft_vect.data[0], i, N
예제 #6
0
파일: snr.py 프로젝트: PyFstat/PyFstat
    def _numpy_array_to_LIGOTimeGPSVector(numpy_array, Tsft=None):
        """
        Maps a numpy array of floats into a LIGOTimeGPS array using `np.floor`
        to separate seconds and nanoseconds.
        """

        if numpy_array.ndim != 1:
            raise ValueError(
                f"Time stamps array must be 1D: Current one has {numpy_array.ndim}."
            )

        seconds_array = np.floor(numpy_array)
        nanoseconds_array = np.floor(1e9 * (numpy_array - seconds_array))

        time_gps_vector = lalpulsar.CreateTimestampVector(numpy_array.shape[0])
        for ind in range(time_gps_vector.length):
            time_gps_vector.data[ind] = lal.LIGOTimeGPS(
                int(seconds_array[ind]), int(nanoseconds_array[ind]))
            time_gps_vector.deltaT = Tsft or 0

        return time_gps_vector
예제 #7
0
def test_five():
    par = PulsarParametersPy()
    par['F'] = [123.456789, -9.87654321e-12]  # set frequency
    par['DELTAF'] = [0.0, 0.0]  # frequency difference
    par['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')  # set right ascension
    par['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    par['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    par['HPLUS'] = 5.6e-26
    par['HCROSS'] = 1.3e-26
    par['HVECTORX'] = 1.4e-26
    par['HVECTORY'] = 2.3e-26
    par['HSCALARB'] = 4.5e-26
    par['HSCALARL'] = 3.1e-26
    par['PHI0TENSOR'] = 0.4
    par['PSITENSOR'] = 1.2
    par['PHI0SCALAR'] = 3.1
    par['PSISCALAR'] = 0.2
    par['PHI0VECTOR'] = 4.5
    par['PSIVECTOR'] = 2.4
    par['PHI0'] = 2.3

    freqfactor = 2.  # set frequency factor

    det = 'H1'  # detector
    detector = lalpulsar.GetSiteInfo(det)

    gpstimes = lalpulsar.CreateTimestampVector(len(t5output))
    for i, time in enumerate(t5output[:, 0]):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    # set the response function look-up table
    dt = t5output[1, 0] - t5output[0, 0]  # time step
    resp = lalpulsar.DetResponseLookupTable(t5output[0, 0], detector,
                                            par['RAJ'], par['DECJ'], 2880, dt)

    # get the heterodyned file SSB delay
    hetSSBdelay = lalpulsar.HeterodynedPulsarGetSSBDelay(
        par.PulsarParameters(), gpstimes, detector, edat, tdat,
        lalpulsar.TIMECORRECTION_TCB)

    fullsignal = lalpulsar.HeterodynedPulsarGetModel(
        par.PulsarParameters(),
        freqfactor,
        1,
        0,
        1,  # use non-GR modes
        gpstimes,
        hetSSBdelay,
        0,
        None,
        0,
        resp,
        edat,
        tdat,
        lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_pulsar_parameter_estimation_nested
    if np.any(np.abs(fullsignal.data.data.real - t5output[:, 1]) > 1e-34):
        return False
    elif np.any(np.abs(fullsignal.data.data.imag - t5output[:, 2]) > 1e-34):
        return False

    return True
예제 #8
0
def test_four():
    parhet = PulsarParametersPy()
    parhet['F'] = [123.4567, -9.876e-12]  # set frequency
    parhet['RAJ'] = lal.TranslateHMStoRAD('01:23:34.6')  # set right ascension
    parhet['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.5')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parhet['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parhet['H0'] = 5.6e-26
    parhet['COSIOTA'] = -0.2
    parhet['PSI'] = 0.4
    parhet['PHI0'] = 2.3
    parhet['BINARY'] = 'BT'
    T0 = lal.TranslateStringMJDTTtoGPS('58121.3')
    parhet['T0'] = T0.gpsSeconds + 1e-9 * T0.gpsNanoSeconds
    parhet['OM'] = np.deg2rad(2.2)
    parhet['A1'] = 8.9
    parhet['PB'] = 0.54 * 86400.
    parhet['ECC'] = 0.0001

    parinj = PulsarParametersPy()
    parinj['F'] = [123.456789, -9.87654321e-12]  # set frequency
    parinj['DELTAF'] = parinj['F'] - parhet['F']  # frequency difference
    parinj['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')  # set right ascension
    parinj['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parinj['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parinj['H0'] = 5.6e-26
    parinj['COSIOTA'] = -0.2
    parinj['PSI'] = 0.4
    parinj['PHI0'] = 2.3
    parinj['BINARY'] = 'BT'
    T0 = lal.TranslateStringMJDTTtoGPS('58121.3')
    parinj['T0'] = T0.gpsSeconds + 1e-9 * T0.gpsNanoSeconds
    parinj['OM'] = np.deg2rad(1.2)
    parinj['A1'] = 8.9
    parinj['PB'] = 0.54 * 86400.
    parinj['ECC'] = 0.0001

    freqfactor = 2.  # set frequency factor
    det = 'H1'  # the detector

    # convert into GPS times
    gpstimes = lalpulsar.CreateTimestampVector(len(t4output))
    for i, time in enumerate(t4output[:, 0]):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    detector = lalpulsar.GetSiteInfo(det)

    # set the response function look-up table
    dt = t4output[1, 0] - t4output[0, 0]  # time step
    resp = lalpulsar.DetResponseLookupTable(t4output[0, 0], detector,
                                            parhet['RAJ'], parhet['DECJ'],
                                            2880, dt)

    # get the heterodyned file SSB delay
    hetSSBdelay = lalpulsar.HeterodynedPulsarGetSSBDelay(
        parhet.PulsarParameters(), gpstimes, detector, edat, tdat,
        lalpulsar.TIMECORRECTION_TCB)

    # get the heterodyned file BSB delay
    hetBSBdelay = lalpulsar.HeterodynedPulsarGetBSBDelay(
        parhet.PulsarParameters(), gpstimes, hetSSBdelay, edat)

    fullsignal = lalpulsar.HeterodynedPulsarGetModel(
        parinj.PulsarParameters(),
        freqfactor,
        1,  # phase is varying between par files
        0,  # not using ROQ
        0,  # not using non-tensorial modes
        gpstimes,
        hetSSBdelay,
        1,  # the SSB delay should be updated compared to hetSSBdelay
        hetBSBdelay,
        1,  # the BSB delay should be updated compared to hetBSBdelay
        resp,
        edat,
        tdat,
        lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_pulsar_parameter_estimation_nested
    if np.any(np.abs(fullsignal.data.data.real - t4output[:, 1]) > 1e-33):
        return False
    elif np.any(np.abs(fullsignal.data.data.imag - t4output[:, 2]) > 1e-33):
        return False
    else:
        return True
    def write_sft_files(self,
                        fmax,
                        T_sft,
                        comment,
                        out_dir=".",
                        window=None,
                        window_param=0):
        """
        Write SFT files [2] containing strain time series of a continuous-wave signal.

        @param fmax: maximum SFT frequency, in Hz
        @param T_sft: length of each SFT, in seconds; should divide evenly into @b T
        @param comment: SFT file name comment, may only contain A-Z, a-z, 0-9, _, +, # characters

        @param out_dir: output directory to write SFT files into
        @param window: if not None, window the time series before performing the FFT, using
            the named window function; see XLALCreateNamedREAL8Window()
        @param window_param: parameter for the window function given by @b window, if needed

        @return (@b file, @b i, @b N), where:
            @b file = name of SFT file just written;
            @b i = SFT file index, starting from zero;
            @b N = number of SFT files

        This is a Python generator function and so should be called as follows:
        ~~~
        S = CWSimulator(...)
        for t, h, i, N in S.write_sft_files(...):
            ...
        ~~~

        [2] https://dcc.ligo.org/LIGO-T040164/public
        """

        # check for valid SFT filename comment (see LIGO-T040164)
        valid_comment = re.compile(r'^[A-Za-z0-9_+#]+$')
        if not valid_comment.match(comment):
            raise ValueError(
                "SFT file comment='%s' may only contain A-Z, a-z, 0-9, _, +, # characters"
                % comment)

        # create timestamps for generating one SFT per time series
        sft_ts = lalpulsar.CreateTimestampVector(1)
        sft_ts.deltaT = T_sft

        # generate strain time series in blocks of length 'T_sft'
        sft_h = None
        sft_fs = 2 * fmax
        for t, h, i, N in self.get_strain_blocks(sft_fs, T_sft):

            # create and initialise REAL8TimeSeries to write to SFT files
            if sft_h is None:
                sft_name = lal.CachedDetectors[
                    self.__det_index].frDetector.prefix
                sft_h = lal.CreateREAL8TimeSeries(sft_name, t, 0, 1.0 / sft_fs,
                                                  lal.DimensionlessUnit,
                                                  len(h))
            sft_h.epoch = t
            sft_h.data.data = h

            # create SFT, possibly with windowing
            sft_ts.data[0] = t
            sft_vect = lalpulsar.MakeSFTsFromREAL8TimeSeries(
                sft_h, sft_ts, window, window_param)

            # create standard SFT file name (see LIGO-T040164)
            sft_desc = 'simCW_%s' % comment
            sft_name = lalpulsar.GetOfficialName4MergedSFTs(sft_vect, sft_desc)
            sft_path = os.path.join(out_dir, sft_name)

            # write SFT
            lalpulsar.WriteSFTVector2NamedFile(sft_vect, sft_path,
                                               self.__origin_str)

            # yield current file name for e.g. printing progress
            yield sft_path, i, N
예제 #10
0
def test_seven():
    parhet = PulsarParametersPy()
    parhet['F'] = [153.4567, -2.876e-11]  # set frequency
    parhet['RAJ'] = lal.TranslateHMStoRAD('04:23:34.6')  # set right ascension
    parhet['DECJ'] = lal.TranslateDMStoRAD('-05:01:23.5')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('55810')
    parhet['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds

    parinj = PulsarParametersPy()
    parinj['F'] = [153.456789, -2.87654321e-11]  # set frequency
    parinj['RAJ'] = lal.TranslateHMStoRAD('04:23:34.5')  # set right ascension
    parinj['DECJ'] = lal.TranslateDMStoRAD('-05:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('55810')
    parinj['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parinj['BINARY'] = 'BT'
    T0 = lal.TranslateStringMJDTTtoGPS('58121.3')
    parinj['T0'] = T0.gpsSeconds + 1e-9 * T0.gpsNanoSeconds
    parinj['OM'] = np.deg2rad(7.2)
    parinj['A1'] = 14.9
    parinj['PB'] = 1.03 * 86400.0
    parinj['ECC'] = 0.0002
    parinj['GLF0'] = [7.4e-6, 3.4e-7]
    parinj['GLF1'] = [-3.2e-12, -1.2e-14]
    parinj['GLF0D'] = [1.2e-5, -0.4e-6]
    parinj['GLTD'] = [0.41 * 86400, 1.45 * 86400]
    parinj['GLPH'] = [0.3, 0.91]
    glep1 = lal.TranslateStringMJDTTtoGPS('55818.08161090822')
    glep2 = lal.TranslateStringMJDTTtoGPS('55818.08276831563')
    parinj['GLEP'] = [
        glep1.gpsSeconds + 1e-9 * glep1.gpsNanoSeconds,
        glep2.gpsSeconds + 1e-9 * glep2.gpsNanoSeconds
    ]
    waveep = lal.TranslateStringMJDTTtoGPS('55818.0')
    parinj['WAVEEPOCH'] = waveep.gpsSeconds + 1e-9 * waveep.gpsNanoSeconds
    parinj['WAVE_OM'] = 0.005
    parinj['WAVESIN'] = [0.098, 0.078, -0.03]
    parinj['WAVECOS'] = [0.056, -0.071, -0.12]

    freqfactor = 2.  # set frequency factor
    det = 'H1'  # the detector

    # convert into GPS times
    gpstimes = lalpulsar.CreateTimestampVector(len(t7output))
    for i, time in enumerate(np.linspace(1000000000.0, 1000000540.0, 10)):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    detector = lalpulsar.GetSiteInfo(det)

    # replicate coarse heterodyne in which no SSB/BSB delay is applied
    hetSSBdelay = lal.CreateREAL8Vector(len(t6output))
    hetBSBdelay = lal.CreateREAL8Vector(len(t6output))
    for i in range(len(t6output)):
        hetSSBdelay.data[i] = 0.0
        hetBSBdelay.data[i] = 0.0

    # get the heterodyne glitch phase (which should be zero)
    glphase = lalpulsar.HeterodynedPulsarGetGlitchPhase(
        parhet.PulsarParameters(), gpstimes, hetSSBdelay, hetBSBdelay)

    assert_equal(glphase.data, np.zeros(len(t7output)))

    # get the FITWAVES phase (which should be zero)
    fwphase = lalpulsar.HeterodynedPulsarGetFITWAVESPhase(
        parhet.PulsarParameters(), gpstimes, hetSSBdelay, parhet["F0"])

    assert_equal(fwphase.data, np.zeros(len(t7output)))

    fullphase = lalpulsar.HeterodynedPulsarPhaseDifference(
        parinj.PulsarParameters(),
        parhet.PulsarParameters(),
        gpstimes,
        freqfactor,
        hetSSBdelay,
        1,  # the SSB delay should be updated compared to hetSSBdelay
        hetBSBdelay,
        1,  # the BSB delay should be updated compared to hetBSBdelay
        glphase,
        1,  # the glitch phase should be updated compared to glphase
        fwphase,
        1,  # the FITWAVES phase should be updated compare to fwphase
        detector,
        edat,
        tdat,
        lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_heterodyne_pulsar
    assert_allclose(2.0 * np.pi * np.fmod(fullphase.data, 1.),
                    t7output,
                    rtol=1e-3)
예제 #11
0
def test_six():
    parhet = PulsarParametersPy()
    parhet['F'] = [123.4567, -9.876e-12]  # set frequency
    parhet['RAJ'] = lal.TranslateHMStoRAD('01:23:34.6')  # set right ascension
    parhet['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.5')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parhet['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds

    parinj = PulsarParametersPy()
    parinj['F'] = [123.456789, -9.87654321e-12]  # set frequency
    parinj['RAJ'] = lal.TranslateHMStoRAD('01:23:34.5')  # set right ascension
    parinj['DECJ'] = lal.TranslateDMStoRAD('-45:01:23.4')  # set declination
    pepoch = lal.TranslateStringMJDTTtoGPS('58000')
    parinj['PEPOCH'] = pepoch.gpsSeconds + 1e-9 * pepoch.gpsNanoSeconds
    parinj['BINARY'] = 'BT'
    T0 = lal.TranslateStringMJDTTtoGPS('58121.3')
    parinj['T0'] = T0.gpsSeconds + 1e-9 * T0.gpsNanoSeconds
    parinj['OM'] = np.deg2rad(1.2)
    parinj['A1'] = 8.9
    parinj['PB'] = 0.54 * 86400.0
    parinj['ECC'] = 0.0001
    parinj['GLF0'] = [5.4e-6, 3.4e-7]
    parinj['GLF1'] = [-3.2e-13, -1.2e-14]
    parinj['GLF0D'] = [1.2e-5, -0.4e-6]
    parinj['GLTD'] = [0.31 * 86400, 0.45 * 86400]
    parinj['GLPH'] = [0.3, 0.7]
    glph1 = lal.TranslateStringMJDTTtoGPS('55818.08161090822')
    glph2 = lal.TranslateStringMJDTTtoGPS('55818.08276831563')
    parinj['GLEP'] = [
        glph1.gpsSeconds + 1e-9 * glph1.gpsNanoSeconds,
        glph2.gpsSeconds + 1e-9 * glph2.gpsNanoSeconds
    ]

    freqfactor = 2.  # set frequency factor
    det = 'H1'  # the detector

    # convert into GPS times
    gpstimes = lalpulsar.CreateTimestampVector(len(t6output))
    for i, time in enumerate(np.linspace(1000000000.0, 1000000540.0, 10)):
        gpstimes.data[i] = lal.LIGOTimeGPS(time)

    detector = lalpulsar.GetSiteInfo(det)

    # replicate coarse heterodyne in which no SSB/BSB delay is applied
    hetSSBdelay = lal.CreateREAL8Vector(len(t6output))
    hetBSBdelay = lal.CreateREAL8Vector(len(t6output))
    for i in range(len(t6output)):
        hetSSBdelay.data[i] = 0.0
        hetBSBdelay.data[i] = 0.0

    # get the heterodyne glitch phase (which should be zero)
    glphase = lalpulsar.HeterodynedPulsarGetGlitchPhase(
        parhet.PulsarParameters(), gpstimes, hetSSBdelay, hetBSBdelay)

    fullphase = lalpulsar.HeterodynedPulsarPhaseDifference(
        parinj.PulsarParameters(),
        parhet.PulsarParameters(),
        gpstimes,
        freqfactor,
        hetSSBdelay,
        1,  # the SSB delay should be updated compared to hetSSBdelay
        hetBSBdelay,
        1,  # the BSB delay should be updated compared to hetBSBdelay
        glphase,
        1,  # the glitch phase should be updated compared to glphase
        None,
        0,
        detector,
        edat,
        tdat,
        lalpulsar.TIMECORRECTION_TCB)

    # check output matches that from lalapps_heterodyne_pulsar
    assert_allclose(2.0 * np.pi * np.fmod(fullphase.data, 1.),
                    t6output,
                    rtol=1e-4)
예제 #12
0
from lalpulsar import globalvar as lalpulsarglobalvar
from lal import globalvar as lalglobalvar
print("PASSED module load")

# check object parent tracking
print("checking object parent tracking ...")
a = lalpulsar.swig_lalpulsar_test_parent_map_struct()
for i in range(0, 7):
    b = a.s
    c = lalpulsarglobalvar.swig_lalpulsar_test_parent_map.s
    lalpulsarglobalvar.swig_lalpulsar_test_parent_map.s = lalglobalvar.swig_lal_test_struct_const
del c
del b
del a
lal.CheckMemoryLeaks()
print("PASSED object parent tracking")

# check multi-vector element assignment
print("checking multi-vector element assignment ...")
mts = lalpulsar.CreateMultiLIGOTimeGPSVector(2)
ts0 = lalpulsar.CreateTimestampVector(3)
mts.data[0] = ts0
lal.swig_set_nasty_error_handlers()
del mts
del ts0
lal.swig_set_nice_error_handlers()
print("PASSED multi-vector element assignment")

# passed all tests!
print("PASSED all tests")