Exemple #1
0
    def phase(self, frequency_array, phi_c=0, orbital_speed=None):
        if orbital_speed is None:
            orbital_speed = self.orbital_speed(frequency_array=frequency_array)
        phase_coefficients = ls.SimInspiralTaylorF2AlignedPhasing(
            self.mass_1, self.mass_2, self.chi_1, self.chi_2, self.param_dict)
        phasing = xp.zeros_like(orbital_speed)
        cumulative_power_frequency = orbital_speed**-5
        for ii in range(len(phase_coefficients.v)):
            phasing += phase_coefficients.v[ii] * cumulative_power_frequency
            phasing += (phase_coefficients.vlogv[ii] *
                        cumulative_power_frequency * xp.log(orbital_speed))
            cumulative_power_frequency *= orbital_speed

        phasing -= 2 * phi_c + np.pi / 4

        return phasing
Exemple #2
0
    def phase(self, frequency_array, phi_c=0):
        orbital_speed = (np.pi * self.total_mass * SOLAR_RADIUS_IN_S *
                         frequency_array)**(1 / 3)
        phase_coefficients = ls.SimInspiralTaylorF2AlignedPhasing(
            self.mass_1, self.mass_2, self.chi_1, self.chi_2, CreateDict())
        phasing = xp.zeros_like(orbital_speed)
        cumulative_power_frequency = orbital_speed**-5
        for ii in range(len(phase_coefficients.v)):
            phasing += phase_coefficients.v[ii] * cumulative_power_frequency
            phasing += (phase_coefficients.vlogv[ii] *
                        cumulative_power_frequency * xp.log(orbital_speed))
            cumulative_power_frequency *= orbital_speed

        phasing -= 2 * phi_c + np.pi / 4
        phasing = phasing % (2 * np.pi)

        return phasing
Exemple #3
0
def spa_tmplt(**kwds):
    """ Generate a minimal TaylorF2 approximant with optimations for the sin/cos
    """
    # Pull out the input arguments
    f_lower = kwds['f_lower']
    delta_f = kwds['delta_f']
    distance = kwds['distance']
    mass1 = kwds['mass1']
    mass2 = kwds['mass2']
    s1z = kwds['spin1z']
    s2z = kwds['spin2z']
    phase_order = int(kwds['phase_order'])
    #amplitude_order = int(kwds['amplitude_order'])
    spin_order = int(kwds['spin_order'])

    if 'out' in kwds:
        out = kwds['out']
    else:
        out = None

    amp_factor = spa_amplitude_factor(mass1=mass1, mass2=mass2) / distance

    lal_pars = lal.CreateDict()
    if phase_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(
            lal_pars, phase_order)

    if spin_order != -1:
        lalsimulation.SimInspiralWaveformParamsInsertPNSpinOrder(
            lal_pars, spin_order)

    #Calculate the PN terms
    phasing = lalsimulation.SimInspiralTaylorF2AlignedPhasing(
        float(mass1), float(mass2), float(s1z), float(s2z), lal_pars)

    pfaN = phasing.v[0]
    pfa2 = phasing.v[2] / pfaN
    pfa3 = phasing.v[3] / pfaN
    pfa4 = phasing.v[4] / pfaN
    pfa5 = phasing.v[5] / pfaN
    pfa6 = (phasing.v[6] - phasing.vlogv[6] * log(4)) / pfaN
    pfa7 = phasing.v[7] / pfaN

    pfl5 = phasing.vlogv[5] / pfaN
    pfl6 = phasing.vlogv[6] / pfaN

    piM = lal.PI * (mass1 + mass2) * lal.MTSUN_SI

    kmin = int(f_lower / float(delta_f))

    vISCO = 1. / sqrt(6.)
    fISCO = vISCO * vISCO * vISCO / piM
    kmax = int(fISCO / delta_f)
    f_max = ceilpow2(fISCO)
    n = int(f_max / delta_f) + 1

    if not out:
        htilde = FrequencySeries(zeros(n, dtype=numpy.complex64),
                                 delta_f=delta_f,
                                 copy=False)
    else:
        if type(out) is not Array:
            raise TypeError("Output must be an instance of Array")
        if len(out) < kmax:
            kmax = len(out)
        if out.dtype != complex64:
            raise TypeError("Output array is the wrong dtype")
        htilde = FrequencySeries(out, delta_f=delta_f, copy=False)

    spa_tmplt_engine(htilde[kmin:kmax], kmin, phase_order, delta_f, piM, pfaN,
                     pfa2, pfa3, pfa4, pfa5, pfl5, pfa6, pfl6, pfa7,
                     amp_factor)
    return htilde
Exemple #4
0
    print str(ph.pn.keys()[i]) + " = " + str(ph.pn.values()[i])

print ""
print "Now comparing to LAL"
print "Note, they will differ in the v[6] (3PN) term"
print "because in PhenomD we do not use the 3PN spin-spin term"

try:
    import lal
except:
    raise ValueError('failed to import lal')
try:
    import lalsimulation as lalsim
except:
    raise ValueError('failed to import lalsimulation')

lalpn = lalsim.SimInspiralTaylorF2AlignedPhasing(10, 50, 0.3, 0.2, 1, 1, 7)
# print lalpn.v

print "\n\n\n"
print "lal v"

for i in range(len(lalpn.v)):
    print str(i) + " = " + str(lalpn.v[i])

print "\n\n\n"
print "lal vlogv"

for i in range(len(lalpn.vlogv)):
    print str(i) + " = " + str(lalpn.vlogv[i])
Exemple #5
0
        kend = len(psd) - 1
    return sqrt(norm1[kend] * norm2) / snr


@schemed("pycbc.waveform.spa_tmplt_")
def spa_tmplt_engine(htilde, kmin, phase_order, delta_f, piM, pfaN, pfa2, pfa3,
                     pfa4, pfa5, pfl5, pfa6, pfl6, pfa7, amp_factor):
    """ Calculate the spa tmplt phase
    """


# FIXME: This a workaround untill all the bundles are upgraded to a new
# version of lalsuite

try:
    lalsimulation.SimInspiralTaylorF2AlignedPhasing(1, 1, 0, 0, 1, 1, -1, None)
    NEW_F2_SYNTAX = True
except TypeError:
    NEW_F2_SYNTAX = False


def spa_tmplt(**kwds):
    """ Generate a minimal TaylorF2 approximant with optimations for the sin/cos
    """
    # Pull out the input arguments
    f_lower = kwds['f_lower']
    delta_f = kwds['delta_f']
    distance = kwds['distance']
    mass1 = kwds['mass1']
    mass2 = kwds['mass2']
    s1z = kwds['spin1z']
Exemple #6
0
def get_chirp_params_new(mass1, mass2, spin1z, spin2z, f0, order):
    """
    Take a set of masses and spins and convert to the various lambda
    coordinates that describe the orbital phase. Accepted PN orders are:
    {}
 
    Parameters
    ----------
    mass1 : float or array
        Mass1 of input(s).
    mass2 : float or array
        Mass2 of input(s).
    spin1z : float or array
        Parallel spin component(s) of body 1.
    spin2z : float or array
        Parallel spin component(s) of body 2.
    f0 : float
        This is an arbitrary scaling factor introduced to avoid the potential
        for numerical overflow when calculating this. Generally the default
        value (70) is safe here. **IMPORTANT, if you want to calculate the
        ethinca metric components later this MUST be set equal to f_low.**
        This value must also be used consistently (ie. don't change its value
        when calling different functions!).
    order : string
        The Post-Newtonian order that is used to translate from masses and
        spins to the lambda_i coordinate system. Valid orders given above.

    Returns
    --------
    lambdas : list of floats or numpy.arrays
        The lambda coordinates for the input system(s)
    """

    # Determine whether array or single value input
    sngl_inp = False
    try:
        num_points = len(mass1)
    except TypeError:
        sngl_inp = True
        # If you care about speed, you aren't calling this function one entry
        # at a time.
        mass1 = numpy.array([mass1])
        mass2 = numpy.array([mass2])
        spin1z = numpy.array([spin1z])
        spin2z = numpy.array([spin2z])
        num_points = 1
    lal_pars = CreateDict()
    phasing_vs = numpy.zeros([num_points, 13])
    phasing_vlogvs = numpy.zeros([num_points, 13])
    phasing_vlogvsqs = numpy.zeros([num_points, 13])
    for i in xrange(num_points):
        phasing = lalsimulation.SimInspiralTaylorF2AlignedPhasing(
                            mass1[i], mass2[i], spin1z[i], spin2z[i], lal_pars)
        phasing_vs[i] = phasing.v
        phasing_vlogvs[i] = phasing.vlogv
        phasing_vlogvsqs[i] = phasing.vlogvsq

    pmf = PI * (mass1 + mass2)*MTSUN_SI * f0
    pmf13 = pmf**(1./3.)

    mapping = generate_inverse_mapping(order)
    lambdas = []
    lambda_str = '^Lambda([0-9]+)'
    loglambda_str = '^LogLambda([0-9]+)'
    logloglambda_str = '^LogLogLambda([0-9]+'
    for idx in xrange(len(mapping.keys())):
        # RE magic engage!
        rematch = re.match(lambda_str, mapping[idx])
        if rematch:
            pn_order = int(rematch.groups()[0])
            lambdas.append(phasing_vs[:,pn_order] * pmf13**(-5+pn_order))
            continue
        rematch = re.match(loglambda_str, mapping[idx])
        if rematch:
            pn_order = int(rematch.groups()[0])
            lambdas.append(phasing_vlogvs[:,pn_order] * pmf13**(-5+pn_order))
            continue
        rematch = re.match(logloglambda_str, mapping[idx])
        if rematch:
            pn_order = int(rematch.groups()[0])
            lambdas.append(phasing_vlogvsqs[:,pn_order] * pmf13**(-5+pn_order))
            continue
        err_msg = "Failed to parse " +  mapping[idx]
        raise ValueError(err_msg)

    if sngl_inp:
        return [l[0] for l in lambdas]
    else:
        return lambdas