Exemplo n.º 1
0
def inverse_transform_precessing_spins(iota, spin_1x, spin_1y, \
                                       spin_1z, spin_2x, spin_2y, \
                                       spin_2z, mass_1, mass_2, \
                                       reference_frequency, phase):

    args_list = bu.convert_args_list_to_float(
        iota, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y, spin_2z, 
        mass_1, mass_2, reference_frequency, phase)
    results = lalsim.SimInspiralTransformPrecessingWvf2PE(*args_list)
    theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2 = (results)

    return theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2
def cartesian_to_spherical_coords(incl, spin_1x, spin_1y, spin_1z, spin_2x,
                                  spin_2y, spin_2z, mass_1, mass_2, phase,
                                  reference_frequency, **kwargs):
    """
    https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group__lalsimulation__inference.html#ga6920c640f473e7125f9ddabc4398d60a
    """
    theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2 = (
        lalsimulation.SimInspiralTransformPrecessingWvf2PE(
            incl=incl,
            S1x=spin_1x,
            S1y=spin_1y,
            S1z=spin_1z,
            S2x=spin_2x,
            S2y=spin_2y,
            S2z=spin_2z,
            m1=mass_1,
            m2=mass_2,
            fRef=reference_frequency,
            phiRef=phase))
    _, phi_1, _, _, phi_2, _, phi_12, theta_12, phi_z_s12 = calculate_relative_spins_from_component_spins(
        spin_1x, spin_1y, spin_1z, spin_2x, spin_2y, spin_2z)
    return theta_jn, phi_jl, tilt_1, tilt_2, phi_1, phi_2, a_1, a_2, phi_12, theta_12, phi_z_s12
Exemplo n.º 3
0
def xml_to_dataframe(prior_file, reference_frequency):
    table = Table.read(prior_file, format="ligolw", tablename="sim_inspiral")
    injection_values = {
        "mass_1": [],
        "mass_2": [],
        "luminosity_distance": [],
        "psi": [],
        "phase": [],
        "geocent_time": [],
        "ra": [],
        "dec": [],
        "theta_jn": [],
        "a_1": [],
        "a_2": [],
        "tilt_1": [],
        "tilt_2": [],
        "phi_12": [],
        "phi_jl": [],
    }
    for row in table:
        injection_values["mass_1"].append(float(row["mass1"]))
        injection_values["mass_2"].append(float(row["mass2"]))

        injection_values["luminosity_distance"].append(float(row["distance"]))
        injection_values["psi"].append(float(row["polarization"]))
        injection_values["phase"].append(float(row["coa_phase"]))
        injection_values["geocent_time"].append(float(row["geocent_end_time"]))
        injection_values["ra"].append(float(row["longitude"]))
        injection_values["dec"].append(float(row["latitude"]))

        args_list = [
            float(arg) for arg in [
                row["inclination"],
                row["spin1x"],
                row["spin1y"],
                row["spin1z"],
                row["spin2x"],
                row["spin2y"],
                row["spin2z"],
                row["mass1"],
                row["mass2"],
                reference_frequency,
                row["coa_phase"],
            ]
        ]
        (
            theta_jn,
            phi_jl,
            tilt_1,
            tilt_2,
            phi_12,
            a_1,
            a_2,
        ) = lalsim.SimInspiralTransformPrecessingWvf2PE(*args_list)
        injection_values["theta_jn"].append(theta_jn)
        injection_values["phi_jl"].append(phi_jl)
        injection_values["tilt_1"].append(tilt_1)
        injection_values["tilt_2"].append(tilt_2)
        injection_values["phi_12"].append(phi_12)
        injection_values["a_1"].append(a_1)
        injection_values["a_2"].append(a_2)

    injection_values = pd.DataFrame.from_dict(injection_values)
    return injection_values
Exemplo n.º 4
0
def l0frame_to_jframe(mass1,
                      mass2,
                      f_ref,
                      phiref=0.,
                      inclination=0.,
                      spin1x=0.,
                      spin1y=0.,
                      spin1z=0.,
                      spin2x=0.,
                      spin2y=0.,
                      spin2z=0.):
    """Converts L0-frame parameters to J-frame.

    Parameters
    ----------
    {mass1}
    {mass2}
    {f_ref}
    phiref : float
        The orbital phase at ``f_ref``.
    {inclination}
    {spin1x}
    {spin1y}
    {spin1z}
    {spin2x}
    {spin2y}
    {spin2z}

    Returns
    -------
    dict :
        Dictionary of:
        * thetajn : float
            Angle between the line of sight and the total angular momentume J.
        * phijl : float
            Azimuthal angle of L on its cone about J.
        * {spin1_a}
        * {spin2_a}
        * spin1_polar : float
            Angle between L and the spin magnitude of the larger object.
        * spin2_polar : float
            Angle betwen L and the spin magnitude of the smaller object.
        * spin12_deltaphi : float
            Difference between the azimuthal angles of the spin of the larger
            object (S1) and the spin of the smaller object (S2).
    """
    # Note: unlike other LALSimulation functions, this one takes masses in
    # solar masses
    thetajn, phijl, s1pol, s2pol, s12_deltaphi, spin1_a, spin2_a = \
        lalsimulation.SimInspiralTransformPrecessingWvf2PE(
            inclination, spin1x, spin1y, spin1z, spin2x, spin2y, spin2z,
            mass1, mass2, f_ref, phiref)
    out = {
        'thetajn': thetajn,
        'phijl': phijl,
        'spin1_polar': s1pol,
        'spin2_polar': s2pol,
        'spin12_deltaphi': s12_deltaphi,
        'spin1_a': spin1_a,
        'spin2_a': spin2_a
    }
    return out
Exemplo n.º 5
0
def l0frame_to_jframe(mass1,
                      mass2,
                      f_ref,
                      phiref=0.,
                      inclination=0.,
                      spin1x=0.,
                      spin1y=0.,
                      spin1z=0.,
                      spin2x=0.,
                      spin2y=0.,
                      spin2z=0.):
    """Converts L0-frame parameters to J-frame.

    Parameters
    ----------
    mass1 : float
        The mass of the first component object in the
        binary (in solar masses)
    mass2 : float
        The mass of the second component object in the
        binary (in solar masses)
    f_ref : float
        The reference frequency.
    phiref : float
        The orbital phase at ``f_ref``.
    inclination : float
        Inclination (rad), defined as the angle between
        the orbital angular momentum L and the
        line-of-sight at the reference frequency.
    spin1x : float
        The x component of the first binary component's
        dimensionless spin.
    spin1y : float
        The y component of the first binary component's
        dimensionless spin.
    spin1z : float
        The z component of the first binary component's
        dimensionless spin.
    spin2x : float
        The x component of the second binary component's
        dimensionless spin.
    spin2y : float
        The y component of the second binary component's
        dimensionless spin.
    spin2z : float
        The z component of the second binary component's
        dimensionless spin.

    Returns
    -------
    dict :
        Dictionary of:

        * thetajn : float
            Angle between the line of sight and the total angular momentume J.
        * phijl : float
            Azimuthal angle of L on its cone about J.
        * spin1_a : float
            The dimensionless spin magnitude :math:`|\\vec{{s}}_1/m^2_1|`.
        * spin2_a : float
            The dimensionless spin magnitude :math:`|\\vec{{s}}_2/m^2_2|`.
        * spin1_polar : float
            Angle between L and the spin magnitude of the larger object.
        * spin2_polar : float
            Angle betwen L and the spin magnitude of the smaller object.
        * spin12_deltaphi : float
            Difference between the azimuthal angles of the spin of the larger
            object (S1) and the spin of the smaller object (S2).
    """
    # Note: unlike other LALSimulation functions, this one takes masses in
    # solar masses
    thetajn, phijl, s1pol, s2pol, s12_deltaphi, spin1_a, spin2_a = \
        lalsimulation.SimInspiralTransformPrecessingWvf2PE(
            inclination, spin1x, spin1y, spin1z, spin2x, spin2y, spin2z,
            mass1, mass2, f_ref, phiref)
    out = {
        'thetajn': thetajn,
        'phijl': phijl,
        'spin1_polar': s1pol,
        'spin2_polar': s2pol,
        'spin12_deltaphi': s12_deltaphi,
        'spin1_a': spin1_a,
        'spin2_a': spin2_a
    }
    return out