In [1]:
!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
Out[1]:
<ScienceState solar_system_ephemeris: 'jpl'>
In [2]:
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
import time

from perylune.horizons import *
from perylune.orbit_tools import *
from perylune.interplanetary import *
from perylune.constants import *
In [3]:
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


ceres_ephem = Ephem.from_horizons(name="Ceres", epochs=date_launch, attractor=Sun, id_type="majorbody")

#Ephem.from_horizons("Ceres")
ceres = Orbit.from_ephem(Sun, ceres_ephem, date_launch)
print_orb(ceres)



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)
3 x 3 AU x 27.2 deg (HCRS) orbit around Sun (☉) at epoch 2020-01-01 00:01:09.184 (TDB)
a(𝑎)=2.7693AU, b=2.7611AU, e=0.0769, i=27.1852deg raan(Ω)=23.36deg argp(𝜔)=132.93deg nu(𝜈)=136.63deg
period=4.61yr perapis=2.5564AU apoapsis=2.9822AU
In [4]:
# Ideal, read from the porkchop
start = time.Time("2020-07-15 11:50", scale="utc").tdb
date_arrival = time.Time("2021-01-20 12:00", scale="utc").tdb

period = time_range(start, end=date_arrival)

mercury = Ephem.from_body(Mercury, time_range(start, end=start + 0.241*u.year))
venus = Ephem.from_body(  Venus,   time_range(start, end=start + 0.615*u.year))
earth = Ephem.from_body(  Earth,   time_range(start, end=start + 1.00*u.year))
mars = Ephem.from_body(   Mars,    time_range(start, end=start + 1.881*u.year))
jupiter = Ephem.from_body(Jupiter, time_range(start, end=start + 11.86*u.year))
saturn = Ephem.from_body( Saturn,  time_range(start, end=start + 29.42*u.year))
uranus = Ephem.from_body( Uranus,  time_range(start, end=start + 84.02*u.year))
neptune = Ephem.from_body(Neptune, time_range(start, end=start + 164.8  *u.year))

ceres    = Ephem.from_horizons(name="Ceres", epochs=time_range(start, end=start + 1*u.year), attractor=Sun, id_type="majorbody")
eris     = Ephem.from_horizons(name="Eris", epochs=time_range(start, end=start + 1*u.year), attractor=Sun, id_type="majorbody")
pluto    = Ephem.from_horizons(name="999", epochs=time_range(start, end=start + 1*u.year), attractor=Sun, id_type="majorbody") #pluto
makemake = Ephem.from_horizons(name="Makemake", epochs=time_range(start, end=start + 1*u.year), attractor=Sun, id_type="majorbody")
haumea   = Ephem.from_horizons(name="Haumea", epochs=time_range(start, end=start + 1*u.year), attractor=Sun, id_type="majorbody")

from poliastro.plotting import OrbitPlotter3D
plotter = OrbitPlotter3D()
plotter.set_attractor(Sun)

plotter.plot_ephem(mercury, start, label="Mercury")
plotter.plot_ephem(venus, start, label="Venus")
plotter.plot_ephem(earth, start, label="Earth")
plotter.plot_ephem(mars, start, label="Mars")
plotter.plot_ephem(jupiter, start, label="Jupiter")
plotter.plot_ephem(saturn, start, label="Saturn")
plotter.plot_ephem(uranus, start, label="Uranus")
plotter.plot_ephem(neptune, start, label="Neptune")

plotter.plot_ephem(ceres, start, label="Ceres")
plotter.plot_ephem(eris, start, label="Eris")
plotter.plot_ephem(pluto, start, label="Pluto")
plotter.plot_ephem(makemake, start, label="Makemake")
plotter.plot_ephem(haumea, start, label="Haumea")

plotter._layout.autosize = False
plotter._layout.width = 1200
plotter._layout.height = 800
plotter._layout.margin=dict(l=10, r=10, b=10, t=10, pad=4 )
plotter.show()
In [5]:
print_orb(Orbit.from_ephem(Sun, mars, start))
1 x 2 AU x 24.7 deg (HCRS) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=1.5017AU, b=1.4962AU, e=0.0856, i=24.6829deg raan(Ω)=3.38deg argp(𝜔)=333.05deg nu(𝜈)=-11.91deg
period=672.17d perapis=1.3732AU apoapsis=1.6302AU
In [7]:
names = [ "mercury",
          "venus",
          "earth",
          "mars",
          "jupiter",
          "saturn",
          "uranus",
          "neptune", 
          "ceres", 
          "eris", 
          "999", # 999
          "makemake", 
          "haumea"]

orbits = []

for name in names:
    hname, id_type = name_to_horizons_id(name)
    o = Orbit.from_horizons(name=hname, attractor=Sun, epoch=start, plane=Planes.EARTH_ECLIPTIC, id_type="majorbody")
    orbits.append(o)

    print("---%s-------" % name)
    print_orb(o)
---mercury-------
0 x 0 AU x 7.0 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=0.3871AU, b=0.3788AU, e=0.2056, i=7.0037deg raan(Ω)=48.31deg argp(𝜔)=29.19deg nu(𝜈)=-111.69deg
period=87.97d perapis=0.3075AU apoapsis=0.4667AU
---venus-------
1 x 1 AU x 3.4 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=0.7233AU, b=0.7233AU, e=0.0068, i=3.3946deg raan(Ω)=76.62deg argp(𝜔)=55.12deg nu(𝜈)=-172.30deg
period=224.70d perapis=0.7184AU apoapsis=0.7282AU
---earth-------
1 x 1 AU x 0.0 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=1.0004AU, b=1.0003AU, e=0.0162, i=0.0038deg raan(Ω)=153.71deg argp(𝜔)=310.08deg nu(𝜈)=-170.62deg
period=365.50d perapis=0.9842AU apoapsis=1.0167AU
---mars-------
1 x 2 AU x 1.8 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=1.5238AU, b=1.5171AU, e=0.0934, i=1.8479deg raan(Ω)=49.50deg argp(𝜔)=286.60deg nu(𝜈)=-11.97deg
period=687.02d perapis=1.3814AU apoapsis=1.6661AU
---jupiter-------
5 x 5 AU x 1.3 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=5.2029AU, b=5.1967AU, e=0.0485, i=1.3040deg raan(Ω)=100.52deg argp(𝜔)=273.59deg nu(𝜈)=-81.95deg
period=11.87yr perapis=4.9503AU apoapsis=5.4554AU
---saturn-------
9 x 10 AU x 2.5 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=9.5788AU, b=9.5660AU, e=0.0515, i=2.4848deg raan(Ω)=113.59deg argp(𝜔)=337.25deg nu(𝜈)=-152.65deg
period=29.65yr perapis=9.0852AU apoapsis=10.0723AU
---uranus-------
18 x 20 AU x 0.8 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=19.1926AU, b=19.1725AU, e=0.0458, i=0.7709deg raan(Ω)=74.07deg argp(𝜔)=98.21deg nu(𝜈)=-135.07deg
period=84.08yr perapis=18.3139AU apoapsis=20.0713AU
---neptune-------
30 x 31 AU x 1.8 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=30.2379AU, b=30.2359AU, e=0.0114, i=1.7645deg raan(Ω)=131.63deg argp(𝜔)=244.40deg nu(𝜈)=-27.12deg
period=166.28yr perapis=29.8926AU apoapsis=30.5832AU
---ceres-------
3 x 3 AU x 10.6 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=2.7672AU, b=2.7589AU, e=0.0777, i=10.5882deg raan(Ω)=80.28deg argp(𝜔)=73.72deg nu(𝜈)=173.51deg
period=4.60yr perapis=2.5522AU apoapsis=2.9823AU
---eris-------
38 x 97 AU x 44.0 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=67.8833AU, b=61.1027AU, e=0.4357, i=44.0223deg raan(Ω)=35.96deg argp(𝜔)=151.63deg nu(𝜈)=-168.50deg
period=559.31yr perapis=38.3095AU apoapsis=97.4571AU
---999-------
30 x 49 AU x 17.1 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=39.4739AU, b=38.2190AU, e=0.2501, i=17.1411deg raan(Ω)=110.31deg argp(𝜔)=113.35deg nu(𝜈)=69.94deg
period=248.01yr perapis=29.6001AU apoapsis=49.3476AU
---makemake-------
38 x 53 AU x 29.0 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=45.4128AU, b=44.8151AU, e=0.1617, i=28.9844deg raan(Ω)=79.61deg argp(𝜔)=294.82deg nu(𝜈)=169.50deg
period=306.04yr perapis=38.0692AU apoapsis=52.7564AU
---haumea-------
35 x 52 AU x 28.2 deg (HeliocentricEclipticIAU76) orbit around Sun (☉) at epoch 2020-07-15 11:51:09.184 (TDB)
a(𝑎)=43.1654AU, b=42.3342AU, e=0.1953, i=28.2137deg raan(Ω)=122.17deg argp(𝜔)=238.83deg nu(𝜈)=-153.56deg
period=283.60yr perapis=34.7351AU apoapsis=51.5957AU