Пример #1
0
def test_tirs_at_least_runs():
    # TODO: find an external source for a TIRS vector to test against.
    # For now, just make sure it doesn't raise an exception.
    ts = load.timescale()
    t = ts.utc(2020, 11, 27, 15, 34)
    g = Geocentric([1,2,3], [4,5,6], t=t)
    g.frame_xyz_and_velocity(framelib.tirs)
Пример #2
0
def test_frame_without_spin():
    ts = load.timescale()
    t = ts.utc(2020, 11, 27, 15, 34)
    g = Geocentric([1,2,3], [4,5,6], t=t)

    # Simply test whether "None" spin raises an exception in either direction.
    f = true_equator_and_equinox_of_date
    r, v = g.frame_xyz_and_velocity(f)
    Geocentric.from_time_and_frame_vectors(t, f, r, v)
Пример #3
0
def test_from_frame_method():
    ts = load.timescale()
    t = ts.utc(2020, 11, 27, 15, 34)
    g1 = Geocentric([1,2,3], [4,5,6], t=t)
    r, v = g1.frame_xyz_and_velocity(itrs)  # which we trust: see the test above

    g2 = Geocentric.from_time_and_frame_vectors(t, itrs, r, v)
    assert max(abs(g2.position.au - [1,2,3])) < 2e-14
    assert max(abs(g2.velocity.au_per_d - [4,5,6])) < 3e-14

    # Make sure original vectors were not harmed (for example, by "+=").
    assert list(g1.position.au) == [1,2,3]
    assert list(g1.velocity.au_per_d) == [4,5,6]
Пример #4
0
def test_vectors():
    ts = load.timescale()
    t = ts.tt(2017, 1, 23, 10, 44)

    planets = load('de421.bsp')
    earth = planets['earth']
    mars = planets['mars']

    v = earth

    assert str(v) == """\
Sum of 2 vectors:
 + Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 + Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == "\
<VectorSum of 2 vectors 0 SOLAR SYSTEM BARYCENTER -> 399 EARTH>"

    assert str(v.at(t)) == "\
<Barycentric BCRS position and velocity at date t center=0 target=399>"

    v = earth + Topos('38.9215 N', '77.0669 W', elevation_m=92.0)

    assert str(v) == """\
Sum of 3 vectors:
 + Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 + Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH
 + Topos 38deg 55' 17.4" N -77deg 04' 00.8" E"""

    assert repr(v) == """\
<VectorSum of 3 vectors 0 SOLAR SYSTEM BARYCENTER -> Topos 38deg 55' 17.4" N -77deg 04' 00.8" E>"""

    print(str(v.at(t)))
    assert str(v.at(t)) == """\
<Barycentric BCRS position and velocity at date t center=0 \
target=Topos 38deg 55' 17.4" N -77deg 04' 00.8" E>"""

    v = earth - mars

    assert str(v) == """\
Sum of 4 vectors:
 - Segment 'de421.bsp' 4 MARS BARYCENTER -> 499 MARS
 - Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 4 MARS BARYCENTER
 + Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 + Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == "\
<VectorSum of 4 vectors 499 MARS -> 399 EARTH>"

    assert str(v.at(t)) == "\
<Geometric ICRS position and velocity at date t center=499 target=399>"

    geocentric = Geocentric([0,0,0])
    assert geocentric.center == 399
Пример #5
0
def test_vectors():
    ts = load.timescale()
    t = ts.tt(2017, 1, 23, 10, 44)

    planets = load('de421.bsp')
    earth = planets['earth']
    mars = planets['mars']

    v = earth

    assert str(v) == """\
Sum of 2 vectors:
 + Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 + Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == "\
<VectorSum of 2 vectors 0 SOLAR SYSTEM BARYCENTER -> 399 EARTH>"

    assert str(v.at(t)) == "\
<Barycentric BCRS position and velocity at date t center=0 target=399>"

    v = earth - mars

    assert str(v) == """\
Sum of 4 vectors:
 - Segment 'de421.bsp' 4 MARS BARYCENTER -> 499 MARS
 - Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 4 MARS BARYCENTER
 + Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 + Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == "\
<VectorSum of 4 vectors 499 MARS -> 399 EARTH>"

    assert str(v.at(t)) == "\
<Geometric ICRS position and velocity at date t center=499 target=399>"

    geocentric = Geocentric([0, 0, 0])
    assert geocentric.center == 399
Пример #6
0
def test_vectors():
    ts = load.timescale()
    t = ts.tt(2017, 1, 23, 10, 44)

    planets = load('de421.bsp')
    earth = planets['earth']
    mars = planets['mars']

    v = earth

    assert str(v) == """\
Sum of 2 vectors:
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == """\
<VectorSum of 2 vectors:
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH>"""

    assert str(v.at(t)) == "\
<Barycentric BCRS position and velocity at date t center=0 target=399>"

    v = earth + Topos('38.9215 N', '77.0669 W', elevation_m=92.0)

    assert str(v) == """\
Sum of 3 vectors:
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH
 Geodetic 399 EARTH -> IERS2010 latitude 38deg 55' 17.4" N longitude -77deg 04' 00.8" E elevation 92 m"""

    assert repr(v) == """\
<VectorSum of 3 vectors:
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH
 Geodetic 399 EARTH -> IERS2010 latitude 38deg 55' 17.4" N longitude -77deg 04' 00.8" E elevation 92 m>"""

    assert str(v.at(t)) == """\
<Barycentric BCRS position and velocity at date t center=0 target=IERS2010 latitude 38deg 55' 17.4" N longitude -77deg 04' 00.8" E elevation 92 m>"""

    v = earth - mars

    assert str(v) == """\
Sum of 4 vectors:
 Reversed 'de421.bsp' segment 499 MARS -> 4 MARS BARYCENTER
 Reversed 'de421.bsp' segment 4 MARS BARYCENTER -> 0 SOLAR SYSTEM BARYCENTER
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH"""

    assert repr(v) == """\
<VectorSum of 4 vectors:
 Reversed 'de421.bsp' segment 499 MARS -> 4 MARS BARYCENTER
 Reversed 'de421.bsp' segment 4 MARS BARYCENTER -> 0 SOLAR SYSTEM BARYCENTER
 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH>"""

    assert str(v.at(t)) == "\
<ICRF position and velocity at date t center=499 target=399>"

    geocentric = Geocentric([0, 0, 0])
    assert geocentric.center == 399
Пример #7
0
#!/usr/bin/env python
from skyfield.api import EarthSatellite
from skyfield.api import load
from skyfield.positionlib import Geocentric
from skyfield.units import Angle

ts = load.timescale()
# Time used to find correct satellite
t = ts.utc(2020, 3, 18, 6, 17, 23.0)

# Coordinates used to find correct satellite
loc = Geocentric([-393.9579313710918, -4609.1758828158, -4905.812181143784])

stations = load.tle_file('wheres_the_sat.tle')
print('Loaded', len(stations), 'stations')

# Zero degrees separation
nada = Angle(degrees=0)

# Iterate over stations looking for a collision (zero degrees separation)
for station in stations:
	geocentric = station.at(t)
	if geocentric.separation_from(loc).degrees == nada.degrees:
		# Found a collision
		print(station.name)
		tgt = station

# Time used to find next waypoint
t2 = ts.utc(2020, 3, 18, 22, 44, 49.0)
# Coordinates of next waypoint
geocentric = tgt.at(t2)