Esempio n. 1
0
def test_angle_ops():

    sign, idmsf = erfa.a2af(6, -np.pi)
    assert sign == b'-'
    assert idmsf.item() == (180, 0, 0, 0)

    sign, ihmsf = erfa.a2tf(6, np.pi)
    assert sign == b'+'
    assert ihmsf.item() == (12, 0, 0, 0)

    rad = erfa.af2a('-', 180, 0, 0.0)
    np.testing.assert_allclose(rad, -np.pi)

    rad = erfa.tf2a('+', 12, 0, 0.0)
    np.testing.assert_allclose(rad, np.pi)

    rad = erfa.anp(3. * np.pi)
    np.testing.assert_allclose(rad, np.pi)

    rad = erfa.anpm(3. * np.pi)
    np.testing.assert_allclose(rad, -np.pi)

    sign, ihmsf = erfa.d2tf(1, -1.5)
    assert sign == b'-'
    assert ihmsf.item() == (36, 0, 0, 0)

    days = erfa.tf2d('+', 3, 0, 0.0)
    np.testing.assert_allclose(days, 0.125)
Esempio n. 2
0
def d2tf_nice(ndp, days):
    sgn, hmsf = erfa.d2tf(ndp, days)
    if sgn == b"+":
        sgn = "+"
    elif sgn == b"-":
        sgn = "-"
    else:
        raise ValueError("Mysterious sign found: {!r}".format(sgn))
    if not hmsf.dtype.names:
        hmsf = hmsf.view(_new_ihmsfs_dtype)
    h = hmsf["h"]
    m = hmsf["m"]
    s = hmsf["s"] + hmsf["f"] / 10.0 ** ndp

    return sgn, h, m, s