示例#1
0
    def __init__(self,
                 mass_1,
                 mass_2,
                 chi_1,
                 chi_2,
                 luminosity_distance,
                 lambda_1=0,
                 lambda_2=0):
        self.mass_1 = mass_1
        self.mass_2 = mass_2
        self.chi_1 = chi_1
        self.chi_2 = chi_2
        self.total_mass = mass_1 + mass_2
        self.symmetric_mass_ratio = mass_1 * mass_2 / self.total_mass**2

        self.lambda_1 = float(lambda_1)
        self.lambda_2 = float(lambda_2)
        self.param_dict = CreateDict()
        ls.SimInspiralWaveformParamsInsertTidalLambda1(self.param_dict,
                                                       self.lambda_1)
        ls.SimInspiralWaveformParamsInsertTidalLambda2(self.param_dict,
                                                       self.lambda_2)
        ls.SimInspiralSetQuadMonParamsFromLambdas(self.param_dict)

        self.luminosity_distance = luminosity_distance * MEGA_PARSEC_SI
示例#2
0
def generateWfparameters(opts):
    '''Turn parameters specified by input file and/or command line options into
    parameter dictionary that can be used for waveform generation.'''
    optsDict = vars(opts)
    inputpar = copy.deepcopy(optsDict)
    inputpar['m1'] *= lal.MSUN_SI
    inputpar['m2'] *= lal.MSUN_SI
    inputpar['distance'] *= (1.e6 * lal.PC_SI)
    inputpar['approximant'] = lalsim.GetApproximantFromString(
        inputpar['approximant'])

    if (inputpar['sampleRate'] != defSampleRate):
        inputpar['deltaT'] = 1./inputpar['sampleRate']
        optsDict['deltaT'] = inputpar['deltaT']

    domain = optsDict['domain']
    wfinputpar=[inputpar[name] for name in paramnames[domain]]
    LALpars=lal.CreateDict()
    if (inputpar['lambda1']):
        lalsim.SimInspiralWaveformParamsInsertTidalLambda1(LALpars,inputpar['lambda1'])
    if (inputpar['lambda2']):
        lalsim.SimInspiralWaveformParamsInsertTidalLambda2(LALpars,inputpar['lambda2'])
    if (inputpar['ampOrder']!=-1):
        lalsim.SimInspiralWaveformParamsInsertPNAmplitudeOrder(LALpars,inputpar['ampOrder'])
    if (inputpar['phaseOrder']!=-1):
        lalsim.SimInspiralWaveformParamsInsertPNPhaseOrder(LALpars,inputpar['phaseOrder'])
    wfinputpar.append(LALpars)
    wfinputpar.append(inputpar['approximant'])

    return domain, wfinputpar, optsDict
示例#3
0
def spin_tidal_IMRPhenomD_FD(m1, m2, s1z, s2z, lambda1, lambda2,
                    f_min, f_max, deltaF=1.0/128.0,
                    delta_t=1.0/16384.0, distance=1.0, inclination=0.0,
                    approximant='IMRPhenomD_NRTidal', verbose=True):
    # print m1, m2, s1z, s2z, lambda1, lambda2, f_min, delta_t, distance, inclination
    f_ref = 0.
    phiRef = 0.

    # Must have aligned spin
    s1x, s1y, s2x, s2y = 0., 0., 0., 0.

    # Eccentricity is not part of the model
    longAscNodes = 0.
    eccentricity = 0.
    meanPerAno = 0.

    lal_approx = LS.GetApproximantFromString(approximant)

    # Insert matter parameters
    lal_params = lal.CreateDict()
    LS.SimInspiralWaveformParamsInsertTidalLambda1(lal_params, lambda1)
    LS.SimInspiralWaveformParamsInsertTidalLambda2(lal_params, lambda2)
    
    # Evaluate FD waveform
    Hp, Hc = LS.SimInspiralFD(
        m1*lal.MSUN_SI, m2*lal.MSUN_SI,
        s1x, s1y, s1z, s2x, s2y, s2z,
        distance*lal.PC_SI, inclination, phiRef, longAscNodes, eccentricity, meanPerAno, 
        deltaF, f_min, f_max, f_ref, lal_params, lal_approx)
    f = deltaF * np.arange(Hp.data.length)
    return f, Hp, Hc
示例#4
0
def compute_modulus(paramspoint, known_bases, distance, deltaF, f_min, f_max,
                    approximant):
    waveFlags = lal.CreateDict()
    m1, m2 = get_m1m2_from_mcq(paramspoint[0], paramspoint[1])
    s1x, s1y, s1z = spherical_to_cartesian(paramspoint[2:5])
    s2x, s2y, s2z = spherical_to_cartesian(paramspoint[5:8])
    iota = paramspoint[8]
    phiRef = paramspoint[9]
    ecc = 0
    if len(paramspoint) == 11:
        ecc = paramspoint[10]
    if len(paramspoint) == 12:
        lambda1 = paramspoint[10]
        lambda2 = paramspoint[11]
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            waveFlags, lambda1)
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            waveFlags, lambda2)
    f_ref = 0
    RA = 0
    DEC = 0
    psi = 0
    phi = 0
    m1 *= lal.lal.MSUN_SI
    m2 *= lal.lal.MSUN_SI
    [plus, cross] = lalsimulation.SimInspiralChooseFDWaveform(
        m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, distance, iota, phiRef, 0, ecc,
        0, deltaF, f_min, f_max, f_ref, waveFlags, approximant)
    hp_tmp = plus.data.data[numpy.int(f_min / deltaF):numpy.int(
        f_max / deltaF)]  # data_tmp is hplus and is a complex vector
    residual = hp_tmp
    for k in numpy.arange(0, len(known_bases)):
        residual -= proj(known_bases[k], hp_tmp)
    modulus = numpy.sqrt(numpy.vdot(residual, residual))
    return modulus
示例#5
0
def lalsim_SimInspiralWaveformParamsInsertTidalLambda1(waveform_dictionary,
                                                       lambda_1):
    try:
        lambda_1 = float(lambda_1)
    except ValueError:
        raise ValueError("Unable to convert lambda_1 to float")

    return lalsim.SimInspiralWaveformParamsInsertTidalLambda1(
        waveform_dictionary, lambda_1)
示例#6
0
def _check_lal_pars(p):
    """ Create a laldict object from the dictionary of waveform parameters

    Parameters
    ----------
    p: dictionary
        The dictionary of lalsimulation paramaters

    Returns
    -------
    laldict: LalDict
        The lal type dictionary to pass to the lalsimulation waveform functions.
    """
    lal_pars = lal.CreateDict()
    #nonGRparams can be straightforwardly added if needed, however they have to
    # be invoked one by one
    if p['phase_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(
            lal_pars, int(p['phase_order']))
    if p['amplitude_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(
            lal_pars, int(p['amplitude_order']))
    if p['spin_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(
            lal_pars, int(p['spin_order']))
    if p['tidal_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNTidalOrder(
            lal_pars, p['tidal_order'])
    if p['eccentricity_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNEccentricityOrder(
            lal_pars, p['eccentricity_order'])
    if p['lambda1']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            lal_pars, p['lambda1'])
    if p['lambda2']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            lal_pars, p['lambda2'])
    if p['dquad_mon1']:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon1(
            lal_pars, p['dquad_mon1'])
    if p['dquad_mon2']:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon2(
            lal_pars, p['dquad_mon2'])
    if p['numrel_data']:
        lalsimulation.SimInspiralWaveformParamsInsertNumRelData(
            lal_pars, str(p['numrel_data']))
    if p['modes_choice']:
        lalsimulation.SimInspiralWaveformParamsInsertModesChoice(
            lal_pars, p['modes_choice'])
    if p['frame_axis']:
        lalsimulation.SimInspiralWaveformParamsInsertFrameAxis(
            lal_pars, p['frame_axis'])
    if p['side_bands']:
        lalsimulation.SimInspiralWaveformParamsInsertSideband(
            lal_pars, p['side_bands'])
    return lal_pars
示例#7
0
def least_match_quadratic_waveform_unnormalized(parallel, nprocesses,
                                                paramspoints, known_quad_bases,
                                                distance, deltaF, f_min, f_max,
                                                waveFlags, approximant):
    if parallel == 1:
        paramspointslist = paramspoints.tolist()
        with mp.Pool(processes=nprocesses) as pool:
            modula = pool.map(
                partial(compute_modulus_quad,
                        known_quad_bases=known_quad_bases,
                        distance=distance,
                        deltaF=deltaF,
                        f_min=f_min,
                        f_max=f_max,
                        approximant=approximant), paramspointslist)
    if parallel == 0:
        npts = len(paramspoints)
        modula = numpy.zeros(npts)
        for i in numpy.arange(0, npts):
            paramspoint = paramspoints[i]
            modula[i] = compute_modulus_quad(paramspoint, known_quad_bases,
                                             distance, deltaF, f_min, f_max,
                                             approximant)
    arg_newbasis = numpy.argmax(modula)
    paramspoint = paramspoints[arg_newbasis]
    mass1, mass2 = get_m1m2_from_mcq(paramspoints[arg_newbasis][0],
                                     paramspoints[arg_newbasis][1])
    mass1 *= lal.lal.MSUN_SI
    mass2 *= lal.lal.MSUN_SI
    sp1x, sp1y, sp1z = spherical_to_cartesian(paramspoints[arg_newbasis, 2:5])
    sp2x, sp2y, sp2z = spherical_to_cartesian(paramspoints[arg_newbasis, 5:8])
    inclination = paramspoints[arg_newbasis][8]
    phi_ref = paramspoints[arg_newbasis][9]
    ecc = 0
    if len(paramspoint) == 11:
        ecc = paramspoints[arg_newbasis][10]
    if len(paramspoint) == 12:
        lambda1 = paramspoints[arg_newbasis][10]
        lambda2 = paramspoints[arg_newbasis][11]
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            waveFlags, lambda1)
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            waveFlags, lambda2)
    [plus_new, cross_new] = lalsimulation.SimInspiralChooseFDWaveform(
        mass1, mass2, sp1x, sp1y, sp1z, sp2x, sp2y, sp2z, distance,
        inclination, phi_ref, 0, ecc, 0, deltaF, f_min, f_max, 0, waveFlags,
        approximant)
    hp_new = plus_new.data.data
    hp_new = hp_new[numpy.int(f_min / deltaF):numpy.int(f_max / deltaF)]
    hp_quad_new = (numpy.absolute(hp_new))**2
    basis_quad_new = gram_schmidt(known_quad_bases, hp_quad_new)
    return numpy.array(
        [basis_quad_new, paramspoints[arg_newbasis],
         modula[arg_newbasis]])  # elements, masses&spins, residual mod
示例#8
0
def FD_waveform_test(Mtot, x, approximant, fLow=20.0, fHigh=16384.0, deltaF=0):
    q = 1.0 / x[0]
    chi1 = x[1]
    chi2 = x[2]
    lambda1 = x[3]
    lambda2 = x[4]

    phiRef, fRef = 0.0, fLow
    distance, inclination = 1.0, 0.0

    m1 = q / (1.0 + q) * Mtot
    m2 = 1.0 / (1.0 + q) * Mtot
    m1SI, m2SI, chi1, chi2, lambda1, lambda2, nk_max = m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, chi1, chi2, lambda1, lambda2, -1

    longAscNodes, eccentricity, meanPerAno = 0, 0, 0

    LALpars = lal.CreateDict()
    LS.SimInspiralWaveformParamsInsertTidalLambda1(LALpars, lambda1)
    LS.SimInspiralWaveformParamsInsertTidalLambda2(LALpars, lambda2)

    # Nyquist frequency is set by fHigh
    # Can set deltaF = 0 to figure out required frequency spacing; the chosen deltaF depends on fLow

    # Documentation from LALSimInspiral.c
    #
    #  * This routine can generate TD approximants and transform them into the frequency domain.
    #  * Waveforms are generated beginning at a slightly lower starting frequency and tapers
    #  * are put in this early region so that the waveform smoothly turns on.
    #  *
    #  * If an FD approximant is used, this routine applies tapers in the frequency domain
    #  * between the slightly-lower frequency and the requested f_min.  Also, the phase of the
    #  * waveform is adjusted to introduce a time shift.  This time shift should allow the
    #  * resulting waveform to be Fourier transformed into the time domain without wrapping
    #  * the end of the waveform to the beginning.
    #  *
    #  * This routine assumes that f_max is the Nyquist frequency of a corresponding time-domain
    #  * waveform, so that deltaT = 0.5 / f_max.  If deltaF is set to 0 then this routine computes
    #  * a deltaF that is small enough to represent the Fourier transform of a time-domain waveform.
    #  * If deltaF is specified but f_max / deltaF is not a power of 2, and the waveform approximant
    #  * is a time-domain approximant, then f_max is increased so that f_max / deltaF is the next
    #  * power of 2.  (If the user wishes to discard the extra high frequency content, this must
    #  * be done separately.)

    hp, hc = LS.SimInspiralFD(m1SI, m2SI, 0.0, 0.0, chi1, 0.0, 0.0, chi2,
                              distance, inclination, phiRef, longAscNodes,
                              eccentricity, meanPerAno, deltaF, fLow, fHigh,
                              fRef, LALpars, approximant)

    fHz = np.arange(hp.data.length) * hp.deltaF
    h = hp.data.data + 1j * hc.data.data

    return hp.deltaF
示例#9
0
def recalculate_waveform(conf):
    '''Reads single data set and returns both the reference waveform and the newly calculated
    waveform with the same parameters.
    Returns: [hpref, hcref, hpnew, hcnew]
    '''
    approx = lalsim.GetApproximantFromString(
        conf.get('approximant', 'approximant'))
    domain = conf.get('approximant', 'domain')
    if domain == 'TD':
        hpref, hcref = [
            np.array(map(float, (conf.get('waveform-data', l)).split()))
            for l in ['hp', 'hc']
        ]
    if domain == 'FD':
        hpRref, hpIref, hcRref, hcIref = [
            np.array(map(float, (conf.get('waveform-data', l)).split()))
            for l in ['hp_real', 'hp_imag', 'hc_real', 'hc_imag']
        ]
        hpref = hpRref + 1j * hpIref
        hcref = hcRref + 1j * hcIref

    names = CheckReferenceWaveforms.paramnames[domain]
    parDict = dict([
        (p, CheckReferenceWaveforms.paramtype[p](conf.get('parameters', p)))
        for p in conf.options('parameters')
    ])
    parDict['m1'] *= lal.MSUN_SI
    parDict['m2'] *= lal.MSUN_SI
    parDict['distance'] *= (1.e6 * lal.PC_SI)

    params = [parDict[name] for name in names]
    LALpars = lal.CreateDict()
    try:
        tmp = parDict['lambda1']
    except:
        tmp = 0.
    if (tmp):
        lalsim.SimInspiralWaveformParamsInsertTidalLambda1(
            LALpars, parDict['lambda1'])
    try:
        tmp = parDict['lambda2']
    except:
        tmp = 0.
    if (tmp):
        lalsim.SimInspiralWaveformParamsInsertTidalLambda2(
            LALpars, parDict['lambda2'])
    params.append(LALpars)
    params.append(approx)

    hp, hc = waveformgenerator(domain, params)

    return [hpref, hcref, hp, hc]
示例#10
0
def generate_a_waveform(m1, m2, spin1, spin2, ecc, lambda1, lambda2, iota,
                        phiRef, distance, deltaF, f_min, f_max, waveFlags,
                        approximant):
    test_mass1 = m1 * lal.lal.MSUN_SI
    test_mass2 = m2 * lal.lal.MSUN_SI
    lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
        waveFlags, lambda1)
    lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
        waveFlags, lambda2)
    [plus_test, cross_test] = lalsimulation.SimInspiralChooseFDWaveform(
        test_mass1, test_mass2, spin1[0], spin1[1], spin1[2], spin2[0],
        spin2[1], spin2[2], distance, iota, phiRef, 0, ecc, 0, deltaF, f_min,
        f_max, 0, waveFlags, approximant)
    hp = plus_test.data.data
    hp_test = hp[numpy.int(f_min / deltaF):numpy.int(f_max / deltaF)]
    return hp_test
def spin_tidal_eob(m1,
                   m2,
                   s1z,
                   s2z,
                   lambda1,
                   lambda2,
                   f_min,
                   delta_t=1.0 / 16384.0,
                   distance=1.0,
                   inclination=0.0,
                   approximant='SEOBNRv4T',
                   verbose=True):
    """EOB waveform with aligned spin and tidal interactions. 
    l=3 tidal interaction and l=2,3 f-mode calculated with universal relations.
    
    Parameters
    ----------
    approximant : 'TEOBv2' or 'TEOBv4' or the new names 'SEOBNRv2T' or 'SEOBNRv4T'.
        Based on the inspiral model given by 'SEOBNRv2' or 'SEOBNRv4'.
    
    Returns
    -------
    Waveform object
    """
    # print m1, m2, s1z, s2z, lambda1, lambda2, f_min, delta_t, distance, inclination
    f_ref = 0.
    phiRef = 0.

    # Must have aligned spin
    s1x, s1y, s2x, s2y = 0., 0., 0., 0.

    # Eccentricity is not part of the model
    longAscNodes = 0.
    eccentricity = 0.
    meanPerAno = 0.

    # Set the EOB approximant
    if (approximant not in ['TEOBv2', 'TEOBv4', 'SEOBNRv2T', 'SEOBNRv4T']):
        raise Exception, "Approximant must be 'TEOBv2' or 'TEOBv4' or 'SEOBNRv2T' or 'SEOBNRv4T'."
    lal_approx = LS.GetApproximantFromString(approximant)

    # Insert matter parameters
    lal_params = lal.CreateDict()
    LS.SimInspiralWaveformParamsInsertTidalLambda1(lal_params, lambda1)
    LS.SimInspiralWaveformParamsInsertTidalLambda2(lal_params, lambda2)

    if verbose:
        ap = LS.GetStringFromApproximant(lal_approx)
        L2A = LS.SimInspiralWaveformParamsLookupTidalLambda1(lal_params)
        L2B = LS.SimInspiralWaveformParamsLookupTidalLambda2(lal_params)
        L3A = LS.SimInspiralWaveformParamsLookupTidalOctupolarLambda1(
            lal_params)
        L3B = LS.SimInspiralWaveformParamsLookupTidalOctupolarLambda2(
            lal_params)
        w2A = LS.SimInspiralWaveformParamsLookupTidalQuadrupolarFMode1(
            lal_params)
        w2B = LS.SimInspiralWaveformParamsLookupTidalQuadrupolarFMode2(
            lal_params)
        w3A = LS.SimInspiralWaveformParamsLookupTidalOctupolarFMode1(
            lal_params)
        w3B = LS.SimInspiralWaveformParamsLookupTidalOctupolarFMode2(
            lal_params)
        print 'Approximant: ' + str(ap)
        print 'm1={:.2f}, m2={:.2f}'.format(m1, m2)
        print 's1z={:.2f}, s2z={:.2f}'.format(s1z, s2z)
        print 'delta_t={:.6f}, 1/delta_t={:.5}, f_min={:.2f}'.format(
            delta_t, 1. / delta_t, f_min)
        print 'L2A, L2B, L3A, L3B, w2A, w2B, w3A, w3B:'
        print '{:.1f}, {:.1f}, {:.1f}, {:.1f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}'.format(
            L2A, L2B, L3A, L3B, w2A, w2B, w3A, w3B)
        sys.stdout.flush()

    # Evaluate waveform
    hp, hc = LS.SimInspiralChooseTDWaveform(m1 * lal.MSUN_SI, m2 * lal.MSUN_SI,
                                            s1x, s1y, s1z, s2x, s2y, s2z,
                                            distance * lal.PC_SI, inclination,
                                            phiRef, longAscNodes, eccentricity,
                                            meanPerAno, delta_t, f_min, f_ref,
                                            lal_params, lal_approx)

    # Extract time array from lalsimulation's structures
    tstart = hp.epoch.gpsSeconds + hp.epoch.gpsNanoSeconds * 1.0e-9
    ts = tstart + hp.deltaT * np.arange(hp.data.length)

    return ts, hp.data.data, hc.data.data
def FD_waveform(m1,
                m2,
                s1z,
                s2z,
                lambda1,
                lambda2,
                f_min,
                f_max=2048.0,
                deltaF=0.0,
                distance=1.0,
                inclination=0.0,
                approximant='SEOBNRv4T',
                verbose=True):
    """Compute waveform in the Fourier domain using SimInspiralFD
    deltaF=0 selects required frequency resolution (the inverse of the selected deltaF will be a power of 2)
    Returns frequency in Hz and h = hp + 1j*hc
    """

    phiRef, fRef = 0.0, f_min
    m1SI, m2SI = m1 * lal.MSUN_SI, m2 * lal.MSUN_SI

    longAscNodes, eccentricity, meanPerAno = 0, 0, 0

    LALpars = lal.CreateDict()
    LS.SimInspiralWaveformParamsInsertTidalLambda1(LALpars, lambda1)
    LS.SimInspiralWaveformParamsInsertTidalLambda2(LALpars, lambda2)

    lal_approx = LS.GetApproximantFromString(approximant)

    # Nyquist frequency is set by fHigh
    # Can set deltaF = 0 to figure out required frequency spacing; the chosen deltaF depends on fLow

    # Documentation from LALSimInspiral.c
    #
    #  * This routine can generate TD approximants and transform them into the frequency domain.
    #  * Waveforms are generated beginning at a slightly lower starting frequency and tapers
    #  * are put in this early region so that the waveform smoothly turns on.
    #  *
    #  * If an FD approximant is used, this routine applies tapers in the frequency domain
    #  * between the slightly-lower frequency and the requested f_min.  Also, the phase of the
    #  * waveform is adjusted to introduce a time shift.  This time shift should allow the
    #  * resulting waveform to be Fourier transformed into the time domain without wrapping
    #  * the end of the waveform to the beginning.
    #  *
    #  * This routine assumes that f_max is the Nyquist frequency of a corresponding time-domain
    #  * waveform, so that deltaT = 0.5 / f_max.  If deltaF is set to 0 then this routine computes
    #  * a deltaF that is small enough to represent the Fourier transform of a time-domain waveform.
    #  * If deltaF is specified but f_max / deltaF is not a power of 2, and the waveform approximant
    #  * is a time-domain approximant, then f_max is increased so that f_max / deltaF is the next
    #  * power of 2.  (If the user wishes to discard the extra high frequency content, this must
    #  * be done separately.)

    hp, hc = LS.SimInspiralFD(m1SI, m2SI, 0.0, 0.0, s1z, 0.0, 0.0, s2z,
                              distance, inclination, phiRef, longAscNodes,
                              eccentricity, meanPerAno, deltaF, f_min, f_max,
                              fRef, LALpars, lal_approx)

    fHz = np.arange(hp.data.length) * hp.deltaF
    h = hp.data.data + 1j * hc.data.data

    return fHz, h
示例#13
0
def lalsim_FD_waveform(m1,
                       m2,
                       s1x,
                       s1y,
                       s1z,
                       s2x,
                       s2y,
                       s2z,
                       theta_jn,
                       phase,
                       duration,
                       dL,
                       fmax,
                       lambda_1=None,
                       lambda_2=None,
                       **kwarg):
    mass1 = m1 * lal.MSUN_SI
    mass2 = m2 * lal.MSUN_SI
    spin_1x = s1x
    spin_1y = s1y
    spin_1z = s1z
    spin_2x = s2x
    spin_2y = s2y
    spin_2z = s2z
    iota = theta_jn
    phaseC = phase  # Phase is hard coded to be zero

    eccentricity = 0
    longitude_ascending_nodes = 0
    mean_per_ano = 0

    waveform_arg = dict(minimum_freq=20.0, reference_frequency=20)
    waveform_arg.update(kwarg)
    dL = dL * lal.PC_SI * 1e6  # MPC --> Km
    approximant = lalsim.GetApproximantFromString(
        waveform_arg["waveform_approximant"])
    flow = waveform_arg["minimum_freq"]
    delta_freq = 1.0 / duration
    maximum_frequency = fmax  # 1024.0 # ISCO(m1, m2)
    fref = waveform_arg["reference_frequency"]
    waveform_dictionary = lal.CreateDict()

    if lambda_1 is not None:
        lalsim.SimInspiralWaveformParamsInsertTidalLambda1(
            waveform_dictionary, float(lambda_1))
    if lambda_2 is not None:
        lalsim.SimInspiralWaveformParamsInsertTidalLambda2(
            waveform_dictionary, float(lambda_2))

    hplus, hcross = lalsim.SimInspiralChooseFDWaveform(
        mass1,
        mass2,
        spin_1x,
        spin_1y,
        spin_1z,
        spin_2x,
        spin_2y,
        spin_2z,
        dL,
        iota,
        phaseC,
        longitude_ascending_nodes,
        eccentricity,
        mean_per_ano,
        delta_freq,
        flow,
        maximum_frequency,
        fref,
        waveform_dictionary,
        approximant,
    )

    h_plus = hplus.data.data[:]
    h_cross = hcross.data.data[:]

    return {"plus": h_plus, "cross": h_cross}
示例#14
0
def make_tidal_waveform(approx='TaylorT4',
                        rate=4096,
                        Lambda1=None,
                        Lambda2=None,
                        mass1=1.4,
                        mass2=1.3,
                        inclination=0,
                        distance=100,
                        eccentricity=0,
                        meanPerAno=0,
                        phiRef=0,
                        f_min=30,
                        f_ref=0,
                        longAscNodes=0,
                        s1x=0,
                        s1y=0,
                        s1z=0,
                        s2x=0,
                        s2y=0,
                        s2z=0,
                        eos=None,
                        save=False):
    # Sanity check
    if (Lambda1 is None) and (Lambda2 is None) and (eos is None):
        # Assuming Lambdas to be zero is not provided
        print("Assuming tidal deformability is zero")
        print(
            "Use arguments Lambda1=, and Lambda2= to provide deformabilities")
        Lambda1 = 0.0
        Lambda2 = 0.0
    if eos:
        if Lambda1 or Lambda2:
            print(
                "Warning: Both eos and Lambda1 and/or Lambda2 has been provided"
            )
            print("Ignoring Lambdas in favor of the eos")
        e = lalsim.SimNeutronStarEOSByName(eos)
        fam = lalsim.CreateSimNeutronStarFamily(e)
        max_mass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
        assert mass1 < max_mass, "mass1 greater than maximum mass allowed for the neutron star"
        assert mass2 < max_mass, "mass2 greater than the maximum mass allowed for the neutron star"
        r1 = lalsim.SimNeutronStarRadius(mass1 * lal.MSUN_SI, fam)
        k1 = lalsim.SimNeutronStarLoveNumberK2(mass1 * lal.MSUN_SI, fam)

        r2 = lalsim.SimNeutronStarRadius(mass2 * lal.MSUN_SI, fam)
        k2 = lalsim.SimNeutronStarLoveNumberK2(mass2 * lal.MSUN_SI, fam)
        c2 = mass2 * lal.MRSUN_SI / r2
        c1 = mass1 * lal.MRSUN_SI / r1

        Lambda1 = (2 / 3) * k1 / (c1**5)
        Lambda2 = (2 / 3) * k2 / (c2**5)

    mass1 = mass1 * lal.MSUN_SI
    mass2 = mass2 * lal.MSUN_SI
    distance = distance * 1e6 * lal.PC_SI
    deltaT = 1.0 / rate
    approximant = lalsim.GetApproximantFromString(approx)
    lal_pars = lal.CreateDict()
    lalsim.SimInspiralWaveformParamsInsertTidalLambda1(lal_pars, Lambda1)
    lalsim.SimInspiralWaveformParamsInsertTidalLambda2(lal_pars, Lambda2)
    hp, hc = lalsim.SimInspiralChooseTDWaveform(mass1,
                                                mass2,
                                                s1x=s1x,
                                                s1y=s1y,
                                                s1z=s1z,
                                                s2x=s2x,
                                                s2y=s2y,
                                                s2z=s2z,
                                                distance=distance,
                                                inclination=inclination,
                                                phiRef=phiRef,
                                                longAscNodes=longAscNodes,
                                                eccentricity=eccentricity,
                                                meanPerAno=meanPerAno,
                                                deltaT=deltaT,
                                                f_min=f_min,
                                                f_ref=f_ref,
                                                params=lal_pars,
                                                approximant=approximant)
    if save:
        plus_data = hp.data.data
        cross_data = hc.data.data
        tstart_p = hp.epoch.gpsSeconds + hp.epoch.gpsNanoSeconds * 1e-9
        tstart_c = hc.epoch.gpsSeconds + hc.epoch.gpsNanoSeconds * 1e-9
        tp = np.arange(tstart_p, 0, hp.deltaT)
        tp = tp[:len(hp.data.data)]
        tc = np.arange(tstart_c, 0, hc.deltaT)
        tc = tc[:len(hc.data.data)]
        output_plus = np.vstack((tp, plus_data)).T
        output_cross = np.vstack((tc, cross_data)).T

        np.savetxt("plus_polarization_data.txt", output_plus, fmt="%f\t%e")
        np.savetxt("cross_polarization_data.txt", output_cross, fmt="%f\t%e")

    return (hp, hc)
示例#15
0
def _check_lal_pars(p):
    """ Create a laldict object from the dictionary of waveform parameters

    Parameters
    ----------
    p: dictionary
        The dictionary of lalsimulation paramaters

    Returns
    -------
    laldict: LalDict
        The lal type dictionary to pass to the lalsimulation waveform functions.
    """
    lal_pars = lal.CreateDict()
    #nonGRparams can be straightforwardly added if needed, however they have to
    # be invoked one by one
    if p['phase_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(
            lal_pars, int(p['phase_order']))
    if p['amplitude_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(
            lal_pars, int(p['amplitude_order']))
    if p['spin_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(
            lal_pars, int(p['spin_order']))
    if p['tidal_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNTidalOrder(
            lal_pars, p['tidal_order'])
    if p['eccentricity_order'] != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNEccentricityOrder(
            lal_pars, p['eccentricity_order'])
    if p['lambda1']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            lal_pars, p['lambda1'])
    if p['lambda2']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            lal_pars, p['lambda2'])
    if p['dquad_mon1']:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon1(
            lal_pars, p['dquad_mon1'])
    if p['dquad_mon2']:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon2(
            lal_pars, p['dquad_mon2'])
    if p['numrel_data']:
        lalsimulation.SimInspiralWaveformParamsInsertNumRelData(
            lal_pars, str(p['numrel_data']))
    if p['modes_choice']:
        lalsimulation.SimInspiralWaveformParamsInsertModesChoice(
            lal_pars, p['modes_choice'])
    if p['frame_axis']:
        lalsimulation.SimInspiralWaveformParamsInsertFrameAxis(
            lal_pars, p['frame_axis'])
    if p['side_bands']:
        lalsimulation.SimInspiralWaveformParamsInsertSideband(
            lal_pars, p['side_bands'])
################################################################################################
#####-------------------------------------Non-GR params-----------------------------------######
################################################################################################
# Phi:
    if 'phi1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRPhi1(
            lal_pars, float(p['phi1']))
    if 'phi2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRPhi2(
            lal_pars, float(p['phi2']))
    if 'phi3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRPhi3(
            lal_pars, float(p['phi3']))
    if 'phi4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRPhi4(
            lal_pars, float(p['phi4']))
# dChi:
    if 'dchi0' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi0(
            lal_pars, float(p['dchi0']))
    if 'dchi1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi1(
            lal_pars, float(p['dchi1']))
    if 'dchi2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi2(
            lal_pars, float(p['dchi2']))
    if 'dchi3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi3(
            lal_pars, float(p['dchi3']))
    if 'dchi4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi4(
            lal_pars, float(p['dchi4']))
    if 'dchi5' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi5(
            lal_pars, float(p['dchi5']))
    if 'dchi5L' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi5L(
            lal_pars, float(p['dchi5L']))
    if 'dchi6' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi6(
            lal_pars, float(p['dchi7']))
    if 'dchi6L' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi6L(
            lal_pars, float(p['dchi6L']))
    if 'dchi7' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi7(
            lal_pars, float(p['dchi7']))
# dXi:
    if 'dxi1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi1(
            lal_pars, float(p['dxi1']))
    if 'dxi2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi2(
            lal_pars, float(p['dxi2']))
    if 'dxi3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi3(
            lal_pars, float(p['dxi3']))
    if 'dxi4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi4(
            lal_pars, float(p['dxi4']))
    if 'dxi5' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi5(
            lal_pars, float(p['dxi5']))
    if 'dxi6' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDXi6(
            lal_pars, float(p['dxi6']))
# Sigma:
    if 'dsigma1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDSigma1(
            lal_pars, float(p['dsigma1']))
    if 'dsigma2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDSigma2(
            lal_pars, float(p['dsigma2']))
    if 'dsigma3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDSigma3(
            lal_pars, float(p['dsigma3']))
    if 'dsigma4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDSigma4(
            lal_pars, float(p['dsigma4']))
# Alpha:
    if 'dalpha1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha1(
            lal_pars, float(p['dalpha1']))
    if 'dalpha2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha2(
            lal_pars, float(p['dalpha2']))
    if 'dalpha3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha3(
            lal_pars, float(p['dalpha3']))
    if 'dalpha4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha4(
            lal_pars, float(p['dalpha4']))
    if 'dalpha5' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha5(
            lal_pars, float(p['dalpha5']))
# Beta:
    if 'dbeta1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta1(
            lal_pars, float(p['dbeta1']))
    if 'dbeta2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta2(
            lal_pars, float(p['dbeta2']))
    if 'dbeta3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta3(
            lal_pars, float(p['dbeta3']))
# Alpha PPE:
    if 'alphaPPE' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE(
            lal_pars, float(p['alphaPPE']))
    if 'alphaPPE0' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE0(
            lal_pars, float(p['alphaPPE0']))
    if 'alphaPPE1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE1(
            lal_pars, float(p['alphaPPE1']))
    if 'alphaPPE2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE2(
            lal_pars, float(p['alphaPPE2']))
    if 'alphaPPE3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE3(
            lal_pars, float(p['alphaPPE3']))
    if 'alphaPPE4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE4(
            lal_pars, float(p['alphaPPE4']))
    if 'alphaPPE5' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRAlphaPPE5(
            lal_pars, float(p['alphaPPE5']))


# Beta PPE:
    if 'betaPPE' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE(
            lal_pars, float(p['betaPPE']))
    if 'betaPPE0' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE0(
            lal_pars, float(p['betaPPE0']))
    if 'betaPPE1' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE1(
            lal_pars, float(p['betaPPE1']))
    if 'betaPPE2' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE2(
            lal_pars, float(p['betaPPE2']))
    if 'betaPPE3' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE3(
            lal_pars, float(p['betaPPE3']))
    if 'betaPPE4' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE4(
            lal_pars, float(p['betaPPE4']))
    if 'betaPPE5' in p:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRBetaPPE5(
            lal_pars, float(p['betaPPE5']))

    return lal_pars
示例#16
0
def least_match_quadratic_waveform_unnormalized(paramspoints, known_quad_bases,
                                                npts, distance, deltaF, f_min,
                                                f_max, waveFlags, approximant):
    overlaps = numpy.zeros(npts)
    modula = numpy.zeros(npts)
    for i in numpy.arange(0, len(paramspoints)):
        paramspoint = paramspoints[i]
        m1, m2 = get_m1m2_from_mcq(paramspoint[0], paramspoint[1])
        s1x, s1y, s1z = spherical_to_cartesian(paramspoint[2:5])
        s2x, s2y, s2z = spherical_to_cartesian(paramspoint[5:8])
        iota = paramspoint[8]
        phiRef = paramspoint[9]
        ecc = 0
        if len(paramspoint) == 11:
            ecc = paramspoint[10]
        if len(paramspoint) == 12:
            lambda1 = paramspoint[10]
            lambda2 = paramspoint[11]
            lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
                waveFlags, lambda1)
            lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
                waveFlags, lambda2)
        f_ref = 0
        RA = 0
        DEC = 0
        psi = 0
        phi = 0
        m1 *= lal.lal.MSUN_SI
        m2 *= lal.lal.MSUN_SI
        [plus, cross] = lalsimulation.SimInspiralChooseFDWaveform(
            m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, distance, iota, phiRef, 0,
            ecc, 0, deltaF, f_min, f_max, f_ref, waveFlags, approximant)
        hp_tmp = plus.data.data[numpy.int(f_min / deltaF):numpy.int(
            f_max / deltaF)]  # data_tmp is hplus and is a complex vector
        hp_quad_tmp = (numpy.absolute(hp_tmp))**2
        residual = hp_quad_tmp
        for k in numpy.arange(0, len(known_quad_bases)):
            residual -= proj(known_quad_bases[k], hp_quad_tmp)
        modula[i] = numpy.sqrt(numpy.vdot(residual, residual))
    arg_newbasis = numpy.argmax(modula)
    mass1, mass2 = get_m1m2_from_mcq(paramspoints[arg_newbasis][0],
                                     paramspoints[arg_newbasis][1])
    mass1 *= lal.lal.MSUN_SI
    mass2 *= lal.lal.MSUN_SI
    sp1x, sp1y, sp1z = spherical_to_cartesian(paramspoints[arg_newbasis, 2:5])
    sp2x, sp2y, sp2z = spherical_to_cartesian(paramspoints[arg_newbasis, 5:8])
    inclination = paramspoints[arg_newbasis][8]
    phi_ref = paramspoints[arg_newbasis][9]
    ecc = 0
    if len(paramspoint) == 11:
        ecc = paramspoints[arg_newbasis][10]
    if len(paramspoint) == 12:
        lambda1 = paramspoints[arg_newbasis][10]
        lambda2 = paramspoints[arg_newbasis][11]
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            waveFlags, lambda1)
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            waveFlags, lambda2)
    [plus_new, cross_new] = lalsimulation.SimInspiralChooseFDWaveform(
        mass1, mass2, sp1x, sp1y, sp1z, sp2x, sp2y, sp2z, distance,
        inclination, phi_ref, 0, ecc, 0, deltaF, f_min, f_max, 0, waveFlags,
        approximant)
    hp_new = plus_new.data.data
    hp_new = hp_new[numpy.int(f_min / deltaF):numpy.int(f_max / deltaF)]
    hp_quad_new = (numpy.absolute(hp_new))**2
    basis_quad_new = gram_schmidt(known_quad_bases, hp_quad_new)
    return numpy.array(
        [basis_quad_new, paramspoints[arg_newbasis],
         modula[arg_newbasis]])  # elements, masses&spins, residual mod
示例#17
0
def spin_tidal_eob_FD(m1, m2, s1z, s2z, lambda1, lambda2,
                    f_min, f_max, deltaF=1.0/128.0,
                    delta_t=1.0/16384.0, distance=1.0, inclination=0.0,
                    approximant='TEOBv4', verbose=True):
    """EOB waveform with aligned spin and tidal interactions. 
    l=3 tidal interaction and l=2,3 f-mode calculated with universal relations.
    
    Parameters
    ----------
    approximant : 'TEOBv2' or 'TEOBv4', 'SEOBNRv4_ROM_NRTidal'
    
    Returns
    -------
    Waveform object
    """
    # print m1, m2, s1z, s2z, lambda1, lambda2, f_min, delta_t, distance, inclination
    f_ref = 0.
    phiRef = 0.

    # Must have aligned spin
    s1x, s1y, s2x, s2y = 0., 0., 0., 0.

    # Eccentricity is not part of the model
    longAscNodes = 0.
    eccentricity = 0.
    meanPerAno = 0.

    # Set the EOB approximant
    if (approximant not in ['TEOBv2', 'TEOBv4', 'SEOBNRv4_ROM_NRTidal']):
        raise Exception, "Approximant must be 'TEOBv2', 'TEOBv4' or 'SEOBNRv4_ROM_NRTidal'."
    lal_approx = LS.GetApproximantFromString(approximant)

    if (approximant in ['TEOBv2', 'TEOBv4']):
        # Calculate higher order matter effects from universal relations
        # lambda3 given in terms of lambda2
        lambda31_ur = LS.SimUniversalRelationlambda3TidalVSlambda2Tidal(lambda1)
        lambda32_ur = LS.SimUniversalRelationlambda3TidalVSlambda2Tidal(lambda2)
        # Omega2 given in terms of lambda2
        omega21_ur = LS.SimUniversalRelationomega02TidalVSlambda2Tidal(lambda1)
        omega22_ur = LS.SimUniversalRelationomega02TidalVSlambda2Tidal(lambda2)
        # Omega3 given in terms of lambda3 (not lambda2)
        omega31_ur = LS.SimUniversalRelationomega03TidalVSlambda3Tidal(lambda31_ur)
        omega32_ur = LS.SimUniversalRelationomega03TidalVSlambda3Tidal(lambda32_ur)

    # Insert matter parameters
    lal_params = lal.CreateDict()
    LS.SimInspiralWaveformParamsInsertTidalLambda1(lal_params, lambda1)
    LS.SimInspiralWaveformParamsInsertTidalLambda2(lal_params, lambda2)
    if (approximant in ['TEOBv2', 'TEOBv4']):
        LS.SimInspiralWaveformParamsInsertTidalOctupolarLambda1(lal_params, lambda31_ur)
        LS.SimInspiralWaveformParamsInsertTidalOctupolarLambda2(lal_params, lambda32_ur)
        LS.SimInspiralWaveformParamsInsertTidalQuadrupolarFMode1(lal_params, omega21_ur)
        LS.SimInspiralWaveformParamsInsertTidalQuadrupolarFMode2(lal_params, omega22_ur)
        LS.SimInspiralWaveformParamsInsertTidalOctupolarFMode1(lal_params, omega31_ur)
        LS.SimInspiralWaveformParamsInsertTidalOctupolarFMode2(lal_params, omega32_ur)
    
    # Evaluate FD waveform
    Hp, Hc = LS.SimInspiralFD(
        m1*lal.MSUN_SI, m2*lal.MSUN_SI,
        s1x, s1y, s1z, s2x, s2y, s2z,
        distance*lal.PC_SI, inclination, phiRef, longAscNodes, eccentricity, meanPerAno, 
        deltaF, f_min, f_max, f_ref, lal_params, lal_approx)
    f = deltaF * np.arange(Hp.data.length)
    return f, Hp, Hc
示例#18
0
def lalsim_td_waveform(long_asc_nodes=0.0,
                       eccentricity=0.0,
                       mean_per_ano=0.0,
                       phi_ref=0.0,
                       f_ref=None,
                       phase_order=-1,
                       amplitude_order=-1,
                       spin_order=-1,
                       tidal_order=-1,
                       **p):
    """Wrapper for lalsimulation.SimInspiralChooseTDWaveform.
    Simplified version of pycbc.waveform.get_td_waveform wrapper.

    Parameters
    ----------
    f_ref : Reference frequency (?For setting phi_ref? Not sure.) Defaults to f_min.
    phi_ref : Reference phase (?at f_ref?).

    Returns
    -------
    h : Waveform
    """
    if f_ref == None:
        f_ref = p['f_min']

    # Set extra arguments in the lal Dict structure
    lal_pars = lal.CreateDict()
    if phase_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(
            lal_pars, int(phase_order))
    if amplitude_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(
            lal_pars, int(amplitude_order))
    if spin_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(
            lal_pars, int(spin_order))
    if tidal_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNTidalOrder(
            lal_pars, int(tidal_order))
    if p['lambda1']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            lal_pars, p['lambda1'])
    if p['lambda2']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            lal_pars, p['lambda2'])

    # Set Approximant (C enum structure) corresponding to approximant string
    lal_approx = lalsimulation.GetApproximantFromString(p['approximant'])

    hp, hc = lalsimulation.SimInspiralChooseTDWaveform(
        float(MSUN_SI * p['mass1']), float(MSUN_SI * p['mass2']),
        float(p['spin1x']), float(p['spin1y']), float(p['spin1z']),
        float(p['spin2x']), float(p['spin2y']), float(p['spin2z']),
        float(MPC_SI * p['distance']), float(p['inclination']), float(phi_ref),
        float(long_asc_nodes), float(eccentricity), float(mean_per_ano),
        float(p['delta_t']), float(p['f_min']), float(f_ref), lal_pars,
        lal_approx)

    # Extract data from lalsimulation's structures
    tstart = hp.epoch.gpsSeconds + hp.epoch.gpsNanoSeconds * 1.0e-9
    xs = tstart + hp.deltaT * np.arange(hp.data.length)
    return wave.Waveform.from_hp_hc(xs, hp.data.data, hc.data.data)
示例#19
0
def getApprox(type,
              name,
              m1=10.0,
              m2=10.0,
              f_ref=0.0,
              f_low=50.0,
              distance=1,
              delta_t=1.0 / 4096.0,
              s1x=0,
              s1y=0,
              s1z=0,
              s2x=0,
              s2y=0,
              s2z=0,
              inclination=0,
              tidal1=0,
              tidal2=0):
    if type == 'pycbc':
        hp, hc = get_td_waveform(approximant=name,
                                 mass1=m1,
                                 mass2=m2,
                                 f_lower=f_low,
                                 f_ref=f_ref,
                                 distance=distance,
                                 delta_t=delta_t,
                                 spin1x=s1x,
                                 spin1y=s1y,
                                 spin1z=s1z,
                                 spin2x=s2x,
                                 spin2y=s2y,
                                 spin2z=s2z,
                                 lambda1=tidal1,
                                 lambda2=tidal2,
                                 inclination=inclination)

        new_hp = np.array(hp)
        new_hc = np.array(hc)
        h = new_hp + new_hc * 1j
        times = np.array(hp.sample_times)
        shift_times = times - times[0]
        return (shift_times, h)
    elif type == 'laltd':
        mpc = 1.0e6 * lal.PC_SI
        m1 = m1 * lal.MSUN_SI
        m2 = m2 * lal.MSUN_SI
        distance = distance * mpc
        tidal_params = lal.CreateDict()
        lalsim.SimInspiralWaveformParamsInsertTidalLambda1(
            tidal_params, tidal1)
        lalsim.SimInspiralWaveformParamsInsertTidalLambda2(
            tidal_params, tidal2)
        hp, hc = lalsim.SimInspiralTD(
            m1, m2, s1x, s1y, s1z, s2x, s2y, s2z, distance, inclination,
            phiRef, 0., 0., 0., delta_t, f_low, f_ref, tidal_params,
            lalsim.SimInspiralGetApproximantFromString(name))
        times = np.arange(len(hp.data.data)) * delta_t + hp.epoch
        shift_times = times - times[0]
        h = np.array(hp.data.data + 1j * hc.data.data)
        return (shift_times, h)
    else:
        print 'Specify pycbc or laltd for approx type'
示例#20
0
def _check_lal_pars(p):
    """ Create a laldict object from the dictionary of waveform parameters

    Parameters
    ----------
    p: dictionary
        The dictionary of lalsimulation paramaters

    Returns
    -------
    laldict: LalDict
        The lal type dictionary to pass to the lalsimulation waveform functions.
    """
    lal_pars = lal.CreateDict()
    #nonGRparams can be straightforwardly added if needed, however they have to
    # be invoked one by one
    if p['phase_order']!=-1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(lal_pars,int(p['phase_order']))
    if p['amplitude_order']!=-1:
        lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(lal_pars,int(p['amplitude_order']))
    if p['spin_order']!=-1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(lal_pars,int(p['spin_order']))
    if p['tidal_order']!=-1:
        lalsimulation.SimInspiralWaveformParamsInsertPNTidalOrder(lal_pars, p['tidal_order'])
    if p['eccentricity_order']!=-1:
        lalsimulation.SimInspiralWaveformParamsInsertPNEccentricityOrder(lal_pars, p['eccentricity_order'])
    if p['lambda1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(lal_pars, p['lambda1'])
    if p['lambda2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(lal_pars, p['lambda2'])
    if p['lambda_octu1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalOctupolarLambda1(lal_pars, p['lambda_octu1'])
    if p['lambda_octu2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalOctupolarLambda2(lal_pars, p['lambda_octu2'])
    if p['quadfmode1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalQuadrupolarFMode1(lal_pars, p['quadfmode1'])
    if p['quadfmode2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalQuadrupolarFMode2(lal_pars, p['quadfmode2'])
    if p['octufmode1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalOctupolarFMode1(lal_pars, p['octufmode1'])
    if p['octufmode2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertTidalOctupolarFMode2(lal_pars, p['octufmode2'])
    if p['dquad_mon1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon1(lal_pars, p['dquad_mon1'])
    if p['dquad_mon2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertdQuadMon2(lal_pars, p['dquad_mon2'])
    if p['numrel_data']:
        lalsimulation.SimInspiralWaveformParamsInsertNumRelData(lal_pars, str(p['numrel_data']))
    if p['modes_choice']:
        lalsimulation.SimInspiralWaveformParamsInsertModesChoice(lal_pars, p['modes_choice'])
    if p['frame_axis']:
        lalsimulation.SimInspiralWaveformParamsInsertFrameAxis(lal_pars, p['frame_axis'])
    if p['side_bands']:
        lalsimulation.SimInspiralWaveformParamsInsertSideband(lal_pars, p['side_bands'])
    if p['mode_array'] is not None:
        ma = lalsimulation.SimInspiralCreateModeArray()
        for l,m in p['mode_array']:
            lalsimulation.SimInspiralModeArrayActivateMode(ma, l, m)
        lalsimulation.SimInspiralWaveformParamsInsertModeArray(lal_pars, ma)
    #TestingGR parameters:
    if p['dchi0'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi0(lal_pars,p['dchi0'])
    if p['dchi1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi1(lal_pars,p['dchi1'])
    if p['dchi2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi2(lal_pars,p['dchi2'])
    if p['dchi3'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi3(lal_pars,p['dchi3'])
    if p['dchi4'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi4(lal_pars,p['dchi4'])
    if p['dchi5'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi5(lal_pars,p['dchi5'])
    if p['dchi5l'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi5L(lal_pars,p['dchi5l'])
    if p['dchi6'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi6(lal_pars,p['dchi6'])
    if p['dchi6l'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi6L(lal_pars,p['dchi6l'])
    if p['dchi7'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDChi7(lal_pars,p['dchi7'])
    if p['dalpha1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha1(lal_pars,p['dalpha1'])
    if p['dalpha2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha2(lal_pars,p['dalpha2'])
    if p['dalpha3'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha3(lal_pars,p['dalpha3'])
    if p['dalpha4'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha4(lal_pars,p['dalpha4'])
    if p['dalpha5'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDAlpha5(lal_pars,p['dalpha5'])
    if p['dbeta1'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta1(lal_pars,p['dbeta1'])
    if p['dbeta2'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta2(lal_pars,p['dbeta2'])
    if p['dbeta3'] is not None:
        lalsimulation.SimInspiralWaveformParamsInsertNonGRDBeta3(lal_pars,p['dbeta3'])
    return lal_pars
示例#21
0
def lalsim_fd_waveform(long_asc_nodes=0.0,
                       eccentricity=0.0,
                       mean_per_ano=0.0,
                       phi_ref=0.0,
                       f_ref=None,
                       phase_order=-1,
                       amplitude_order=-1,
                       spin_order=-1,
                       tidal_order=-1,
                       quad1=None,
                       quad2=None,
                       **p):
    """Wrapper for lalsimulation.SimInspiralChooseTDWaveform.
    Simplified version of pycbc.waveform.get_td_waveform wrapper.

    Parameters
    ----------
    f_ref : Reference frequency (?For setting phi_ref? Not sure.) Defaults to f_min.
    phi_ref : Reference phase (?at f_ref?).

    Returns
    -------
    h : Waveform
    """
    if f_ref == None:
        f_ref = p['f_min']

    # Set extra arguments in the lal Dict structure
    lal_pars = lal.CreateDict()
    if phase_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(
            lal_pars, int(phase_order))
    if amplitude_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(
            lal_pars, int(amplitude_order))
    if spin_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(
            lal_pars, int(spin_order))
    if tidal_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNTidalOrder(
            lal_pars, int(tidal_order))
    if p['lambda1']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(
            lal_pars, p['lambda1'])
    if p['lambda2']:
        lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(
            lal_pars, p['lambda2'])
    # Add spin-induced quadrupole terms. Default is universal relations.
    # dQuadMon1 = quad1 - 1
    # dQuadMon2 = quad2 - 1
    if quad1 == None:
        quad1 = taylorf2.quad_of_lambda_fit(p['lambda1'])
    if quad2 == None:
        quad2 = taylorf2.quad_of_lambda_fit(p['lambda2'])
    lalsimulation.SimInspiralWaveformParamsInsertdQuadMon1(
        lal_pars, quad1 - 1.0)
    lalsimulation.SimInspiralWaveformParamsInsertdQuadMon2(
        lal_pars, quad2 - 1.0)
    print quad1, quad2
    print 'dQuadMon1 =', lalsimulation.SimInspiralWaveformParamsLookupdQuadMon1(
        lal_pars)
    print 'dQuadMon2 =', lalsimulation.SimInspiralWaveformParamsLookupdQuadMon2(
        lal_pars)

    # Set Approximant (C enum structure) corresponding to approximant string
    lal_approx = lalsimulation.GetApproximantFromString(p['approximant'])

    hp, hc = lalsimulation.SimInspiralChooseFDWaveform(
        float(MSUN_SI * p['mass1']), float(MSUN_SI * p['mass2']),
        float(p['spin1x']), float(p['spin1y']), float(p['spin1z']),
        float(p['spin2x']), float(p['spin2y']), float(p['spin2z']),
        float(MPC_SI * p['distance']), float(p['inclination']), float(phi_ref),
        float(long_asc_nodes), float(eccentricity), float(mean_per_ano),
        float(p['delta_f']), float(p['f_min']), float(p['f_max']),
        float(f_ref), lal_pars, lal_approx)

    # Extract data from lalsimulation's structures
    # The first data point in hp.data.data corresponds to f=0 not f=f_min
    fs = hp.deltaF * np.arange(hp.data.length)
    return wave.Waveform.from_hp_hc(fs, hp.data.data, hc.data.data)