Ejemplo n.º 1
0
def test_leap_second():

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=0.,
                             tai_utc=36.0)

        t1 = Date(2016, 12, 31, 23, 59, 59)

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=0.,
                             tai_utc=37.0)
        t2 = Date(2017, 1, 1, 0, 0, 0)

    t3 = Date(2017, 1, 1, 0, 0, 36, scale='TAI')

    assert t1 == Date(2017, 1, 1, 0, 0, 35, scale='TAI')
    assert t2 == Date(2017, 1, 1, 0, 0, 37, scale='TAI')

    assert t2 - t1 == timedelta(seconds=2)
    assert t3 - t1 == timedelta(seconds=1)
Ejemplo n.º 2
0
def test_comparison():

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=0.10362957986110499,
                             tai_utc=36.0)

        # Same scale
        t1 = Date(2016, 11, 14)
        t2 = Date(2016, 11, 14, 12)
        assert t2 > t1

        # Different scale
        t1 = Date(2016, 11, 14)  # 00:00:36 in TAI
        t2 = Date(2016, 11, 14, scale='TAI')

        assert t2 < t1
        assert t1 > t2

        t1 = Date(2016, 11, 14)
        t2 = Date(2016, 11, 14, 0, 0, 36, scale='TAI')
        assert t1 == t2
        assert t1 >= t2
        assert t1 <= t2
Ejemplo n.º 3
0
def test_sun(helper):

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             deps=0,
                             dpsi=0,
                             lod=0,
                             ut1_utc=0.2653703,
                             tai_utc=33.0)
        sun = get_body('Sun')
        sun_orb = sun.propagate(Date(2006, 4, 2))

    assert str(sun_orb.form) == 'cartesian'
    assert str(sun_orb.frame) == 'MOD'
    assert isinstance(sun_orb.propagator, SunPropagator)
    assert sun_orb.date.scale.name == "UT1"
    assert abs(32.734629699999999274950823746622 -
               sun_orb.date._offset) <= np.finfo(float).eps

    helper.assert_vector(
        sun_orb.base,
        np.array([
            146186235643.53641, 28789144480.499767, 12481136552.345926,
            -5757.901470756284, 26793.699110930935, 11616.03628136728
        ]))
Ejemplo n.º 4
0
def test_change_scale():

    with patch('beyond.dates.date.EopDb.get') as m:

        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=0.1242558,
                             tai_utc=36.0)

        t = Date(2015, 12, 6)  # UTC object
        assert str(t.scale) == "UTC"

        t2 = t.change_scale('TT')
        assert str(t2) == "2015-12-06T00:01:08.184000 TT"

        t3 = t.change_scale('GPS')
        assert str(t3) == "2015-12-06T00:00:17 GPS"

        t4 = t.change_scale('UT1')
        assert str(t4) == "2015-12-06T00:00:00.124256 UT1"

        t5 = t.change_scale('TDB')
        assert str(t5) == "2015-12-06T00:01:08.183225 TDB"

        assert str(t5.change_scale('UTC')) == "2015-12-06T00:00:00 UTC"

        with raises(ValueError):
            t.change_scale('unknown')
Ejemplo n.º 5
0
def test_moon(helper):
    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             deps=0,
                             dpsi=0,
                             lod=0,
                             ut1_utc=-0.0889898,
                             tai_utc=28.0)
        moon = get_body('Moon')
        moon_orb = moon.propagate(Date(1994, 4, 28))

    assert str(moon_orb.form) == 'cartesian'
    assert str(moon_orb.frame) == 'EME2000'
    assert isinstance(moon_orb.propagator, MoonPropagator)
    assert moon_orb.date.scale.name == "TDB"
    assert abs(32.185528758994394138426287099719 +
               moon_orb.date._offset) <= np.finfo(float).eps
    helper.assert_vector(
        moon_orb,
        np.array([
            -134181155.8063418, -311598172.21627569, -126699062.57176001,
            976.8878152910264, -438.8323937765414, -87.42035305682552
        ]))
Ejemplo n.º 6
0
def test_moon():
    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             deps=0,
                             dpsi=0,
                             lod=0,
                             ut1_utc=-0.0889898,
                             tai_utc=28.0)
        moon = get_body('Moon')
        moon_orb = moon.propagate(Date(1994, 4, 28))

    assert str(moon_orb.form) == 'cartesian'
    assert str(moon_orb.frame) == 'EME2000'
    assert isinstance(moon_orb.propagator, MoonPropagator)
    assert moon_orb.date.scale.name == "TDB"
    assert abs(32.185528758994394138426287099719 +
               moon_orb.date._offset) <= np.finfo(float).eps
    np.testing.assert_array_equal(
        moon_orb.base,
        np.array([
            -134181155.8063418, -311598172.21627569, -126699062.57176001, 0.0,
            0.0, 0.0
        ]))
Ejemplo n.º 7
0
def model_correction():
    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=-0.140682,
                             y=0.333309,
                             dpsi=-52.195,
                             deps=-3.875,
                             dx=-0.205,
                             dy=-0.136,
                             lod=1.5563,
                             ut1_utc=-0.4399619,
                             tai_utc=32)
        yield
Ejemplo n.º 8
0
def common_env():
    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=-0.00951054166666622,
                             y=0.31093590624999734,
                             dpsi=-94.19544791666682,
                             deps=-10.295645833333051,
                             dy=-0.10067361111115315,
                             dx=-0.06829513888889051,
                             lod=1.6242802083331438,
                             ut1_utc=0.01756018472222477,
                             tai_utc=36.0)
        yield
Ejemplo n.º 9
0
def test_julian():

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=0.10362957986110499,
                             tai_utc=36.0)

        t = Date(2015, 12, 18, 22, 25)
        assert t.mjd == 57374.93402777778
        assert t.jd == 2457375.434027778
        assert t.change_scale('TT').julian_century == 0.1596286055289367
Ejemplo n.º 10
0
def test_barycenter():
    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0,
                             y=0,
                             dx=0,
                             dy=0,
                             dpsi=0,
                             deps=0,
                             lod=0,
                             ut1_utc=-0.463326,
                             tai_utc=32.0)

        t = Date(2004, 5, 14, 16, 43)  # UTC

        t2 = t.change_scale('TT')
        assert str(t2) == "2004-05-14T16:44:04.184000 TT"

        t3 = t2.change_scale('TDB')
        assert str(t3) == "2004-05-14T16:44:04.185254 TDB"
Ejemplo n.º 11
0
def test_change_tle():

    # lines = """1 00005U 58002B   00179.78495062  .00000023  00000-0  28098-4 0  4753
    #            2 00005  34.2682 348.7242 1859667 331.7664  19.3264 10.82419157413667"""
    # tle = Tle(lines).orbit()
    # tle = tle.propagate(timedelta(days=3))

    # from beyond.dates.eop import get_pole
    # t = Date(2000, 6, 30, 18, 50, 19, 733568).mjd

    # print(get_timescales(t))
    # print(get_pole(t))
    # assert False

    with patch('beyond.dates.date.EopDb.get') as m:
        m.return_value = Eop(x=0.11019218256776,
                             y=0.28053771387248,
                             dx=-0.06607524689999991,
                             dy=-0.05407524689999991,
                             dpsi=-54.91309785252,
                             deps=-6.363882395480003,
                             lod=0.06999515274799778,
                             ut1_utc=0.20415904149231798,
                             tai_utc=32.0)

        tle = Orbit(Date(2000, 6, 30, 18, 50, 19, 733568), [
            -9060473.7357, 4658709.52502, 813686.731536, -2232.83278274,
            -4110.45348994, -3157.34543346
        ], "cartesian", "TEME", None)
        tle.frame = 'EME2000'

        eme2000_ref = [
            -9059942.6552, 4659694.9162, 813957.7525, -2233.346698,
            -4110.136822, -3157.394202
        ]

        assert_vector(eme2000_ref, tle)