In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from astropy import units as u

from poliastro.bodies import Earth, Sun
from poliastro.twobody import Orbit

plt.style.use("seaborn")  # Recommended
In [2]:
ss_i = Orbit.circular(Earth, alt=700 * u.km)
ss_i
Out[2]:
7078 x 7078 km x 0.0 deg orbit around Earth (♁)
In [3]:
ss_i.r_a
Out[3]:
$7078.1366 \; \mathrm{km}$
In [4]:
from poliastro.maneuver import Maneuver
In [5]:
hoh = Maneuver.hohmann(ss_i, 36000 * u.km)
In [6]:
hoh.get_total_cost()
Out[6]:
$3.6173999 \; \mathrm{\frac{km}{s}}$
In [7]:
hoh.get_total_time()
Out[7]:
$15729.733 \; \mathrm{s}$
In [8]:
hoh.impulses[0]
Out[8]:
(<Quantity 0.0 s>,
 <Quantity [    0.       , 2197.3992373,    0.       ] m / s>)
In [9]:
hoh[0]  # Equivalenthoh[0]  # Equivalent
Out[9]:
(<Quantity 0.0 s>,
 <Quantity [    0.       , 2197.3992373,    0.       ] m / s>)
In [10]:
hoh[1]
Out[10]:
(<Quantity 15729.733147123985 s>,
 <Quantity [   -0.        ,-1420.00066617,   -0.        ] m / s>)
In [11]:
tuple(val.decompose([u.km, u.s]) for val in hoh[1])
Out[11]:
(<Quantity 15729.733147123985 s>,
 <Quantity [-0.        ,-1.42000067,-0.        ] km / s>)
In [12]:
ss_f = ss_i.apply_maneuver(hoh)
In [13]:
ss_f
Out[13]:
36000 x 36000 km x 0.0 deg orbit around Earth (♁)
In [14]:
print(plt.style.available)
['seaborn-talk', 'seaborn-white', 'classic', 'seaborn-bright', 'seaborn-dark', 'seaborn-pastel', 'dark_background', 'seaborn-whitegrid', 'bmh', 'seaborn-notebook', 'seaborn-ticks', 'seaborn-muted', 'grayscale', 'seaborn-poster', 'seaborn', '_classic_test', 'seaborn-darkgrid', 'seaborn-deep', 'ggplot', 'fivethirtyeight', 'seaborn-colorblind', 'seaborn-paper', 'seaborn-dark-palette']
In [15]:
from poliastro.plotting import OrbitPlotter

op = OrbitPlotter()
ss_a, ss_f = ss_i.apply_maneuver(hoh, intermediate=True)
op.plot(ss_i, label="Initial orbit")
la, lb = op.plot(ss_a, label="Transfer orbit")
lc, ld = op.plot(ss_f, label="Final orbit")

la.set_color("C2")
lb.set_color("C2")

lc.set_color("C4")
ld.set_color("C4")

plt.legend()

plt.savefig("hohmann.png")
../_images/examples_Untitled_14_0.png
In [16]:
Orbit.from_body_ephem(Earth)
Out[16]:
1 x 1 AU x 23.4 deg orbit around Sun (☉)
In [ ]:

In [ ]:
from poliastro.neos import neows
from poliastro.bodies import Sun, Earth
from poliastro.twobody.orbit import Orbit
from poliastro.plotting import OrbitPlotter

apophis_orbit = neows.orbit_from_name('apophis') #Also '99942' or '99942 apophis' could be used
earth_orbit =  Orbit.from_body_ephem(Earth)
In [33]:
op = OrbitPlotter()
op.plot(earth_orbit, label='Earth')
la, lb = op.plot(apophis_orbit, label='Apophis')

la.set_color("C2")
lb.set_color("C2")

plt.legend()
plt.savefig("neos.png")
../_images/examples_Untitled_18_0.png
In [18]:
from astropy import time
from poliastro.bodies import Mars
In [19]:
    date_launch = time.Time('2011-11-26 15:02', scale='utc')
    date_arrival = time.Time('2012-08-06 05:17', scale='utc')
    tof = date_arrival - date_launch

    ss0 = Orbit.from_body_ephem(Earth, date_launch)
    ssf = Orbit.from_body_ephem(Mars, date_arrival)

    from poliastro import iod
    (v0, v), = iod.lambert(Sun.k, ss0.r, ssf.r, tof)
In [20]:
v0
Out[20]:
$[-29.291223,~14.532568,~5.4159321] \; \mathrm{\frac{km}{s}}$
In [21]:
v
Out[21]:
$[17.615804,~-10.998605,~-4.2076386] \; \mathrm{\frac{km}{s}}$
In [ ]: