示例#1
0
def test_time_to_longdouble_types(format_):
    t = Time.now()
    t.format = format_
    assert isinstance(time_to_longdouble(t), np.longdouble)

    t2 = Time(val=50000.0, val2=np.linspace(0, 1, 10), format=format_, scale="utc")
    assert time_to_longdouble(t2).dtype == np.longdouble
示例#2
0
def test_time_to_longdouble_utc(format, scale, i_f):
    i, f = i_f
    t = Time(val=i, val2=f, format=format, scale="utc")
    ld = np.longdouble(i) + np.longdouble(f)
    assert_quantity_allclose(
        time_to_longdouble(t) * u.day, ld * u.day, rtol=0, atol=1.0 * u.ns
    )
示例#3
0
def test_time_to_longdouble_close_to_time_to_mjd_string(format, i_f):
    i, f = i_f
    t = Time(val=i, val2=f, format=format, scale="utc")
    tld = time_to_longdouble(t)
    tstr = time_to_mjd_string(t)
    # NOTE: have to add str() here, because of a numpy bug which treats
    # numpy string type differently from python str.
    # See https://github.com/numpy/numpy/issues/15608
    tld_str = np.longdouble(str(tstr))
    assert abs(tld_str - tld) * u.day < 1 * u.ns
示例#4
0
def test_time_to_longdouble_no_longer_than_time_to_mjd_string(i_f):
    i, f = i_f
    t = Time(val=i, val2=f, format="mjd", scale="tai")
    assert len(time_to_mjd_string(t)) >= len(str(time_to_longdouble(t)))
示例#5
0
def test_time_to_longdouble_close_to_time_to_mjd_string(format, i_f):
    i, f = i_f
    t = Time(val=i, val2=f, format=format, scale="utc")
    assert (
        abs(np.longdouble(time_to_mjd_string(t)) - time_to_longdouble(t)) * u.day
    ).to(u.ns) < 1 * u.ns
示例#6
0
def test_time_to_longdouble(scale, i_f):
    i, f = i_f
    t = Time(val=i, val2=f, format="mjd", scale=scale)
    ld = np.longdouble(i) + np.longdouble(f)
    assert (abs(time_to_longdouble(t) - ld) * u.day).to(u.ns) < 1 * u.ns
示例#7
0
def test_time_to_longdouble_via_jd(scale, i_f):
    i, f = i_f
    jd1, jd2 = day_frac(i + erfa.DJM0, f)
    t = Time(val=jd1, val2=jd2, format="jd", scale=scale)
    ld = np.longdouble(i) + np.longdouble(f)
    assert (abs(time_to_longdouble(t) - ld) * u.day).to(u.ns) < 1 * u.ns
示例#8
0
# Solar mass in time units (sec)
Tsun = (GMsun / c.c ** 3).to(u.s)

# Planet system(!) masses in time units
Tmercury = Tsun / 6023600.0
Tvenus = Tsun / 408523.71
Tearth = Tsun / 328900.56  # Includes Moon!
Tmars = Tsun / 3098708.0
Tjupiter = Tsun / 1047.3486
Tsaturn = Tsun / 3497.898
Turanus = Tsun / 22902.98
Tneptune = Tsun / 19412.24

# The Epoch J2000
J2000 = time.Time("2000-01-01 12:00:00", scale="utc")
J2000ld = time_to_longdouble(J2000)
JD_MJD = 2400000.5
# PINT special units list
pint_units = {
    "H:M:S": u.hourangle,
    "D:M:S": u.deg,
    "lt-s": ls,
    "ls": ls,
    "Tsun": Tsun,
    "GMsun": GMsun,
    "MJD": u.day,
    "pulse phase": u.dimensionless_unscaled,
    "hourangle_second": hourangle_second,
}

import astropy.version