Visualizing the SpaceX Tesla Roadster trip to Mars¶
[1]:
from astropy.time import Time
from astropy import units as u
from poliastro.bodies import Earth, Mars, Sun
from poliastro.ephem import Ephem
from poliastro.frames import Planes
from poliastro.plotting import OrbitPlotter
from poliastro.plotting.orbit.backends import Plotly3D
from poliastro.util import time_range
EPOCH = Time("2018-02-18 12:00:00", scale="tdb")
[2]:
roadster = Ephem.from_horizons(
"SpaceX Roadster",
epochs=time_range(EPOCH, end=EPOCH + 360 * u.day),
attractor=Sun,
plane=Planes.EARTH_ECLIPTIC,
id_type="majorbody",
)
roadster
WARNING: AstropyDeprecationWarning: ``id_type``s 'majorbody' and 'id' are deprecated and replaced with ``None``, which has the same functionality. [astroquery.jplhorizons.core]
[2]:
Ephemerides at 50 epochs from 2018-02-18 12:00:00.000 (TDB) to 2019-02-13 12:00:00.000 (TDB)
[3]:
from poliastro.plotting.misc import plot_solar_system
[4]:
frame = plot_solar_system(outer=False, epoch=EPOCH)
frame.plot_ephem(roadster, EPOCH, label="SpaceX Roadster", color="black")
[4]:
(<matplotlib.lines.Line2D at 0x7f887e45fa90>,
<matplotlib.lines.Line2D at 0x7f887e260b50>)

[5]:
frame = OrbitPlotter(backend=Plotly3D(), plane=Planes.EARTH_ECLIPTIC)
frame.plot_body_orbit(Earth, EPOCH)
frame.plot_body_orbit(Mars, EPOCH)
frame.plot_ephem(roadster, EPOCH, label="SpaceX Roadster", color="black")
frame.set_view(45 * u.deg, -120 * u.deg, 4 * u.km)