!which python; python -V;
# This makes the diagrams to more reliably appear in Jupyter environment
import plotly.io as pio
pio.renderers.default = "notebook_connected"
# This will cause the ephemerides to be imported from JPL horizons system
from astropy.coordinates import solar_system_ephemeris
solar_system_ephemeris.set("jpl")
/home/thomson/devel/perylune/venv/bin/python Python 3.8.5
<ScienceState solar_system_ephemeris: 'jpl'>
from poliastro.bodies import Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Sun, Pluto
from poliastro.twobody import Orbit
from poliastro.constants import GM_earth
from astropy import units as u
from astropy import time
import numpy as np
from perylune.orbit_tools import *
from perylune.interplanetary import *
from perylune.constants import *
from poliastro.ephem import Ephem
from poliastro.util import time_range
import plotly.graph_objs as go
date_launch = time.Time("2020-01-01 00:00", scale="utc").tdb
date_1step = time.Time("2020-01-11 00:00", scale="utc").tdb
date_arrival = time.Time("2020-12-31 23:59", scale="utc").tdb
earth = Ephem.from_body(Earth, time_range(date_launch, end=date_arrival))
mars = Ephem.from_body(Mars, time_range(date_launch, end=date_arrival))
# Solve for departure and target orbits
ss_earth = Orbit.from_ephem(Sun, earth, date_launch)
ss_mars = Orbit.from_ephem(Sun, mars, date_arrival)
from poliastro.plotting import OrbitPlotter3D
plotter = OrbitPlotter3D()
plotter.set_attractor(Sun)
plotter.plot_ephem(earth, date_launch, label="Earth at launch position")
plotter.plot_ephem(mars, date_launch, label="Mars at arrival position")
plotter.set_view(30 * u.deg, 260 * u.deg, distance=3 * u.km)
date_start = time.Time("2012-01-01 00:00", scale="utc").tdb
# 1 step = 10 days, 100 steps ~= 3 years
delta_t = 10 * u.day
steps = 1000
fig = distance_chart(Earth, Venus, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Mars, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Sun, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Venus, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Jupiter, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Saturn, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Uranus, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Neptune, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Pluto, date_start, delta_t, steps)
fig.show()
fig = distance_chart(Earth, Mercury, date_start, delta_t, int(steps / 1))
fig.show()