예제 #1
0
def test_time_from_mjd_string_accuracy_vs_longdouble(format, i_f):
    i, f = i_f
    mjd = np.longdouble(i) + np.longdouble(f)
    assume(not (format == "pulsar_mjd" and i in leap_sec_days and
                (1 - f) * 86400 < 1e-9))
    s = str(mjd)
    t = Time(val=i, val2=f, format=format, scale="utc")
    assert (abs(time_from_mjd_string(s, format=format, scale="utc") - t).to(
        u.us) < 1 * u.us)
    if 40000 <= i <= 60000:
        assert (abs(time_from_mjd_string(s, format=format, scale="utc") -
                    t).to(u.us) < 1 * u.ns)
예제 #2
0
def test_time_from_mjd_string_versus_longdouble_tai(i_f):
    i, f = i_f
    m = np.longdouble(i) + np.longdouble(f)
    s = str(m)
    assert (abs(
        time_from_mjd_string(s, scale="tai") -
        time_from_longdouble(m, scale="tai")).to(u.ns) < 1 * u.ns)
예제 #3
0
def test_time_from_mjd_string_roundtrip(format, i_f):
    i, f = i_f
    assume(not (format == "pulsar_mjd" and i in leap_sec_days and
                (1 - f) * 86400 < 1e-9))
    t = Time(val=i, val2=f, format=format, scale="utc")
    assert (
        abs(t - time_from_mjd_string(time_to_mjd_string(t), format=format)).to(
            u.ns) < 1 * u.ns)
예제 #4
0
def test_time_from_mjd_string_versus_longdouble_utc(format, i_f):
    i, f = i_f
    m = np.longdouble(i) + np.longdouble(f)
    s = str(m)
    assert (abs(
        time_from_mjd_string(s, scale="utc", format=format) -
        time_from_longdouble(s, scale="utc", format=format)).to(u.ns) <
            1 * u.ns)
예제 #5
0
def test_time_from_mjd_string_rejects_other_formats():
    with pytest.raises(ValueError):
        time_from_mjd_string("58000", format="cxcsec")
예제 #6
0
def test_time_from_mjd_string_roundtrip_very_close(format):
    i = 50000
    f = np.finfo(float).eps
    t = Time(val=i, val2=f, format=format, scale="utc")
    s = time_to_mjd_string(t)
    assert abs(time_from_mjd_string(s) - t).to(u.ns) <= 4 * time_eps