コード例 #1
0
ファイル: test_utils.py プロジェクト: devbhakt/PINT
def test_pulsar_mass_error_noquantity_Pb():
    Pb = 1.0 * u.d
    x = 2.0 * pint.ls
    inc = 60 * u.deg
    Mc = 0.5 * u.solMass
    with pytest.raises(ValueError):
        pulsar_mass(Pb.value, x, Mc, inc=inc)
コード例 #2
0
ファイル: test_utils.py プロジェクト: devbhakt/PINT
def test_companion_mass_error_noquantity_Pb():
    Pb = 1.0 * u.d
    x = 2.0 * pint.ls
    inc = 60 * u.deg
    Mpsr = 1.4 * u.solMass
    with pytest.raises(ValueError):
        pulsar_mass(Pb.value, x, Mpsr, inc=inc)
コード例 #3
0
ファイル: test_utils.py プロジェクト: devbhakt/PINT
def test_pulsar_mass_array(Mpsr, Mc, Pb, incl):
    """
    test pulsar mass calculations for a range of values given np.ndarray inputs
    """
    Mc = Mc * u.Msun
    Mpsr = Mpsr * u.Msun
    Pb = Pb * u.day
    incl = incl * u.deg

    Mtot = Mc + Mpsr
    # full semi-major axis
    a = (c.G * Mtot * (Pb / (2 * np.pi))**2)**(1.0 / 3)
    # pulsar semi-major axis
    apsr = (Mc / Mtot) * a
    # projected
    x = (apsr * np.sin(incl)).to(pint.ls)
    # computed pulsar mass
    assert (np.isclose(pulsar_mass(Pb, x, Mc, inc=incl), Mpsr)).all()